Fix added for extension update with always active extensions, thanks to profi-concept
authorRoland Häder <roland@mxchange.org>
Mon, 10 Nov 2008 07:08:06 +0000 (07:08 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 10 Nov 2008 07:08:06 +0000 (07:08 +0000)
inc/databases.php
inc/doubler_send.php
inc/extensions.php
inc/libs/rallye_functions.php
inc/libs/refback_functions.php
inc/modules/admin/what-del_email.php
inc/monthly/monthly_bonus.php
inc/pool-update.php
mailid_top.php

index 4e17136..061185b 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "530");
+define('CURR_SVN_REVISION', "531");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 8df3d83..0efe4f5 100644 (file)
@@ -45,7 +45,7 @@ $DOUBLER_POINTS = DOUBLER_GET_TOTAL_POINTS_LEFT();
 if ($DOUBLER_POINTS == 0) {
        // Exit here to prevent some SQL errors (SQL_QUERY_ESC doen't insert zeros! We need to fix this...)
        return;
-}
+} // END - if
 
 // If not currently doubled set it to zero
 unset($_GET['DOUBLER_UID']);
@@ -71,6 +71,7 @@ WHERE u.status='CONFIRMED' AND d.points <= %s AND d.points >= %s AND d.completed
 ORDER BY d.timemark
 LIMIT %d", array($DOUBLER_POINTS, $min, $_CONFIG['doubler_max_sent']), __FILE__, __LINE__);
 
+// Do we have entries found?
 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;
@@ -129,7 +130,7 @@ if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y"))
                        if (!$OK) {
                                // Add points to used doubler points
                                UPDATE_CONFIG("doubler_used", $points, "+");
-                       }
+                       } // END - if
 
                        // Update variables to prevent errors
                        $_CONFIG['doubler_used'] += $points;
@@ -150,9 +151,9 @@ if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y"))
                        // Load mail template and send mail away...
                        $msg = LOAD_EMAIL_TEMPLATE("member_doubler", $content, $uid);
                        SEND_EMAIL($uid, DOUBLER_MEMBER_SUBJECT, $msg);
-               }
-       }
-}
+               } // END - if
+       } // END - while
+} // END - if
 
 // Free memory
 SQL_FREERESULT($result_total);
index fee99ba..722fa68 100644 (file)
@@ -89,20 +89,25 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                        $SQLs  = array();
                        $test  = false;
 
-                       // Backup language as well
-                       $LANG_BCK = $EXT_LANG_PREFIX;
-                       $EXT_ALWAYS_ACTIVE = "N";
-
                        // Load required extension also in update mode
                        $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $EXT_UPDATE_DEPENDS);
 
                        // Check for required file
                        if (FILE_READABLE($file)) {
-                               // File exists so let's load it
+                               // Bacup version number
                                $VER_BACKUP = $EXT_VERSION;
+
+                               // Backup language as well
+                               $LANG_BCK = $EXT_LANG_PREFIX;
+
+                               // Save the Parrent $EXT_ALWAYS_ACTIVE for later!
+                               $EXT_ALWAYS_ACTIVE_PARRENT = $EXT_ALWAYS_ACTIVE;
+
+                               // Set EXT_ALWAYS_ACTIVE for update
                                $EXT_ALWAYS_ACTIVE = "N";
+
+                               // File exists so let's load it
                                require($file);
-                               $EXT_VERSION = $VER_BACKUP;
 
                                // If versions mismatch update extension first
                                $ext_ver = GET_EXT_VERSION($EXT_UPDATE_DEPENDS);
@@ -134,6 +139,15 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                                        // Nothing to register / update before...
                                        $test = true;
                                }
