From c47293f5523a4a9e8791f0922b138fa6865aefaf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 6 Sep 2008 20:46:36 +0000 Subject: [PATCH 1/1] Problem with one URL not in reload lock fixed --- inc/functions.php | 5 ++++ inc/libs/surfbar_functions.php | 52 +++++++++++++++++++++++++++++++--- surfbar.php | 3 +- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index da970eb6f5..640ff9df0f 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -939,6 +939,11 @@ function LOAD_URL($URL, $addUrlData=true) { OUTPUT_HTML("".$URL.""); } elseif (!headers_sent()) { // Load URL when headers are not sent + /* + print("
");
+		debug_print_backtrace();
+		die("
URL={$URL}"); + */ @header ("Location: ".str_replace("&", "&", $URL)); } else { // Output error message diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 8d1df27d79..1c676079a1 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -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}
\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}
\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}
\n"; + $IDs[$url] = $last; + $USE[$url] = $id; + } // END - if + } else { + // Ignore these old entries! + //* DEBUG: */ echo __FUNCTION__.": ignore - id={$id},url={$url},last={$last}
\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}
\n"; + //* DEBUG: */ echo __FUNCTION__.":randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."
\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 "
".print_r($content, true)."
"; + } + 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)."*
\n"; + //* DEBUG: */ echo __FUNCTION__.":count(".count($SURFBAR_CACHE).") - BEFORE
\n"; $SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result)); - //* DEBUG: */ echo __FUNCTION__.":".count($SURFBAR_CACHE)."*
\n"; + //* DEBUG: */ echo __FUNCTION__.":count(".count($SURFBAR_CACHE).") - AFTER
\n"; // Is the time there? if (is_null($SURFBAR_CACHE['time'])) { diff --git a/surfbar.php b/surfbar.php index a5dd72bd50..677c2c1c15 100644 --- a/surfbar.php +++ b/surfbar.php @@ -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}
\ncontent=
".print_r($content, true)."
"); LOAD_TEMPLATE($templateName, false, $content); } -- 2.30.2