X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=39da8f2203a27fa9d7c66a114fdc03f01bb1ecad;hb=820a65d753f3103901bec03a93588044670684fa;hp=00f7d155e3ed547a09234f6c41f498a584328103;hpb=2305bb069ede07db6227ab5e51960e501e75d7e6;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 00f7d155e3..39da8f2203 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -65,7 +65,7 @@ function ADD_MODULE_TITLE($mod) { // Still no luck or empty title? if (empty($name)) { // No name found - $name = LANG_UNKNOWN_MODULE." (".$mod.")"; + $name = sprintf("%s (%s)", LANG_UNKNOWN_MODULE, $mod); if (SQL_NUMROWS($result) == 0) { // Add module to database $dummy = CHECK_MODULE($mod); @@ -77,7 +77,7 @@ function ADD_MODULE_TITLE($mod) { } // Check validity of a given module name (no file extension) -function CHECK_MODULE($mod) { +function CHECK_MODULE ($mod) { // We need them now here... global $cacheArray, $_CONFIG, $cacheInstance; @@ -190,7 +190,7 @@ function CHECK_MODULE($mod) { // Add menu description pending on given file name (without path!) function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { - global $DEPTH, $_CONFIG; + global $NAV_DEPTH, $_CONFIG; // Use only filename of the file ;) $file = basename($file); @@ -205,13 +205,13 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { switch ($ACC_LVL) { case "admin": - $MOD_CHECK = "admin"; + $modCheck = "admin"; break; case "sponsor": case "guest": case "member": - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; break; } $AND = " AND (what='' OR what IS NULL)"; @@ -223,12 +223,12 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { switch ($ACC_LVL) { case "admin": - $MOD_CHECK = "admin"; + $modCheck = "admin"; break; case "guest": case "member": - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; if (!IS_ADMIN()) { $AND = " AND visible='Y' AND locked='N'"; } @@ -240,20 +240,20 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { // Sponsor / engine menu $type = "what"; $search = $file; - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; $AND = ""; } else { // Other $type = "menu"; $search = $file; - $MOD_CHECK = $GLOBALS['module']; + $modCheck = $GLOBALS['module']; $AND = ""; } - if ((!isset($DEPTH)) && (!$return)) { - $DEPTH = 0; + if ((!isset($NAV_DEPTH)) && (!$return)) { + $NAV_DEPTH = 0; $prefix = "
".YOU_ARE_HERE." Home"; } else { - if (!$return) $DEPTH++; + if (!$return) $NAV_DEPTH++; $prefix = ""; } @@ -278,9 +278,9 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { 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()) && ($modCheck == "admin"))) { // Output HTML code - $OUT = $prefix."".$ret."\n"; + $OUT = $prefix."".$ret."\n"; // Can we close the you-are-here navigation? //* DEBUG: */ echo __LINE__."*".$type."/".$GLOBALS['what']."*
\n"; @@ -297,7 +297,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { // Add line-break tag $OUT .= "
\n"; - $DEPTH = "0"; + $NAV_DEPTH = "0"; // Handle failed logins here if not in guest //* DEBUG: */ print __FUNCTION__."(".__LINE__."):type={$type},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$ACC_LVL}
\n"; @@ -335,11 +335,11 @@ function ADD_MENU($MODE, $act, $wht) { // Non-admin shall not see all menus if (!IS_ADMIN()) { - $AND = "AND visible='Y' AND locked='N'"; + $AND = " AND visible='Y' AND locked='N'"; } // 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), __FILE__, __LINE__); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; if (SQL_NUMROWS($result_main) > 0) { @@ -794,7 +794,7 @@ function SEND_MODE_MAILS($mod, $modes) // Load hash $result_main = SQL_QUERY_ESC("SELECT password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1", - array($GLOBALS['userid']), __FILE__, __LINE__); + array($GLOBALS['userid']), __FILE__, __LINE__); if (SQL_NUMROWS($result_main) == 1) { // Load hash from database list($hashDB) = SQL_FETCHROW($result_main); @@ -807,7 +807,7 @@ function SEND_MODE_MAILS($mod, $modes) if (($hash == get_session('u_hash')) || ($_POST['pass1'] == $_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", - array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__); + array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load the data $DATA = SQL_FETCHROW($result); @@ -839,15 +839,16 @@ function SEND_MODE_MAILS($mod, $modes) break; default: + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode)); $content = MEMBER_UNKNOWN_MODE.": ".$mode."\n\n"; break; - } + } // END - switch } // END - if if (EXT_IS_ACTIVE("country")) { // Replace code with description $DATA[4] = COUNTRY_GENERATE_INFO($_POST['country_code']); - } + } // END - if // Load template $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']); @@ -855,42 +856,43 @@ function SEND_MODE_MAILS($mod, $modes) 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; + $sub_adm = ADMIN_CHANGED_DATA; } else { // No mail to admin $msg_admin = ""; - $sub_adm = ""; + $sub_adm = ""; } // Set subject lines $sub_mem = MEMBER_CHANGED_DATA; // Output success message - $content = "".MYDATA_MAIL_SENT.""; + $content = "".MYDATA_MAIL_SENT.""; break; default: - $content = "".UNKNOWN_MODULE.""; + DEBUG_LOG(__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.""; + $content = "".MEMBER_CANNOT_LOAD_PROFILE.""; } } else { // Passwords mismatch - $content = "".MEMBER_PASSWORD_ERROR.""; + $content = "".MEMBER_PASSWORD_ERROR.""; } } else { // Could not load profile - $content = "".MEMBER_CANNOT_LOAD_PROFILE.""; + $content = "".MEMBER_CANNOT_LOAD_PROFILE.""; } // Send email to user if required if ((!empty($sub_mem)) && (!empty($msg))) { // Send member mail SEND_EMAIL($DATA[7], $sub_mem, $msg); - } + } // END - if // Send only if no other error has occured if (empty($content)) { @@ -902,22 +904,20 @@ function SEND_MODE_MAILS($mod, $modes) $content = CANNOT_SEND_ADMIN_MAILS; } else { // No mail to admin - $content = "".MYDATA_MAIL_SENT.""; + $content = "".MYDATA_MAIL_SENT.""; } - } + } // END - if // Load template LOAD_TEMPLATE("admin_settings_saved", false, $content); } // Update module counter -function COUNT_MODULE($mod) -{ - if ($mod != "css") - { +function COUNT_MODULE($mod) { + if ($mod != "css") { // Do count all other modules but not accesses on CSS file css.php! $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_mod_reg SET clicks=clicks+1 WHERE module='%s' LIMIT 1", - array($mod), __FILE__, __LINE__); - } + array($mod), __FILE__, __LINE__); + } // END - if } // Get action value from mode (admin/guest/member) and what-value function GET_ACTION ($MODE, &$wht) @@ -972,7 +972,8 @@ function GET_ACTION ($MODE, &$wht) // Return action value return $ret; } -// + +// Get category name back function GET_CATEGORY ($cid) { // Default is not found $ret = _CATEGORY_404; @@ -997,7 +998,8 @@ function GET_CATEGORY ($cid) { // Return result return $ret; } -// + +// Get a string of "mail title" and price back function GET_PAYMENT ($pid, $full=false) { // Default is not found $ret = _PAYMENT_404; @@ -1023,7 +1025,8 @@ function GET_PAYMENT ($pid, $full=false) { // Return result return $ret; } -// + +// Get (basicly) the price of given payment id function GET_PAY_POINTS($pid, $lookFor="price") { $ret = "-1"; @@ -1037,8 +1040,9 @@ function GET_PAY_POINTS($pid, $lookFor="price") } return $ret; } + // Remove a receiver's ID from $ARRAY and add a link for him to confirm -function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false) +function REMOVE_RECEIVER (&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false) { $ret = "failed"; if ($uid > 0) @@ -1076,16 +1080,19 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal } // Calculate sum (default) or count records of given criteria -function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") { +function GET_TOTAL_DATA ($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") { $ret = 0; - if ($onlyRows) { + //* DEBUG: */ echo $search."/".$tableName."/".$lookFor."/".$whereStatement."/".$add."
\n"; + if (($onlyRows) || ($lookFor == "userid")) { // Count rows - $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'%s", - array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__); + //* DEBUG: */ echo "COUNT!
\n"; + $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add, + 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'%s", - array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__); + //* DEBUG: */ echo "SUM!
\n"; + $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add, + array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__); } // Load row @@ -1096,8 +1103,12 @@ function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", // Fix empty values if ((empty($ret)) && ($lookFor != "counter") && ($lookFor != "id") && ($lookFor != "userid")) { + // Float number $ret = "0.00000"; - } // END - if + } elseif ("".$ret."" == "") { + // Fix empty result + $ret = "0"; + } // Return value return $ret; @@ -1142,6 +1153,7 @@ function GET_REF_LEVEL_PERCENTS ($level) { * * Dynamic referal system, can also send mails! * + * subject = Subject line, write in lower-case letters and underscore is allowed * uid = Referal ID wich should receive... * points = ... xxx points * send_notify = shall I send the referal an email or not? @@ -1150,7 +1162,7 @@ function GET_REF_LEVEL_PERCENTS ($level) { * add_mode = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct" * for default value will cause no referal will get points ever!!!) */ -function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") { +function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") { //* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------