]> git.mxchange.org Git - mailer.git/blob - inc/gen_sql_patches.php
Now with more feedback if no payout types are found
[mailer.git] / inc / gen_sql_patches.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/08/2005 *
4  * ===============                              Last change: 01/01/2006 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : gen_sql_patches.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : Patch password system after upgrading            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Patcht das Passwort-System nach DB-Update        *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 }
43
44 // Check for version of sql_patches
45 if (getExtensionVersion('sql_patches') < '0.3.6') return false;
46
47 // Check if there is no scrambling string
48 if (getConfig('pass_scramble') == '') {
49         // Generate 40 chars long scramble string
50         $scrambleString = genScrambleString(40);
51
52         // ... and store it there for future usage
53         updateConfiguration('pass_scramble', $scrambleString);
54
55         // Remove dummy string
56         unset($scrambleString);
57 } // END - if
58
59 // Check if there is no master salt string
60 if (getConfig('master_salt') == '') {
61         // Generate the master salt which is the first chars minus 40 chars of this random hash
62         // We do an extra scrambling here...
63         $masterSalt = scrambleString(sha1(generatePassword(mt_rand(128, 256))));
64
65         // ... and store it there for future usage
66         updateConfiguration('master_salt', $masterSalt);
67
68         // Remove dummy string
69         unset($masterSalt);
70 } // END - if
71
72 if (getConfig('file_hash') == '') {
73         // Create filename from hashed random string
74         $fileHash = sha1(generatePassword(mt_rand(128, 256)));
75         $FQFN = sprintf("%sinc/.secret/.%s",
76                 getConfig('PATH'),
77                 $fileHash
78         );
79
80         // Count of chars to be taken from back of the string
81         $nums = mt_rand(40, 45);
82
83         // Generate secret key from a randomized string
84         $secretKey = substr(sha1(generatePassword(mt_rand(128, 256))), -$nums);
85
86         // File hash was never created
87         writeToFile($FQFN, $secretKey);
88
89         // Is the file there?
90         if (isFileReadable($FQFN)) {
91                 //* DEBUG: */ removeFile($FQFN);
92                 //* DEBUG: */ $test = hexdec(getSession('u_hash')) / hexdec($secretKey);
93                 //* DEBUG: */ $test = generateHash(str_replace('.', '', $test));
94                 //* DEBUG: */ die("Secret-Key: ".$secretKey."<br />Cookie: ".getSession('u_hash')."<br />Test: ".$test);
95
96                 // Write $fileHash to database
97                 updateConfiguration('file_hash', $fileHash);
98
99                 // Generate FQFN for .htaccess file
100                 $FQFN = sprintf("%sinc/.secret/.htaccess",
101                         getConfig('PATH')
102                 );
103
104                 // Is the .htaccess file there?
105                 if (!isFileReadable($FQFN)) {
106                         // Also create .htaccess file
107                         writeToFile($FQFN, "Deny from all\n");
108                 } // END - if
109
110                 // Also update configuration
111                 setConfigEntry('secret_key', $secretKey);
112
113                 // Remove variables
114                 unset($secretKey);
115                 unset($fileHash);
116         } // END - if
117 } // END - if
118
119 //
120 ?>