X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=ef0072bff840a4949ee980158bf3be301cc21706;hp=923427e6aaa4adb902f248eef7816a7ff6a04a02;hb=3c4fbc22e3c04348734182d4d29bfef7eb050aa6;hpb=524c58a61b0a074fed8d7c9dc2f9ddab7f653595 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 923427e6aa..ef0072bff8 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,27 +190,32 @@ 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); + + // Init variables $LINK_ADD = ""; $OUT = ""; $AND = ""; + // First we have to do some analysis... - if (ereg("action-", $file)) { + if (substr($file, 0, 7) == "action-") { // This is an action file! $type = "action"; $search = substr($file, 7); 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)"; - } elseif (ereg("what-", $file)) { + } elseif (substr($file, 0, 5) == "what-") { // This is an admin what file! $type = "what"; $search = substr($file, 5); @@ -218,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'"; } @@ -235,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 = ""; } @@ -273,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"; @@ -292,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"; @@ -330,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) { @@ -789,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); @@ -802,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); @@ -834,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']); @@ -850,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)) { @@ -897,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) @@ -967,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; @@ -992,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; @@ -1018,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"; @@ -1032,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) @@ -1069,17 +1078,21 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal // Return status for sending routine return $ret; } -// -function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") { + +// Calculate sum (default) or count records of given criteria +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 @@ -1090,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; @@ -1136,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? @@ -1144,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 ------------------------