From 9bc2a494fae1a98f0873a6f3bd8c878b09124b9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 29 Jun 2010 13:20:38 +0000 Subject: [PATCH] Rewrites/fixes for surfbar --- inc/expression-functions.php | 2 +- inc/js/js-surfbar_frame_top.php | 68 ++++++++++++++++ inc/libs/surfbar_functions.php | 8 +- surfbar.php | 6 +- templates/de/html/js/js_surfbar_frame_top.tpl | 78 +++++++++++++++++++ .../de/html/surfbar/surfbar_frame_top.tpl | 72 ++--------------- 6 files changed, 162 insertions(+), 72 deletions(-) create mode 100644 inc/js/js-surfbar_frame_top.php create mode 100644 templates/de/html/js/js_surfbar_frame_top.tpl diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 458dd1792c..bb7a1807a2 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -175,7 +175,7 @@ function doExpressionPipe ($data) { // Do we have a call-back? Should always be there! if (!empty($data['callback'])) { // Parse it through this function - $replacer = '{DQUOTE} . ' . $data['callback'] . "('" . $replacer . "') . {DQUOTE}"; + $replacer = '{DQUOTE} . ' . $data['extra_func'] . '(' . $data['callback'] . "('" . $replacer . "')) . {DQUOTE}"; } // END - if // Replace the config entry diff --git a/inc/js/js-surfbar_frame_top.php b/inc/js/js-surfbar_frame_top.php new file mode 100644 index 0000000000..25b3c3a325 --- /dev/null +++ b/inc/js/js-surfbar_frame_top.php @@ -0,0 +1,68 @@ + bigintval(getRequestParameter('url_id')) +); + +// Load template +loadTemplate('js_surfbar_frame_top', false, $content); + +// [EOF] +?> diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 02c9c01cfa..fff246464e 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -807,7 +807,7 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() { // Check if the "reload lock" of the current user is full, call this function // before you call SURFBAR_CHECK_RELOAD_LOCK(). -function SURFBAR_CHECK_RELOAD_FULL() { +function SURFBAR_CHECK_RELOAD_FULL () { // Default is full! $isFull = true; @@ -899,6 +899,9 @@ LIMIT 1", // Free result SQL_FREERESULT($result); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt); + // Return result return $cnt; } @@ -1076,6 +1079,9 @@ function SURFBAR_UPDATE_SALT_STATS () { // Update statistics record SURFBAR_UPDATE_INSERT_STATS_RECORD(); + // Update salt + SURFBAR_GENERATE_VALIDATION_CODE(SURFBAR_GET_ID()); + // Simply store the salt from cache away in database... SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1", array( diff --git a/surfbar.php b/surfbar.php index d659861935..63facf329f 100644 --- a/surfbar.php +++ b/surfbar.php @@ -194,8 +194,8 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in if ($nextId > 0) { // Then prepare other content $content = array( - 'url_id' => $nextId, - 'xxx' => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId))) + 'url_id' => $nextId, + 'xxx' => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId))), ); // Update salt (double-call lock!) and statistics @@ -213,7 +213,7 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in loadIncludeOnce('inc/header.php'); // Load that template - //* DEBUG: */ die("templateName={$templateName}
\ncontent=
".print_r($content, true)."
"); + //* DEBUG: */ die('templateName=' . $templateName . '
content=
' . print_r($content, true) . '
'); loadTemplate($templateName, false, $content); } diff --git a/templates/de/html/js/js_surfbar_frame_top.tpl b/templates/de/html/js/js_surfbar_frame_top.tpl new file mode 100644 index 0000000000..b5cabc4564 --- /dev/null +++ b/templates/de/html/js/js_surfbar_frame_top.tpl @@ -0,0 +1,78 @@ +var currCounter = "{%pipe,SURFBAR_GET_RELOAD_TIME=$content[url_id]%}"; +var maxCounter = "{%pipe,SURFBAR_GET_RELOAD_TIME=$content[url_id]%}"; +var counter = document.getElementById("surfbar_counter"); +var points = document.getElementById("surfbar_points"); +var reload = document.getElementById("surfbar_reload"); +var max = document.getElementById("surfbar_max"); +var countDown = null; + +function startStopCounter () { + if (countDown == null) { + // Start counter + document.getElementById("start").innerHTML = "{--MEMBER_SURFBAR_ACTION_PAUSE_SUBMIT--}"; + countDown = window.setInterval("startCounter()", 1000); + } else { + document.getElementById("start").innerHTML = "{--MEMBER_SURFBAR_ACTION_UNPAUSE_SUBMIT--}"; + window.clearInterval(countDown); + countDown = null; + } + return false; +} + +function init () { + countDown = window.setInterval("startCounter()", 1000); + window.setTimeout("initCounter()", 500); +} + +function confirm () { + if (parent.surfbar_url != null) { + // Is in right frameset + parent.surfbar_url.location.href = "{%url=surfbar.php?id=$content[url_id]&check={%pipe,SURFBAR_GENERATE_VALIDATION_CODE=$content[url_id]%}&salt={%pipe,SURFBAR_GET_SALT%}%}"; + } else { + // Called frame=top directly + window.location.href = "{%url=surfbar.php%}"; + } +} + +function reloadSurfbar () { + if (parent.surfbar_stats != null) { + // Is in right frameset + parent.surfbar_stats.location.reload(); + } else { + // Called frame=top directly + window.location.href = "{%url=surfbar.php%}"; + } + this.location.reload(); +} + +function initCounter () { + if (parent.surfbar_url != null) { + // Is in right frameset + parent.surfbar_url.location.href = '{%pipe,SURFBAR_GET_URL=$content[url_id]%}'; + } else { + // Called frame=top directly + window.location.href = "{%url=surfbar.php%}"; + } + + counter.innerHTML = "{%pipe,SURFBAR_GET_RELOAD_TIME=$content[url_id]%}"; + points.innerHTML = "{%pipe,SURFBAR_GET_REWARD,translateComma=$content[url_id]%}"; + reload.innerHTML = "{%pipe,SURFBAR_GET_USER_LOCKS%}"; + max.innerHTML = "{%pipe,SURFBAR_GET_TOTAL_URLS%}"; +} + +function startCounter () { + if (currCounter < 1) { + return false; + } + + currCounter--; + counter.innerHTML = currCounter; + + if (currCounter == 0) { + clearInterval(countDown); + confirm(); + window.setTimeout("reloadSurfbar()", 500); + } +} + +init(); diff --git a/templates/de/html/surfbar/surfbar_frame_top.tpl b/templates/de/html/surfbar/surfbar_frame_top.tpl index 6574dedf7f..f73f4fa6e9 100644 --- a/templates/de/html/surfbar/surfbar_frame_top.tpl +++ b/templates/de/html/surfbar/surfbar_frame_top.tpl @@ -3,8 +3,8 @@
- »$content[xxx]=$content[xxx] {?POINTS?} in - $content[xxx] + »$content[xxx] {?POINTS?} in + $content[xxx] Sekunden« »X von X im Reload« @@ -14,7 +14,7 @@ »Aktuelle Seite in neuem Fenster öffnen« [Anhalten|{--MEMBER_SURFBAR_ACTION_PAUSE_SUBMIT--}|Loginbereich|Ausloggen|Schliessen] @@ -27,68 +27,6 @@
- + -- 2.39.5