2 /************************************************************************
3 * MXChange v0.2.1 Start: 08/31/2008 *
4 * =============== Last change: 08/31/2008 *
6 * -------------------------------------------------------------------- *
7 * File : surfbar_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for surfbar *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer die Surfbar *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // -----------------------------------------------------------------------------
42 // -----------------------------------------------------------------------------
44 // Admin has added an URL with given user id and so on
45 function SURFBAR_ADMIN_ADD_URL ($url, $limit) {
50 } elseif (!VALIDATE_URL($url)) {
53 } elseif (SURFBAR_LOOKUP_BY_URL($url, "0")) {
54 // URL already found in surfbar!
56 } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
59 } elseif ("".bigintval($limit)."" != "".$limit."") {
60 // Invalid amount entered
64 // Register the new URL
65 return SURFBAR_REGISTER_URL($url, "0", "ACTIVE", "unlock", $limit);
67 // Admin unlocked an email so we can migrate the URL
68 function SURFBAR_ADMIN_MIGRATE_URL ($url, $uid) {
73 } elseif (!VALIDATE_URL($url)) {
76 } elseif (SURFBAR_LOOKUP_BY_URL($url, $uid)) {
77 // URL already found in surfbar!
79 } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS($uid)) {
84 // Register the new URL
85 return SURFBAR_REGISTER_URL($url, $uid, "MIGRATED", "migrate");
87 // Admin function for unlocking URLs
88 function SURFBAR_ADMIN_UNLOCK_URL_IDS ($IDs) {
89 // Is this an admin or invalid array?
91 // Not admin or invalid IDs array
93 } elseif (!is_array($IDs)) {
96 } elseif (count($IDs) == 0) {
101 // Set to true to make AND expression valid if first URL got unlocked
104 // Update the status for all ids
105 foreach ($IDs as $id => $dummy) {
106 // Test all ids through (ignores failed)
107 $done = (($done) && (SURFBAR_CHANGE_STATUS($id, "PENDING", "ACTIVE")));
110 // Return total status
113 // Admin function for rejecting URLs
114 function SURFBAR_ADMIN_REJECT_URL_IDS ($IDs) {
115 // Is this an admin or invalid array?
117 // Not admin or invalid IDs array
119 } elseif (!is_array($IDs)) {
122 } elseif (count($IDs) == 0) {
127 // Set to true to make AND expression valid if first URL got unlocked
130 // Update the status for all ids
131 foreach ($IDs as $id => $dummy) {
132 // Test all ids through (ignores failed)
133 $done = (($done) && (SURFBAR_CHANGE_STATUS($id, "PENDING", "REJECTED")));
136 // Return total status
140 // -----------------------------------------------------------------------------
142 // -----------------------------------------------------------------------------
144 // Member has added an URL
145 function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
148 // Do some pre-checks
152 } elseif (!VALIDATE_URL($url)) {
155 } elseif (SURFBAR_LOOKUP_BY_URL($url, $GLOBALS['userid'])) {
156 // URL already found in surfbar!
158 } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS($GLOBALS['userid'])) {
161 } elseif ("".bigintval($limit)."" != "".$limit."") {
162 // Invalid amount entered
166 // Register the new URL
167 return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], "PENDING", "reg", $limit);
169 // Create list of actions depending on status for the user
170 function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
171 // Load all actions in an array for given status
172 $actionArray = SURFBAR_GET_ACTION_ARRAY($status);
175 $OUT = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">
179 $width = round(100 / count($actionArray));
181 // "Walk" through all actions and create forms
182 foreach ($actionArray as $actionId=>$action) {
183 // Add form for this action
184 $OUT .= sprintf(" <td align=\"center\" width=\"%d%%\">
185 <form action=\"".URL."/modules.php?module=login&what=surfbar_list\" method=\"post\" style=\"padding-bottom:0px\">
186 <input type=\"hidden\" name=\"id\" value=\"%s\" />
187 <input type=\"hidden\" name=\"action\" value=\"%s\" />
188 <input type=\"submit\" class=\"member_submit\" name=\"ok\" title=\"{--MEMBER_SURFBAR_ACTION_%s_TITLE--}\" value=\"{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}\" />
206 // Do the member form request
207 function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
208 global $SURFBAR_CACHE;
210 // By default no action is performed
217 } elseif ((!isset($formData['id'])) || (!isset($formData['action']))) {
218 // Important form elements are missing!
220 } elseif (!isset($URLs[$formData['id']])) {
221 // ID not found in cache
223 } elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $URLs[$formData['id']]['status'])) {
224 // Action not allowed for current URL status
228 // Create the function name for selected action
229 $functionName = sprintf("SURFBAR_MEMBER_%s_ACTION", strtoupper(SQL_ESCAPE($formData['action'])));
231 // Is the function there?
232 if (function_exists($functionName)) {
234 $URLs[$formData['id']]['new_status'] = $SURFBAR_CACHE['new_status'];
236 // Extract URL data for call-back
237 $urlData = array($URLs[$formData['id']]);
239 // Action found so execute it
240 $performed = call_user_func_array($functionName, $urlData);
242 // Log invalid request
243 DEBUG_LOG(__FUNCTION__.": action={$formData['action']},id={$formData['id']},function={$functionName}");
249 // Validate if the requested action can be performed on current URL status
250 function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
251 global $SURFBAR_CACHE;
253 // Search for the requested action/status combination in database
254 $result = SQL_QUERY_ESC("SELECT new_status FROM "._MYSQL_PREFIX."_surfbar_actions WHERE action='%s' AND status='%s' LIMIT 1",
255 array($action, $status), __FILE__, __LINE__);
257 // Is the entry there?
258 $isValid = (SQL_NUMROWS($result) == 1);
260 // Fetch the new status if found
262 list($SURFBAR_CACHE['new_status']) = SQL_FETCHROW($result);
266 SQL_FREERESULT($result);
272 // -----------------------------------------------------------------------------
274 // -----------------------------------------------------------------------------
277 function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
278 // Create the data array for next function call
280 $urlData['id'] => $urlData
283 // Simply change the status here
284 return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
286 // Book an URL now (from migration)
287 function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
288 // Create the data array for next function call
290 $urlData['id'] => $urlData
293 // Simply change the status here
294 return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
297 // -----------------------------------------------------------------------------
298 // Self-maintenance functions
299 // -----------------------------------------------------------------------------
302 function SURFBAR_HANDLE_SELF_MAINTENANCE () {
303 // Handle URLs which limit has depleted so we can stop them
304 SURFBAR_HANDLE_DEPLETED_VIEWS();
306 // Handle low-points amounts
307 SURFBAR_HANDLE_LOW_POINTS();
309 // Handle URLs which limit has depleted
310 function SURFBAR_HANDLE_DEPLETED_VIEWS () {
312 $urlArray = SURFBAR_GET_URL_DATA("0", "views_max", "id", "ASC", "id", " AND views_allowed>0 AND status='ACTIVE'");
314 // Do we have some entries?
315 if (count($urlArray) > 0) {
317 foreach ($urlArray as $id => $urlData) {
321 // Rewrite array for next call
322 $urlData[$id] = $data;
325 SURFBAR_CHANGE_STATUS($id, "ACTIVE", "DEPLETED", $urlData);
329 // Alert users which have URLs booked and are low on points amount
330 function SURFBAR_HANDLE_LOW_POINTS () {
334 $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS($_CONFIG['surfbar_warn_low_points']);
336 // "Walk" through all URLs
337 foreach ($UIDs['uid'] as $uid => $dummy) {
338 // Is the last notification far enougth away to notify again?
339 if ((time() - $UIDs['notified'][$uid]) >= $_CONFIG['surfbar_low_interval']) {
343 'low' => TRANSLATE_COMMA($_CONFIG['surfbar_warn_low_points']),
344 'points' => TRANSLATE_COMMA($UIDs['points'][$uid]),
345 'notified' => MAKE_DATETIME($UIDs['notified'][$uid]),
346 'interval' => CREATE_FANCY_TIME($_CONFIG['surfbar_low_interval'])
350 SURFBAR_NOTIFY_USER("low_points", $content);
352 // Update last notified
353 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
354 array($uid), __FILE__, __LINE__);
359 // -----------------------------------------------------------------------------
361 // -----------------------------------------------------------------------------
363 // Looks up by an URL
364 function SURFBAR_LOOKUP_BY_URL ($url, $uid) {
365 // Now lookup that given URL by itself
366 $urlArray = SURFBAR_GET_URL_DATA($url, "url", "id", "ASC", "id", sprintf(" AND userid=%s", bigintval($uid)));
369 return (count($urlArray) > 0);
371 // Load URL data by given search term and column
372 function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add="") {
375 // By default nothing is found
376 $lastUrlData = array();
378 // Is the column an id number?
379 if (($column == "id") || ($column == "userid")) {
380 // Extra secure input
381 $searchTerm = bigintval($searchTerm);
384 // If the column is "id" there can be only one entry
386 if ($column == "id") {
390 // Look up the record
391 $result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, status, registered, last_locked, lock_reason, views_max, views_allowed
392 FROM "._MYSQL_PREFIX."_surfbar_urls
393 WHERE %s='%s'".$add."
396 array($column, $searchTerm, $order, $sort, $limit), __FILE__, __LINE__);
398 // Is there at least one record?
399 if (SQL_NUMROWS($result) > 0) {
401 while ($dataRow = SQL_FETCHARRAY($result)) {
402 // Shall we group these results?
403 if ($group == "id") {
404 // Add the row by id as index
405 $lastUrlData[$dataRow['id']] = $dataRow;
408 $lastUrlData[$dataRow[$group]][$dataRow['id']] = $dataRow;
414 SQL_FREERESULT($result);
419 // Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
420 function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $limit=0) {
423 // Make sure by the user registered URLs are always pending
424 if ($addMode == "reg") $status = "PENDING";
429 'frametester' => FRAMETESTER($url),
435 // Insert the URL into database
436 $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
439 if ($content['insert_id'] == 0) {
440 // INSERT did not insert any data!
444 // Translate status and limit
445 $content['status'] = SURFBAR_TRANSLATE_STATUS($content['status']);
446 $content['limit'] = SURFBAR_TRANSLATE_LIMIT($content['limit']);
448 // If in reg-mode we notify admin
449 if (($addMode == "reg") || ($_CONFIG['surfbar_notify_admin_unlock'] == "Y")) {
450 // Notify admin even when he as unlocked an email
451 SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
455 SURFBAR_NOTIFY_USER("url_{$addMode}", $content);
457 // Return the insert id
458 return $content['insert_id'];
460 // Inserts an url by given data array and return the insert id
461 function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
463 $uid = bigintval($urlData['uid']);
466 if (empty($uid)) $uid = 0;
468 // Just run the insert query for now
469 SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid,url,status,views_max,views_allowed) VALUES(%s,'%s','%s','%s','%s')",
476 ), __FILE__, __LINE__
480 return SQL_INSERTID();
482 // Notify admin(s) with a selected message and content
483 function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
484 // Prepare template name
485 $templateName = sprintf("admin_surfbar_%s", $messageType);
487 // Set default subject if following eval() wents wrong
488 $subject = ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
491 $eval = sprintf("\$subject = ADMIN_SURFBAR_NOTIFY_%s_SUBJECT;",
492 strtoupper($messageType)
496 // Send the notification out
497 return SEND_ADMIN_NOTIFICATION($subject, $templateName, $content, $content['uid']);
499 // Notify the user about the performed action
500 function SURFBAR_NOTIFY_USER ($messageType, $content) {
501 // Skip notification if userid is zero
502 if ($content['uid'] == 0) {
506 // Prepare template name
507 $templateName = sprintf("member_surfbar_%s", $messageType);
509 // Set default subject if following eval() wents wrong
510 $subject = MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
513 $eval = sprintf("\$subject = MEMBER_SURFBAR_NOTIFY_%s_SUBJECT;",
514 strtoupper($messageType)
519 $mailText = LOAD_EMAIL_TEMPLATE($templateName, $content, $content['uid']);
522 return SEND_EMAIL($content['uid'], $subject, $mailText);
524 // Translates the limit
525 function SURFBAR_TRANSLATE_LIMIT ($limit) {
529 $return = MEMBER_SURFBAR_UNLIMITED_VIEWS;
532 $return = TRANSLATE_COMMA($limit);
538 // Translate the URL status
539 function SURFBAR_TRANSLATE_STATUS ($status) {
540 // Create constant name
541 $constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
543 // Set default translated status
544 $statusTranslated = "!".$constantName."!";
546 // Generate eval() command
547 if (defined($constantName)) {
548 $eval = "\$statusTranslated = ".$constantName.";";
553 return $statusTranslated;
556 function SURFBAR_DETERMINE_REWARD ($onlyMin=false) {
559 // Static values are default
560 $reward = $_CONFIG['surfbar_static_reward'];
562 // Do we have static or dynamic?
563 if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
564 // "Calculate" dynamic reward
566 $reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
568 $reward += SURFBAR_CALCULATE_DYNAMIC_ADD();
576 function SURFBAR_DETERMINE_COSTS ($onlyMin=false) {
579 // Static costs is default
580 $costs = $_CONFIG['surfbar_static_costs'];
582 // Do we have static or dynamic?
583 if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
584 // "Calculate" dynamic costs
586 $costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
588 $costs += SURFBAR_CALCULATE_DYNAMIC_ADD();
595 // "Calculate" dynamic add
596 function SURFBAR_CALCULATE_DYNAMIC_ADD () {
597 // Get min/max values
598 $min = SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
599 $max = SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE();
601 // "Calculate" dynamic part and return it
602 return mt_rand($min, $max);
604 // Determine right template name
605 function SURFBAR_DETERMINE_TEMPLATE_NAME() {
606 // Default is the frameset
607 $templateName = "surfbar_frameset";
609 // Any frame set? ;-)
610 if (isset($_GET['frame'])) {
611 // Use the frame as a template name part... ;-)
612 $templateName = sprintf("surfbar_frame_%s",
613 SQL_ESCAPE($_GET['frame'])
618 return $templateName;
620 // Check if the "reload lock" of the current user is full, call this function
621 // before you call SURFBAR_CHECK_RELOAD_LOCK().
622 function SURFBAR_CHECK_RELOAD_FULL() {
623 global $SURFBAR_CACHE, $_CONFIG;
628 // Cache static reload lock
629 $SURFBAR_CACHE['surf_lock'] = $_CONFIG['surfbar_static_lock'];
630 //DEBUG_LOG(__FUNCTION__.":Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."");
632 // Do we have dynamic model?
633 if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
634 // "Calculate" dynamic lock
635 $SURFBAR_CACHE['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
639 $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt FROM "._MYSQL_PREFIX."_surfbar_locks
640 WHERE userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") < UNIX_TIMESTAMP(last_surfed)
642 array($GLOBALS['userid']), __FILE__, __LINE__
646 list($SURFBAR_CACHE['user_locks']) = SQL_FETCHROW($result);
649 if (is_null($SURFBAR_CACHE['user_locks'])) {
650 // Then fix it to zero!
651 $SURFBAR_CACHE['user_locks'] = 0;
655 SQL_FREERESULT($result);
658 $total = SURFBAR_GET_TOTAL_URLS();
660 // Do we have some URLs in lock? Admins can always surf on own URLs!
661 //DEBUG_LOG(__FUNCTION__.":userLocks=".SURFBAR_GET_DATA('user_locks').",total={$total}");
662 $isFull = ((SURFBAR_GET_DATA('user_locks') == $total) && ($total > 0));
667 // Get total amount of URLs of given status for current user or of ACTIVE URLs by default
668 function SURFBAR_GET_TOTAL_URLS ($status="ACTIVE", $excludeUserId=0) {
669 // Determine depleted user account
670 $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
672 // Is the exlude userid set?
673 if ($excludeUserId > 0) {
675 $UIDs['uid'][$excludeUserId] = $excludeUserId;
678 // Get amount from database
679 $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
680 FROM "._MYSQL_PREFIX."_surfbar_urls
681 WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND status='%s'",
682 array($status), __FILE__, __LINE__
686 list($cnt) = SQL_FETCHROW($result);
689 SQL_FREERESULT($result);
694 // Check wether the user is allowed to book more URLs
695 function SURFBAR_IF_USER_BOOK_MORE_URLS ($uid=0) {
698 // Is this admin and userid is zero or does the user has some URLs left to book?
699 return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < $_CONFIG['surfbar_max_order']));
701 // Get total amount of URLs of given status for current user
702 function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") {
705 // Is the user 0 and user is logged in?
706 if (($uid == 0) && (IS_MEMBER())) {
707 // Then use this userid
708 $uid = $GLOBALS['userid'];
709 } elseif ($uid == 0) {
711 return ($_CONFIG['surfbar_max_order'] + 1);
714 // Default is all URLs
717 // Is the status set?
718 if (is_array($status)) {
719 // Only URLs with these status
720 $ADD = sprintf(" AND status IN('%s')", implode("','", $status));
721 } elseif (!empty($status)) {
722 // Only URLs with this status
723 $ADD = sprintf(" AND status='%s'", $status);
724 } elseif (is_array($exclude)) {
725 // Exclude URLs with these status
726 $ADD = sprintf(" AND status NOT IN('%s')", implode("','", $exclude));
727 } elseif (!empty($exclude)) {
728 // Exclude URLs with this status
729 $ADD = sprintf(" AND status != '%s'", $exclude);
732 // Get amount from database
733 $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
734 FROM "._MYSQL_PREFIX."_surfbar_urls
735 WHERE userid=%s".$ADD."
737 array($uid, $_CONFIG['surfbar_max_order']), __FILE__, __LINE__
741 list($cnt) = SQL_FETCHROW($result);
744 SQL_FREERESULT($result);
749 // Generate a validation code for the given id number
750 function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") {
751 global $_CONFIG, $SURFBAR_CACHE;
753 // @TODO Invalid salt should be refused
754 $SURFBAR_CACHE['salt'] = "INVALID";
756 // Get code length from config
757 $length = $_CONFIG['code_length'];
760 if ($length == 0) $length = 10;
762 // Generate a code until the length matches
764 while (strlen($valCode) != $length) {
767 // Generate random hashed string
768 $SURFBAR_CACHE['salt'] = sha1(GEN_PASS(255));
769 //DEBUG_LOG(__FUNCTION__.":newSalt=".SURFBAR_GET_SALT()."");
772 $SURFBAR_CACHE['salt'] = $salt;
773 //DEBUG_LOG(__FUNCTION__.":oldSalt=".SURFBAR_GET_SALT()."");
776 // ... and now the validation code
777 $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
778 //DEBUG_LOG(__FUNCTION__.":valCode={$valCode}");
781 // Hash it with md5() and salt it with the random string
782 $hashedCode = generateHash(md5($valCode), SURFBAR_GET_SALT());
784 // Finally encrypt it PGP-like and return it
785 $valHashedCode = generatePassString($hashedCode);
786 //DEBUG_LOG(__FUNCTION__.":finalValCode={$valHashedCode}");
787 return $valHashedCode;
789 // Check validation code
790 function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
791 global $SURFBAR_CACHE;
794 $urlId = bigintval($urlId);
796 // Now generate the code again
797 $code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
799 // Return result of checking hashes and salts
800 //DEBUG_LOG(__FUNCTION__.":---".$code."|".$check."---");
801 //DEBUG_LOG(__FUNCTION__.":+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++");
802 return (($code == $check) && ($salt == SURFBAR_GET_DATA('last_salt')));
804 // Lockdown the userid/id combination (reload lock)
805 function SURFBAR_LOCKDOWN_ID ($urlId) {
806 //* //DEBUG: */ print "LOCK!");
807 ///* //DEBUG: */ return;
808 // Just add it to the database
809 SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_locks (userid, url_id) VALUES(%s, %s)",
810 array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__);
812 // Remove the salt from database
813 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_surfbar_salts WHERE url_id=%s AND userid=%s LIMIT 1",
814 array(bigintval($urlId), $GLOBALS['userid']), __FILE__, __LINE__);
816 // Pay points to the user and remove it from the sender
817 function SURFBAR_PAY_POINTS ($urlId) {
818 // Remove it from the URL owner
819 //DEBUG_LOG(__FUNCTION__.":uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."");
820 if (SURFBAR_GET_USERID() > 0) {
821 SUB_POINTS(SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
824 // Book it to the user
825 //DEBUG_LOG(__FUNCTION__.":uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."");
826 ADD_POINTS_REFSYSTEM($GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
828 // Updates the statistics of current URL/userid
829 function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
836 $allowed = SURFBAR_GET_ALLOWED_VIEWS();
838 // Do we have a limit?
840 // Then count views_max down!
841 $ADD .= ",views_max=views_max-1";
845 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET views_total=views_total+1".$ADD." WHERE id=%s LIMIT 1",
846 array(SURFBAR_GET_ID()), __FILE__, __LINE__);
848 // Update the stats entry
849 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_stats SET count=count+1 WHERE userid=%s AND url_id=%s LIMIT 1",
850 array($GLOBALS['userid'], SURFBAR_GET_ID()), __FILE__, __LINE__);
852 // Was that update okay?
853 if (SQL_AFFECTEDROWS() < 1) {
854 // No, then insert entry
855 SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_stats (userid,url_id,count) VALUES(%s,%s,1)",
856 array($GLOBALS['userid'], SURFBAR_GET_ID()), __FILE__, __LINE__);
859 // Update total/daily/weekly/monthly counter
860 $_CONFIG['surfbar_total_counter']++;
861 $_CONFIG['surfbar_daily_counter']++;
862 $_CONFIG['surfbar_weekly_counter']++;
863 $_CONFIG['surfbar_monthly_counter']++;
865 // Update config as well
866 UPDATE_CONFIG(array("surfbar_total_counter", "surfbar_daily_counter", "surfbar_weekly_counter", "surfbar_monthly_counter"), array(1,1,1,1), "+");
868 // Update the salt for validation and statistics
869 function SURFBAR_UPDATE_SALT_STATS () {
870 // Update statistics record
871 SURFBAR_UPDATE_INSERT_STATS_RECORD();
873 // Simply store the salt from cache away in database...
874 SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_salts SET last_salt='%s' WHERE url_id=%s AND userid=%s LIMIT 1",
875 array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), $GLOBALS['userid']), __FILE__, __LINE__);
878 //DEBUG_LOG(__FUNCTION__.":salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."");
881 if (SQL_AFFECTEDROWS() < 1) {
882 // Insert missing entry!
883 SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_salts (url_id,userid,last_salt) VALUES(%s, %s, '%s')",
884 array(SURFBAR_GET_ID(), $GLOBALS['userid'], SURFBAR_GET_SALT()), __FILE__, __LINE__);
888 //DEBUG_LOG(__FUNCTION__.":affectedRows=".SQL_AFFECTEDROWS()."");
890 // Return if the update was okay
891 return (SQL_AFFECTEDROWS() == 1);
893 // Check if the reload lock is active for given id
894 function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
895 //DEBUG_LOG(__FUNCTION__.":id={$urlId}");
897 $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
898 FROM "._MYSQL_PREFIX."_surfbar_locks
899 WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") < UNIX_TIMESTAMP(last_surfed)
900 ORDER BY last_surfed ASC
902 array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
906 list($cnt) = SQL_FETCHROW($result);
909 SQL_FREERESULT($result);
912 //DEBUG_LOG(__FUNCTION__.":cnt={$cnt},".SURFBAR_GET_DATA('surf_lock')."");
915 // Determine which user hash no more points left
916 function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
920 // Do we have a current user id?
921 if ((IS_MEMBER()) && ($limit == 0)) {
922 // Then add this as well
923 $UIDs['uid'][$GLOBALS['userid']] = $GLOBALS['userid'];
924 $UIDs['points'][$GLOBALS['userid']] = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
925 $UIDs['notified'][$GLOBALS['userid']] = 0;
927 // Get all userid except logged in one
928 $result = SQL_QUERY_ESC("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
929 FROM "._MYSQL_PREFIX."_surfbar_urls AS u
930 INNER JOIN "._MYSQL_PREFIX."_user_data AS d
932 WHERE u.userid NOT IN (%s,0) AND u.status='ACTIVE'
934 ORDER BY u.userid ASC",
935 array($GLOBALS['userid']), __FILE__, __LINE__);
938 $result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
939 FROM "._MYSQL_PREFIX."_surfbar_urls AS u
940 INNER JOIN "._MYSQL_PREFIX."_user_data AS d
942 WHERE u.status='ACTIVE'
944 ORDER BY u.userid ASC", __FILE__, __LINE__);
948 while (list($uid, $notified) = SQL_FETCHROW($result)) {
950 $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
951 //DEBUG_LOG(__FUNCTION__.":uid={$uid},points={$points}");
953 // Shall we add this to ignore?
954 if ($points <= $limit) {
956 //DEBUG_LOG(__FUNCTION__.":uid={$uid} has depleted points amount!");
957 $UIDs['uid'][$uid] = $uid;
958 $UIDs['points'][$uid] = $points;
959 $UIDs['notified'][$uid] = $notified;
964 SQL_FREERESULT($result);
967 //DEBUG_LOG(__FUNCTION__.":UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")");
972 // Determine how many users are Online in surfbar
973 function SURFBAR_DETERMINE_TOTAL_ONLINE () {
976 // Count all users in surfbar modue and return the value
977 $result = SQL_QUERY_ESC("SELECT id
978 FROM "._MYSQL_PREFIX."_surfbar_stats
979 WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s
981 array($_CONFIG['online_timeout']), __FILE__, __LINE__);
984 $cnt = SQL_NUMROWS($result);
987 SQL_FREERESULT($result);
992 // Determine waiting time for one URL
993 function SURFBAR_DETERMINE_WAIT_TIME () {
996 // Static time is default
997 $time = $_CONFIG['surfbar_static_time'];
999 // Which payment model do we have?
1000 if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
1001 // "Calculate" dynamic time
1002 $time += SURFBAR_CALCULATE_DYNAMIC_ADD();
1008 // Changes the status of an URL from given to other
1009 function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
1012 // Get URL data for status comparison if missing
1013 if (count($data) == 0) {
1014 $data = SURFBAR_GET_URL_DATA($urlId);
1017 // Is the status like prevStatus is saying?
1018 if ($data[$urlId]['status'] != $prevStatus) {
1019 // No, then abort here
1024 // Update the status now
1025 // ---------------------- Commented out for debugging member actions! -----------------------
1026 //SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET status='%s' WHERE id=%s LIMIT 1",
1027 // array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
1028 // ---------------------- Commented out for debugging member actions! -----------------------
1031 if (SQL_AFFECTEDROWS() != 1) {
1032 // No, something went wrong
1036 // Prepare content for notification routines
1037 $data[$urlId]['uid'] = $data[$urlId]['userid'];
1038 $data[$urlId]['frametester'] = FRAMETESTER($data[$urlId]['url']);
1039 $data[$urlId]['reward'] = TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']);
1040 $data[$urlId]['costs'] = TRANSLATE_COMMA($_CONFIG['surfbar_static_costs']);
1041 $data[$urlId]['status'] = SURFBAR_TRANSLATE_STATUS($newStatus);
1042 $data[$urlId]['registered'] = MAKE_DATETIME($data[$urlId]['registered'], "2");
1043 $newStatus = strtolower($newStatus);
1045 // Send admin notification
1046 SURFBAR_NOTIFY_ADMIN("url_{$newStatus}", $data[$urlId]);
1048 // Send user notification
1049 SURFBAR_NOTIFY_USER("url_{$newStatus}", $data[$urlId]);
1054 // Calculate minimum value for dynamic payment model
1055 function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
1058 // Addon is zero by default
1062 $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
1065 $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
1068 $onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
1071 $addon += abs(log($onlineUsers / $totalUsers + 1) * $percent * $totalUsers);
1074 $totalUrls = SURFBAR_GET_TOTAL_URLS("ACTIVE", "0");
1076 // Get user's total URLs
1077 $userUrls = SURFBAR_GET_TOTAL_USER_URLS(0, "ACTIVE");
1080 if ($totalUrls > 0) {
1081 $addon += abs(log($userUrls / $totalUrls + 1) * $percent * $totalUrls);
1083 $addon += abs(log($userUrls / 1 + 1) * $percent * $totalUrls);
1089 // Calculate maximum value for dynamic payment model
1090 function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
1093 // Addon is zero by default
1100 $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
1103 $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
1106 $addon += abs($max * $percent * $totalUsers);
1109 $totalUrls = SURFBAR_GET_TOTAL_URLS("ACTIVE", "0");
1112 $addon += abs($max * $percent * $totalUrls);
1117 // Calculate dynamic lock
1118 function SURFBAR_CALCULATE_DYNAMIC_LOCK () {
1121 // Default lock is 30 seconds
1125 $onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
1128 $addon = abs(log($onlineUsers / $addon + 1));
1133 // "Getter" for lock ids array
1134 function SURFBAR_GET_LOCK_IDS () {
1135 // Prepare some arrays
1140 // Get all id from locks within the timestamp
1141 $result = SQL_QUERY_ESC("SELECT id, url_id, UNIX_TIMESTAMP(last_surfed) AS last
1143 "._MYSQL_PREFIX."_surfbar_locks
1147 id ASC", array($GLOBALS['userid']),
1148 __FILE__, __LINE__);
1151 while (list($lid, $url, $last) = SQL_FETCHROW($result)) {
1153 //DEBUG_LOG(__FUNCTION__.":next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_DATA('surf_lock')."");
1155 // Skip entries that are too old
1156 if (($last > (time() - SURFBAR_GET_DATA('surf_lock'))) && (!in_array($url, $ignored))) {
1158 //DEBUG_LOG(__FUNCTION__.":okay - lid={$lid},url={$url},last={$last}");
1160 // Add only if missing or bigger
1161 if ((!isset($IDs[$url])) || ($IDs[$url] > $last)) {
1163 //DEBUG_LOG(__FUNCTION__.":ADD - lid={$lid},url={$url},last={$last}");
1171 //DEBUG_LOG(__FUNCTION__.":ignore - lid={$lid},url={$url},last={$last}");
1173 // Ignore these old entries!
1181 SQL_FREERESULT($result);
1186 // "Getter" for maximum random number
1187 function SURFBAR_GET_MAX_RANDOM ($UIDs, $ADD) {
1189 // Count max availabe entries
1190 $result = SQL_QUERY("SELECT sbu.id AS cnt
1191 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
1192 LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
1193 ON sbu.id=sbs.url_id
1194 LEFT JOIN "._MYSQL_PREFIX."_surfbar_locks AS l
1196 WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.status='ACTIVE'".$ADD."
1197 GROUP BY sbu.id", __FILE__, __LINE__);
1200 //DEBUG_LOG(__FUNCTION__.":lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."");
1203 $maxRand = SQL_NUMROWS($result);
1206 SQL_FREERESULT($result);
1211 // Load all URLs of the current user and return it as an array
1212 function SURFBAR_GET_USER_URLS () {
1217 $result = SQL_QUERY_ESC("SELECT u.id, u.userid, u.url, u.views_total, u.status, UNIX_TIMESTAMP(u.registered) AS registered, UNIX_TIMESTAMP(u.last_locked) AS last_locked, u.lock_reason AS lock_reason
1218 FROM "._MYSQL_PREFIX."_surfbar_urls AS u
1219 WHERE u.userid=%s AND u.status != 'DELETED'
1221 array($GLOBALS['userid']), __FILE__, __LINE__);
1223 // Are there entries?
1224 if (SQL_NUMROWS($result) > 0) {
1226 while ($row = SQL_FETCHARRAY($result)) {
1228 $URLs[$row['id']] = $row;
1233 SQL_FREERESULT($result);
1238 // "Getter" for member action array for given status
1239 function SURFBAR_GET_ACTION_ARRAY ($status) {
1241 $returnArray = array();
1243 // Get all assigned actions
1244 $result = SQL_QUERY_ESC("SELECT action FROM "._MYSQL_PREFIX."_surfbar_actions WHERE status='%s' ORDER BY id ASC",
1245 array($status), __FILE__, __LINE__);
1247 // Some entries there?
1248 if (SQL_NUMROWS($result) > 0) {
1250 while (list($action) = SQL_FETCHROW($result)) {
1251 $returnArray[] = $action;
1256 SQL_FREERESULT($result);
1259 return $returnArray;
1261 // Reload to configured stop page
1262 function SURFBAR_RELOAD_TO_STOP_PAGE($page="stop") {
1265 // Internal or external?
1266 if (($_CONFIG['surfbar_pause_mode'] == "INTERNAL") || (empty($_CONFIG['surfbar_pause_url']))) {
1267 // Reload to internal page
1268 LOAD_URL("surfbar.php?frame=".$page);
1270 // Reload to external page
1271 LOAD_URL($_CONFIG['surfbar_pause_url']);
1275 // Determine next id for surfbar or get data for given id, always call this before you call other
1276 // getters below this function!!!
1277 function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
1278 global $SURFBAR_CACHE, $_CONFIG;
1280 // Default is no id and no random number
1286 // Get array with lock ids
1287 $USE = SURFBAR_GET_LOCK_IDS();
1289 // Shall we add some URL ids to ignore?
1291 if (count($USE) > 0) {
1293 $ADD = " AND sbu.id NOT IN (";
1294 foreach ($USE as $url_id => $lid) {
1296 $ADD .= $url_id.",";
1299 // Add closing bracket
1300 $ADD = substr($ADD, 0, -1) . ")";
1303 // Determine depleted user account
1304 $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
1306 // Get maximum randomness factor
1307 $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['uid'], $ADD);
1309 // If more than one URL can be called generate the random number!
1311 // Generate random number
1312 $randNum = mt_rand(0, ($maxRand - 1));
1315 // And query the database
1316 //DEBUG_LOG(__FUNCTION__.":randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."");
1317 $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
1318 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
1319 LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
1320 ON sbu.id=sbs.url_id
1321 LEFT JOIN "._MYSQL_PREFIX."_surfbar_locks AS l
1323 WHERE sbu.userid NOT IN (".implode(",", $UIDs['uid']).") AND sbu.status='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$ADD."
1325 ORDER BY l.last_surfed ASC, sbu.id ASC
1327 array($randNum), __FILE__, __LINE__
1330 // Get data from specified id number
1331 $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
1332 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
1333 LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
1334 ON sbu.id=sbs.url_id
1335 LEFT JOIN "._MYSQL_PREFIX."_surfbar_locks AS l
1337 WHERE sbu.userid != %s AND sbu.status='ACTIVE' AND sbu.id=%s AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))
1339 array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
1343 // Is there an id number?
1344 //DEBUG_LOG(__FUNCTION__.":lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."");
1345 if (SQL_NUMROWS($result) == 1) {
1347 //DEBUG_LOG(__FUNCTION__.":count(".count($SURFBAR_CACHE).") - BEFORE");
1348 $SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result));
1349 //DEBUG_LOG(__FUNCTION__.":count(".count($SURFBAR_CACHE).") - AFTER");
1351 // Determine waiting time
1352 $SURFBAR_CACHE['time'] = SURFBAR_DETERMINE_WAIT_TIME();
1354 // Is the last salt there?
1355 if (is_null($SURFBAR_CACHE['last_salt'])) {
1356 // Then repair it wit the static!
1357 //DEBUG_LOG(__FUNCTION__.":last_salt - FIXED!");
1358 $SURFBAR_CACHE['last_salt'] = "";
1361 // Fix missing last_surfed
1362 if ((!isset($SURFBAR_CACHE['last_surfed'])) || (is_null($SURFBAR_CACHE['last_surfed']))) {
1364 //DEBUG_LOG(__FUNCTION__.":last_surfed - FIXED!");
1365 $SURFBAR_CACHE['last_surfed'] = 0;
1368 // Get base/fixed reward and costs
1369 $SURFBAR_CACHE['reward'] = SURFBAR_DETERMINE_REWARD();
1370 $SURFBAR_CACHE['costs'] = SURFBAR_DETERMINE_COSTS();
1371 //DEBUG_LOG(__FUNCTION__.":BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."");
1373 // Only in dynamic model add the dynamic bonus!
1374 if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
1375 // Calculate dynamic reward/costs and add it
1376 $SURFBAR_CACHE['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
1377 $SURFBAR_CACHE['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
1378 //DEBUG_LOG(__FUNCTION__.":DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."");
1382 $nextId = SURFBAR_GET_ID();
1386 SQL_FREERESULT($result);
1389 //DEBUG_LOG(__FUNCTION__.":nextId={$nextId}");
1392 // -----------------------------------------------------------------------------
1393 // PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE ELSE THEY "WRAP" THE
1394 // $SURFBAR_CACHE ARRAY!
1395 // -----------------------------------------------------------------------------
1396 // Private getter for data elements
1397 function SURFBAR_GET_DATA ($element) {
1398 global $SURFBAR_CACHE;
1399 //DEBUG_LOG(__FUNCTION__.":element={$element}");
1404 // Is the entry there?
1405 if (isset($SURFBAR_CACHE[$element])) {
1407 $data = $SURFBAR_CACHE[$element];
1408 } else { // END - if
1410 print_r($SURFBAR_CACHE);
1411 debug_print_backtrace();
1416 //DEBUG_LOG(__FUNCTION__.":element[$element]={$data}");
1419 // Getter for reward from cache
1420 function SURFBAR_GET_REWARD () {
1421 // Get data element and return its contents
1422 return SURFBAR_GET_DATA('reward');
1424 // Getter for costs from cache
1425 function SURFBAR_GET_COSTS () {
1426 // Get data element and return its contents
1427 return SURFBAR_GET_DATA('costs');
1429 // Getter for URL from cache
1430 function SURFBAR_GET_URL () {
1431 // Get data element and return its contents
1432 return SURFBAR_GET_DATA('url');
1434 // Getter for salt from cache
1435 function SURFBAR_GET_SALT () {
1436 // Get data element and return its contents
1437 return SURFBAR_GET_DATA('salt');
1439 // Getter for id from cache
1440 function SURFBAR_GET_ID () {
1441 // Get data element and return its contents
1442 return SURFBAR_GET_DATA('id');
1444 // Getter for userid from cache
1445 function SURFBAR_GET_USERID () {
1446 // Get data element and return its contents
1447 return SURFBAR_GET_DATA('userid');
1449 // Getter for user reload locks
1450 function SURFBAR_GET_USER_RELOAD_LOCK () {
1451 // Get data element and return its contents
1452 return SURFBAR_GET_DATA('user_locks');
1454 // Getter for reload time
1455 function SURFBAR_GET_RELOAD_TIME () {
1456 // Get data element and return its contents
1457 return SURFBAR_GET_DATA('time');
1459 // Getter for allowed views
1460 function SURFBAR_GET_ALLOWED_VIEWS () {
1461 // Get data element and return its contents
1462 return SURFBAR_GET_DATA('views_allowed');