+
+                               // Restore version number
+                               $EXT_VERSION = $VER_BACKUP;
+
+                               // Restore language back
+                               $EXT_LANG_PREFIX = $LANG_BCK;
+
+                               // Restore $EXT_ALWAYS_ACTIVE with the value from parrent
+                               $EXT_ALWAYS_ACTIVE = $EXT_ALWAYS_ACTIVE_PARRENT;
                        } else {
                                // Required file for update does not exists!
                                $test = true;
@@ -142,7 +156,6 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
 
                        // Finally restore previous SQLs
                        $SQLs = $SQLs2; unset($SQLs2);
-                       $EXT_LANG_PREFIX = $LANG_BCK;
                } else {
                        // Does not depend on an other extension
                        $test = true;
index 700d0ca..af9a01b 100644 (file)
@@ -367,8 +367,7 @@ function RALLYE_EXPIRE_RALLYES($result)
 
        // Just count...
        $TOTAL = 0;
-       foreach($prices['uid'] as $key => $uid)
-       {
+       foreach($prices['uid'] as $key => $uid) {
                // Check status
                //   active = 1: account is still confirmed
                //   active = 0: account is deleted or locked
@@ -382,28 +381,25 @@ LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
                $prices['active'][$key] = $active;
 
                // Allow valid and active users with at least one ref to get points
-               if (($uid > 0) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0))
-               {
+               if (($uid > 0) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
                        $TOTAL++;
-               }
-       }
+               } // END - if
+       } // END - foreach
 
        if (($TOTAL < $min_prices) || ($TOTAL == 0)) {
                // Do not end this rallye!
                unset($DATA);
                return;
-       }
+       } // END - if
 
        // Expire rallye
        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_rallye_data SET expired='Y' WHERE id=%s LIMIT 1",
-        array(bigintval($id)), __FILE__, __LINE__);
+               array(bigintval($id)), __FILE__, __LINE__);
 
        // Run array through (by uid is the most important 2nd-level-array)
-       foreach($prices['uid'] as $key => $uid)
-       {
+       foreach($prices['uid'] as $key => $uid) {
                // Allow valid and active users with at least one ref to get points
-               if (($uid > 0) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0))
-               {
+               if (($uid > 0) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
                        // Transfer data to array for the mail template
                        $DATA['level']  = $prices['level'][$key];
                        $DATA['points'] = $prices['points'][$key];
@@ -413,7 +409,7 @@ LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
                        if ($DATA['points'] > 0) {
                                // Add points directly to user's account
                                ADD_POINTS_REFSYSTEM($uid, $DATA['points'], false, "0", false, "direct");
-                       }
+                       } // END - if
 
                        if ($notify == "Y") {
                                // Prepare infos for the mail template
@@ -447,8 +443,8 @@ LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
                        $cnt++;
                        $users['uid'][$uid] = $uid;
                        $users['poi'][$uid] = $DATA['infos'];
-               }
-       }
+               } // END - if
+       } // END - foreach
 
        // Select template depending on notfication is switch on / off
        if ($notify == "Y") {
@@ -459,7 +455,6 @@ LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
        }
 
        // Send mail to admin
-       die("OK!");
        SEND_ADMIN_NOTIFICATION(RALLYE_ADMIN_EXPIRED.": ".$title, $templ, $cnt, 0);
 
        // Add task
index 4f7e655..c93d950 100644 (file)
@@ -56,7 +56,7 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
                // Reset ref depths
                $DEPTH = -1;
 
-               // "Walk through all refids
+               // "Walk" through all refids
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},level={$level},points={$points}<br />\n";
                foreach (GET_REFBACK_USERID_ARRAY($uid, $level) as $refid) {
                        // Skip level zero or if both are the same
@@ -69,7 +69,7 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
                        // Some percents given?
                        if ($percents > 0) {
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):points={$points},perc={$perc},percents={$percents},level={$level}<br />\n";
-                               // Get points for refback
+                               // Calculate points for refback
                                $refback = $points * ($perc / 100) * ($percents / 100);
 
                                // Update refback table ("refid" and "uid" must be exchanged!)
index 7ea60fc..ca1e16b 100644 (file)
@@ -138,7 +138,7 @@ WHERE s.pool_id=%s LIMIT 1",
 
                        // Output link for manually removing stats entry
                        LOAD_TEMPLATE("admin_settings_saved", false, "<A href=\"".URL."/modules.php?module=admin&amp;what=del_email&amp;pid=".bigintval($_GET['mid'])."\">".ADMIN_REMOVE_STATS_ENTRY."</A>");
-               }
+               } // END - if
 
                // Free the result
                SQL_FREERESULT($result_pool);
index 459afa6..c11ad3c 100644 (file)
@@ -69,17 +69,19 @@ if (($curr != $_CONFIG['last_month']) && ($_CONFIG['bonus_ranks'] > 0) && ($CSS
        if ($_CONFIG['bonus_stats_yn'] == "Y") $ADD .= " + bonus_stats";
        if ($_CONFIG['bonus_ref_yn']   == "Y") $ADD .= " + bonus_ref";
 
+       // Shall we add some entries?
        if (!empty($ADD)) {
-               $ADD .= " AND (0".$ADD.") > 0";
+               $whereStatement1 .= " AND (0".$ADD.") > 0";
        } // END - if
 
-       // SQL string to check for accounts
-       $result_main = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, (turbo_bonus + login_bonus + bonus_order + bonus_stats + bonus_ref) AS points
+       // Run SQL string to check for accounts
+       $result_main = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, (0".$ADD.") AS points
 FROM "._MYSQL_PREFIX."_user_data
 ".$whereStatement1."".$ADD."
 ORDER BY active_bonus DESC, userid LIMIT %s",
- array($whereStatement2), __FILE__, __LINE__);
              array($whereStatement2), __FILE__, __LINE__);
 
