X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=efe2ced2495208908cfb0f1b7ef72ac748cf1f0b;hb=a090e351c49fe021fb3064325694da03402332e0;hp=d9c2eddf94bcd44d676c7e97dc2da48ed68ae9e9;hpb=452578b5bf17d14099ee44956deb4e4dc0832874;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index d9c2eddf94..efe2ced249 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -10,10 +10,10 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle MySQL-Relevanten Funktionen * * -------------------------------------------------------------------- * - * $Revision:: 856 $ * - * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009) $ * + * $Revision:: $ * + * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * - * $Author:: stelzi $ * + * $Author:: $ * * Needs to be in all Files and every File needs "svn propset * * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * @@ -45,21 +45,21 @@ if (!defined('__SECURITY')) { // Returns the title for given module function ADD_MODULE_TITLE ($mod) { // Init variables - $name = ""; + $name = ''; $result = false; // Is the script installed? if (isInstalled()) { // Check if cache is valid - if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) { + if ((GET_EXT_VERSION('cache') >= '0.1.2') && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) { // Load from cache $name = $GLOBALS['cache_array']['modules']['title'][$mod]; // Update cache hits incrementConfigEntry('cache_hits'); - } elseif (!EXT_IS_ACTIVE("cache")) { + } elseif (!EXT_IS_ACTIVE('cache')) { // Load from database - $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", array($mod), __FUNCTION__, __LINE__); list($name) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -86,11 +86,11 @@ function ADD_MODULE_TITLE ($mod) { // Check validity of a given module name (no file extension) function checkModulePermissions ($mod) { // Filter module name (names with low chars and underlines are fine!) - $mod = preg_replace("/[^a-z_]/", "", $mod); + $mod = preg_replace("/[^a-z_]/", '', $mod); // Check for prefix is a extension... $modSplit = explode("_", $mod); - $extension = ""; $mod_chk = $mod; + $extension = ''; $mod_chk = $mod; //* DEBUG: */ echo __LINE__."*".count($modSplit)."*/".$mod."*
"; if (count($modSplit) == 2) { // Okay, there is a seperator (_) in the name so is the first part a module? @@ -118,7 +118,7 @@ function checkModulePermissions ($mod) { $found = false; // Check if cache is latest version - if (GET_EXT_VERSION("cache") >= "0.1.2") { + if (GET_EXT_VERSION('cache') >= '0.1.2') { // Is the cache there? if (!isset($GLOBALS['cache_array']['modules'])) { // This should normally not happen... @@ -140,9 +140,9 @@ function checkModulePermissions ($mod) { // No, then we have to update it! $ret = "cache_miss"; } - } elseif (!EXT_IS_ACTIVE("cache")) { + } 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", + $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", array($mod_chk), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Read data @@ -157,16 +157,16 @@ function checkModulePermissions ($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_MEMBER())))) { + 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_MEMBER())) { + } 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"; } else { @@ -185,7 +185,7 @@ function checkModulePermissions ($mod) { // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- if ((FILE_READABLE(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) { // Data is missing so we add it - if (GET_EXT_VERSION("sql_patches") >= "0.3.6") { + 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* SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg` @@ -235,9 +235,9 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $file = basename($FQFN); // Init variables - $LINK_ADD = ""; - $OUT = ""; - $AND = ""; + $LINK_ADD = ''; + $OUT = ''; + $AND = ''; // First we have to do some analysis... if (substr($file, 0, 7) == "action-") { @@ -245,29 +245,29 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $type = "action"; $search = substr($file, 7); switch ($ACC_LVL) { - case "admin": - $modCheck = "admin"; + case 'admin': + $modCheck = 'admin'; break; - case "sponsor": - case "guest": - case "member": + case 'sponsor': + case 'guest': + case 'member': $modCheck = $GLOBALS['module']; break; } - $AND = " AND (what='' OR `what` IS NULL)"; + $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); - $AND = ""; + $AND = ''; switch ($ACC_LVL) { - case "admin": - $modCheck = "admin"; + case 'admin': + $modCheck = 'admin'; break; - case "guest": - case "member": + case 'guest': + case 'member': $modCheck = $GLOBALS['module']; if (!IS_ADMIN()) { $AND = " AND `visible`='Y' AND `locked`='N'"; @@ -276,18 +276,18 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { } $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; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ''; } else { // Other $type = "menu"; $search = $file; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ''; } // Begin the navigation line @@ -296,7 +296,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $prefix = "
{--YOU_ARE_HERE--} Home"; } else { if (!$return) $GLOBALS['nav_depth']++; - $prefix = ""; + $prefix = ''; } $prefix .= " -> "; @@ -320,7 +320,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { if ($return === true) { // Return title return $ret; - } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && (getConfig('youre_here') == "Y")) || ((IS_ADMIN()) && ($modCheck == "admin"))) { + } elseif (((GET_EXT_VERSION('sql_patches') >= '0.2.3') && (getConfig('youre_here') == 'Y')) || ((IS_ADMIN()) && ($modCheck == 'admin'))) { // Output HTML code $OUT = $prefix."".$ret."\n"; @@ -356,9 +356,9 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { function ADD_MENU ($MODE, $act, $wht) { // Init some variables $main_cnt = 0; - $AND = ""; - $main_action = ""; - $sub_what = ""; + $AND = ''; + $main_action = ''; + $sub_what = ''; // is the menu action valid? if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) { @@ -371,7 +371,7 @@ function ADD_MENU ($MODE, $act, $wht) { } // 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`", + $result_main = SQL_QUERY_ESC("SELECT title, action FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort`", array($MODE), __FUNCTION__, __LINE__); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; if (SQL_NUMROWS($result_main) > 0) { @@ -404,7 +404,7 @@ function ADD_MENU ($MODE, $act, $wht) { $content = merge_array($content, $content2); // Init content - $OUT = ""; + $OUT = ''; // Full file name for checking menu //* DEBUG: */ echo __LINE__.":!!!!".$content['sub_what']."!!!
\n"; @@ -455,13 +455,13 @@ function ADD_MENU ($MODE, $act, $wht) { $INC_BLOCK = sprintf("inc/modules/%s/action-%s.php", $MODE, $content['action']); if (FILE_READABLE($INC_BLOCK)) { // Load include file - if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == "online")) OUTPUT_HTML(" + if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == 'online')) OUTPUT_HTML(" "); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; LOAD_INC($INC_BLOCK); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; - if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == "online")) OUTPUT_HTML(" + if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == 'online')) OUTPUT_HTML(" "); } //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; @@ -485,7 +485,7 @@ function ADD_MENU ($MODE, $act, $wht) { // This patched function will reduce many SELECT queries for the specified or current admin login function IS_ADMIN ($admin="") { // Init variables - $ret = false; $passCookie = ""; $valPass = ""; + $ret = false; $passCookie = ''; $valPass = ''; //* DEBUG: */ echo __LINE__."ADMIN:".$admin."
"; // If admin login is not given take current from cookies... @@ -509,13 +509,13 @@ function IS_ADMIN ($admin="") { // Count cache hits incrementConfigEntry('cache_hits'); - } elseif ((!empty($admin)) && ((!EXT_IS_ACTIVE("cache"))) || (!isset($GLOBALS['cache_array']['admins']['password'][$admin]))) { + } elseif ((!empty($admin)) && ((!EXT_IS_ACTIVE('cache'))) || (!isset($GLOBALS['cache_array']['admins']['password'][$admin]))) { // Search for admin $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1", array($admin), __FUNCTION__, __LINE__); // Is he admin? - $passDB = ""; + $passDB = ''; if (SQL_NUMROWS($result) == 1) { // Admin login was found so let's load password from DB list($passDB) = SQL_FETCHROW($result); @@ -534,7 +534,7 @@ function IS_ADMIN ($admin="") { if (!empty($valPass)) { // Check if password is valid //* DEBUG: */ print __FUNCTION__."*".$valPass."/".$passCookie."*
\n"; - $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!EXT_IS_ACTIVE("cache")))); + $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!EXT_IS_ACTIVE('cache')))); } // Return result of comparision @@ -544,17 +544,17 @@ function IS_ADMIN ($admin="") { // Generates a list of "max receiveable emails per day" function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) { - $OUT = ""; + $OUT = ''; $result = false; switch ($MODE) { - case "guest": + case 'guest': // Guests (in the registration form) are not allowed to select 0 mails per day. $result = SQL_QUERY("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value > 0 ORDER BY value", __FUNCTION__, __LINE__); break; - case "member": + case 'member': // Members are allowed to set to zero mails per day (we will change this soon!) $result = SQL_QUERY("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` ORDER BY value", __FUNCTION__, __LINE__); @@ -567,7 +567,7 @@ function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) { // Some entries are found? if (SQL_NUMROWS($result) > 0) { - $OUT = ""; + $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { $OUT .= " \n"; @@ -1862,18 +1887,18 @@ WHERE userid=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML } // Add bonus mail to queue -function ADD_BONUS_MAIL_TO_QUEUE ($subject, $text, $receiverList, $points, $seconds, $url, $cat, $mode="normal", $receiver=0) { +function ADD_BONUS_MAIL_TO_QUEUE ($subject, $text, $receiverList, $points, $seconds, $url, $cat, $mode='normal', $receiver=0) { // Is admin or bonus extension there? if (!IS_ADMIN()) { // Abort here return false; - } elseif (!EXT_IS_ACTIVE("bonus")) { + } elseif (!EXT_IS_ACTIVE('bonus')) { // Abort here return false; } // Calculcate target sent - $target = SELECTION_COUNT(explode(";", $receiverList)); + $target = SELECTION_COUNT(explode(';', $receiverList)); // Receiver is zero? if ($receiver == 0) { @@ -1882,12 +1907,12 @@ function ADD_BONUS_MAIL_TO_QUEUE ($subject, $text, $receiverList, $points, $seco } // END - if // HTML extension active? - if (EXT_IS_ACTIVE("html")) { + if (EXT_IS_ACTIVE('html_mail')) { // No HTML by default $HTML = "N"; // HTML mode? - if ($mode == "html") $HTML = "Y"; + if ($mode == 'html') $HTML = "Y"; // Add HTML mail SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_bonus` @@ -1928,8 +1953,8 @@ VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s')", function GENERATE_RECEIVER_LIST ($cat, $receiver, $mode="") { // Init variables $CAT_TABS = "%s"; - $CAT_WHERE = ""; - $receiverList = ""; + $CAT_WHERE = ''; + $receiverList = ''; $result = false; // Secure data @@ -1950,12 +1975,12 @@ function GENERATE_RECEIVER_LIST ($cat, $receiver, $mode="") { } // END - if // Exclude users in holiday? - if (GET_EXT_VERSION("holiday") >= "0.1.3") { + if (GET_EXT_VERSION('holiday') >= '0.1.3') { // Add something for the holiday extension $CAT_WHERE .= " AND d.holiday_active='N'"; } // END - if - if ((EXT_IS_ACTIVE("html_mail")) && ($mode == "html")) { + if ((EXT_IS_ACTIVE('html_mail')) && ($mode == 'html')) { // Only include HTML receivers $result = SQL_QUERY_ESC("SELECT d.userid FROM `{!_MYSQL_PREFIX!}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.html='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s", array($cat, getConfig('order_select'), getConfig('order_mode'), $receiver), __FUNCTION__, __LINE__); @@ -1970,7 +1995,7 @@ function GENERATE_RECEIVER_LIST ($cat, $receiver, $mode="") { // Load all entries while ($content = SQL_FETCHARRAY($result)) { // Add receiver when not empty - if (!empty($content['userid'])) $receiverList .= $content['userid'].";"; + if (!empty($content['userid'])) $receiverList .= $content['userid'] . ';'; } // END - while // Free memory @@ -1995,7 +2020,7 @@ function USER_STATS_GET_TIMESTAMP ($type, $data, $uid = 0) { } // END - if // Is the extension installed and updated? - if ((!EXT_IS_ACTIVE("sql_patches")) || (EXT_VERSION_IS_OLDER("sql_patches", "0.5.6"))) { + if ((!EXT_IS_ACTIVE('sql_patches')) || (EXT_VERSION_IS_OLDER('sql_patches', '0.5.6'))) { // Return zero here return $stamp; } // END - if @@ -2023,7 +2048,7 @@ LIMIT 1", // Inserts user stats function USER_STATS_INSERT_RECORD ($uid, $type, $data) { // Is the extension installed and updated? - if ((!EXT_IS_ACTIVE("sql_patches")) || (EXT_VERSION_IS_OLDER("sql_patches", "0.5.6"))) { + if ((!EXT_IS_ACTIVE('sql_patches')) || (EXT_VERSION_IS_OLDER('sql_patches', '0.5.6'))) { // Return zero here return false; } // END - if @@ -2043,16 +2068,16 @@ function USER_STATS_INSERT_RECORD ($uid, $type, $data) { function GET_USER_REF_POINTS ($uid, $level) { //* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------