From 0211214187aa95bd5726ecc7dac13dfe0f699c63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Oct 2008 19:55:05 +0000 Subject: [PATCH 1/1] More fixes, missing js.php added --- .gitattributes | 2 + img.php | 28 ++++++---- inc/databases.php | 2 +- inc/doubler_send.php | 33 ++++-------- inc/img/.htaccess | 1 + inc/language/beg_de.php | 6 +++ inc/modules/admin/what-del_email.php | 65 +++++++++++----------- inc/modules/guest/what-mediadata.php | 12 ++--- inc/mysql-connect.php | 9 ++++ inc/mysql-manager.php | 34 ++++++++++-- js.php | 81 ++++++++++++++++++++++++++++ 11 files changed, 195 insertions(+), 78 deletions(-) create mode 100644 inc/img/.htaccess create mode 100644 js.php diff --git a/.gitattributes b/.gitattributes index 3d8078eedf..a52ab12f94 100644 --- a/.gitattributes +++ b/.gitattributes @@ -152,6 +152,7 @@ inc/gen_mediadata.php -text inc/gen_refback.php -text inc/gen_sql_patches.php -text inc/header.php -text +inc/img/.htaccess -text inc/install-inc.php -text inc/js/.htaccess -text inc/language.php -text @@ -600,6 +601,7 @@ inc/weekly/weekly_surfbar.php -text install/menu-de.sql -text install/menu-en.sql -text install/tables.sql -text +/js.php -text /lead-confirm.php -text /login.php -text /mailid.php -text diff --git a/img.php b/img.php index df3c72506b..64919e4066 100644 --- a/img.php +++ b/img.php @@ -1,7 +1,7 @@ = %s AND d.completed ORDER BY d.timemark LIMIT %d", array($DOUBLER_POINTS, $min, $_CONFIG['doubler_max_sent']), __FILE__, __LINE__); -if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) || ((SQL_NUMROWS($result_main) == $_CONFIG['doubler_group_sent']) && ($_CONFIG['doubler_sent_all'] == "N"))) -{ +if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) || ((SQL_NUMROWS($result_main) == $_CONFIG['doubler_group_sent']) && ($_CONFIG['doubler_sent_all'] == "N"))) { // Switch to matching SQL resource $result_load = $result_main; if ((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) $result_load = $result_total; // At least one account was found - while(list($id, $uid, $points, $ip, $time) = SQL_FETCHROW($result_load)) - { + while(list($id, $uid, $points, $ip, $time) = SQL_FETCHROW($result_load)) { // Only double when points are enougth! - if ($DOUBLER_POINTS >= $points) - { + if ($DOUBLER_POINTS >= $points) { // Check for his ref points - $result_ref = SQL_QUERY_ESC("SELECT SUM(points) FROM "._MYSQL_PREFIX."_doubler WHERE refid=%s AND completed='N' AND is_ref='Y'", - array(bigintval($uid)), __FILE__, __LINE__); - list($ref) = SQL_FETCHROW($result_ref); - - // Free memory - SQL_FREERESULT($result_ref); + $ref = GET_TOTAL_DATA($uid, "doubler", "points", "refid", false, " AND completed='N' AND is_ref='Y'"); // Zero refid when empty (might be helpful!) if (empty($ref)) $ref = 0; - if (($ref > 0) && ($DOUBLER_UID == $uid) && (!empty($ref))) - { + if (($ref > 0) && ($DOUBLER_UID == $uid) && (!empty($ref))) { // Referal points found so add them and set line(s) to completed='Y' $points += $ref; $result_ref = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_doubler SET completed='Y' WHERE refid=%s AND completed='N' AND is_ref='Y'", array(bigintval($uid)), __FILE__, __LINE__); - } - else - { + } else { // No referal points found $ref = 0; } @@ -118,25 +107,23 @@ if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) $OK = false; // Check for jackpot inclusion in doubling process - if (($jackpot > 0) && ($jackpot >= $points) && ($_CONFIG['doubler_jackpot'] == "Y")) - { + if (($jackpot > 0) && ($jackpot >= $points) && ($_CONFIG['doubler_jackpot'] == "Y")) { // Subtract points from jackpot SUB_JACKPOT($points); $jackpot -= $points; // Okay, done! $OK = true; - } + } // END - if // Exclude also webmaster's ID in taking points from webmaster's account - if (($user > 0) && ($user >= $points) && (!$OK) && ($_CONFIG['doubler_uid'] > 0) && ($uid != $_CONFIG['doubler_uid'])) - { + if (($user > 0) && ($user >= $points) && (!$OK) && ($_CONFIG['doubler_uid'] > 0) && ($uid != $_CONFIG['doubler_uid'])) { // Add points to used points SUB_POINTS($_CONFIG['doubler_uid'], $points); // Okay, done! $OK = true; - } + } // END - if // Update doubler's account only when others are not updated if (!$OK) { diff --git a/inc/img/.htaccess b/inc/img/.htaccess new file mode 100644 index 0000000000..14249c50bd --- /dev/null +++ b/inc/img/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/inc/language/beg_de.php b/inc/language/beg_de.php index 0ba7e75813..8a9876ed9b 100644 --- a/inc/language/beg_de.php +++ b/inc/language/beg_de.php @@ -90,6 +90,12 @@ define('ADMIN_BEG_PAY_MODE_JS', "Abgesichert durch ein Fake-JavaScript"); define('ADMIN_BEG_PAY_MODE_BOTH', "Durch beides obriges absichern"); define('ADMIN_BEG_PAY_MODE_NONE', "Keine Absicherung (unsicher)"); +// More strings for beg link +define('BEG_LINK_PAY_BOTH_1', "Das Mitglied "); +define('BEG_LINK_PAY_BOTH_2', " hat bei Ihnen gerade "); +define('BEG_LINK_PAY_BOTH_3', " {!POINTS!} erbettelt. Dies war der "); +define('BEG_LINK_PAY_BOTH_4', ". Klick auf seinen Bettellink. Vielen Dank für Ihre Spende!"); + // Begging rallye define('BEG_RANK', "Bettel-Rank"); define('BEG_TOTAL', "Gesamt erbettelt"); diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index da714d623e..7ea60fcd40 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -74,32 +74,21 @@ if (!empty($_GET['mid'])) { $msg_user = LOAD_EMAIL_TEMPLATE("order-deleted", array(), $sender); SEND_EMAIL($sender, MEMBER_ORDER_DELETED, $msg_user); - // Delete mail from queue - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1", - array(bigintval($_GET['mid'])), __FILE__, __LINE__); - // Fetch right stats_id from pool - $result = SQL_QUERY_ESC("SELECT s.id FROM "._MYSQL_PREFIX."_user_stats AS s + $result_pool = SQL_QUERY_ESC("SELECT s.id FROM "._MYSQL_PREFIX."_user_stats AS s LEFT JOIN "._MYSQL_PREFIX."_pool AS p ON s.pool_id=p.id WHERE s.pool_id=%s LIMIT 1", array(bigintval($_GET['mid'])), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { + if (SQL_NUMROWS($result_pool) == 1) { // Fetch stats id - list($stats_id) = SQL_FETCHROW($result); - - // Free the result - SQL_FREERESULT($result); + list($stats_id) = SQL_FETCHROW($result_pool); // Get all user links - $result = SQL_QUERY_ESC("SELECT COUNT(id) AS 'cnt' FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s", - array(bigintval($stats_id)), __FILE__, __LINE__); - - // Get unconfirmed links for calculation of total points - list($links) = SQL_FETCHROW($result); + $links = GET_TOTAL_DATA($stats_id, "user_links", "userid", "stats_id", true); - // Free result - SQL_FREERESULT($result); + // Reset sent mails for recipient(s) + REDUCT_RECIPIENT_RECEIVED_MAILS("stats_id", $_GET['mid'], $links); // Calc total points and pay them back $totalPoints = $links * $price; @@ -112,7 +101,7 @@ WHERE s.pool_id=%s LIMIT 1", if ($_CONFIG['repay_deleted_mails'] == "JACKPOT") { // Set jackpot $sender = 0; - } + } // END - if // Pay back points //* DEBUG: */ echo "PAYBACK:".$sender."
\n"; @@ -122,12 +111,12 @@ WHERE s.pool_id=%s LIMIT 1", if ($_CONFIG['repay_deleted_mails'] == 'REPAY') { // Repayed LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_REPAYED, - number_format($totalPoints, 0, ",", ".") + TRANSLATE_COMMA($totalPoints) )); } else { // To jackpot LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_TO_JACKPOT, - number_format($totalPoints, 0, ",", ".") + TRANSLATE_COMMA($totalPoints) )); } } else { @@ -139,13 +128,20 @@ WHERE s.pool_id=%s LIMIT 1", LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_SHREDDED, $totalPoints)); } + // Delete mail from queue + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1", + array(bigintval($_GET['mid'])), __FILE__, __LINE__); + // Remove links from DB - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s", - array(bigintval($stats_id)), __FILE__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s", + array(bigintval($stats_id)), __FILE__, __LINE__); // Output link for manually removing stats entry LOAD_TEMPLATE("admin_settings_saved", false, "".ADMIN_REMOVE_STATS_ENTRY.""); } + + // Free the result + SQL_FREERESULT($result_pool); } else { // Mail already deleted! LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NORMAL_MAIL_ALREADY_DELETED); @@ -153,24 +149,28 @@ WHERE s.pool_id=%s LIMIT 1", } elseif (!empty($_GET['pid'])) { // Remove stats entries $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%s LIMIT 1", - array(bigintval($_GET['pid'])), __FILE__, __LINE__); + array(bigintval($_GET['pid'])), __FILE__, __LINE__); + + // Output message LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_USER_STATS_REMOVED); } elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus"))) { // Load data from bonus mail - $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp FROM "._MYSQL_PREFIX."_bonus WHERE id=%s", - array(bigintval($_GET['bid'])), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp, mails_sent FROM "._MYSQL_PREFIX."_bonus WHERE id=%s", + array(bigintval($_GET['bid'])), __FILE__, __LINE__); // Delete mail only once if (SQL_NUMROWS($result) == 1) { // Load data - list ($id, $subject, $url, $timestamp) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + list ($id, $subject, $url, $timestamp, $sent) = SQL_FETCHROW($result); + + // Reset sent mails for recipient(s) + REDUCT_RECIPIENT_RECEIVED_MAILS ("bonus_id", $_GET['bid'], $sent); // Delete bonus mail entirely from database - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1", - array(bigintval($_GET['bid'])), __FILE__, __LINE__); - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s", - array(bigintval($_GET['bid'])), __FILE__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1", + array(bigintval($_GET['bid'])), __FILE__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s", + array(bigintval($_GET['bid'])), __FILE__, __LINE__); // Prepare data for the template define('__ID' , $id); @@ -184,6 +184,9 @@ WHERE s.pool_id=%s LIMIT 1", // Mail already deleted! LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_MAIL_ALREADY_DELETED); } + + // Free result + SQL_FREERESULT($result); } elseif ((!empty($_GET['nid'])) && (GET_EXT_VERSION("bonus") >= "0.8.7")) { // Load data from bonus mail $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp FROM "._MYSQL_PREFIX."_bonus WHERE id=%s", diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index c6bdf9c4e1..36a08cea70 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -89,16 +89,10 @@ SQL_FREERESULT($result_rec); define('user_max_rec', $dummy); // Max mails per day -$result_max = SQL_QUERY("SELECT SUM(max_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__); -list($dmy) = SQL_FETCHROW($result_max); -SQL_FREERESULT($result_max); -define('max', $dmy); +define('max', GET_TOTAL_DATA("CONFIRMED", "user_data", "max_mails", "status", false, " AND `max_mails` > 0")); // Max mails for this day -$result_rec = SQL_QUERY("SELECT SUM(receive_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__); -list($dummy) = SQL_FETCHROW($result_rec); -define('rec', $dummy); -SQL_FREERESULT($result_rec); +define('rec', GET_TOTAL_DATA("CONFIRMED", "user_data", "receive_mails", "status", false, " AND `receive_mails` > 0")); // Initial lots of variables $bmails = 0; $sent = 0; $max = 0; $rec = 0; $clicks = 0; @@ -124,7 +118,7 @@ if (EXT_IS_ACTIVE("bonus")) { if (empty($dmy)) $dmy = 0; if (empty($dmy2)) $dmy2 = 0; $sent += $dmy2; $clicks += $dmy; -} +} // END - if define('user_stats', ($nmails + $bmails)); define('sent' , $sent); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 230c4b91d9..7bbaee5e1e 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -209,15 +209,24 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT define('RAND_NUMBER', mt_rand(1000000, 9999999)); } } else { + // Add language system + include (PATH."inc/language.php"); + // Wrong database? ADD_FATAL(WRONG_DB_SELECTED); } } else { + // Add language system + include (PATH."inc/language.php"); + // No link to database! ADD_FATAL(NO_DB_LINK); $db = false; } } else { + // Add language system + include (PATH."inc/language.php"); + // Maybe you forgot to enter your MySQL data? ADD_FATAL(MYSQL_DATA_MISSING); } diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index be834e68f2..b47722f6d9 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1074,16 +1074,17 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal // Return status for sending routine return $ret; } -// + +// 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) { // Count rows - $result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'%s", + $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'%s", array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__); } else { // Add all rows - $result = SQL_QUERY_ESC("SELECT SUM(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'%s", + $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'%s", array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__); } @@ -1525,7 +1526,7 @@ function GET_ADMIN_DEFAULT_ACL ($aid) { } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result_aid = SQL_QUERY_ESC("SELECT default_acl FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1", - array(bigintval($ret)), __FILE__, __LINE__); + array(bigintval($aid)), __FILE__, __LINE__); if (SQL_NUMROWS($result_aid) == 1) { // Fetch data list($ret) = SQL_FETCHROW($result_aid); @@ -2267,5 +2268,28 @@ ORDER BY ur.refid ASC", return $refs; } -// +// Recuced the amount of received emails for the receipients for given email +function REDUCT_RECIPIENT_RECEIVED_MAILS ($column, $id, $count) { + // Search for mail in database + $result = SQL_QUERY_ESC("SELECT `userid` FROM `"._MYSQL_PREFIX."_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s", + array($column, bigintval($id), $count), __FILE__, __LINE__); + + // Are there entries? + if (SQL_NUMROWS($result) > 0) { + // Now load all userids for one big query! + $UIDs = array(); + while (list($uid) = SQL_FETCHROW($result)) { + $UIDs[$uid] = $uid; + } // END - while + + // Now update all user accounts + SQL_QUERY_ESC("UPDATE `"._MYSQL_PREFIX."_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s", + array(implode(",", $UIDs), count($UIDs)), __FILE__, __LINE__); + } // END - if + + // Free result + SQL_FREERESULT($result); +} + +// [EOF] ?> diff --git a/js.php b/js.php new file mode 100644 index 0000000000..922b8768a5 --- /dev/null +++ b/js.php @@ -0,0 +1,81 @@ + -- 2.39.2