X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=b986d783baef83eb44ccdc717ba0f9a62040e1e0;hp=17b3ae9f72937c50751ce00c2007a095e56001f0;hb=adb34cea9c14bcac14030f8eb1e6ae2c3231c962;hpb=3c23bfaee208fa12adf5cdd9d8e9882612199d03 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 17b3ae9f72..b986d783ba 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']++; @@ -363,56 +354,41 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru $search = substr($search, 0, -4); } // END - i - // Get the title from menu - $result = SQL_QUERY_ESC("SELECT title FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1", - array($accessLevel, $type, $search), __FUNCTION__, __LINE__); + if (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) { + // Output HTML code + $OUT = $prefix . ""); + if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) { + //* DEBUG: */ print(__LINE__.'+'.$type."+
"); + // Add closing div and br-tag + $OUT .= "
\n"; + $GLOBALS['nav_depth'] = '0'; - // Shall we return it? - if ($return === true) { - // Return title - return $ret; - } elseif (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) { - // Output HTML code - $OUT = $prefix . "
"); - if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) { - //* DEBUG: */ print(__LINE__.'+'.$type."+
"); - // Add closing div and br-tag - $OUT .= "
\n"; - $GLOBALS['nav_depth'] = 0; - - // Run the filter chain - $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => "")); - $OUT .= $ret['content']; - } // END - if - } - } // END - if + // Run the filter chain + $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => '')); - // Free result - SQL_FREERESULT($result); + // Add additional content + $OUT .= $ret['content']; + } // END - if + } // Return or output HTML code? - if ($output) { - // Output HTML code here - outputHtml($OUT); - } else { + if ($return === true) { // Return HTML code return $OUT; + } else { + // Output HTML code here + outputHtml($OUT); } } // Adds a menu (mode = guest/member/admin/sponsor) to output function addMenu ($mode, $action, $what) { // Init some variables - $main_cnt = 0; - $AND = ''; + $main_cnt = '0'; + $ADD = ''; // is the menu action valid? if (!isMenuActionValid($mode, $action, $what, true)) { @@ -421,11 +397,11 @@ function addMenu ($mode, $action, $what) { // Non-admin shall not see all menus if (!isAdmin()) { - $AND = " AND `visible`='Y' AND `locked`='N'"; + $ADD = " AND `visible`='Y' AND `locked`='N'"; } // END - if // Load SQL data and add the menu to the output stream... - $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort` ASC", + $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$ADD." ORDER BY `sort` ASC", array($mode), __FUNCTION__, __LINE__); //* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*
"); @@ -442,7 +418,7 @@ function addMenu ($mode, $action, $what) { $GLOBALS['rows'] .= loadTemplate($mode . '_menu_title', true, $content); // Sub menu - $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$AND." ORDER BY `sort`", + $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$ADD." ORDER BY `sort`", array($mode, $content['action']), __FUNCTION__, __LINE__); // Get number of rows @@ -451,7 +427,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,7 +556,7 @@ function isMember () { if (isset($GLOBALS['is_member'])) { // Then return it return $GLOBALS['is_member']; - } elseif (getMemberId() == 0) { + } elseif (getMemberId() == '0') { // No member return false; } else { @@ -611,17 +587,15 @@ function isMember () { $ret = true; } else { // Maybe got locked etc. - //* DEBUG: */ print(__LINE__."!!!
"); + logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status')); destroyMemberSession(); } } else { // Cookie data is invalid! - //* DEBUG: */ print(__LINE__."***
"); destroyMemberSession(); } } else { // Cookie data is invalid! - //* DEBUG: */ print(__LINE__."///
"); destroyMemberSession(); } @@ -676,7 +650,7 @@ 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') { @@ -899,132 +873,26 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { return $ret; } -// Send out mails depending on the 'mod/modes' combination -// @TODO Lame description for this function -function sendModeMails ($mod, $modes) { - // Load hash - if (fetchUserData(getMemberId())) { - // Extract salt from cookie - $salt = substr(getSession('u_hash'), 0, -40); - - // Now let's compare passwords - $hash = generatePassString(getUserData('password')); - - // Does the hash match or should we change it? - 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(getMemberId(), getUserData('password')), __FUNCTION__, __LINE__); - if (SQL_NUMROWS($result) == 1) { - // Load the data - $content = SQL_FETCHARRAY($result, 0, false); - - // Free result - SQL_FREERESULT($result); - - // Translate gender - $content['gender'] = translateGender($content['gender']); - - // Clear/init the content variable - $content['message'] = ''; - - switch ($mod) { - case 'mydata': - foreach ($modes as $mode) { - switch ($mode) { - case 'normal': break; // Do not add any special lines - case 'email': // Email was changed! - $content['message'] = getMessage('MEMBER_CHANGED_EMAIL').": ".postRequestElement('old_email')."\n"; - break; - - case 'pass': // Password was changed - $content['message'] = getMessage('MEMBER_CHANGED_PASS')."\n"; - break; - - default: - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode)); - $content['message'] = getMessage('MEMBER_UNKNOWN_MODE') . ': ' . $mode . "\n\n"; - break; - } // END - switch - } // END - foreach - - if (isExtensionActive('country')) { - // Replace code with description - $content['country'] = generateCountryInfo(postRequestElement('country_code')); - } // END - if - - // Merge content with data from POST - $content = merge_array($content, postRequestArray()); - - // Load template - $message = loadEmailTemplate('member_mydata_notify', $content, getMemberId()); - - if (getConfig('admin_notify') == 'Y') { - // The admin needs to be notified about a profile change - $message_admin = 'admin_mydata_notify'; - $sub_adm = getMessage('ADMIN_CHANGED_DATA'); - } else { - // No mail to admin - $message_admin = ''; - $sub_adm = ''; - } - - // Set subject lines - $sub_mem = getMessage('MEMBER_CHANGED_DATA'); - - // Output success message - $content = "{--MYDATA_MAIL_SENT--}"; - break; - - default: // Unsupported module! - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod)); - $content = "{--UNKNOWN_MODULE--}"; - break; - } // END - switch - } else { - // Could not load profile data - $content = "{--MEMBER_CANNOT_LOAD_PROFILE--}"; - } - } else { - // Passwords mismatch - $content = "{--MEMBER_PASSWORD_ERROR--}"; - } - } else { - // Could not load profile - $content = "{--MEMBER_CANNOT_LOAD_PROFILE--}"; - } - - // Send email to user if required - if ((!empty($sub_mem)) && (!empty($message))) { - // Send member mail - sendEmail($content['email'], $sub_mem, $message); - } // END - if - - // Send only if no other error has occured - if (empty($content)) { - if ((!empty($sub_adm)) && (!empty($message_admin))) { - // Send admin mail - sendAdminNotification($sub_adm, $message_admin, $content, getMemberId()); - } elseif (getConfig('admin_notify') == 'Y') { - // Cannot send mails to admin! - $content = getMessage('CANNOT_SEND_ADMIN_MAILS'); - } else { - // No mail to admin - $content = "{--MYDATA_MAIL_SENT--}"; - } - } // END - if - - // Load template - loadTemplate('admin_settings_saved', false, $content); -} - // Get action value from mode (admin/guest/member) and what-value function getModeAction ($mode, $what) { // Init status $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 (isWhatSet()) { + // Use setted what + $what = getWhat(); + } elseif ($mode == 'admin') { + // Admin area + $what = 'overview'; + } else { + // Everywhere else + $what = 'welcome'; + } + } elseif ((empty($what)) && ($mode != 'admin')) { + // Use configured 'home' $what = getConfig('index_home'); } // END - if @@ -1064,7 +932,7 @@ function getModeAction ($mode, $what) { // Free memory SQL_FREERESULT($result); - } elseif ((!isExtensionInstalled('sql_patches')) && ($mode != 'admin')) { + } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) { // No sql_patches installed, but maybe we need to register an admin? if (isAdminRegistered()) { // Redirect to admin area @@ -1082,7 +950,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) { @@ -1172,7 +1040,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__); @@ -1193,7 +1061,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? @@ -1230,7 +1098,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen $ret = '0.00000'; } elseif (''.$ret.'' == '') { // Fix empty result - $ret = 0; + $ret = '0'; } // Return value @@ -1240,7 +1108,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen // 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'))) { @@ -1285,13 +1153,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 ------------------------
  • \n"); // Convert mode to lower-case $add_mode = strtolower($add_mode); - // When $userid = 0 add points to jackpot - if (($userid == 0) && (isExtensionActive('jackpot'))) { + // When $userid = '0' add points to jackpot + if (($userid == '0') && (isExtensionActive('jackpot'))) { // Add points to jackpot addPointsToJackpot($points); return; @@ -1316,7 +1184,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify if (!isset($GLOBALS['ref_level'])) { // Initialialize referal system //* DEBUG: */ print(__FUNCTION__."(".__LINE__."): Referal system initialized!
    "); - $GLOBALS['ref_level'] = 0; + $GLOBALS['ref_level'] = '0'; } else { // Increase referal level $GLOBALS['ref_level']++; @@ -1379,7 +1247,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify $message = loadEmailTemplate('confirm-referal', $content, bigintval($userid)); sendEmail(getUserData('email'), THANX_REFERAL_ONE, $message); - } elseif (($sendNotify) && (getUserData('refid') == 0) && ($locked === false) && ($add_mode == 'direct')) { + } elseif (($sendNotify) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) { // Prepare content $content = array( 'text' => getMessage('REASON_DIRECT_PAYMENT'), @@ -1426,7 +1294,7 @@ function updateReferalCounter ($userid) { } // END - if // Init referal id - $ref = 0; + $ref = '0'; // Check for his referal if (fetchUserData($userid)) { @@ -1442,7 +1310,7 @@ function updateReferalCounter ($userid) { //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):ref={$ref} - ADVANCE!
    "); $GLOBALS['cache_array']['ref_level'][$userid]++; updateReferalCounter($ref); - } elseif ((($ref == $userid) || ($ref == 0)) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) { + } elseif ((($ref == $userid) || ($ref == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) { // Remove cache here //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):ref={$ref} - CACHE!
    "); rebuildCacheFile('refsystem', 'refsystem'); @@ -1646,22 +1514,32 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher $ret = ''; if ($table == '/ARRAY/') { // Selection from array - if (is_array($id) && is_array($name) && count($id) == count($name)) { + if ((is_array($id)) && (is_array($name)) && (count($id)) == (count($name))) { // Both are arrays foreach ($id as $idx => $value) { $ret .= ''; } // END - while - - // Free memory - SQL_FREERESULT($result); } else { // No data found $ret = ''; } + + // Free memory + SQL_FREERESULT($result); } // Return - hopefully - the requested data @@ -1687,7 +1565,7 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher // Activate exchange function FILTER_ACTIVATE_EXCHANGE () { // Is the extension 'user' there? - if ((!isExtensionActive('user')) || (getConfig('activate_xchange') == 0)) { + if ((!isExtensionActive('user')) || (getConfig('activate_xchange') == '0')) { // Silently abort here return false; } // END - if @@ -1715,7 +1593,7 @@ function FILTER_ACTIVATE_EXCHANGE () { // Deletes a user account with given reason function deleteUserAccount ($userid, $reason) { - $points = 0; + $points = '0'; $result = SQL_QUERY_ESC("SELECT (SUM(p.points) - d.used_points) AS points FROM @@ -1735,7 +1613,7 @@ WHERE SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s", array(bigintval($userid)), __FUNCTION__, __LINE__); // Update mediadata as well - if (getExtensionVersion('mediadata') >= '0.0.4') { + if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { // Update database updateMediadataEntry(array('total_points'), 'sub', $points); } // END - if @@ -1770,7 +1648,7 @@ function generateMetaDescriptionCode ($mod, $what) { // Exclude admin and member's area if (($mod != 'admin') && ($mod != 'login')) { // Construct dynamic description - $DESCR = '{?MAIN_TITLE?} '.trim(getConfig('title_middle')) . ' ' . addMenuDescription('guest', 'what-'.$what, true); + $DESCR = '{?MAIN_TITLE?} '.trim(getConfig('title_middle')) . ' ' . getTitleFromMenu('guest', $what); // Output it directly outputHtml(''); @@ -1871,7 +1749,10 @@ function generateCategoryOptionsList ($mode) { ); // Get categories - $result = SQL_QUERY("SELECT id, cat FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort`", __FUNCTION__, __LINE__); + $result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort` ASC", + __FUNCTION__, __LINE__); + + // Do we have entries? if (SQL_NUMROWS($result) > 0) { // ... and begin loading stuff while ($content = SQL_FETCHARRAY($result)) { @@ -1884,7 +1765,7 @@ function generateCategoryOptionsList ($mode) { array(bigintval($content['id'])), __FUNCTION__, __LINE__); // Start adding all - $userid_cnt = 0; + $userid_cnt = '0'; // @TODO Rewrite this to $content = SQL_FETCHARRAY() while (list($ucat) = SQL_FETCHROW($result_userids)) { $result_ver = SQL_QUERY_ESC("SELECT @@ -1892,7 +1773,9 @@ function generateCategoryOptionsList ($mode) { FROM `{?_MYSQL_PREFIX?}_user_data` WHERE - `userid`=%s AND `status`='CONFIRMED' AND `receive_mails` > 0".runFilterChain('exclude_users', $mode)." + `userid`=%s AND + `status`='CONFIRMED' AND + `receive_mails` > 0".runFilterChain('exclude_users', $mode)." LIMIT 1", array(bigintval($ucat)), __FUNCTION__, __LINE__); @@ -1943,7 +1826,7 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, $target = countSelection(explode(';', $receiverList)); // Receiver is zero? - if ($receiver == 0) { + if ($receiver == '0') { // Then auto-fix it $receiver = $target; } // END - if @@ -2004,7 +1887,7 @@ function generateReceiverList ($cat, $receiver, $mode = '') { $receiver = bigintval($receiver); // Is the receiver zero and mode set? - if (($receiver == 0) && (!empty($mode))) { + if (($receiver == '0') && (!empty($mode))) { // Auto-fix receiver maximum $receiver = getTotalReceivers($mode); } // END - if @@ -2056,12 +1939,12 @@ function generateReceiverList ($cat, $receiver, $mode = '') { } // Get timestamp for given stats type and data -function getTimestampFromUserStats ($type, $data, $userid = 0) { +function getTimestampFromUserStats ($type, $data, $userid = '0') { // Default timestamp is zero - $stamp = 0; + $stamp = '0'; // User id set? - if ((isMemberIdSet()) && ($userid == 0)) { + if ((isMemberIdSet()) && ($userid == '0')) { $userid = getMemberId(); } // END - if @@ -2161,7 +2044,7 @@ ORDER BY ur.refid ASC", $row['unconfirmed'] = countSumTotalData($row['refid'], 'user_links', 'id', 'userid', true); // Init clickrate with zero - $row['clickrate'] = 0; + $row['clickrate'] = '0'; // Is at least one mail received? if ($row['emails_received'] > 0) { @@ -2221,10 +2104,10 @@ function reduceRecipientReceivedMails ($column, $id, $count) { } // Creates a new task -function createNewTask ($subject, $notes, $taskType, $userid = 0, $adminId = 0, $strip = true) { +function createNewTask ($subject, $notes, $taskType, $userid = '0', $adminId = '0', $strip = true) { // Insert the task data into the database SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())", - array($adminId, $userid, $taskType, $subject, smartAddSlashes($notes)), __FUNCTION__, __LINE__, true, $strip); + array($adminId, $userid, $taskType, $subject, escapeQuotes($notes)), __FUNCTION__, __LINE__, true, $strip); } // Updates last module / online time