]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/rallye_functions.php
Even more variables renamed and login procedure prepared for filter
[mailer.git] / inc / libs / rallye_functions.php
index 4461b4ad53489c884c6279cc07066542eab1b78f..5f83e14adb02a01323a6592f662192fd766041c9 100644 (file)
@@ -10,7 +10,7 @@
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Spezielle Funktion fuer rallye-Erweiterung       *
  * -------------------------------------------------------------------- *
- * $Revision:: 856                                                    $ *
+ * $Revision::                                                        $ *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
@@ -43,11 +43,10 @@ if (!defined('__SECURITY')) {
 }
 
 //
-function RALLYE_AUTOSTART_RALLYES($result)
-{
+function RALLYE_AUTOSTART_RALLYES ($result) {
        // Global data array for LOAD_EMAIL_TEMPLATE()
-       $DATA = array();
        global $DATA;
+       $DATA = array();
 
        // Load all rallyes (usally we have only one rallye active per time!
        list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
@@ -255,15 +254,15 @@ LIMIT 1", array(bigintval($content['userid']), getConfig('ref_payout')), __FUNCT
 // Run this function only when a new member has confirmed his email address!
 function RALLYE_AUTOADD_USER ($uid) {
        global $DATA;
-       $ADD = "";
+       $add = "";
 
        // Updated extension?
        if (GET_EXT_VERSION("rallye") >= "0.2.0") {
-               $ADD .= ", min_users, min_prices";
+               $add .= ", min_users, min_prices";
        } // END - if
 
        // Check for an auto-add rallye
-       $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify".$ADD." FROM `{!_MYSQL_PREFIX!}_rallye_data` WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FUNCTION__, __LINE__);
+       $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify".$add." FROM `{!_MYSQL_PREFIX!}_rallye_data` WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Init variables
                $min_users = 0; $min_prices = 0;
@@ -315,9 +314,9 @@ VALUES ('%s','%s','0')",
                } // END - if
        } // END - if
 }
+
 //
-function RALLYE_EXPIRE_RALLYES($result)
-{
+function RALLYE_EXPIRE_RALLYES ($result) {
        global $DATA;
 
        // Load rallye data
@@ -336,7 +335,7 @@ function RALLYE_EXPIRE_RALLYES($result)
        $DATA['now_t']  = MAKE_DATETIME(time(), "1");
 
        // Just count...
-       $TOTAL = 0;
+       $total = 0;
        foreach($prices['uid'] as $key => $uid) {
                // Check status
                //   active = 1: account is still confirmed
@@ -352,11 +351,11 @@ LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__);
 
                // 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)) {
-                       $TOTAL++;
+                       $total++;
                } // END - if
        } // END - foreach
 
-       if (($TOTAL < $min_prices) || ($TOTAL == 0)) {
+       if (($total < $min_prices) || ($total == 0)) {
                // Do not end this rallye!
                unset($DATA);
                return;
@@ -570,8 +569,7 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
        // Generate table
        $OUT = LOAD_TEMPLATE("guest_rallye_expired_header", true);
        $SW = 2;
-       for ($idx = 0; $idx < $prices; $idx++)
-       {
+       for ($idx = 0; $idx < $prices; $idx++) {
                // Check status
                //   active = 1: account is still confirmed
                //   active = 0: account is deleted or locked
@@ -581,38 +579,35 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
                SQL_FREERESULT($result_active);
 
                if (empty($DATA['uid'][$idx])) $DATA['uid'][$idx] = "---";
-               if ((empty($DATA['ref'][$idx])) || ($DATA['ref'][$idx] == 0) || ($active == 0) || ("".round($DATA['cpoints'][$idx])."" == "0") || (empty($DATA['cpoints'][$idx])))
-               {
+               if ((empty($DATA['ref'][$idx])) || ($DATA['ref'][$idx] == 0) || ($active == 0) || ("".round($DATA['cpoints'][$idx])."" == "0") || (empty($DATA['cpoints'][$idx]))) {
                        // Allow valid and active users with at least one ref to get points
                        $DATA['ref'][$idx]   = "---";
                        $DATA['uid'][$idx]   = "---";
                }
-               if (!empty($DATA['info'][$idx]))
-               {
+
+               if (!empty($DATA['info'][$idx])) {
                        // Take direct infos
                        $DATA['infos'][$idx] = $DATA['info'][$idx];
-               }
-                else
-               {
+               } else {
                        // Take ppints
                        $DATA['infos'][$idx] = $DATA['points'][$idx]." {!POINTS!}";
                }
 
                // Add row
-               $ADD = "";
+               $add = "";
                $OUT .= "<tr>
-  <td class=\"switch_sw".$SW." bottom2".$ADD."\">&nbsp;&nbsp;".($idx+1).".</td>
-  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$ADD."\">";
+  <td class=\"switch_sw".$SW." bottom2".$add."\">&nbsp;&nbsp;".($idx+1).".</td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$add."\">";
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "<strong>";
                $OUT .= $DATA['uid'][$idx];
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "</strong>";
                $OUT .= "</td>
-  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$ADD."\">";
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$add."\">";
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "<strong>";
                $OUT .= $DATA['ref'][$idx];
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "</strong>";
                $OUT .= "</td>
-  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$ADD."\">";
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2".$add."\">";
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "<strong>";
                $OUT .= $DATA['infos'][$idx];
                if (($DATA['uid'][$idx] == $default) && ($default > 0)) $OUT .= "</strong>";
@@ -620,6 +615,7 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
 </tr>\n";
                $SW = 3 - $SW;
        }
+
        // Add footer
        $OUT .= LOAD_TEMPLATE("guest_rallye_expired_footer", true);
 
@@ -675,18 +671,16 @@ VALUES ('NEW','RALLYE_PURGED','{--RALLYE_ADMIN_PURGED--}: %s','{--RALLYE_ADMIN_P
        // Free memory
        SQL_FREERESULT($result_rallye);
 }
+
 //
-function RALLYE_TEMPLATE_SELECTION($name="template", $default="")
-{
+function RALLYE_TEMPLATE_SELECTION ($name="template", $default="") {
        // Check templates directory
        $OUT = ""; $ral = array();
        $BASE = sprintf("%stemplates/%s/html/rallye/", constant('PATH'), GET_LANGUAGE());
        $dir = opendir($BASE);
-       while ($read = readdir($dir))
-       {
+       while ($read = readdir($dir)) {
                // If it is no dir (so a file)
-               if (!is_dir($BASE.$read))
-               {
+               if (!isDirectory($BASE.$read)) {
                        // Accept only templates matching with rallye_????.tpl.xx
                        if (eregi("^rallye_.*\.tpl", $read))
                        {
@@ -718,6 +712,7 @@ function RALLYE_TEMPLATE_SELECTION($name="template", $default="")
        // Return selection
        return $OUT;
 }
+
 //
 function RALLYE_GET_REFCOUNT ($uid, $old=0) {
        // Check current refs
@@ -757,7 +752,7 @@ function RALLYE_GET_REFCOUNT ($uid, $old=0) {
                        // Remove old refs
                        //* DEBUG: */ echo "+".$cnt."/".$old."+<br />";
                        $cnt -= $old;
-               }
+               } // END - if
        } else {
                // Load current refs from database
                $result_ref = SQL_QUERY_ESC("SELECT DISTINCT SUM(s.counter) AS cnt