+       // Some entries were found?
        if (SQL_NUMROWS($result_main) > 0) {
                // Load our winners...
                while ($content = SQL_FETCHARRAY($result_main)) {
index 6f1fc8f..baa7f89 100644 (file)
@@ -212,7 +212,9 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                                // Get sender's data
                                                $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
-                                                array(bigintval($DATA[1])), __FILE__, __LINE__);
+                                                       array(bigintval($DATA[1])), __FILE__, __LINE__);
+
+                                               // Is the sender found?
                                                if (SQL_NUMROWS($result_sender) == 1) {
                                                        // Load data and prepare mail
                                                        list($sname, $fname, $email) = SQL_FETCHROW($result_sender);
@@ -223,7 +225,7 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                                        // Send it also waway
                                                        SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg);
-                                               }
+                                               } // END - if
 
                                                // Set status to SEND because we completely send it away
                                                $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1",
@@ -237,19 +239,17 @@ if (SQL_NUMROWS($result_main) > 0)
                                                $cnt2 += $cnt;
 
                                                // Update mediadata if version is 0.0.4 or higher
-                                               if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                                               {
+                                               if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                                                        // Update entry (or add missing)
                                                        //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
                                                        MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), "add", 1);
-                                               }
+                                               } // END - if
 
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$P."<br />";
                                                break;
                                        }
                                        // Do we have send maximum mails?
-                                        elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send']))
-                                       {
+                                        elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send'])) {
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $ADD = "";
                                                if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt;
@@ -259,29 +259,27 @@ if (SQL_NUMROWS($result_main) > 0)
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
                                                break;
                                        }
-                               }
-                                else
-                               {
+                               } else {
                                        // User does not exists so we have add the sender's points back to sender's account
-                                       if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0])))
-                                       {
+                                       if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) {
                                                // List was empty
                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND' WHERE id=%s LIMIT 1",
                                                 array(bigintval($DATA[0])), __FILE__, __LINE__);
-                                       }
-                                        else
-                                       {
-                                               if ($uid > 0)
-                                               {
+                                       } else {
+                                               // Is the userid set?
+                                               if ($uid > 0) {
                                                        // User does not exists, pay points back
                                                        $points = GET_PAY_POINTS($DATA[5]);
                                                        ADD_POINTS_REFSYSTEM($DATA[1], $points, false, "0", false, "direct");
 
                                                        // Add points together and remove user
                                                        $points_BACK[$DATA[1]] += $points;
-                                               }
+                                               } // END - if
+
+                                               // Count up
                                                $cnt_back[$DATA[1]]++;
                                        }
+
                                        // Remove entry from list
                                        unset($dummy[$key]);
 
@@ -292,7 +290,10 @@ if (SQL_NUMROWS($result_main) > 0)
                        }
                }
        }
+
+       // Do we have points to "pay back"?
        if ((sizeof($points_BACK) > 0) && (!empty($points_BACK[0]))) {
+               // Walk through all points
                foreach ($points_BACK as $uid => $PB) {
                        // Add points only when we have points left to add and a valid user ID
                        if (($PB > 0) && ($uid > 0)) {
@@ -305,6 +306,8 @@ if (SQL_NUMROWS($result_main) > 0)
                                $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
                                        array(bigintval($uid)), __FILE__, __LINE__);
                                $DATA[10] = $PB; $DATA[11] = $cnt_back[$uid];
+
+                               // User found?
                                if (SQL_NUMROWS($result) == 1) {
                                        list($email) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
@@ -321,9 +324,9 @@ if (SQL_NUMROWS($result_main) > 0)
                                        // Send mail out to admin
                                        SEND_ADMIN_NOTIFICATION(ADMIN_BACK_JACKPOT." (".$uid.")", "back-admin", $content, "admin");
                                }
-                       }
-               }
-       }
+                       } // END - if
+               } // END - foreach
+       } // END - if
 }
 
 // Free memory
