]> git.mxchange.org Git - mailer.git/blob - inc/gen_sql_patches.php
- Beg link does now (not yet implemented but prepared) log all referal URLs. It
[mailer.git] / inc / gen_sql_patches.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Check if there is no scrambling string
44 if (getPassScramble() == '') {
45         // Generate 40 chars long scramble string
46         $scrambleString = genScrambleString(40);
47
48         // ... and store it there for future usage
49         updateConfiguration('pass_scramble', $scrambleString);
50
51         // Remove dummy string
52         unset($scrambleString);
53 } // END - if
54
55 // Check if there is no master salt string
56 if (getMasterSalt() == '') {
57         // Generate the master salt which is the first chars minus 40 chars of this random hash
58         // We do an extra scrambling here...
59         $masterSalt = scrambleString(sha1(generatePassword(mt_rand(128, 256))));
60
61         // ... and store it there for future usage
62         updateConfiguration('master_salt', $masterSalt);
63
64         // Remove dummy string
65         unset($masterSalt);
66 } // END - if
67
68 if (getFileHash() == '') {
69         // Create filename from hashed random string
70         $fileHash = sha1(generatePassword(mt_rand(128, 256)));
71         $FQFN = sprintf("%sinc/cache/.%s.cache",
72                 getPath(),
73                 $fileHash
74         );
75
76         // Generate secret key from a randomized string
77         $secretKey = sha1(generateHash(mt_rand(128, 256)));
78
79         // File hash was never created
80         writeToFile($FQFN, $secretKey);
81
82         // Is the file there?
83         if (isFileReadable($FQFN)) {
84                 // Also update configuration
85                 setConfigEntry('secret_key', $secretKey);
86                 updateConfiguration('file_hash', $fileHash);
87
88                 // Remove variables
89                 unset($secretKey);
90                 unset($fileHash);
91         } // END - if
92 } // END - if
93
94 // @TODO Rewrite this to a filter
95 if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isCacheInstanceValid())) {
96         // Destroy some cache files
97         if ($GLOBALS['cache_instance']->loadCacheFile('config'))    $GLOBALS['cache_instance']->removeCacheFile();
98         if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
99         if ($GLOBALS['cache_instance']->loadCacheFile('modules'))   $GLOBALS['cache_instance']->removeCacheFile();
100 } // END - if
101
102 // [EOF]
103 ?>