X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=e33b1b395e995c187edbccd29b2fbde77684f250;hb=263a089d8a499e0e26d0af9e7aa7639f88b8ca60;hp=1c9a5c64cfef11039c97297211784ee18d01b34d;hpb=9f6c30cc0e06098171d773d671292081ecee3d29;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 1c9a5c64cf..e33b1b395e 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1,7 +1,7 @@ {--YOU_ARE_HERE--} Home"; } else { if ($return === false) $GLOBALS['nav_depth']++; @@ -386,7 +386,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru //* DEBUG: */ print(__LINE__.'+'.$type."+
"); // Add closing div and br-tag $OUT .= "
\n"; - $GLOBALS['nav_depth'] = 0; + $GLOBALS['nav_depth'] = '0'; // Run the filter chain $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => "")); @@ -411,7 +411,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru // Adds a menu (mode = guest/member/admin/sponsor) to output function addMenu ($mode, $action, $what) { // Init some variables - $main_cnt = 0; + $main_cnt = '0'; $AND = ''; // is the menu action valid? @@ -451,7 +451,7 @@ function addMenu ($mode, $action, $what) { // Do we have some entries? if ($totalWhats > 0) { // Init counter - $cnt = 0; + $cnt = '0'; // Load all sub menus while ($content2 = SQL_FETCHARRAY($result_sub)) { @@ -580,9 +580,12 @@ function isMember () { if (isset($GLOBALS['is_member'])) { // Then return it return $GLOBALS['is_member']; - } elseif (getUserId() == 0) { + } elseif (getMemberId() == '0') { // No member return false; + } else { + // Transfer userid=>current + setCurrentUserid(getMemberId()); } // Init global user data array @@ -592,9 +595,9 @@ function isMember () { fixDeletedCookies(array('userid', 'u_hash')); // Are cookies set? - if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) { + if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) { // Cookies are set with values, but are they valid? - if (fetchUserData(getUserId()) === true) { + if (fetchUserData(getMemberId()) === true) { // Validate password by created the difference of it and the secret key $valPass = generatePassString(getUserData('password')); @@ -608,18 +611,16 @@ function isMember () { $ret = true; } else { // Maybe got locked etc. - //* DEBUG: */ print(__LINE__."!!!
"); - destroyUserSession(); + logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status')); + destroyMemberSession(); } } else { // Cookie data is invalid! - //* DEBUG: */ print(__LINE__."***
"); - destroyUserSession(); + destroyMemberSession(); } } else { // Cookie data is invalid! - //* DEBUG: */ print(__LINE__."///
"); - destroyUserSession(); + destroyMemberSession(); } // Cache status @@ -631,24 +632,31 @@ function isMember () { // Fetch user data for given user id function fetchUserData ($userid, $column='userid') { - // Don't look for invalid userids... - if ($userid < 1) { - // Invalid, so abort here - debug_report_bug('User id ' . $userid . ' is invalid.'); - } elseif (isset($GLOBALS['user_data'][$userid])) { + // If we should look for userid secure&set it here + if (substr($column, -2, 2) == 'id') { + // Secure userid + $userid = bigintval($userid); + + // Set it here + setCurrentUserId($userid); + + // Don't look for invalid userids... + if ($userid < 1) { + // Invalid, so abort here + debug_report_bug('User id ' . $userid . ' is invalid.'); + } elseif (isUserDataValid()) { + // Use cache, so it is fine + return true; + } + } elseif (isUserDataValid()) { // Use cache, so it is fine return true; } + // By default none was found $found = false; - // Do we have userid/refid? - if (($column == 'userid') || ($column == 'refid')) { - // Then secure the id - $userid = bigintval($userid); - } // END - if - // Query for the user $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1", array($column, $userid), __FUNCTION__, __LINE__); @@ -666,12 +674,12 @@ function fetchUserData ($userid, $column='userid') { if (isset($GLOBALS['user_data'][getCurrentUserId()]['last_failure'])) { // Backup the raw one and zero it $GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] = $GLOBALS['user_data'][getCurrentUserId()]['last_failure']; - $GLOBALS['user_data'][getCurrentUserId()]['last_failure'] = 0; + $GLOBALS['user_data'][getCurrentUserId()]['last_failure'] = '0'; // Is it not zero? if ($GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] != '0000-00-00 00:00:00') { // Seperate data/time - $array = explode(' ', $GLOBALS['user_data'][getCurrentUserId()]['last_failure']); + $array = explode(' ', $GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw']); // Seperate data and time again $array['date'] = explode('-', $array[0]); @@ -869,6 +877,8 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { // Run SQL command $result = SQL_QUERY($sql, __FUNCTION__, __LINE__); + + // Should we look for affected rows (only update) or found rows? if ($updateEntry === true) { // Check updated/affected rows $ret = (SQL_AFFECTEDROWS() == 1); @@ -891,7 +901,7 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { // @TODO Lame description for this function function sendModeMails ($mod, $modes) { // Load hash - if (fetchUserData(getUserId())) { + if (fetchUserData(getMemberId())) { // Extract salt from cookie $salt = substr(getSession('u_hash'), 0, -40); @@ -902,7 +912,7 @@ function sendModeMails ($mod, $modes) { if (($hash == getSession('u_hash')) || (postRequestElement('pass1') == postRequestElement('pass2'))) { // Load user's data 0 1 2 3 4 5 6 7 $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s AND password='%s' LIMIT 1", - array(getUserId(), getUserData('password')), __FUNCTION__, __LINE__); + array(getMemberId(), getUserData('password')), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load the data $content = SQL_FETCHARRAY($result, 0, false); @@ -945,7 +955,7 @@ function sendModeMails ($mod, $modes) { $content = merge_array($content, postRequestArray()); // Load template - $message = loadEmailTemplate('member_mydata_notify', $content, getUserId()); + $message = loadEmailTemplate('member_mydata_notify', $content, getMemberId()); if (getConfig('admin_notify') == 'Y') { // The admin needs to be notified about a profile change @@ -992,7 +1002,7 @@ function sendModeMails ($mod, $modes) { if (empty($content)) { if ((!empty($sub_adm)) && (!empty($message_admin))) { // Send admin mail - sendAdminNotification($sub_adm, $message_admin, $content, getUserId()); + sendAdminNotification($sub_adm, $message_admin, $content, getMemberId()); } elseif (getConfig('admin_notify') == 'Y') { // Cannot send mails to admin! $content = getMessage('CANNOT_SEND_ADMIN_MAILS'); @@ -1012,7 +1022,15 @@ function getModeAction ($mode, $what) { $ret = ''; //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=
"); - if ((empty($what)) && ($mode != 'admin')) { + if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) { + // sql_patches is missing so choose depending on mode + if ($mode == 'admin') { + $what = 'overview'; + } else { + $what = 'welcome'; + } + } elseif ((empty($what)) && ($mode != 'admin')) { + // Use configured 'home' $what = getConfig('index_home'); } // END - if @@ -1070,7 +1088,7 @@ function getCategory ($cid) { $ret = getMessage('_CATEGORY_404'); // Is the category id set? - if ($cid == 0) { + if ($cid == '0') { // No category $ret = getMessage('_CATEGORY_NONE'); } elseif ($cid > 0) { @@ -1160,7 +1178,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__); // Was it *not* found? - if (SQL_NUMROWS($result) == 0) { + if (SQL_NUMROWS($result) == '0') { // So we add one! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')", array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__); @@ -1181,7 +1199,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // Calculate sum (default) or count records of given criteria function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') { - $ret = 0; + $ret = '0'; //* DEBUG: */ print($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'
'); if ((empty($search)) && ($search != '0')) { // Count or sum whole table? @@ -1218,16 +1236,17 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen $ret = '0.00000'; } elseif (''.$ret.'' == '') { // Fix empty result - $ret = 0; + $ret = '0'; } // Return value + //* DEBUG: */ print 'ret='.$ret.'
'; return $ret; } // Getter fro ref level percents function getReferalLevelPercents ($level) { // Default is zero - $per = 0; + $per = '0'; // Do we have cache? if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) { @@ -1272,13 +1291,13 @@ function getReferalLevelPercents ($level) { * add_mode = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct' * for default value will cause no referal will get points ever!!!) */ -function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = 0, $locked = false, $add_mode = 'ref') { +function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = '0', $locked = false, $add_mode = 'ref') { //* DEBUG: */ print("----------------------- ".__FUNCTION__." - ENTRY ------------------------