************************************************************************/
// Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
+{
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ require($INC);
}
// Check for version of sql_patches
if (GET_EXT_VERSION("sql_patches") < "0.3.6") return false;
// Check if there is no scrambling string
-if (empty($_CONFIG['pass_scramble'])) {
- // Generate 40 chars long scramble string
- $scrambleString = genScrambleString(40);
-
- // ... and store it there for future usage
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET pass_scramble='%s' WHERE config=0 LIMIT 1",
- array($scrambleString), __FILE__, __LINE__);
-
- // Also remember it in config
- $_CONFIG['pass_scramble'] = $scrambleString;
- unset($scrambleString);
+if (empty($_CONFIG['pass_scramble']))
+{
+ // Generate 40 chars long scramble string
+ $scrambleString = genScrambleString(40);
+
+ // ... and store it there for future usage
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET pass_scramble='%s' WHERE config=0 LIMIT 1",
+ array($scrambleString), __FILE__, __LINE__);
+
+ // Also remember it in config
+ $_CONFIG['pass_scramble'] = $scrambleString;
+ unset($scrambleString);
}
// Check if there is no master salt string
-if (empty($_CONFIG['master_salt'])) {
- // Generate the master salt which is the first chars minus 40 chars of this random hash
- // We do an extra scrambling here...
- $masterSalt = scrambleString(substr(generateHash(GEN_PASS(rand(128, 256))), 0, -40));
-
- // ... and store it there for future usage
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET master_salt='%s' WHERE config=0 LIMIT 1",
- array($masterSalt), __FILE__, __LINE__);
-
- // Also remember it in config
- $_CONFIG['master_salt'] = $masterSalt;
- unset($masterSalt);
+if (empty($_CONFIG['master_salt']))
+{
+ // Generate the master salt which is the first chars minus 40 chars of this random hash
+ // We do an extra scrambling here...
+ $masterSalt = scrambleString(substr(generateHash(GEN_PASS(rand(128, 256))), 0, -40));
+
+ // ... and store it there for future usage
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET master_salt='%s' WHERE config=0 LIMIT 1",
+ array($masterSalt), __FILE__, __LINE__);
+
+ // Also remember it in config
+ $_CONFIG['master_salt'] = $masterSalt;
+ unset($masterSalt);
}
-if (empty($_CONFIG['file_hash'])) {
- // Create filename from hashed random string
- $file_hash = generateHash(GEN_PASS(rand(128, 256)));
- $file = PATH."inc/.secret/.".$file_hash;
-
- // File hash was never created
- $fp = @fopen($file, 'w') or mxchange_die("Cannot write secret key file!");
- if ($fp != false) {
- // Could write to secret file! So let's generate the secret key...
- // 1. Count of chars to be taken from back of the string
- $nums = rand(40, 45);
- // 2. Generate secret key from a randomized string
- $secretKey = substr(generateHash(GEN_PASS(rand(128, 256))), -$nums);
- // 3. Write the key to the file
- fwrite($fp, $secretKey);
- // 4. Close file
- fclose($fp);
-
- // Change access rights for more security
- @chmod($file, 0644);
-
- //* DEBUG: */ unlink($file);
- //* DEBUG: */ $test = hexdec(get_session('u_hash')) / hexdec($secretKey);
- //* DEBUG: */ $test = generateHash(str_replace('.', "", $test));
- //* DEBUG: */ die("Secret-Key: ".$secretKey."<br>Cookie: ".get_session('u_hash')."<br>Test: ".$test);
-
- // Write $file_hash to database
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET file_hash='%s' WHERE config=0 LIMIT 1",
- array($file_hash), __FILE__, __LINE__);
-
- // Also create .htaccess file
- $fp = @fopen(PATH."inc/.secret/.htaccess", 'w') or mxchange_die("Cannot write to .htaccess file!");
- if ($fp != false) {
- // Add deny line to file
- fwrite($fp, "Deny from all");
-
- // Close the file
- fclose($fp);
- }
-
- // Also update configuration
- $_CONFIG['secret_key'] = $secretKey; unset($secretKey);
- $_CONFIG['file_hash'] = $file_hash; unset($file_hash);
-
- // Don't miss the admin hash here...
- $passHash = generatePassString(get_session('admin_md5'));
- set_session('admin_md5', $passHash);
- }
+if (empty($_CONFIG['file_hash']))
+{
+ // Create filename from hashed random string
+ $file_hash = generateHash(GEN_PASS(rand(128, 256)));
+ $file = PATH."inc/.secret/.".$file_hash;
+
+ // File hash was never created
+ $fp = @fopen($file, 'w') or mxchange_die("Cannot write secret key file!");
+ if ($fp != false)
+ {
+ // Could write to secret file! So let's generate the secret key...
+ // 1. Count of chars to be taken from back of the string
+ $nums = rand(40, 45);
+ // 2. Generate secret key from a randomized string
+ $secretKey = substr(generateHash(GEN_PASS(rand(128, 256))), -$nums);
+ // 3. Write the key to the file
+ fwrite($fp, $secretKey);
+ // 4. Close file
+ fclose($fp);
+
+ // Change access rights for more security
+ @chmod($file, 0644);
+
+ //* DEBUG: */ unlink($file);
+ //* DEBUG: */ $test = hexdec(get_session('u_hash')) / hexdec($secretKey);
+ //* DEBUG: */ $test = generateHash(str_replace('.', "", $test));
+ //* DEBUG: */ die("Secret-Key: ".$secretKey."<br>Cookie: ".get_session('u_hash')."<br>Test: ".$test);
+
+ // Write $file_hash to database
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET file_hash='%s' WHERE config=0 LIMIT 1",
+ array($file_hash), __FILE__, __LINE__);
+
+ // Also create .htaccess file
+ $fp = @fopen(PATH."inc/.secret/.htaccess", 'w') or mxchange_die("Cannot write to .htaccess file!");
+ if ($fp != false)
+ {
+ // Add deny line to file
+ fwrite($fp, "Deny from all");
+
+ // Close the file
+ fclose($fp);
+ }
+
+ // Also update configuration
+ $_CONFIG['secret_key'] = $secretKey; unset($secretKey);
+ $_CONFIG['file_hash'] = $file_hash; unset($file_hash);
+ }
}
//
switch ($ret)
{
case "done":
- admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define ('admin_registered', ", ");", "true", 0);
+ admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
if (!_FATAL) {
// Registering is done
LOAD_URL(URL."/modules.php?module=admin&action=login®ister=done");
}
if (!isBooleanConstantAndTrue('admin_registered')) {
// Write to config that registration is done
- admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define ('admin_registered', ", ");", "true", 0);
+ admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
// Load URL for login
$URL = URL."/modules.php?module=admin&action=login";
// Try to register the session variables
if ((set_session("admin_md5", generatePassString(generateHash($_POST['pass'], __SALT)))) && (set_session("admin_login", $_POST['login'])) && (set_session("admin_last", time())) && (set_session("admin_to", $_POST['timeout']))) {
// Construct URL and redirect
- die("OK");
$URL = URL."/modules.php?module=admin&";
// Rewrite overview module
}
} else {
// Maybe an Admin want's to login?
- $ret = CHECK_ADMIN_COOKIES('admin_login', 'admin_md5');
+ $ret = CHECK_ADMIN_COOKIES(SQL_ESCAPE(get_session('admin_login')), SQL_ESCAPE(get_session('admin_md5')));
switch ($ret) {
case "done":
// Cookie-Data accepted
************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
require($INC);
}
// Add description as navigation point
ADD_DESCR("admin", basename(__FILE__));
-OPEN_TABLE("100%", "admin_content admin_content_align", "");
-if (!empty($_GET['mid']))
-{
+
+if (!empty($_GET['mid'])) {
// Load email data
$result = SQL_QUERY_ESC("SELECT id, sender, subject, url, timestamp FROM "._MYSQL_PREFIX."_pool WHERE id=%d LIMIT 1",
array(bigintval($_GET['mid'])), __FILE__, __LINE__);
SQL_FREERESULT($result);
// Delete mail only once
- if ($sender > 0)
- {
+ if ($sender > 0) {
// Prepare data for the template
define('__ID' , $id);
define('__SENDER' , ADMIN_USER_PROFILE_LINK($sender));
LEFT JOIN "._MYSQL_PREFIX."_pool AS p
ON s.pool_id=%d LIMIT 1",
array(bigintval($_GET['mid'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
+ if (SQL_NUMROWS($result) == 1) {
// Fetch stats id
list($stats_id) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Output link for manually removing stats entry
LOAD_TEMPLATE("admin_settings_saved", false, "<A href=\"".URL."/modules.php?module=admin&what=del_email&pid=".$_GET['mid']."\">".ADMIN_REMOVE_STATS_ENTRY."</A>");
}
- }
- else
- {
+ } else {
// Mail already deleted!
LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NORMAL_MAIL_ALREADY_DELETED);
}
-}
- elseif (!empty($_GET['pid']))
-{
+} elseif (!empty($_GET['pid'])) {
// Remove stats entries
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%d LIMIT 1",
array(bigintval($_GET['pid'])), __FILE__, __LINE__);
LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_USER_STATS_REMOVED);
-}
- elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus")))
-{
+} elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus"))) {
// Load data from bonus mail
$result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp FROM "._MYSQL_PREFIX."_bonus WHERE id=%d",
array(bigintval($_GET['bid'])), __FILE__, __LINE__);
SQL_FREERESULT($result);
// Delete mail only once
- if ($id > 0)
- {
+ if ($id > 0) {
// Delete bonus mail entirely from database
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",
array(bigintval($_GET['bid'])), __FILE__, __LINE__);
// Load template
LOAD_TEMPLATE("admin_del_email_bonus");
- }
- else
- {
+ } else {
// Mail already deleted!
LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_MAIL_ALREADY_DELETED);
}
-}
- else
-{
+} else {
// No mail orders fond
LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_WRONG_CALL);
}
-CLOSE_TABLE();
+
//
?>