From 81f648125535d3fbb1ac770ce99202a0da2faa1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 6 Sep 2008 22:23:43 +0000 Subject: [PATCH] Validation of points amount added to surfbar --- inc/functions.php | 1 + inc/libs/surfbar_functions.php | 28 ++++++++++++++++++++++++++-- surfbar.php | 12 +++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 640ff9df0f..a75df20813 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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))."\";"; diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 898b2a5d64..efb49a9a0a 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -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}
\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')."
\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)) { diff --git a/surfbar.php b/surfbar.php index cc01a06f8d..3c23ad4de5 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()) || ((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; -- 2.39.2