Validation of points amount added to surfbar
authorRoland Häder <roland@mxchange.org>
Sat, 6 Sep 2008 22:23:43 +0000 (22:23 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 6 Sep 2008 22:23:43 +0000 (22:23 +0000)
inc/functions.php
inc/libs/surfbar_functions.php
surfbar.php

index 640ff9d..a75df20 100644 (file)
@@ -290,6 +290,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="") {
                while (strpos($tmpl_file, "\'") !== false) { $tmpl_file = str_replace("\'", '{QUOT}', $tmpl_file); }
 
                // Do we have to compile the code?
+               $ret = "";
                if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) {
                        // Okay, compile it!
                        $tmpl_file = "\$ret=\"".COMPILE_CODE(addslashes($tmpl_file))."\";";
index 898b2a5..efb49a9 100644 (file)
@@ -459,6 +459,30 @@ ORDER BY
                        $ADD = " AND l.id IN (".implode(",", $USE).")";
                } // END - if
 
+               // Get all userid
+               $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_surfbar_urls
+WHERE userid != %s AND status='CONFIRMED'
+GROUP BY userid
+ORDER BY userid ASC",
+                       array($GLOBALS['userid']), __FILE__, __LINE__);
+
+               // Load all userid
+               $UIDs = array($GLOBALS['userid']);
+               while (list($uid) = SQL_FETCHROW($result)) {
+                       // Get total points
+                       $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
+                       //* DEBUG: */ echo __FUNCTION__.":uid={$uid},points={$points}<br />\n";
+
+                       // Shall we add this to ignore?
+                       if ($points <= 0) {
+                               // Ignore this one!
+                               $UIDs[] = $uid;
+                       } // END - if
+               } // END - while
+
+               // Free result
+               SQL_FREERESULT($result);
+
                // And query the database
                //* DEBUG: */ echo __FUNCTION__.":randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."<br />\n";
                $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.reward, sbu.costs, sbu.views_total, p.time, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
@@ -469,11 +493,11 @@ LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN "._MYSQL_PREFIX."_surfbar_locks AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid != %s AND sbu.status='CONFIRMED'".$ADD."
+WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND sbu.status='CONFIRMED'".$ADD."
 GROUP BY sbu.id
 ORDER BY l.last_surfed ASC, sbu.id ASC
 LIMIT %s,1",
-                       array($GLOBALS['userid'], $randNum), __FILE__, __LINE__
+                       array($randNum), __FILE__, __LINE__
                );
                /*
                while($content = SQL_FETCHARRAY($result)) {
index cc01a06..3c23ad4 100644 (file)
@@ -58,7 +58,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
        } // END - if
 
        // Is there a check value?
-       if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isset($_GET['frame'])) && ($_GET['frame'] == "stop"))) {
+       if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isset($_GET['frame'])) && (($_GET['frame'] == "stop") || ($_GET['frame'] == "stop2")))) {
                // Reload-lock is full, surfbar stopped so...
                // Load header
                require_once(PATH."inc/header.php");
@@ -133,11 +133,17 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                                        'curr_reload' => SURFBAR_GET_USER_RELOAD_LOCK(),
                                        'max_urls'    => SURFBAR_GET_TOTAL_URLS(),
                                        'reload'      => SURFBAR_GET_RELOAD_TIME($nextId)
-                       );
+                               );
 
                                // Update salt (double-call lock!)
                                SURFBAR_UPDATE_SALT();
-                       } // END - if
+                       } else {
+                               // Load new URL
+                               LOAD_URL("surfbar.php?frame=stop2");
+                       }
+               } elseif ((isset($_GET['frame'])) && ($_GET['frame'] == "start")) {
+                       // Starter frame found so let the footer display
+                       unset($_GET['frame']);
                } else {
                        // Load header in frameset mode
                        $isFrameset = true;