X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fmysql-manager.php;h=6abad5048fe15f1a1aa7984742be33837b174e95;hb=ae64f8d8d403a8e4990f484d14aad36722e1da51;hp=f11a84bf7493969c8533f933f211cb52f77fbb37;hpb=032c58de69aa2ebc83c46d62af9c14ead90004b9;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index f11a84bf74..6abad5048f 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -32,7 +32,7 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) { +if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } @@ -44,19 +44,20 @@ function ADD_MODULE_TITLE($mod) { // Is the script installed? if (isBooleanConstantAndTrue('mxchange_installed')) { - if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod]))) { + // Check if cache is valid + if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (in_array($mod, $cacheArray['modules']['module']))) { // Load from cache $name = $cacheArray['modules']['title'][$mod]; // Update cache hits - $_CONFIG['cache_hits']++; - } else { + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__); list($name) = SQL_FETCHROW($result); SQL_FREERESULT($result); } - } + } // END - if // Trim name $name = trim($name); @@ -64,17 +65,19 @@ function ADD_MODULE_TITLE($mod) { // Still no luck or empty title? if (empty($name)) { // No name found - $name = LANG_UNKNOWN_MODULE." (".$mod.")"; + $name = sprintf("%s (%s)", LANG_UNKNOWN_MODULE, $mod); if (SQL_NUMROWS($result) == 0) { // Add module to database $dummy = CHECK_MODULE($mod); - } - } + } // END - if + } // END - if + + // Return name return $name; } // Check validity of a given module name (no file extension) -function CHECK_MODULE($mod) { +function CHECK_MODULE ($mod) { // We need them now here... global $cacheArray, $_CONFIG, $cacheInstance; @@ -101,7 +104,7 @@ function CHECK_MODULE($mod) { if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done"; // Check if cache is latest version - $locked = 'Y'; $hidden = 'N'; $admin = 'N'; $mem = 'N'; $found = false; + $locked = "Y"; $hidden = "N"; $admin = "N"; $mem = "N"; $found = false; if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module']))) { // Is the module cached? if (isset($cacheArray['modules']['locked'][$mod_chk])) { @@ -112,13 +115,13 @@ function CHECK_MODULE($mod) { $mem = $cacheArray['modules']['mem_only'][$mod_chk]; // Update cache hits - $_CONFIG['cache_hits']++; + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } $found = true; } else { // No, then we have to update it! $ret = "cache_miss"; } - } else { + } elseif (!EXT_IS_ACTIVE("cache")) { // Check for module in database $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod_chk), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { @@ -132,49 +135,46 @@ function CHECK_MODULE($mod) { // Check returned values against current access permissions // // Admin access ----- Guest access ----- --- Guest or member? --- - if ((IS_ADMIN()) || (($locked == 'N') && ($admin == 'N') && (($mem == 'N') || (IS_LOGGED_IN())))) { + if ((IS_ADMIN()) || (($locked == "N") && ($admin == "N") && (($mem == "N") || (IS_MEMBER())))) { // If you are admin you are welcome for everything! $ret = "done"; - } elseif ($locked == 'Y') { + } elseif ($locked == "Y") { // Module is locked $ret = "locked"; - } elseif (($mem == 'Y') && (!IS_LOGGED_IN())) { + } elseif (($mem == "Y") && (!IS_MEMBER())) { // You have to login first! $ret = "mem_only"; - } elseif (($admin == 'Y') && (!IS_ADMIN())) { + } elseif (($admin == "Y") && (!IS_ADMIN())) { // Only the Admin is allowed to enter this module! $ret = "admin_only"; } // Still no luck or not found? if (($ret == "major") || ($ret == "cache_miss") || (!$found)) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- - if ((file_exists(PATH."inc/modules/".$mod.".php")) || (file_exists(PATH.$mod.".php")) || (file_exists(PATH.$extension."/".$mod.".php"))) { + // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + if ((FILE_READABLE(sprintf("%sinc/modules/%s.php", PATH, $mod))) || (FILE_READABLE(sprintf("%s%s.php", PATH, $mod))) || (FILE_READABLE(sprintf("%s%s/%s.php", PATH, $extension, $mod)))) { // Data is missing so we add it if (GET_EXT_VERSION("sql_patches") >= "0.3.6") { // Since 0.3.6 we have a has_menu column, this took me a half hour // to find a loop here... *sigh* $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_mod_reg (module, locked, hidden, mem_only, admin_only, has_menu) VALUES -('%s', 'Y', 'N', 'N', 'N', 'N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N','N')", array($mod_chk), __FILE__, __LINE__); } else { // Wrong/missing sql_patches! $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_mod_reg (module, locked, hidden, mem_only, admin_only) VALUES -('%s', 'Y', 'N', 'N', 'N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N')", array($mod_chk), __FILE__, __LINE__); } // Everthing is fine? - if (SQL_AFFECTEDROWS() == 0) { + if (SQL_AFFECTEDROWS() < 1) { // Something bad happend! return "major"; - } + } // END - if // Destroy cache here - if (GET_EXT_VERSION("cache") >= "0.1.2") { - if ($cacheInstance->cache_file("mod_reg", true)) $cacheInstance->cache_destroy(); - unset($cacheArray['modules']); - } + REBUILD_CACHE("mod_reg", "modreg"); // And reload data $ret = CHECK_MODULE($mod_chk); @@ -182,7 +182,7 @@ function CHECK_MODULE($mod) { // Module not found we don't add it to the database $ret = "404"; } - } + } // END - if // Return the value return $ret; @@ -190,27 +190,32 @@ function CHECK_MODULE($mod) { // Add menu description pending on given file name (without path!) function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { - global $DEPTH, $_CONFIG; + global $NAV_DEPTH, $_CONFIG; + // Use only filename of the file ;) + $file = basename($file); + + // Init variables $LINK_ADD = ""; $OUT = ""; $AND = ""; + // First we have to do some analysis... - if (ereg("action-", $file)) { + if (substr($file, 0, 7) == "action-") { // This is an action file! $type = "action"; $search = substr($file, 7); switch ($ACC_LVL) { case "admin": - $MOD_CHECK = "admin"; + $modCheck = "admin"; break; case "sponsor": case "guest": case "member": - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; break; } - $AND = " AND what=''"; - } elseif (ereg("what-", $file)) { + $AND = " AND (what='' OR what IS NULL)"; + } elseif (substr($file, 0, 5) == "what-") { // This is an admin what file! $type = "what"; $search = substr($file, 5); @@ -218,12 +223,12 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { switch ($ACC_LVL) { case "admin": - $MOD_CHECK = "admin"; + $modCheck = "admin"; break; case "guest": case "member": - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; if (!IS_ADMIN()) { $AND = " AND visible='Y' AND locked='N'"; } @@ -235,49 +240,77 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { // Sponsor / engine menu $type = "what"; $search = $file; - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; $AND = ""; } else { // Other $type = "menu"; $search = $file; - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; $AND = ""; } - if ((!isset($DEPTH)) && (!$return)) { - $DEPTH = "0"; + if ((!isset($NAV_DEPTH)) && (!$return)) { + $NAV_DEPTH = 0; $prefix = "
".print_r($_CONFIG, true).""); + if (($type == "what") || (($type == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview")))) { //* DEBUG: */ echo __LINE__."+".$type."+
"; + debug_print_backtrace(); + die(""); + } // END - if + // Initialize variables - $uid = "0"; $rid = "0"; $MEM = 'N'; $ADMIN = 'N'; - if (!empty($GLOBALS['userid'])) - { - // Update member status only when userid is valid - if (($GLOBALS['userid'] > 0) && (IS_LOGGED_IN())) - { - // Is valid user - $uid = $GLOBALS['userid']; - $MEM = 'Y'; - } - } - if (IS_ADMIN()) - { + $uid = 0; $rid = 0; $MEM = "N"; $ADMIN = "N"; + + // Valid userid? + if ((!empty($GLOBALS['userid'])) && ($GLOBALS['userid'] > 0) && (IS_MEMBER())) { + // Is valid user + $uid = bigintval($GLOBALS['userid']); + $MEM = "Y"; + } // END - if + + if (IS_ADMIN()) { // Is administrator - $ADMIN = 'Y'; - } + $ADMIN = "Y"; + } // END - if + if (isSessionVariableSet('refid')) { // Check cookie - if (get_session('refid') > 0) $rid = $GLOBALS['refid']; - } + if (get_session('refid') > 0) $rid = bigintval($GLOBALS['refid']); + } // END - if - // Now Read data + // Now search for the user $result = SQL_QUERY_ESC("SELECT timestamp FROM "._MYSQL_PREFIX."_online WHERE sid='%s' LIMIT 1", array($SID), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { - SQL_FREERESULT($result); - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET + // Entry found? + if (SQL_NUMROWS($result) == 1) { + // Then update it + SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET module='%s', action='%s', what='%s', -userid=%d, -refid=%d, +userid=%s, +refid=%s, is_member='%s', is_admin='%s', timestamp=UNIX_TIMESTAMP() WHERE sid='%s' LIMIT 1", - array( - $mod, - $act, - $wht, - bigintval($uid), - bigintval($rid), - $MEM, - $ADMIN, - $SID -), __FILE__, __LINE__); - } - else - { + array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID), __FILE__, __LINE__ + ); + } else { // No entry does exists so we simply add it! - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', UNIX_TIMESTAMP(), '%s', '%s')", - array($mod, $act, $wht, bigintval($uid), bigintval($rid), $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__); + SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", + array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID, GET_REMOTE_ADDR()), __FILE__, __LINE__ + ); } + // Free result + SQL_FREERESULT($result); + // Purge old entries - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= (UNIX_TIMESTAMP() - %d)", - array($_CONFIG['online_timeout']), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= (UNIX_TIMESTAMP() - %s)", + array(getConfig('online_timeout')), __FILE__, __LINE__); } -// OBSULETE: Sends out mail to all administrators -function SEND_ADMIN_EMAILS($subj, $msg) -{ - $result = SQL_QUERY("SELECT email FROM "._MYSQL_PREFIX."_admins ORDER BY id", __FILE__, __LINE__); - while (list($email) = SQL_FETCHROW($result)) - { +// OBSOLETE: Sends out mail to all administrators +function SEND_ADMIN_EMAILS ($subj, $msg) { + // Load all admin email addresses + $result = SQL_QUERY("SELECT email FROM "._MYSQL_PREFIX."_admins ORDER BY id ASC", __FILE__, __LINE__); + while (list($email) = SQL_FETCHROW($result)) { + // Send the email out SEND_EMAIL($email, $subj, $msg); - } - // Really simple... ;-) + } // END - if + + // Free result SQL_FREERESULT($result); + + // Really simple... ;-) } // Get ID number from administrator's login name -function GET_ADMIN_ID($login) -{ - global $cacheArray; +function GET_ADMIN_ID ($login) { + global $cacheArray, $_CONFIG; $ret = "-1"; - if (!empty($cacheArray['admins']['aid'][$login])) - { + if (!empty($cacheArray['admins']['aid'][$login])) { // Check cache $ret = $cacheArray['admins']['aid'][$login]; - if (empty($ret)) $ret = "-1"; - } - else - { + + // Update cache hits + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", array($login), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { list($ret) = SQL_FETCHROW($result); - SQL_FREERESULT($result); - } + } // END - if + + // Free result + SQL_FREERESULT($result); } return $ret; } -// + +// "Getter" for current admin id +function GET_CURRENT_ADMIN_ID () { + // Get the admin login from session + $adminLogin = get_session('admin_login'); + + // "Solve" it into an id + $adminId = GET_ADMIN_ID($adminLogin); + + // Secure and return it + return bigintval($adminId); +} + // Get password hash from administrator's login name -function GET_ADMIN_HASH($login) +function GET_ADMIN_HASH ($aid) { - global $cacheArray; + global $cacheArray, $_CONFIG; $ret = "-1"; - if (!empty($cacheArray['admins']['password'][$login])) - { + if (!empty($cacheArray['admins']['password'][$aid])) { // Check cache - $ret = $cacheArray['admins']['password'][$login]; - if (empty($ret)) $ret = "-1"; - } - else - { + $ret = $cacheArray['admins']['password'][$aid]; + + // Update cache hits + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database - $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array($login), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + $result = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array($aid), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Fetch data list($ret) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + + // Set cache + $cacheArray['admins']['password'][$aid] = $ret; } + + // Free result + SQL_FREERESULT($result); } return $ret; } // -function GET_ADMIN_LOGIN($aid) -{ - global $cacheArray; +function GET_ADMIN_LOGIN ($aid) { + global $cacheArray, $_CONFIG; $ret = "***"; - if (!empty($cacheArray['admins']['login']['aid'])) - { - // Check cache - if (!empty($cacheArray['admins']['login'][$aid])) $ret = $cacheArray['admins']['login'][$aid]; - if (empty($ret)) $ret = "***"; - } - else - { + if (!empty($cacheArray['admins']['login'][$aid])) { + // Get cache + $ret = $cacheArray['admins']['login'][$aid]; + + // Update cache hits + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database - $result = SQL_QUERY_ESC("SELECT login FROM "._MYSQL_PREFIX."_admins WHERE id=%d LIMIT 1", - array(bigintval($aid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + $result = SQL_QUERY_ESC("SELECT login FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array(bigintval($aid)), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { // Fetch data list($ret) = SQL_FETCHROW($result); - } + + // Set cache + $cacheArray['admins']['login'][$aid] = $ret; + } // END - if // Free memory SQL_FREERESULT($result); } return $ret; } +// Get email address of admin id +function GET_ADMIN_EMAIL ($aid) { + global $cacheArray, $_CONFIG; + + $ret = "***"; + if (!empty($cacheArray['admins']['email'][$aid])) { + // Get cache + $ret = $cacheArray['admins']['email'][$aid]; + + // Update cache hits + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { + // Load from database + $result_aid = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array(bigintval($ret)), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Get data + list($ret) = SQL_FETCHROW($result_aid); + + // Set cache + $cacheArray['admins']['email'][$aid] = $ret; + } // END - if + + // Free result + SQL_FREERESULT($result_aid); + } + + // Return email + return $ret; +} +// Get default ACL of admin id +function GET_ADMIN_DEFAULT_ACL ($aid) { + global $cacheArray, $_CONFIG; + + $ret = "***"; + if (!empty($cacheArray['admins']['def_acl'][$aid])) { + // Use cache + $ret = $cacheArray['admins']['def_acl'][$aid]; + + // Update cache hits + if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + } elseif (!EXT_IS_ACTIVE("cache")) { + // Load from database + $result_aid = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", + array(bigintval($aid)), __FILE__, __LINE__); + if (SQL_NUMROWS($result_aid) == 1) { + // Fetch data + list($ret) = SQL_FETCHROW($result_aid); + + // Set cache + $cacheArray['admins']['def_acl'][$aid] = $ret; + } + + // Free result + SQL_FREERESULT($result_aid); + } + + // Return email + return $ret; +} // -function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") -{ +function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") { $ret = ""; - if ($table == "/ARRAY/") - { + if ($table == "/ARRAY/") { // Selection from array - if (is_array($id) && is_array($name) && sizeof($id) == sizeof($name)) - { + if (is_array($id) && is_array($name) && sizeof($id) == sizeof($name)) { // Both are arrays - foreach ($id as $idx=>$value) - { + foreach ($id as $idx => $value) { $ret .= "\n"; } } + // Return - hopefully - the requested data return $ret; } -// Aiut +// Activate exchange (DEPERECATED???) function activateExchange() { global $_CONFIG; - $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__); - if (SQL_NUMROWS($result) >= $_CONFIG['activate_xchange']) + $result = SQL_QUERY("SELECT userid FROM `"._MYSQL_PREFIX."_user_data` WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__); + if (SQL_NUMROWS($result) >= getConfig('activate_xchange')) { // Free memory SQL_FREERESULT($result); @@ -1384,17 +1628,16 @@ function activateExchange() { // Activate System $SQLs = array( "UPDATE "._MYSQL_PREFIX."_mod_reg SET locked='N', hidden='N', mem_only='Y' WHERE module='order' LIMIT 1", - "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE what='order' OR what='unconfirmed' LIMIT 2", - "UPDATE "._MYSQL_PREFIX."_config SET activate_xchange='0' WHERE config=0 LIMIT 1" + "UPDATE `"._MYSQL_PREFIX."_member_menu` SET visible='Y', locked='N' WHERE what='order' OR what='unconfirmed' LIMIT 2", + "UPDATE `"._MYSQL_PREFIX."_config` SET activate_xchange='0' WHERE config=0 LIMIT 1" ); // Run SQLs - foreach ($SQLs as $sql) - { + foreach ($SQLs as $sql) { $result = SQL_QUERY($sql, __FILE__, __LINE__); } - // Destroy cache + // @TODO Destroy cache } } // @@ -1403,114 +1646,105 @@ function DELETE_USER_ACCOUNT($uid, $reason) $points = 0; $result = SQL_QUERY_ESC("SELECT (SUM(p.points) - d.used_points) AS points FROM "._MYSQL_PREFIX."_user_points AS p -LEFT JOIN "._MYSQL_PREFIX."_user_data AS d +LEFT JOIN `"._MYSQL_PREFIX."_user_data` AS d ON p.userid=d.userid -WHERE p.userid=%d", array(bigintval($uid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { +WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { // Save his points to add them to the jackpot list($points) = SQL_FETCHROW($result); SQL_FREERESULT($result); // Delete points entries as well - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_points WHERE userid=%d", array(bigintval($uid)), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_points WHERE userid=%s", array(bigintval($uid)), __FILE__, __LINE__); // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { + if (GET_EXT_VERSION("mediadata") >= "0.0.4") { // Update database MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points); - } + } // END - if // Now, when we have all his points adds them do the jackpot! ADD_JACKPOT($points); } // Delete category selections as well... - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%d", + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%s", array(bigintval($uid)), __FILE__, __LINE__); // Remove from rallye if found - if (EXT_IS_ACTIVE("rallye")) - { - $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_users WHERE userid=%d", + if (EXT_IS_ACTIVE("rallye")) { + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_users WHERE userid=%s", array(bigintval($uid)), __FILE__, __LINE__); } // Now a mail to the user and that's all... - $msg = LOAD_EMAIL_TEMPLATE("del-user", $reason, $uid); + $msg = LOAD_EMAIL_TEMPLATE("del-user", array('text' => $reason), $uid); SEND_EMAIL($uid, ADMIN_DEL_ACCOUNT, $msg); // Ok, delete the account! - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); } // -function META_DESCRIPTION($mod, $wht) -{ +function META_DESCRIPTION ($mod, $wht) { global $_CONFIG, $DEPTH; - if (($mod != "admin") && ($mod != "login")) - { - // Exclude admin and member's area - $DESCR = MAIN_TITLE." ".trim($_CONFIG['title_middle'])." ".ADD_DESCR("guest", "what-".$wht, true); - unset($DEPTH); - OUTPUT_HTML(""); - } + + // Exclude admin and member's area + if (($mod != "admin") && ($mod != "login")) { + // Construct dynamic description + $DESCR = MAIN_TITLE." ".trim(getConfig('title_middle'))." ".ADD_DESCR("guest", "what-".$wht, true); + + // Output it directly + OUTPUT_HTML(""); + } // END - if + + // Remove depth + unset($DEPTH); } // -function ADD_JACKPOT($points) -{ +function ADD_JACKPOT($points) { $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + if (SQL_NUMROWS($result) == 0) { // Create line - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', '%s')", array($points), __FILE__, __LINE__); - } - else - { + $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok','%s')", array($points), __FILE__, __LINE__); + } else { // Free memory SQL_FREERESULT($result); // Update points $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points+%s WHERE ok='ok' LIMIT 1", - array($points), __FILE__, __LINE__); + array($points), __FILE__, __LINE__); } } // -function SUB_JACKPOT($points) -{ +function SUB_JACKPOT($points) { // First failed $ret = "-1"; // Get current points $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + if (SQL_NUMROWS($result) == 0) { // Create line - $result = SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__); - } - else - { - // Free memory - SQL_FREERESULT($result); - + SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__); + } else { // Read points list($jackpot) = SQL_FETCHROW($result); - if ($jackpot >= $points) - { + if ($jackpot >= $points) { // Update points when there are enougth points in jackpot - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1", + SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1", array($points), __FILE__, __LINE__); $ret = $jackpot - $points; - } + } // END - if } + + // Free memory + SQL_FREERESULT($result); } // function IS_DEMO() { return ((EXT_IS_ACTIVE("demo")) && (get_session('admin_login') == "demo")); } // -function LOAD_CONFIG($no="0") -{ +function LOAD_CONFIG ($no="0") { global $cacheArray; $CFG_DUMMY = array(); @@ -1518,15 +1752,17 @@ function LOAD_CONFIG($no="0") if ((is_array($cacheArray)) && (isset($cacheArray['config'][$no])) && (is_array($cacheArray['config'][$no]))) { // Load config from cache //* DEBUG: */ echo gettype($cacheArray['config'][$no])."