index 60ee809..a61ce99 100644 (file)
@@ -215,44 +215,38 @@ if (isBooleanConstantAndTrue('mxchange_installed'))
                                                                                        SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET rand_confirmed=rand_confirmed + 1 WHERE userid=%s LIMIT 1",
                                                                                                array($url_uid), __FILE__, __LINE__);
                                                                                } // END - if
-                                                                       }
+                                                                       } // END - if
 
                                                                        // Insert stats record
                                                                        USER_STATS_INSERT_RECORD($url_uid, $type, $stats_data);
 
                                                                        // Right code entered?
                                                                        if (bigintval($_POST['gfx_check']) == $img_code) {
+                                                                               // Add points over referal system is the default
+                                                                               $locked = false;
+                                                                               $template = "mailid_points_done";
+
                                                                                // Right code entered add points and remove entry
-                                                                               if (($ref_pay > 0) && ($_CONFIG['allow_direct_pay'] == "N"))
-                                                                               {
+                                                                               if (($ref_pay > 0) && ($_CONFIG['allow_direct_pay'] == "N")) {
                                                                                        // Don't add points over the referal system
                                                                                        $locked = true;
                                                                                        $template = "mailid_points_locked";
-                                                                               }
-                                                                                else
-                                                                               {
-                                                                                       // Add points over referal system
-                                                                                       $locked = false;
-                                                                                       $template = "mailid_points_done";
-                                                                               }
+                                                                               } // END - if
 
                                                                                // Count down ref_payout value
                                                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=ref_payout-1 WHERE userid=%s AND ref_payout > 0 LIMIT 1",
-                                                                                array($url_uid), __FILE__, __LINE__);
+                                                                                       array($url_uid), __FILE__, __LINE__);
 
                                                                                // Add points
                                                                                unset($DEPTH);
                                                                                ADD_POINTS_REFSYSTEM($url_uid, $payment, false, "0", $locked);
 
                                                                                // Shall I add bonus points for "turbo clickers" ?
-                                                                               if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (function_exists('BONUS_ADD_TURBO_POINTS')))
-                                                                               {
+                                                                               if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (function_exists('BONUS_ADD_TURBO_POINTS'))) {
                                                                                        // Is an active-rallye running and this is not a notification mail?
-                                                                                       if (($_CONFIG['bonus_active'] == "Y") && ($notify == "N"))
-                                                                                       {
+                                                                                       if (($_CONFIG['bonus_active'] == "Y") && ($notify == "N")) {
                                                                                                // Shall I exclude the webmaster's own userid from the active-rallye?
-                                                                                               if (((($_CONFIG['bonus_uid'] == $url_uid) && ($_CONFIG['bonus_include_own'] == "Y")) || ($_CONFIG['bonus_uid'] != $url_uid)) && ($_CONFIG['def_refid'] != $url_uid))
-                                                                                               {
+                                                                                               if (((($_CONFIG['bonus_uid'] == $url_uid) && ($_CONFIG['bonus_include_own'] == "Y")) || ($_CONFIG['bonus_uid'] != $url_uid)) && ($_CONFIG['def_refid'] != $url_uid)) {
                                                                                                        // Add points and remember ranking are done in this function....
                                                                                                        BONUS_ADD_TURBO_POINTS($DATA, $url_uid, $type);
 
@@ -262,13 +256,9 @@ if (isBooleanConstantAndTrue('mxchange_installed'))
                                                                                                        define('_UID_VALUE' , $url_uid);
                                                                                                        define('_TYPE_VALUE', $type);
                                                                                                        define('_DATA_VALUE', TRANSLATE_COMMA($DATA));
-                                                                                               }
-                                                                                       }
-                                                                               }
-
-                                                                               // Remove link from table
-                                                                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
-                                                                                array(bigintval($lid)), __FILE__, __LINE__);
+                                                                                               } // END - if
+                                                                                       } // END - if
+                                                                               } // END - if
 
                                                                                // Load total points
                                                                                define('__TOTAL_POINTS', TRANSLATE_COMMA(
@@ -283,13 +273,13 @@ if (isBooleanConstantAndTrue('mxchange_installed'))
                                                                                unset($DEPTH);
                                                                                ADD_POINTS_REFSYSTEM($sender, $payment, false, 0, false, "direct");
 
-                                                                               // Remove link from table
-                                                                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
-                                                                                array(bigintval($lid)), __FILE__, __LINE__);
-
                                                                                // Load template
                                                                                LOAD_TEMPLATE("mailid_points_failed");
                                                                        }
+
+                                                                       // Remove link from table
+                                                                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
+                                                                               array(bigintval($lid)), __FILE__, __LINE__);
                                                                        break;
 
                                                                case "img":