//
function ADD_MODULE_TITLE($mod)
{
- global $MODULES, $CONFIG;
+ global $MODULES, $_CONFIG;
$name = ""; $result = false;
// Load title
if (!mxchange_installing)
$name = $MODULES['title'][$mod];
// Update cache hits
- $CONFIG['cache_hits']++;
+ $_CONFIG['cache_hits']++;
}
else
{
}
return $name;
}
-//
-function CHECK_MODULE($mod)
-{
+// Check validity of a given module name (no file extension)
+function CHECK_MODULE($mod) {
// We need them now here...
- global $MODULES, $CONFIG, $CACHE;
+ global $MODULES, $_CONFIG, $CACHE;
// Filter module name (names with low chars and underlines are fine!)
$mod = preg_replace("/[^a-z_]/", "", $mod);
// Check for prefix is a extension...
- $MOD_SPLIT = explode("_", $mod);
+ $modSplit = explode("_", $mod);
$extension = ""; $mod_chk = $mod;
- //* DEBUG: */ echo __LINE__."*".count($MOD_SPLIT)."*/".$mod."*<BR>";
- if (count($MOD_SPLIT) == 2)
- {
+ //* DEBUG: */ echo __LINE__."*".count($modSplit)."*/".$mod."*<br />";
+ if (count($modSplit) == 2) {
// Okay, there is a seperator (_) in the name so is the first part a module?
- //* DEBUG: */ echo __LINE__."*".$MOD_SPLIT[0]."*<BR>";
- if (EXT_IS_ACTIVE($MOD_SPLIT[0]))
- {
+ //* DEBUG: */ echo __LINE__."*".$modSplit[0]."*<br />";
+ if (EXT_IS_ACTIVE($modSplit[0])) {
// The prefix is an extension's name, so let's set it
- $extension = $MOD_SPLIT[0]; $mod = $MOD_SPLIT[1];
+ $extension = $modSplit[0]; $mod = $modSplit[1];
}
}
if ((!mxchange_installed) || (mxchange_installing) || (!admin_registered)) return "done";
// Check if cache is latest version
- $locked = "Y"; $hidden = "N"; $admin = "N"; $mem = "N"; $found = false;
- if ((GET_EXT_VERSION("cache") >= "0.1.2") && (is_array($MODULES['module'])))
- {
+ $locked = 'Y'; $hidden = 'N'; $admin = 'N'; $mem = 'N'; $found = false;
+ if ((GET_EXT_VERSION("cache") >= "0.1.2") && (is_array($MODULES['module']))) {
// Is the module cached?
if (isset($MODULES['locked'][$mod_chk])) {
// Check cache
$mem = $MODULES['mem_only'][$mod_chk];
// Update cache hits
- $CONFIG['cache_hits']++;
+ $_CONFIG['cache_hits']++;
$found = true;
} else {
// No, then we have to update it!
$ret = "cache_miss";
}
- }
- else
- {
+ } else {
// 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)
- {
+ if (SQL_NUMROWS($result) == 1) {
// Read data
list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// 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_LOGGED_IN())))) {
// 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_LOGGED_IN())) {
// 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))
- {
+ 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")))
- {
+ if ((file_exists(PATH."inc/modules/".$mod.".php")) || (file_exists(PATH.$mod.".php")) || (file_exists(PATH.$extension."/".$mod.".php"))) {
// 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
}
// Destroy cache here
- if (GET_EXT_VERSION("cache") >= "0.1.2")
- {
+ if (GET_EXT_VERSION("cache") >= "0.1.2") {
if ($CACHE->cache_file("mod_reg", true)) $CACHE->cache_destroy();
unset($MODULES);
}
// And reload data
$ret = CHECK_MODULE($mod_chk);
- }
- else
- {
+ } else {
// Module not found we don't add it to the database
$ret = "404";
}
// Return the value
return $ret;
}
-//
-function ADD_DESCR($ACC_LVL, $FILE, $return = false, $output = true)
+// Add menu description pending on given file name (without path!)
+function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true)
{
- global $_GET, $DEPTH, $CONFIG;
+ global $DEPTH, $_CONFIG;
$LINK_ADD = ""; $OUT = ""; $AND = "";
// First we have to do some analysis...
- if (ereg("action-", $FILE))
- {
+ if (ereg("action-", $file)) {
// This is an action file!
- $TYPE = "action";
- $SEARCH = substr($FILE, 7);
+ $type = "action";
+ $search = substr($file, 7);
switch ($ACC_LVL)
{
case "admin":
break;
}
$AND = " AND what=''";
- }
- elseif (ereg("what-", $FILE))
- {
+ } elseif (ereg("what-", $file)) {
// This is an admin what file!
- $TYPE = "what";
- $SEARCH = substr($FILE, 5);
+ $type = "what";
+ $search = substr($file, 5);
$AND = "";
switch ($ACC_LVL)
{
case "guest":
case "member":
$MOD_CHECK = $GLOBALS['module'];
- if (!IS_ADMIN())
- {
+ if (!IS_ADMIN()) {
$AND = " AND visible='Y' AND locked='N'";
}
break;
}
- $DUMMY = substr($SEARCH, 0, -4);
+ $DUMMY = substr($search, 0, -4);
$AND .= " AND action='".GET_ACTION($ACC_LVL, $DUMMY)."'";
- }
- elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine"))
- {
+ } elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine")) {
// Sponsor / engine menu
- $TYPE = "what";
- $SEARCH = $FILE;
+ $type = "what";
+ $search = $file;
$MOD_CHECK = $GLOBALS['module'];
$AND = "";
- }
- else
- {
+ } else {
// Other
- $TYPE = "menu";
- $SEARCH = $FILE;
+ $type = "menu";
+ $search = $file;
$MOD_CHECK = $GLOBALS['module'];
$AND = "";
}
- if ((!isset($DEPTH)) && (!$return))
- {
+ if ((!isset($DEPTH)) && (!$return)) {
$DEPTH = "0";
- $PREFIX = "<DIV class=\"you_are_here\">".YOU_ARE_HERE." <STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
- }
- else
- {
+ $prefix = "<DIV class=\"you_are_here\">".YOU_ARE_HERE." <STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
+ } else {
if (!$return) $DEPTH++;
- $PREFIX = "";
+ $prefix = "";
}
- $PREFIX .= " -> ";
- if (ereg(".php", $SEARCH))
- {
- $SEARCH = substr($SEARCH, 0, strpos($SEARCH, ".php"));
+ $prefix .= " -> ";
+ if (ereg(".php", $search)) {
+ $search = substr($search, 0, strpos($search, ".php"));
}
$result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_%s_menu WHERE %s='%s' ".$AND." LIMIT 1",
- array($ACC_LVL, $TYPE, $SEARCH), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
+ array($ACC_LVL, $type, $search), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result) == 1) {
list($ret) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
- if ($return)
- {
+ if ($return) {
// Return title
return $ret;
- }
- elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($CONFIG['youre_here'] == "Y")) || ((IS_ADMIN()) && ($MOD_CHECK == "admin")))
- {
+ } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == 'Y')) || ((IS_ADMIN()) && ($MOD_CHECK == "admin"))) {
// Output HTML code
- $OUT = $PREFIX."<STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$MOD_CHECK."&".$TYPE."=".$SEARCH.$LINK_ADD."\">".$ret."</A></STRONG>\n";
- //* DEBUG: */ echo __LINE__."*".$TYPE."/".$GLOBALS['what']."*<br />\n";
- if (($TYPE == "what") || (($TYPE == "action") && (!isset($_GET['what'])) && ($GLOBALS['what'] != "welcome"))) {
- //* DEBUG: */ echo __LINE__."+".$TYPE."+<br />\n";
- $OUT .= "</DIV><BR>\n";
+ $OUT = $prefix."<STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$MOD_CHECK."&".$type."=".$search.$LINK_ADD."\">".$ret."</A></STRONG>\n";
+ //* DEBUG: */ echo __LINE__."*".$type."/".$GLOBALS['what']."*<br />\n";
+ if (($type == "what") || (($type == "action") && (!isset($_GET['what'])) && ($GLOBALS['what'] != "welcome"))) {
+ //* DEBUG: */ echo __LINE__."+".$type."+<br />\n";
+ $OUT .= "</DIV><br />\n";
}
}
}
// Return or output HTML code?
- if ($output)
- {
+ if ($output) {
// Output HTML code here
OUTPUT_HTML($OUT);
- }
- else
- {
+ } else {
// Return HTML code
return $OUT;
}
}
//
-function ADD_MENU($MODE, $act, $wht)
-{
- global $CONFIG;
+function ADD_MENU($MODE, $act, $wht) {
+ global $_CONFIG;
if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) return CODE_MENU_NOT_VALID;
$main_cnt = 0; $AND = ""; $main_action = ""; $sub_what = "";
if (!IS_ADMIN())
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
if (SQL_NUMROWS($result_main) > 0)
{
- OUTPUT_HTML ("<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"".$MODE."_menu\">");
+ OUTPUT_HTML("<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"".$MODE."_menu\">");
// There are menus available, so we simply display them... :)
while (list($main_title, $main_action) = SQL_FETCHROW($result_main))
{
//* DEBUG: */ echo __LINE__.":!!!!".$sub_what."!!!<br />\n";
$test_inc = sprintf("%sinc/modules/%s/what-%s.php", PATH, $MODE, $sub_what);
$test = (file_exists($test_inc) && is_readable($test_inc));
- if ($test)
- {
- if ((!empty($wht)) && (($wht == $sub_what)))
- {
+ if ($test) {
+ if ((!empty($wht)) && (($wht == $sub_what))) {
$content = "<STRONG>";
}
// Navigation link
- $content .= "<A name=\"menu\" class=\"menu_blur\" href=\"".URL."/modules.php?module=".$GLOBALS['module']."&what=".$sub_what.ADD_URL_DATA("")."\"";
-
- if (frameset_active)
- {
- // We need to add a JavaScript here to reload both frames!
- }
- else
- {
- // Add the default target _self
- $content .= " target=\"_self\"";
- }
- $content .= ">";
- }
- else
- {
+ $content .= "<A name=\"menu\" class=\"menu_blur\" href=\"".URL."/modules.php?module=".$GLOBALS['module']."&what=".$sub_what.ADD_URL_DATA("")."\" target=\"_self\">";
+ } else {
$content .= "<I>";
}
// Menu title
- $content .= $CONFIG['middot'].$sub_title;
+ $content .= $_CONFIG['middot'].$sub_title;
- if ($test)
- {
+ if ($test) {
$content .= "</A>";
- }
- else
- {
+ } else {
$content .= "</I>";
}
- if ((!empty($wht)) && (($wht == $sub_what)))
- {
+ if ((!empty($wht)) && (($wht == $sub_what))) {
$content .= "</STRONG>";
}
$wht = $sub_what; $cnt++;
- if ($cnt < $ctl)
- {
+ if ($cnt < $ctl) {
LOAD_TEMPLATE($MODE."_menu_row", false, $content);
- }
- else
- {
+ } else {
LOAD_TEMPLATE($MODE."_menu_bottom", false, $content);
}
}
- }
- else
- {
+ } else {
// This is a menu block... ;-)
$BLOCK_MODE = true;
$INC_BLOCK = sprintf(PATH."inc/modules/%s/action-%s.php", $MODE, $main_action);
- if ((file_exists($INC_BLOCK)) && (is_readable($INC_BLOCK)))
- {
+ if ((file_exists($INC_BLOCK)) && (is_readable($INC_BLOCK))) {
// Load include file
- if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML ("<TR>
+ if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML("<TR>
<TD class=\"".$MODE."_menu_whats\">");
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
include ($INC_BLOCK);
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
- if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML (" </TD>
+ if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML(" </TD>
</TR>");
}
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
}
$main_cnt++;
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
- if (SQL_NUMROWS($result_main) > $main_cnt) OUTPUT_HTML ("<TR><TD class=\"".$MODE."_menu_seperator\"></TD></TR>");
+ if (SQL_NUMROWS($result_main) > $main_cnt) OUTPUT_HTML("<TR><TD class=\"".$MODE."_menu_seperator\"></TD></TR>");
}
// Free memory
// Close table
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
- OUTPUT_HTML ("</TABLE>");
+ OUTPUT_HTML("</TABLE>");
}
}
// This patched function will reduce many SELECT queries for the specified or current admin login
function IS_ADMIN($admin="")
{
- global $_COOKIE, $ADMINS, $CONFIG;
+ global $_SESSION, $ADMINS, $_CONFIG;
$ret = false; $passCookie = ""; $valPass = "";
- //* DEBUG: */ echo __LINE__."ADMIN:".$admin."<BR>";
+ //* DEBUG: */ echo __LINE__."ADMIN:".$admin."<br />";
// If admin login is not given take current from cookies...
- if ((empty($admin)) && (!empty($_COOKIE['admin_login'])) && (!empty($_COOKIE['admin_md5'])))
+ if ((empty($admin)) && (!empty($_SESSION['admin_login'])) && (!empty($_SESSION['admin_md5'])))
{
- $admin = SQL_ESCAPE($_COOKIE['admin_login']); $passCookie = $_COOKIE['admin_md5'];
+ $admin = SQL_ESCAPE($_SESSION['admin_login']); $passCookie = $_SESSION['admin_md5'];
}
- //* DEBUG: */ echo __LINE__."ADMIN:".$admin."/".$passCookie."<BR>";
+ //* DEBUG: */ echo __LINE__."ADMIN:".$admin."/".$passCookie."<br />";
// Search in array for entry
if ((!empty($passCookie)) && (isset($ADMINS['password'][$admin])) && (!empty($admin)))
{
// Count cache hits
- $CONFIG['cache_hits']++;
+ $_CONFIG['cache_hits']++;
// Login data is valid or not?
$valPass = generatePassString($ADMINS['password'][$admin]);
else
{
// Output directly (default)
- OUTPUT_HTML ($OUT);
+ OUTPUT_HTML($OUT);
}
}
//
return $ret;
}
//
-function WHAT_IS_VALID($act, $wht, $TYPE="guest")
+function WHAT_IS_VALID($act, $wht, $type="guest")
{
if (IS_ADMIN())
{
else
{
$ret = false;
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what='%s' AND locked='N' LIMIT 1", array($TYPE, $act, $wht), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what='%s' AND locked='N' LIMIT 1", array($type, $act, $wht), __FILE__, __LINE__);
// Is "what" valid?
if (SQL_NUMROWS($result) == 1) $ret = true;
SQL_FREERESULT($result);
//
function IS_LOGGED_IN()
{
- global $_COOKIE, $status, $LAST;
+ global $_SESSION, $status, $LAST;
if (!is_array($LAST)) $LAST = array();
$ret = false;
FIX_DELETED_COOKIES(array('userid', 'u_hash', 'lifetime'));
// Are cookies set?
- if ((!empty($GLOBALS['userid'])) && (!empty($_COOKIE['u_hash'])) && (!empty($_COOKIE['lifetime'])) && (defined('COOKIE_PATH')))
+ if ((!empty($GLOBALS['userid'])) && (!empty($_SESSION['u_hash'])) && (!empty($_SESSION['lifetime'])) && (defined('COOKIE_PATH')))
{
// Cookies are set with values, but are they valid?
$result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
if ((!empty($mod)) && (empty($LAST['module']))) { $LAST['module'] = $mod; $LAST['online'] = $onl; }
// So did we now have valid data and an unlocked user?
- //* DEBUG: */ echo $valPass."<br>".$_COOKIE['u_hash']."<br>";
- if (($status == "CONFIRMED") && ($valPass == $_COOKIE['u_hash']))
+ //* DEBUG: */ echo $valPass."<br>".$_SESSION['u_hash']."<br>";
+ if (($status == "CONFIRMED") && ($valPass == $_SESSION['u_hash']))
{
// Account is confirmed and all cookie data is valid so he is definely logged in! :-)
$ret = true;
{
// Maybe got locked etc.
//* DEBUG: */ echo __LINE__."!!!<br>";
- @setcookie("userid", "", time() - 3600, COOKIE_PATH);
- @setcookie("u_hash", "", time() - 3600, COOKIE_PATH);
- @setcookie("lifetime", "0", time() - 3600, COOKIE_PATH);
+ set_session("userid", "", time() - 3600, COOKIE_PATH);
+ set_session("u_hash", "", time() - 3600, COOKIE_PATH);
+ set_session("lifetime", "", time() - 3600, COOKIE_PATH);
// Remove array elements to prevent errors
unset($GLOBALS['userid']);
- unset($_COOKIE['u_hash']);
- unset($_COOKIE['lifetime']);
}
}
else
{
// Cookie data is invalid!
//* DEBUG: */ echo __LINE__."***<br>";
- @setcookie("userid", "", time() - 3600, COOKIE_PATH);
- @setcookie("u_hash", "", time() - 3600, COOKIE_PATH);
- @setcookie("lifetime", "0", time() - 3600, COOKIE_PATH);
+ set_session("userid", "", time() - 3600, COOKIE_PATH);
+ set_session("u_hash", "", time() - 3600, COOKIE_PATH);
+ set_session("lifetime", "", time() - 3600, COOKIE_PATH);
// Remove array elements to prevent errors
unset($GLOBALS['userid']);
- unset($_COOKIE['u_hash']);
- unset($_COOKIE['lifetime']);
}
// Free memory
{
// Cookie data is invalid!
//* DEBUG: */ echo __LINE__."///<br>";
- @setcookie("userid", "", time() - 3600, COOKIE_PATH);
- @setcookie("u_hash", "", time() - 3600, COOKIE_PATH);
- @setcookie("lifetime", "0", time() - 3600, COOKIE_PATH);
+ set_session("userid", "", time() - 3600, COOKIE_PATH);
+ set_session("u_hash", "", time() - 3600, COOKIE_PATH);
+ set_session("lifetime", "", time() - 3600, COOKIE_PATH);
// Remove array elements to prevent errors
unset($GLOBALS['userid']);
- unset($_COOKIE['u_hash']);
- unset($_COOKIE['lifetime']);
}
return $ret;
}
if (!is_array($LAST)) $LAST = array();
// Are the required cookies set?
- if ((!isset($GLOBALS['userid'])) || (!isset($_COOKIE['u_hash'])) || (!isset($_COOKIE['lifetime']))) {
+ if ((!isset($GLOBALS['userid'])) || (!isset($_SESSION['u_hash'])) || (!isset($_SESSION['lifetime']))) {
// Nope, then return here to caller function
return false;
} else {
// Secure user ID
- $GLOBALS['userid'] = bigintval($_COOKIE['userid']);
+ $GLOBALS['userid'] = bigintval($_SESSION['userid']);
}
// Extract last online time (life) and how long is auto-login valid (time)
- $newl = time() + bigintval($_COOKIE['lifetime']);
+ $newl = time() + bigintval($_SESSION['lifetime']);
// Recheck if logged in
if (!IS_LOGGED_IN()) return false;
// Maybe first login time?
if (empty($mod)) $mod = "login";
- if (@setcookie("userid", $GLOBALS['userid'], $newl, COOKIE_PATH) && @setcookie("u_hash", SQL_ESCAPE($_COOKIE['u_hash']), $newl, COOKIE_PATH) && @setcookie("lifetime", bigintval($_COOKIE['lifetime']), $newl, COOKIE_PATH)) {
+ if (set_session("userid", $GLOBALS['userid'], $newl, COOKIE_PATH) && set_session("u_hash", SQL_ESCAPE($_SESSION['u_hash']), $newl, COOKIE_PATH) && set_session("lifetime", bigintval($_SESSION['lifetime']), $newl, COOKIE_PATH)) {
// This will be displayed on welcome page! :-)
if (empty($LAST['module'])) {
$LAST['module'] = $mod; $LAST['online'] = $onl;
else
{
// Destroy session, we cannot update!
- @setcookie("userid", "", time() - 3600, COOKIE_PATH);
- @setcookie("u_hash", "", time() - 3600, COOKIE_PATH);
- @setcookie("lifetime", "0", time() - 3600, COOKIE_PATH);
+ set_session("userid", "", time() - 3600, COOKIE_PATH);
+ set_session("u_hash", "", time() - 3600, COOKIE_PATH);
+ set_session("lifetime", "", time() - 3600, COOKIE_PATH);
}
}
//
//
function SEND_MODE_MAILS($mod, $modes)
{
- global $_COOKIE, $_POST, $CONFIG, $DATA;
+ global $_CONFIG, $DATA;
+
// Load hash
- $result_main = SQL_QUERY("SELECT password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d AND status='CONFIRMED' LIMIT 1",
+ $result_main = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d AND status='CONFIRMED' LIMIT 1",
array($GLOBALS['userid']), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_main) == 1)
- {
- // Load hash and extract salt
- list($hash) = SQL_FETCHROW($result_main);
- $salt = substr($hash, 0, -40);
+ if (SQL_NUMROWS($result_main) == 1) {
+ // Load hash from database
+ list($hashDB) = SQL_FETCHROW($result_main);
+
+ // Extract salt from cookie
+ $salt = substr($_SESSION['u_hash'], 0, -40);
// Now let's compare passwords
- $hash = generateHash($_POST['pass1'], $salt);
- if (($hash == $_COOKIE['u_hash']) || ($_POST['pass1'] == $_POST['pass2']))
- {
+ $hash = generatePassString($hashDB);
+ if (($hash == $_SESSION['u_hash']) || ($_POST['pass1'] == $_POST['pass2'])) {
// Load user's data
$result = SQL_QUERY_ESC("SELECT sex, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d AND password='%s' LIMIT 1",
- array($GLOBALS['userid'], $hash), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
+ array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result) == 1) {
+ // Load the data
$DATA = SQL_FETCHROW($result);
+
+ // Free result
SQL_FREERESULT($result);
+
+ // Translate salutation
$DATA[0] = TRANSLATE_SEX($DATA[0]);
+
+ // Clear/init the content variable
+ $content = "";
+ $DATA['info'] = "";
+
switch ($mod)
{
case "mydata":
- foreach ($modes as $mode)
- {
+ foreach ($modes as $mode) {
switch ($mode)
{
case "normal": break; // Do not add any special lines
$content = MEMBER_UNKNOWN_MODE.": ".$mode."\n\n";
break;
}
- }
+ } // END - if
- if (EXT_IS_ACTIVE("country"))
- {
+ if (EXT_IS_ACTIVE("country")) {
// Replace code with description
$DATA[4] = COUNTRY_GENERATE_INFO($_POST['country_code']);
}
// Load template
$msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']);
- if ($CONFIG['admin_notify'] == "Y")
- {
+ if ($_CONFIG['admin_notify'] == 'Y') {
// The admin needs to be notified about a profile change
$msg_admin = "admin_mydata_notify";
$sub_adm = ADMIN_CHANGED_DATA;
- }
- else
- {
+ } else {
// No mail to admin
$msg_admin = "";
$sub_adm = "";
$content = "<STRONG><SPAN class=\"member_failed\">".UNKNOWN_MODULE."</SPAN></STRONG>";
break;
}
- }
- else
- {
+ } else {
// Could not load profile data
$content = "<STRONG><SPAN class=\"member_failed\">".MEMBER_CANNOT_LOAD_PROFILE."</SPAN></STRONG>";
}
- }
- else
- {
+ } else {
// Passwords mismatch
$content = "<STRONG><SPAN class=\"member_failed\">".MEMBER_PASSWORD_ERROR."</SPAN></STRONG>";
}
- }
- else
- {
+ } else {
// Could not load profile
$content = "<STRONG><SPAN class=\"member_failed\">".MEMBER_CANNOT_LOAD_PROFILE."</SPAN></STRONG>";
}
- if ((!empty($sub_mem)) && (!empty($msg)))
- {
+
+ // Send email to user if required
+ if ((!empty($sub_mem)) && (!empty($msg))) {
// Send member mail
SEND_EMAIL($DATA[7], $sub_mem, $msg);
}
- if ((!empty($sub_adm)) && (!empty($msg_admin)))
- {
- // Send admin mail
- if (GET_EXT_VERSION("admins") >= "0.4.1")
- {
- SEND_ADMIN_EMAILS_PRO($sub_adm, $msg_admin, $content, $GLOBALS['userid']);
- }
- else
- {
- SEND_ADMIN_EMAILS($sub_adm, LOAD_EMAIL_TEMPLATE($msg_admin, $content, $GLOBALS['userid']));
+
+ // Send only if no other error has occured
+ if (empty($content)) {
+ if ((!empty($sub_adm)) && (!empty($msg_admin))) {
+ // Send admin mail
+ if (GET_EXT_VERSION("admins") >= "0.4.1") {
+ SEND_ADMIN_EMAILS_PRO($sub_adm, $msg_admin, $content, $GLOBALS['userid']);
+ } else {
+ SEND_ADMIN_EMAILS($sub_adm, LOAD_EMAIL_TEMPLATE($msg_admin, $content, $GLOBALS['userid']));
+ }
+ } elseif ($_CONFIG['admin_notify'] == 'Y') {
+ // Cannot send mails to admin!
+ $content = CANNOT_SEND_ADMIN_MAILS;
+ } else {
+ // No mail to admin
+ $content = "<STRONG><SPAN class=\"member_done\">".MYDATA_MAIL_SENT."</SPAN></STRONG>";
}
}
- elseif ($CONFIG['admin_notify'] == "Y")
- {
- // Cannot send mails to admin!
- $content = CANNOT_SEND_ADMIN_MAILS;
- }
- else
- {
- // No mail to admin
- $content = "<STRONG><SPAN class=\"member_done\">".MYDATA_MAIL_SENT."</SPAN></STRONG>";
- }
// Load template
LOAD_TEMPLATE("admin_settings_saved", false, $content);
return $ret;
}
//
-function GET_PAY_POINTS($pid, $DATA="price")
+function GET_PAY_POINTS($pid, $lookFor="price")
{
$ret = "-1";
- $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_payments WHERE id=%d LIMIT 1", array($DATA, $pid), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT %s FROM "._MYSQL_PREFIX."_payments WHERE id=%d LIMIT 1",
+ array($lookFor, $pid), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1)
{
// Payment type found... :-)
if ($stats_id > 0)
{
// Only when we got a real stats ID continue searching for the entry
- $TYPE = "NORMAL"; $ROW = "stats_id";
- if ($bonus) { $TYPE = "BONUS"; $ROW = "bonus_id"; }
+ $type = "NORMAL"; $rowName = "stats_id";
+ if ($bonus) { $type = "BONUS"; $rowName = "bonus_id"; }
$result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE %s='%s' AND userid=%d AND link_type='%s' LIMIT 1",
- array($ROW, $stats_id, bigintval($uid), $TYPE), __FILE__, __LINE__);
+ array($rowName, $stats_id, bigintval($uid), $type), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 0)
{
// No, so we add one!
$result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_links (%s, userid, link_type) VALUES ('%s', '%s', '%s')",
- array($ROW, $stats_id, bigintval($uid), $TYPE), __FILE__, __LINE__);
+ array($rowName, $stats_id, bigintval($uid), $type), __FILE__, __LINE__);
$ret = "done";
}
else
return $ret;
}
//
-function GET_TOTAL_DATA($SEARCH, $TABLE, $DATA, $WHERE="userid", $ONLY_ROWS=false)
+function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false)
{
$ret = "0";
- if ($ONLY_ROWS)
- {
+ if ($onlyRows) {
// Count rows
$result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
- array($DATA, $TABLE, $WHERE, $SEARCH), __FILE__, __LINE__);
- }
- else
- {
+ array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
+ } else {
// Add all rows
$result = SQL_QUERY_ESC("SELECT SUM(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
- array($DATA, $TABLE, $WHERE, $SEARCH), __FILE__, __LINE__);
+ array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
}
+
// Load row
list($ret) = SQL_FETCHROW($result);
- //* DEBUG: */ echo __LINE__."*".$DATA."/".$SEARCH."/".$TABLE."/".$ret."*<br />\n";
+ //* DEBUG: */ echo __LINE__."*".$DATA."/".$search."/".$tableName."/".$ret."*<br />\n";
SQL_FREERESULT($result);
if (empty($ret)) {
- if (($DATA == "counter") || ($DATA == "id")) {
+ if (($lookFor == "counter") || ($lookFor == "id")) {
$ret = "0";
} else {
$ret = "0.00000";
*/
function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref")
{
- global $DEPTH, $_GET, $CONFIG, $DATA, $link;
+ global $DEPTH, $_CONFIG, $DATA, $link;
// When $uid = 0 add points to jackpot
if ($uid == "0")
$P = $points * $per / 100;
// Update points...
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%d AND ref_depth='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%d AND ref_depth=%d LIMIT 1",
array($data, $data, $P, bigintval($uid), bigintval($DEPTH)), __FILE__, __LINE__);
if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 0)
{
// First ref in this level! :-)
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid, ref_depth, %s) VALUES ('%s', '%s', '%s')",
+ $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid, ref_depth, %s) VALUES (%d, %d, %s)",
array($data, bigintval($uid), bigintval($DEPTH), $P), __FILE__, __LINE__);
}
//
function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht)
{
- global $_COOKIE, $_SERVER, $link, $_GET, $CONFIG;
+ global $link, $_CONFIG;
// Do not update online list when extension is deactivated
if (!EXT_IS_ACTIVE("online", true)) return;
// Initialize variables
- $uid = "0"; $rid = "0"; $MEM = "N"; $ADMIN = "N";
+ $uid = "0"; $rid = "0"; $MEM = 'N'; $ADMIN = 'N';
if (!empty($GLOBALS['userid']))
{
// Update member status only when userid is valid
{
// Is valid user
$uid = $GLOBALS['userid'];
- $MEM = "Y";
+ $MEM = 'Y';
}
}
if (IS_ADMIN())
{
// Is administrator
- $ADMIN = "Y";
+ $ADMIN = 'Y';
}
- if (!empty($_COOKIE['refid']))
+ if (!empty($_SESSION['refid']))
{
// Check cookie
- if ($_COOKIE['refid'] > 0) $rid = $GLOBALS['refid'];
+ if ($_SESSION['refid'] > 0) $rid = $GLOBALS['refid'];
}
// Now Read data
}
// Purge old entries
- $TIMEOUT = time() - $CONFIG['online_timeout'];
+ $TIMEOUT = time() - $_CONFIG['online_timeout'];
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= %d",
array($TIMEOUT), __FILE__, __LINE__);
}
}
// Aiut
function activateExchange() {
- global $CONFIG;
+ 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'])
+ if (SQL_NUMROWS($result) >= $_CONFIG['activate_xchange'])
{
// Free memory
SQL_FREERESULT($result);
//
function DELETE_USER_ACCOUNT($uid, $reason)
{
- $POINTS = 0;
+ $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
if (SQL_NUMROWS($result) == 1)
{
// Save his points to add them to the jackpot
- list($POINTS) = SQL_FETCHROW($result);
+ list($points) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Delete points entries as well
if (GET_EXT_VERSION("mediadata") >= "0.0.4")
{
// Update database
- MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
+ MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
}
// Now, when we have all his points adds them do the jackpot!
- ADD_JACKPOT($POINTS);
+ ADD_JACKPOT($points);
}
// Delete category selections as well...
}
// Now a mail to the user and that's all...
- $msg = LOAD_EMAIL_TEMPLATE("del-user", stripslashes($reason), $uid);
+ $msg = LOAD_EMAIL_TEMPLATE("del-user", $reason, $uid);
SEND_EMAIL($uid, ADMIN_DEL_ACCOUNT, $msg);
// Ok, delete the account!
//
function META_DESCRIPTION($mod, $wht)
{
- global $CONFIG, $DEPTH;
+ 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);
+ $DESCR = MAIN_TITLE." ".trim($_CONFIG['title_middle'])." ".ADD_DESCR("guest", "what-".$wht, true);
unset($DEPTH);
- OUTPUT_HTML ("<META name=\"description\" content=\"".$DESCR."\">\n");
+ OUTPUT_HTML("<META name=\"description\" content=\"".$DESCR."\">");
}
}
//
if (SQL_NUMROWS($result) == 0)
{
// Create line
- $result = SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', '0.00000')", __FILE__, __LINE__);
+ $result = SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__);
}
else
{
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", array($points), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1",
+ array($points), __FILE__, __LINE__);
$ret = $jackpot - $points;
}
}
//
function IS_DEMO()
{
- global $_COOKIE;
- return ((EXT_IS_ACTIVE("demo")) && ($_COOKIE['admin_login'] == "demo"));
+ global $_SESSION;
+ return ((EXT_IS_ACTIVE("demo")) && ($_SESSION['admin_login'] == "demo"));
}
//
function LOAD_CONFIG($no="0")
{
- global $CFG_CACHE, $CONFIG;
+ global $CFG_CACHE, $_CONFIG;
$CFG_DUMMY = false;
// Check for cache extension, cache-array and if the requested configuration is in cache
if ((is_array($CFG_CACHE)) && (isset($CFG_CACHE['config'][$no])))
}
// Count cache hits
- $CONFIG['cache_hits']++;
+ $_CONFIG['cache_hits']++;
}
else
{
//
function MODULE_HAS_MENU($mod)
{
- global $EXTENSIONS, $MODULES, $CONFIG;
+ global $EXTENSIONS, $MODULES, $_CONFIG;
// All is false by default
$ret = false;
if (isset($MODULES['has_menu'][$mod]))
{
// Check module cache and count hit
- if ($MODULES['has_menu'][$mod] == "Y") $ret = true;
- $CONFIG['cache_hits']++;
+ if ($MODULES['has_menu'][$mod] == 'Y') $ret = true;
+ $_CONFIG['cache_hits']++;
}
elseif (isset($EXTENSIONS['ext_menu'][$mod]))
{
// Check cache and count hit
- if ($EXTENSIONS['ext_menu'][$mod] == "Y") $ret = true;
- $CONFIG['cache_hits']++;
+ if ($EXTENSIONS['ext_menu'][$mod] == 'Y') $ret = true;
+ $_CONFIG['cache_hits']++;
}
}
if ((GET_EXT_VERSION("sql_patches") >= "0.3.6") && ($ret === false))
if (SQL_NUMROWS($result) == 1)
{
list($has_menu) = SQL_FETCHROW($result);
- if ($has_menu == "Y") $ret = true;
+ if ($has_menu == 'Y') $ret = true;
}
// Free memory
// Return status
return $ret;
}
+
//
?>