]> git.mxchange.org Git - mailer.git/commitdiff
Problem with one URL not in reload lock fixed
authorRoland Häder <roland@mxchange.org>
Sat, 6 Sep 2008 20:46:36 +0000 (20:46 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 6 Sep 2008 20:46:36 +0000 (20:46 +0000)
inc/functions.php
inc/libs/surfbar_functions.php
surfbar.php

index da970eb6f5f4b07d62acf20550100a73dc66c608..640ff9df0f317ec2310b2cfdb3b429cf48b0cd89 100644 (file)
@@ -939,6 +939,11 @@ function LOAD_URL($URL, $addUrlData=true) {
                OUTPUT_HTML("<A href=\"".$URL."\">".$URL."</A>");
        } elseif (!headers_sent()) {
                // Load URL when headers are not sent
+               /*
+               print("<pre>");
+               debug_print_backtrace();
+               die("</pre>URL={$URL}");
+               */
                @header ("Location: ".str_replace("&amp;", "&", $URL));
        } else {
                // Output error message
index 8d1df27d7976eb349f7ebb97ba80f830f9342d22..1c676079a1b9bab66fa350ac92364f5836ca5a7b 100644 (file)
@@ -416,8 +416,45 @@ function SURFBAR_GET_NEXT_ID ($id = 0) {
                        $randNum = mt_rand(0, $maxRand);
                } // END - if
 
+               // Get all id from locks within the timestamp
+               $result = SQL_QUERY_ESC("SELECT id, url_id, UNIX_TIMESTAMP(last_surfed)
+FROM
+       "._MYSQL_PREFIX."_surfbar_locks
+WHERE
+       userid=%s
+ORDER BY
+       id ASC", array($GLOBALS['userid']),
+                       __FILE__, __LINE__);
+
+               // Load all entries
+               $IDs = array(); $USE = array();
+               $ignored = array();
+               while (list($id, $url, $last) = SQL_FETCHROW($result)) {
+                       //* DEBUG: */ echo __FUNCTION__.": next - id={$id},url={$url},last={$last}<br />\n";
+                       // Skip entries that are too old
+                       if (($last < (time() - SURFBAR_GET_DATA('surf_lock'))) && (!in_array($url, $ignored))) {
+                               //* DEBUG: */ echo __FUNCTION__.": okay - id={$id},url={$url},last={$last}<br />\n";
+                               // Add only if missing or bigger
+                               if ((!isset($IDs[$url])) || ($IDs[$url] <= $last)) {
+                                       // Add this ID
+                                       //* DEBUG: */ echo __FUNCTION__.": ADD - id={$id},url={$url},last={$last}<br />\n";
+                                       $IDs[$url] = $last;
+                                       $USE[$url] = $id;
+                               } // END - if
+                       } else {
+                               // Ignore these old entries!
+                               //* DEBUG: */ echo __FUNCTION__.": ignore - id={$id},url={$url},last={$last}<br />\n";
+                               $ignored[] = $url;
+                               unset($IDs[$url]);
+                               unset($USE[$url]);
+                       }
+               } // END - if
+
+               // Free result
+               SQL_FREERESULT($result);
+
                // And query the database
-               //* DEBUG: */ echo __FUNCTION__.":randNum={$randNum},maxRand={$maxRand}<br />\n";
+               //* 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
 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
 LEFT JOIN "._MYSQL_PREFIX."_payments AS p
@@ -426,11 +463,18 @@ 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' AND (l.last_surfed IS NULL OR (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") >= UNIX_TIMESTAMP(l.last_surfed))
+WHERE sbu.userid != %s AND sbu.status='CONFIRMED' AND l.id IN (".implode(",", $USE).")
+GROUP BY sbu.id
 ORDER BY l.last_surfed ASC, sbu.id ASC
 LIMIT %s,1",
                        array($GLOBALS['userid'], $randNum), __FILE__, __LINE__
                );
+               /*
+               while($content = SQL_FETCHARRAY($result)) {
+                       echo "<pre>".print_r($content, true)."</pre>";
+               }
+               die();
+               */
        } else {
                // Get data from specified id number
                $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
@@ -450,9 +494,9 @@ LIMIT 1",
        // Is there an id number?
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
-               //* DEBUG: */ echo __FUNCTION__.":".count($SURFBAR_CACHE)."*<br />\n";
+               //* DEBUG: */ echo __FUNCTION__.":count(".count($SURFBAR_CACHE).") - BEFORE<br />\n";
                $SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result));
-               //* DEBUG: */ echo __FUNCTION__.":".count($SURFBAR_CACHE)."*<br />\n";
+               //* DEBUG: */ echo __FUNCTION__.":count(".count($SURFBAR_CACHE).") - AFTER<br />\n";
 
                // Is the time there?
                if (is_null($SURFBAR_CACHE['time'])) {
index a5dd72bd508c8a2087edb1eb5da503c2c5afd1a8..677c2c1c15de38fe7b3ef0aa436d2d2cc0926788 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()) {
+       if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isset($_GET['frame'])) && ($_GET['frame'] == "stop"))) {
                // Reload-lock is full, surfbar stopped so...
                // Load header
                require_once(PATH."inc/header.php");
@@ -149,6 +149,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                require_once(PATH."inc/header.php");
 
                // Load that template
+               //* DEBUG: */ die("templateName={$templateName}<br />\n<strong>content</strong>=<pre>".print_r($content, true)."</pre>");
                LOAD_TEMPLATE($templateName, false, $content);
        }