X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=49962859a1e1f5f053af6b143002057b016671f1;hp=76f6957921e860d40daed4920ea22c33a96a99ea;hb=36c3c8b749a88ce05ad0fda81e00047f9cb5433f;hpb=b8aa17b98b99c27eafbdca0fa090bae63527da9a diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 76f6957921..49962859a1 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -117,10 +117,10 @@ function checkModulePermissions ($mod) { // Check for prefix is a extension... $modSplit = explode("_", $mod); $extension = ''; $mod_chk = $mod; - //* DEBUG: */ echo __LINE__."*".count($modSplit)."*/".$mod."*
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."*".count($modSplit)."*/".$mod."*
"); if (count($modSplit) == 2) { // Okay, there is a seperator (_) in the name so is the first part a module? - //* DEBUG: */ echo __LINE__."*".$modSplit[0]."*
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."*".$modSplit[0]."*
"); if (EXT_IS_ACTIVE($modSplit[0])) { // The prefix is an extension's name, so let's set it $extension = $modSplit[0]; $mod = $modSplit[1]; @@ -253,7 +253,7 @@ function checkModulePermissions ($mod) { // Module not found we don't add it to the database $ret = '404'; } - } elseif ($ret == 'cache_miss') { + } elseif (($ret == 'cache_miss') && (getOutputMode() > -1)) { // Rebuild the cache files rebuildCacheFiles('modreg', 'modreg'); } elseif ($found === false) { @@ -370,9 +370,9 @@ function ADD_DESCR ($accessLevel, $FQFN, $return = false, $output = true) { $OUT = $prefix . "\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."*".$type.'/'.getWhat()."*
"); if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) { - //* DEBUG: */ echo __LINE__.'+'.$type."+
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'+'.$type."+
"); // Add closing div and br-tag $OUT .= "
\n"; $GLOBALS['nav_depth'] = '0'; @@ -418,12 +418,12 @@ function ADD_MENU ($mode, $act, $wht) { // 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", array($mode), __FUNCTION__, __LINE__); - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$main_action.'/'.$sub_what.':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$main_action.'/'.$sub_what.':'.getWhat()."*
"); if (SQL_NUMROWS($result_main) > 0) { OUTPUT_HTML(""); // There are menus available, so we simply display them... :) while ($content = SQL_FETCHARRAY($result_main)) { - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$sub_what.':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$sub_what.':'.getWhat()."*
"); // Init variables enableBlockMode(false); $act = $content['action']; @@ -452,7 +452,7 @@ function ADD_MENU ($mode, $act, $wht) { $OUT = ''; // Full file name for checking menu - //* DEBUG: */ echo __LINE__.":!!!!".$content['sub_what']."!!!
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.":!!!!".$content['sub_what']."!!!
"); $INC = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']); if (isIncludeReadable($INC)) { if ((!empty($wht)) && (($wht == $content['sub_what']))) { @@ -505,16 +505,16 @@ function ADD_MENU ($mode, $act, $wht) { if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == 'online')) OUTPUT_HTML(""); } - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
"); } $main_cnt++; - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
"); if (SQL_NUMROWS($result_main) > $main_cnt) { OUTPUT_HTML(""); } // END - if @@ -524,7 +524,7 @@ function ADD_MENU ($mode, $act, $wht) { SQL_FREERESULT($result_main); // Close table - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
"); OUTPUT_HTML("
"); - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
"); loadInclude($INC_BLOCK); - //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
"); if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == 'online')) OUTPUT_HTML("
"); } // END - if } @@ -575,12 +575,12 @@ function IS_MEMBER () { $ret = true; } else { // Maybe got locked etc. - //* DEBUG: */ echo __LINE__."!!!
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."!!!
"); destroyUserSession(); } } else { // Cookie data is invalid! - //* DEBUG: */ echo __LINE__."***
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."***
"); destroyUserSession(); } @@ -588,7 +588,7 @@ function IS_MEMBER () { SQL_FREERESULT($result); } else { // Cookie data is invalid! - //* DEBUG: */ echo __LINE__."///
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."///
"); destroyUserSession(); } @@ -603,7 +603,7 @@ function IS_MEMBER () { function IS_ADMIN ($admin = '') { // Init variables $ret = false; $passCookie = ''; $valPass = ''; - //* DEBUG: */ echo __LINE__."ADMIN:".$admin."
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."ADMIN:".$admin."
"); // If admin login is not given take current from cookies... if ((empty($admin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) { @@ -611,7 +611,7 @@ function IS_ADMIN ($admin = '') { $admin = getSession('admin_login'); $passCookie = getSession('admin_md5'); } - //* DEBUG: */ echo __LINE__."ADMIN:".$admin.'/'.$passCookie."
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__."ADMIN:".$admin.'/'.$passCookie."
"); // Search in array for entry if (isset($GLOBALS['cache_array']['admin_hash'])) { @@ -650,12 +650,12 @@ function IS_ADMIN ($admin = '') { if (!empty($valPass)) { // Check if password is valid - //* DEBUG: */ print __FUNCTION__."*".$valPass.'/'.$passCookie."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."*".$valPass.'/'.$passCookie."*
"); $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!EXT_IS_ACTIVE('cache')))); } // END - if // Return result of comparision - //* DEBUG: */ if (!$ret) echo __LINE__."OK!
"; + //* DEBUG: */ if (!$ret) OUTPUT_HTML(__LINE__."OK!
"); return $ret; } @@ -747,7 +747,7 @@ function isMenuActionValid ($mode, $act, $wht, $UPDATE=false) { $add = ''; if ((!IS_ADMIN()) && ($mode != 'admin')) $add = " AND `locked`='N'"; - //* DEBUG: */ echo __LINE__.':'.$mode.'/'.$act.'/'.$wht."*
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.':'.$mode.'/'.$act.'/'.$wht."*
"); if (($mode != 'admin') && ($UPDATE === true)) { // Update guest or member menu $sql = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", @@ -800,7 +800,7 @@ function sendModeMails ($mod, $modes) { $hash = generatePassString($hashDB); if (($hash == getSession('u_hash')) || (REQUEST_POST('pass1') == REQUEST_POST('pass2'))) { // Load user's data - $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", + $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(), $hashDB), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load the data @@ -921,7 +921,7 @@ function getModeAction ($mode, $wht) { // Init status $ret = ''; - //* DEBUG: */ echo __LINE__.'='.$mode.'/'.$wht.'/'.getAction()."=
"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'='.$mode.'/'.$wht.'/'.getAction()."=
"); if ((empty($wht)) && ($mode != 'admin')) { $wht = 'welcome'; if (getConfig('index_home') != '') $wht = getConfig('index_home'); @@ -943,7 +943,7 @@ function getModeAction ($mode, $wht) { // Get it directly from URL return getAction(); } - //* DEBUG: */ echo __FUNCTION__."(".__LINE__."): ret=".$ret."
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."): ret=".$ret."
"); // Does the module have a menu? if (MODULE_HAS_MENU($mode)) { @@ -1097,7 +1097,7 @@ function removeReceiver (&$receivers, $key, $uid, $pool_id, $stats_id = '', $bon // Calculate sum (default) or count records of given criteria function GET_TOTAL_DATA ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') { $ret = 0; - //* DEBUG: */ echo $search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'
\n'; + //* DEBUG: */ OUTPUT_HTML($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'
'); if ((empty($search)) && ($search != '0')) { // Count or sum whole table? if ($countRows === true) { @@ -1111,12 +1111,12 @@ function GET_TOTAL_DATA ($search, $tableName, $lookFor = 'id', $whereStatement = } } elseif (($countRows === true) || ($lookFor == 'userid')) { // Count rows - //* DEBUG: */ echo "COUNT!
\n"; + //* DEBUG: */ OUTPUT_HTML("COUNT!
"); $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s'".$add, array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__); } else { // Add all rows - //* DEBUG: */ echo "SUM!
\n"; + //* DEBUG: */ OUTPUT_HTML("SUM!
"); $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s'".$add, array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__); } @@ -1188,7 +1188,7 @@ function getReferalLevelPercents ($level) { * for default value will cause no referal will get points ever!!!) */ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $rid = '0', $locked = false, $add_mode = 'ref') { - //* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); } // Wrapper function for ADD_POINTS_REFSYSTEM() @@ -1325,19 +1325,19 @@ function ADD_POINTS_REFSYSTEM_DIRECT ($subject, $uid, $points) { function updateReferalCounter ($uid) { // Make it sure referal level zero (member him-/herself) is at least selected if (empty($GLOBALS['cache_array']['ref_level'][$uid])) $GLOBALS['cache_array']['ref_level'][$uid] = 1; - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level={$GLOBALS['cache_array']['ref_level'][$uid]}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):uid={$uid},level={$GLOBALS['cache_array']['ref_level'][$uid]}
"); // Update counter SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`='%s' LIMIT 1", array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__); // When no entry was updated then we have to create it here - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):updated=".SQL_AFFECTEDROWS()."
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):updated=".SQL_AFFECTEDROWS()."
"); if (SQL_AFFECTEDROWS() < 1) { // First count! SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)", array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):uid={$uid}
"); } // END - if // Check for his referal @@ -1349,16 +1349,16 @@ function updateReferalCounter ($uid) { // Free memory SQL_FREERESULT($result); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref}
"); // When he has a referal... if (($ref > 0) && ($ref != $uid)) { // Move to next referal level and count his counter one up! - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):ref={$ref} - ADVANCE!
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):ref={$ref} - ADVANCE!
"); $GLOBALS['cache_array']['ref_level'][$uid]++; updateReferalCounter($ref); } elseif ((($ref == $uid) || ($ref == 0)) && (GET_EXT_VERSION('cache') >= '0.1.2')) { // Remove cache here - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):ref={$ref} - CACHE!
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):ref={$ref} - CACHE!
"); rebuildCacheFiles('refsystem', 'refsystem'); } @@ -1634,7 +1634,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); list($points) = SQL_FETCHROW($result); // Delete points entries as well - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_points` WHERE `userid`=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); // Update mediadata as well if (GET_EXT_VERSION('mediadata') >= '0.0.4') { @@ -1650,12 +1650,12 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); SQL_FREERESULT($result); // Delete category selections as well... - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE userid=%s", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE `userid`=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); // Remove from rallye if found if (EXT_IS_ACTIVE('rallye')) { - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE userid=%s", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE `userid`=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); } // END - if @@ -1664,7 +1664,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); sendEmail($uid, getMessage('ADMIN_DEL_ACCOUNT'), $message); // Ok, delete the account! - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); } // Generates meta description for given module and 'what' value @@ -1739,7 +1739,7 @@ function getWhatFromModule ($modCheck) { // Default is empty $wht = ''; - //* DEBUG: */ echo __LINE__.'!'.$modCheck."!
\n"; + //* DEBUG: */ OUTPUT_HTML(__LINE__.'!'.$modCheck."!
"); switch ($modCheck) { case 'admin': $wht = 'overview'; @@ -1763,7 +1763,7 @@ function getWhatFromModule ($modCheck) { // Subtract points from database and mediadata cache function SUB_POINTS ($subject, $uid, $points) { // Add points to used points - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `used_points`=`used_points`+%s WHERE `userid`=%s LIMIT 1", array($points, bigintval($uid)), __FUNCTION__, __LINE__); // Insert booking record @@ -1796,18 +1796,18 @@ function updateConfiguration ($entries, $values, $updateMode='') { if (!empty($updateMode)) { // Update entry // @TODO Find a way for updating $_CONFIG here - $all .= sprintf("%s=%s%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]); + $all .= sprintf("`%s`=%s%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]); } else { // Check if string or number if (($values[$idx] + 0) === $values[$idx]) { // Number detected - $all .= sprintf("%s=%s,", $entry, (float)$values[$idx]); + $all .= sprintf("`%s`=%s,", $entry, (float)$values[$idx]); } elseif ($values[$idx] == 'UNIX_TIMESTAMP()') { // Function UNIX_TIMESTAMP() detected - $all .= sprintf("%s=%s,", $entry, $values[$idx]); + $all .= sprintf("`%s`=%s,", $entry, $values[$idx]); } else { // String detected - $all .= sprintf("%s='%s',", $entry, SQL_ESCAPE($values[$idx])); + $all .= sprintf("`%s`='%s',", $entry, SQL_ESCAPE($values[$idx])); } } @@ -1835,7 +1835,7 @@ function updateConfiguration ($entries, $values, $updateMode='') { // Get affected rows $affectedRows = SQL_AFFECTEDROWS(); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):entries={$entries},affectedRows={$affectedRows}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):entries={$entries},affectedRows={$affectedRows}
"); // Rebuild cache rebuildCacheFiles('config', 'config'); @@ -1906,9 +1906,14 @@ function generateCategoryOptionsList ($mode) { $uid_cnt = 0; // @TODO Rewrite this to $content = SQL_FETCHARRAY() while (list($ucat) = SQL_FETCHROW($result_uids)) { - $result_ver = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE userid=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode)." LIMIT 1", - array(bigintval($ucat)), __FUNCTION__, __LINE__); + $result_ver = SQL_QUERY_ESC("SELECT + `userid` +FROM + `{!_MYSQL_PREFIX!}_user_data` +WHERE + `userid`=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode)." +LIMIT 1", + array(bigintval($ucat)), __FUNCTION__, __LINE__); // Add user count $uid_cnt += SQL_NUMROWS($result_ver); @@ -2126,7 +2131,7 @@ function insertUserStatsRecord ($uid, $type, $data) { // "Getter" for array for user refs and points in given level function getUserReferalPoints ($uid, $level) { - //* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); return $refs; }