2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/08/2005 *
4 * =================== Last change: 01/01/2006 *
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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Check if there is no scrambling string
44 if (getPassScramble() == '') {
45 // Generate 40 chars long scramble string
46 $scrambleString = genScrambleString(40);
48 // ... and store it there for future usage
49 updateConfiguration('pass_scramble', $scrambleString);
51 // Remove dummy string
52 unset($scrambleString);
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))));
61 // ... and store it there for future usage
62 updateConfiguration('master_salt', $masterSalt);
64 // Remove dummy string
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",
76 // Generate secret key from a randomized string
77 $secretKey = sha1(generateHash(mt_rand(128, 256)));
79 // File hash was never created
80 writeToFile($FQFN, $secretKey);
83 if (isFileReadable($FQFN)) {
84 // Also update configuration
85 setConfigEntry('secret_key', $secretKey);
86 updateConfiguration('file_hash', $fileHash);
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();