* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Surfbar *
* -------------------------------------------------------------------- *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Surfbar *
* -------------------------------------------------------------------- *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Admin has added an URL with given user id and so on
function SURFBAR_ADMIN_ADD_URL ($url, $limit, $reload) {
// Do some pre-checks
// Admin has added an URL with given user id and so on
function SURFBAR_ADMIN_ADD_URL ($url, $limit, $reload) {
// Do some pre-checks
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Not admin.", $url, $limit, $reload));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid URL.", $url, $limit, $reload));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Already added.", $url, $limit, $reload));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : No more URLs allowed.", $url, $limit, $reload));
- } elseif ("".($limit + 0)."" != "".$limit."") {
- // Invalid amount entered
+ } elseif ('' . ($limit + 0) . '' != '' . $limit . '') {
+ // Invalid limit entered
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid limit entered.", $url, $limit, $reload));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid reload entered.", $url, $limit, $reload));
- return SURFBAR_REGISTER_URL($url, "0", "ACTIVE", "unlock", array('limit' => $limit, 'reload' => $reload));
+ return SURFBAR_REGISTER_URL($url, 0, 'ACTIVE', 'unlock', array('limit' => $limit, 'reload' => $reload));
- return SURFBAR_REGISTER_URL($url, $uid, "MIGRATED", "migrate");
+ return SURFBAR_REGISTER_URL($url, $userid, 'MIGRATED', 'migrate');
// Admin function for unlocking URLs
function SURFBAR_ADMIN_UNLOCK_URL_IDS ($IDs) {
// Is this an admin or invalid array?
// Admin function for unlocking URLs
function SURFBAR_ADMIN_UNLOCK_URL_IDS ($IDs) {
// Is this an admin or invalid array?
// Update the status for all ids
foreach ($IDs as $id => $dummy) {
// Test all ids through (ignores failed)
// Update the status for all ids
foreach ($IDs as $id => $dummy) {
// Test all ids through (ignores failed)
// Admin function for rejecting URLs
function SURFBAR_ADMIN_REJECT_URL_IDS ($IDs) {
// Is this an admin or invalid array?
// Admin function for rejecting URLs
function SURFBAR_ADMIN_REJECT_URL_IDS ($IDs) {
// Is this an admin or invalid array?
// Update the status for all ids
foreach ($IDs as $id => $dummy) {
// Test all ids through (ignores failed)
// Update the status for all ids
foreach ($IDs as $id => $dummy) {
// Test all ids through (ignores failed)
//
// Member has added an URL
function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
//
// Member has added an URL
function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
- return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], "PENDING", "reg", array('limit' => $limit));
+ return SURFBAR_REGISTER_URL($url, getUserId(), 'PENDING', 'reg', array('limit' => $limit));
// Create list of actions depending on status for the user
function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
// Load all actions in an array for given status
// Create list of actions depending on status for the user
function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
// Load all actions in an array for given status
- $OUT .= sprintf(" <td align=\"center\" width=\"%d%%\">
- <form action=\"{!URL!}/modules.php?module=login&what=surfbar_list\" method=\"post\" style=\"padding-bottom:0px\">
- <input type=\"hidden\" name=\"id\" value=\"%s\" />
- <input type=\"hidden\" name=\"action\" value=\"%s\" />
- <input type=\"submit\" class=\"member_submit\" name=\"ok\" title=\"{--MEMBER_SURFBAR_ACTION_%s_TITLE--}\" value=\"{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}\" />
- </form>
- </td>\n",
- $width,
- bigintval($urlId),
- strtolower($action),
- strtoupper($action),
- strtoupper($action)
- );
+ $OUT .= loadTemplate('member_surfbar_list_form', true, array(
+ 'width' => $width,
+ 'id' => bigintval($urlId),
+ 'action' => strtolower($action),
+ 'title' => '{--MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_TITLE--}',
+ 'submit' => '{--MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_SUBMIT--}',
+ ));
// Do the member form request
function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
// Do the member form request
function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
// Extract URL data for call-back
$urlData = array(merge_array($URLs[$formData['id']], array($action => $formData)));
// Extract URL data for call-back
$urlData = array(merge_array($URLs[$formData['id']], array($action => $formData)));
- DEBUG_LOG(__FUNCTION__, __LINE__, " action={$formData['action']},id={$formData['id']},function={$functionName}");
- addFatalMessage(sprintf("Invalid member action! action=%s,id=%s,function=%s", $formData['action'], $formData['id'], $functionName));
+ logDebugMessage(__FUNCTION__, __LINE__, "action={$formData['action']},id={$formData['id']},function={$functionName}");
+ addFatalMessage(__FUNCTION__, __LINE__, "Invalid member action! action=%s,id=%s,function=%s", array($formData['action'], $formData['id'], $functionName));
// Validate if the requested action can be performed on current URL status
function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
// Validate if the requested action can be performed on current URL status
function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
- $result = SQL_QUERY_ESC("SELECT new_status FROM `{!_MYSQL_PREFIX!}_surfbar_actions` WHERE action='%s' AND `status`='%s' LIMIT 1",
- array($action, $status), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT new_status FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `action`='%s' AND `status`='%s' LIMIT 1",
+ array($action, $status), __FUNCTION__, __LINE__);
);
// Simply change the status here
return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
}
);
// Simply change the status here
return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
}
// Book an URL now (from migration)
function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
// Create the data array for next function call
$data = array(
// Book an URL now (from migration)
function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
// Create the data array for next function call
$data = array(
);
// Simply change the status here
return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
}
);
// Simply change the status here
return SURFBAR_CHANGE_STATUS ($urlData['id'], $urlData['status'], $urlData['new_status'], $data);
}
// Show edit form or do the changes
function SURFBAR_MEMBER_EDIT_ACTION ($urlData) {
// Is the "execute" flag there?
if (isset($urlData['edit']['execute'])) {
// Execute the changes
// Show edit form or do the changes
function SURFBAR_MEMBER_EDIT_ACTION ($urlData) {
// Is the "execute" flag there?
if (isset($urlData['edit']['execute'])) {
// Execute the changes
// Show delete form or do the changes
function SURFBAR_MEMBER_DELETE_ACTION ($urlData) {
// Is the "execute" flag there?
if (isset($urlData['delete']['execute'])) {
// Execute the changes
// Show delete form or do the changes
function SURFBAR_MEMBER_DELETE_ACTION ($urlData) {
// Is the "execute" flag there?
if (isset($urlData['delete']['execute'])) {
// Execute the changes
// Pause active banner
function SURFBAR_MEMBER_PAUSE_ACTION ($urlData) {
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Pause active banner
function SURFBAR_MEMBER_PAUSE_ACTION ($urlData) {
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Unpause stopped banner
function SURFBAR_MEMBER_UNPAUSE_ACTION ($urlData) {
// Fix missing entry for template
// Unpause stopped banner
function SURFBAR_MEMBER_UNPAUSE_ACTION ($urlData) {
// Fix missing entry for template
// Return status change
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Return status change
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Resubmit locked URL
function SURFBAR_MEMBER_RESUBMIT_ACTION ($urlData) {
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Resubmit locked URL
function SURFBAR_MEMBER_RESUBMIT_ACTION ($urlData) {
return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
}
// Display selected "action form"
function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
// Translate some data
// Display selected "action form"
function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
// Translate some data
- $urlData['registered'] = MAKE_DATETIME($urlData['registered'], "2");
- $urlData['views_total'] = TRANSLATE_COMMA($urlData['views_total']);
- $urlData['views_max'] = TRANSLATE_COMMA($urlData['views_max']);
- $urlData['views_allowed'] = TRANSLATE_COMMA($urlData['views_allowed']);
- $urlData['last_locked'] = MAKE_DATETIME($urlData['last_locked'], "2");
+ $urlData['registered'] = generateDateTime($urlData['registered'], 2);
+ $urlData['views_total'] = translateComma($urlData['views_total']);
+ $urlData['views_max'] = translateComma($urlData['views_max']);
+ $urlData['views_allowed'] = translateComma($urlData['views_allowed']);
+ $urlData['last_locked'] = generateDateTime($urlData['last_locked'], 2);
// Is the lock reason empty?
if (empty($urlData['lock_reason'])) {
// Fix it to three dashes
// Is the lock reason empty?
if (empty($urlData['lock_reason'])) {
// Fix it to three dashes
- $urlData['limited_yes'] = "";
- $urlData['limited_no'] = " checked=\"checked\"";
- $urlData['limited'] = "false";
+ $urlData['limited_y'] = '';
+ $urlData['limited_n'] = ' checked="checked"';
+ $urlData['limited'] = 'false';
- $urlData['limited_yes'] = " checked=\"checked\"";
- $urlData['limited_no'] = "";
- $urlData['limited'] = "true";
+ $urlData['limited_y'] = ' checked="checked"';
+ $urlData['limited_n'] = '';
+ $urlData['limited'] = 'true';
- LOAD_TEMPLATE(sprintf("member_surfbar_%s_action_form", $action), false, $urlData);
+ loadTemplate(sprintf("member_surfbar_%s_action_form", $action), false, $urlData);
// Execute choosen action
function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) {
// By default nothing is executed
$executed = false;
// Is limitation "no" and "limit" is > 0?
// Execute choosen action
function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) {
// By default nothing is executed
$executed = false;
// Is limitation "no" and "limit" is > 0?
// Construct function name
$functionName = sprintf("SURFBAR_MEMBER_EXECUTE_%s_ACTION", strtoupper($action));
// Construct function name
$functionName = sprintf("SURFBAR_MEMBER_EXECUTE_%s_ACTION", strtoupper($action));
- // Is 'userid' set and not 'uid' ?
- if ((!isset($urlData['uid'])) && (isset($urlData['userid']))) {
+ // Is 'userid' set and not 'userid' ?
+ if ((!isset($urlData['userid'])) && (isset($urlData['userid']))) {
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET url='%s', views_allowed=%s, views_max=%s WHERE id=%s AND `status`='%s' LIMIT 1",
- array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET url='%s', views_allowed=%s, views_max=%s WHERE `id`=%s AND `status`='%s' LIMIT 1",
+ array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FUNCTION__, __LINE__);
- $urlArray = SURFBAR_GET_URL_DATA("0", "views_max", "id", "ASC", "id", " AND views_allowed>0 AND `status`='ACTIVE'");
+ $urlArray = SURFBAR_GET_URL_DATA(0, 'views_max', 'id', 'ASC', 'id', " AND views_allowed>0 AND `status`='ACTIVE'");
- SURFBAR_CHANGE_STATUS($id, "ACTIVE", "DEPLETED", $urlData);
+ SURFBAR_CHANGE_STATUS($id, 'ACTIVE', 'DEPLETED', $urlData);
// Alert users which have URLs booked and are low on points amount
function SURFBAR_HANDLE_LOW_POINTS () {
// Alert users which have URLs booked and are low on points amount
function SURFBAR_HANDLE_LOW_POINTS () {
// Get all userids
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
// "Walk" through all URLs
// Get all userids
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
// "Walk" through all URLs
- 'uid' => $uid,
- 'low' => TRANSLATE_COMMA(getConfig('surfbar_warn_low_points')),
- 'points' => TRANSLATE_COMMA($UIDs['points'][$uid]),
- 'notified' => MAKE_DATETIME($UIDs['notified'][$uid]),
- 'interval' => CREATE_FANCY_TIME(getConfig('surfbar_low_interval'))
+ 'userid' => $userid,
+ 'low' => translateComma(getConfig('surfbar_warn_low_points')),
+ 'points' => translateComma($UIDs['points'][$userid]),
+ 'notified' => generateDateTime($UIDs['notified'][$userid]),
+ 'interval' => createFancyTime(getConfig('surfbar_low_interval'))
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
- array($uid), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET surfbar_low_notified=NOW() WHERE `userid`=%s LIMIT 1",
+ array($userid), __FUNCTION__, __LINE__);
//
// -----------------------------------------------------------------------------
// Generic functions
// -----------------------------------------------------------------------------
//
//
// -----------------------------------------------------------------------------
// Generic functions
// -----------------------------------------------------------------------------
//
- $urlArray = SURFBAR_GET_URL_DATA($url, "url", "id", "ASC", "id", sprintf(" AND userid=%s", bigintval($uid)));
+ $urlArray = SURFBAR_GET_URL_DATA($url, 'url', 'id', 'ASC', 'id', sprintf(" AND `userid`=%s", bigintval($userid)));
-// Load URL data by given search term and column
-function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add="") {
- global $lastUrlData;
+// Load URL data by given search term and column
+function SURFBAR_GET_URL_DATA ($searchTerm, $column = 'id', $order = 'id', $sort = 'ASC', $group = 'id', $add = '') {
$limit = "LIMIT 1";
} // END - if
// Look up the record
$result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, views_max, views_allowed, status, registered, last_locked, lock_reason, views_max, views_allowed, fixed_reload
$limit = "LIMIT 1";
} // END - if
// Look up the record
$result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, views_max, views_allowed, status, registered, last_locked, lock_reason, views_max, views_allowed, fixed_reload
- array($column, $searchTerm, $order, $sort, $limit), __FILE__, __LINE__);
+ array($column, $searchTerm, $order, $sort, $limit), __FUNCTION__, __LINE__);
// Is there at least one record?
if (SQL_NUMROWS($result) > 0) {
// Then load all!
while ($dataRow = SQL_FETCHARRAY($result)) {
// Shall we group these results?
// Is there at least one record?
if (SQL_NUMROWS($result) > 0) {
// Then load all!
while ($dataRow = SQL_FETCHARRAY($result)) {
// Shall we group these results?
+// Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
+function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'reg', $extraFields = array()) {
- if (!isset($config['limit'])) $content['limit'] = 0;
- if (!isset($config['reload'])) $content['reload'] = 0;
+ if (!isset($config['limit'])) {
+ $content['limit'] = 0;
+ } // END - if
+ if (!isset($config['reload'])) {
+ $content['reload'] = 0;
+ } // END - if
// Notify admin even when he as unlocked an email
SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
} // END - if
// Notify admin even when he as unlocked an email
SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
} // END - if
// Inserts an url by given data array and return the insert id
function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
// Get userid
// Inserts an url by given data array and return the insert id
function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
// Get userid
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_urls` (userid,url,status,views_max,views_allowed,fixed_reload) VALUES (%s,'%s','%s',%s,%s,%s)",
- array(
- $uid,
- $urlData['url'],
- $urlData['status'],
- $urlData['limit'],
- $urlData['limit'],
- $urlData['reload']
- ), __FILE__, __LINE__
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (userid,url,status,views_max,views_allowed,fixed_reload) VALUES (%s,'%s','%s',%s,%s,%s)",
+ array(
+ $userid,
+ $urlData['url'],
+ $urlData['status'],
+ $urlData['limit'],
+ $urlData['limit'],
+ $urlData['reload']
+ ), __FUNCTION__, __LINE__
// Notify admin(s) with a selected message and content
function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
// Prepare template name
$templateName = sprintf("admin_surfbar_%s", $messageType);
// Notify admin(s) with a selected message and content
function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
// Prepare template name
$templateName = sprintf("admin_surfbar_%s", $messageType);
- // Set default subject if following eval() wents wrong
- $subject = ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
-
- // Create constant name
- $constantName = sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
+ // Prepare subject
+ $subject = getMessage(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
- // Prepare subject
- if (defined($constantName)) {
- $subject = constant($constantName);
- } else {
- addFatalMessage(getMessage('ADMIN_SURFBAR_NOTIFY_SUBJECT_404'), $constantName);
- }
+ // Is the subject line there?
+ if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
+ // Set default subject if following eval() wents wrong
+ $subject = getMessage('ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
+ } // END - if
- if (isset($content['status'])) $content['status'] = SURFBAR_TRANSLATE_STATUS($content['status']);
- if (isset($content['registered'])) $content['registered'] = MAKE_DATETIME($content['registered'], "2");
- if (isset($content['last_locked'])) $content['last_locked'] = MAKE_DATETIME($content['last_locked'], "2");
- if (isset($content['views_total'])) $content['views_total'] = TRANSLATE_COMMA($content['views_total']);
- if (isset($content['views_allowed'])) $content['views_allowed'] = TRANSLATE_COMMA($content['views_allowed']);
- if (isset($content['views_max'])) $content['views_max'] = TRANSLATE_COMMA($content['views_max']);
+ if (isset($content['status'])) $content['status'] = translateSurfbarUrlStatus($content['status']);
+ if (isset($content['registered'])) $content['registered'] = generateDateTime($content['registered'], 2);
+ if (isset($content['last_locked'])) $content['last_locked'] = generateDateTime($content['last_locked'], 2);
+ if (isset($content['views_total'])) $content['views_total'] = translateComma($content['views_total']);
+ if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
+ if (isset($content['views_max'])) $content['views_max'] = translateComma($content['views_max']);
- return SEND_ADMIN_NOTIFICATION($subject, $templateName, $content, $content['uid']);
+ return sendAdminNotification($subject, $templateName, $content, $content['userid']);
// Notify the user about the performed action
function SURFBAR_NOTIFY_USER ($messageType, $content) {
// Skip notification if userid is zero
// Notify the user about the performed action
function SURFBAR_NOTIFY_USER ($messageType, $content) {
// Skip notification if userid is zero
- // Set default subject if following eval() wents wrong
- $subject = MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
-
- // Create constant name
- $constantName = sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
- strtoupper($messageType)
- );
-
- if (defined($constantName)) {
- $subject = constant($constantName);
- } else {
- addFatalMessage(getMessage('MEMBER_SURFBAR_NOTIFY_SUBJECT_404'), $constantName);
- }
+ $subject = getMessage(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
+ strtoupper($messageType)
+ ));
+
+ // Is the subject line there?
+ if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
+ // Set default subject if following eval() wents wrong
+ $subject = getMessage('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
+ } // END - if
- if (isset($content['status'])) $content['status'] = SURFBAR_TRANSLATE_STATUS($content['status']);
- if (isset($content['registered'])) $content['registered'] = MAKE_DATETIME($content['registered'], "2");
- if (isset($content['last_locked'])) $content['last_locked'] = MAKE_DATETIME($content['last_locked'], "2");
- if (isset($content['views_total'])) $content['views_total'] = TRANSLATE_COMMA($content['views_total']);
- if (isset($content['views_allowed'])) $content['views_allowed'] = TRANSLATE_COMMA($content['views_allowed']);
- if (isset($content['views_max'])) $content['views_max'] = TRANSLATE_COMMA($content['views_max']);
+ if (isset($content['status'])) $content['status'] = translateSurfbarUrlStatus($content['status']);
+ if (isset($content['registered'])) $content['registered'] = generateDateTime($content['registered'], 2);
+ if (isset($content['last_locked'])) $content['last_locked'] = generateDateTime($content['last_locked'], 2);
+ if (isset($content['views_total'])) $content['views_total'] = translateComma($content['views_total']);
+ if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
+ if (isset($content['views_max'])) $content['views_max'] = translateComma($content['views_max']);
// Create constant name
$constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
// Set default translated status
// Create constant name
$constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
// Set default translated status
// Static values are default
$reward = getConfig('surfbar_static_reward');
// Do we have static or dynamic?
// Static values are default
$reward = getConfig('surfbar_static_reward');
// Do we have static or dynamic?
// Static costs is default
$costs = getConfig('surfbar_static_costs');
// Do we have static or dynamic?
// Static costs is default
$costs = getConfig('surfbar_static_costs');
// Do we have static or dynamic?
// "Calculate" dynamic part and return it
return mt_rand($min, $max);
}
// "Calculate" dynamic part and return it
return mt_rand($min, $max);
}
// Determine right template name
function SURFBAR_DETERMINE_TEMPLATE_NAME() {
// Default is the frameset
$templateName = "surfbar_frameset";
// Any frame set? ;-)
// Determine right template name
function SURFBAR_DETERMINE_TEMPLATE_NAME() {
// Default is the frameset
$templateName = "surfbar_frameset";
// Any frame set? ;-)
// Use the frame as a template name part... ;-)
$templateName = sprintf("surfbar_frame_%s",
// Use the frame as a template name part... ;-)
$templateName = sprintf("surfbar_frame_%s",
// 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() {
// 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() {
- $SURFBAR_CACHE['surf_lock'] = getConfig('surfbar_static_lock');
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".getConfig('surfbar_static_lock')."", false);
+ $GLOBALS['surfbar_cache']['surf_lock'] = getConfig('surfbar_static_lock');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false);
- $result = SQL_QUERY_ESC("SELECT COUNT(l.id) AS cnt FROM `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
-INNER JOIN `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
-ON u.id=l.url_id
-WHERE l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
+ $result = SQL_QUERY_ESC("SELECT
+ COUNT(l.id) AS cnt
+FROM
+ `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+ON
+ u.id=l.url_id
+WHERE
+ l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
$total = SURFBAR_GET_TOTAL_URLS();
// Do we have some URLs in lock? Admins can always surf on own URLs!
$total = SURFBAR_GET_TOTAL_URLS();
// Do we have some URLs in lock? Admins can always surf on own URLs!
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "userLocks=".SURFBAR_GET_USER_LOCKS().",total={$total}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userLocks=".SURFBAR_GET_USER_LOCKS().",total={$total}", false);
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND `status`='%s'",
- array($status), __FILE__, __LINE__
+ $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt
+FROM `{?_MYSQL_PREFIX?}_surfbar_urls`
+WHERE `userid` NOT IN (".implode(', ', $UIDs['userid']).") AND `status`='%s'",
+ array($status), __FUNCTION__, __LINE__
- return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < getConfig('surfbar_max_order')));
+ return ((($userid == 0) && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array("REJECTED")) < getConfig('surfbar_max_order')));
- $ADD = sprintf(" AND status IN('%s')", implode("','", $status));
+ $add = sprintf(" AND `status` IN('%s')", implode("','", $status));
- $ADD = sprintf(" AND status NOT IN('%s')", implode("','", $exclude));
+ $add = sprintf(" AND `status` NOT IN('%s')", implode("','", $exclude));
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid=%s".$ADD."
-LIMIT %s",
- array($uid, getConfig('surfbar_max_order')), __FILE__, __LINE__
- );
-
- // Fetch row
- list($cnt) = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
+ $cnt = countSumTotalData($userid, 'surfbar_urls', 'id', 'userid', true, $add);
- $SURFBAR_CACHE['salt'] = sha1(GEN_PASS(255));
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "newSalt=".SURFBAR_GET_SALT()."", false);
+ $GLOBALS['surfbar_cache']['salt'] = sha1(generatePassword(mt_rand(200, 255)));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.SURFBAR_GET_SALT().'', false);
- $SURFBAR_CACHE['salt'] = $salt;
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "oldSalt=".SURFBAR_GET_SALT()."", false);
+ $GLOBALS['surfbar_cache']['salt'] = $salt;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.SURFBAR_GET_SALT().'', false);
- $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
+ $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getUserId());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valCode='.valCode.'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "finalValCode={$valHashedCode}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'finalValCode='.$valHashedCode.'', false);
$code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
// Return result of checking hashes and salts
$code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
// Return result of checking hashes and salts
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "---".$code."|".$check."---", false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '---'.$code.'|'.$check.'---', false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '+++'.$salt.'|'.SURFBAR_GET_DATA('last_salt').'+++', false);
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_locks` (userid, url_id) VALUES (%s, %s)",
- array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`userid`, `url_id`) VALUES (%s, %s)",
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__);
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_surfbar_salts` WHERE url_id=%s AND userid=%s LIMIT 1",
- array(bigintval($urlId), $GLOBALS['userid']), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `url_id`=%s AND `userid`=%s LIMIT 1",
+ array(bigintval($urlId), getUserId()), __FUNCTION__, __LINE__);
// Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
function SURFBAR_PAY_POINTS () {
// Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
function SURFBAR_PAY_POINTS () {
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
- SUB_POINTS(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
+ subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
- ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getUserId().',reward='.SURFBAR_GET_REWARD().'', false);
+ addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getUserId(), SURFBAR_GET_DATA('reward'));
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET views_total=views_total+1".$ADD." WHERE id=%s LIMIT 1",
- array(SURFBAR_GET_ID()), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `views_total`=`views_total`+1".$add." WHERE `id`=%s LIMIT 1",
+ array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_stats` SET count=count+1 WHERE userid=%s AND url_id=%s LIMIT 1",
- array($GLOBALS['userid'], SURFBAR_GET_ID()), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `count`=`count`+1 WHERE `userid`=%s AND `url_id`=%s LIMIT 1",
+ array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_stats` (userid,url_id,count) VALUES (%s,%s,1)",
- array($GLOBALS['userid'], SURFBAR_GET_ID()), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (userid,url_id,count) VALUES (%s,%s,1)",
+ array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
- UPDATE_CONFIG(array("surfbar_total_counter", "surfbar_daily_counter", "surfbar_weekly_counter", "surfbar_monthly_counter"), array(1,1,1,1), "+");
+ updateConfiguration(array('surfbar_total_counter', 'surfbar_daily_counter', 'surfbar_weekly_counter', 'surfbar_monthly_counter'), array(1,1,1,1), '+');
// Update the salt for validation and statistics
function SURFBAR_UPDATE_SALT_STATS () {
// Update statistics record
SURFBAR_UPDATE_INSERT_STATS_RECORD();
// Simply store the salt from cache away in database...
// Update the salt for validation and statistics
function SURFBAR_UPDATE_SALT_STATS () {
// Update statistics record
SURFBAR_UPDATE_INSERT_STATS_RECORD();
// Simply store the salt from cache away in database...
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_salts` SET last_salt='%s' WHERE url_id=%s AND userid=%s LIMIT 1",
- array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), $GLOBALS['userid']), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `last_salt`='%s' WHERE `url_id`=%s AND `userid`=%s LIMIT 1",
+ array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), getUserId()), __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt='.SURFBAR_GET_SALT().',id='.SURFBAR_GET_ID().',userid='.getUserId().'', false);
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_salts` (url_id,userid,last_salt) VALUES (%s, %s, '%s')",
- array(SURFBAR_GET_ID(), $GLOBALS['userid'], SURFBAR_GET_SALT()), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`url_id`, `userid`, `last_salt`) VALUES (%s, %s, '%s')",
+ array(SURFBAR_GET_ID(), getUserId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "affectedRows=".SQL_AFFECTEDROWS()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows='.SQL_AFFECTEDROWS().'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "id={$urlId}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $urlId . '', false);
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_locks`
-WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(last_surfed)
-ORDER BY last_surfed ASC
+ $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt
+FROM
+ `{?_MYSQL_PREFIX?}_surfbar_locks`
+WHERE
+ `userid`=%s AND `url_id`=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(`last_surfed`)
+ORDER BY
+ `last_surfed` ASC
- array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "cnt={$cnt},".SURFBAR_GET_SURF_LOCK()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt . ',' . SURFBAR_GET_SURF_LOCK() . '', false);
// Determine which user hash no more points left
function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Init array
$UIDs = array(
// Determine which user hash no more points left
function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Init array
$UIDs = array(
- $UIDs['uid'][$GLOBALS['userid']] = $GLOBALS['userid'];
- $UIDs['points'][$GLOBALS['userid']] = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
- $UIDs['notified'][$GLOBALS['userid']] = 0;
+ $UIDs['userid'][getUserId()] = getUserId();
+ $UIDs['points'][getUserId()] = countSumTotalData(getUserId(), 'user_points', 'points') - countSumTotalData(getUserId(), 'user_data', 'used_points');
+ $UIDs['notified'][getUserId()] = 0;
- $result = SQL_QUERY_ESC("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
-INNER JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
-ON u.userid=d.userid
-WHERE u.userid NOT IN (%s,0) AND u.`status`='ACTIVE'
-GROUP BY u.userid
-ORDER BY u.userid ASC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+FROM
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+ON
+ u.userid=d.userid
+WHERE
+ u.userid NOT IN (%s,0) AND u.`status`='ACTIVE'
+GROUP BY
+ u.userid
+ORDER BY
+ u.userid ASC",
+ array(getUserId()), __FUNCTION__, __LINE__);
- $result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
-INNER JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
-ON u.userid=d.userid
-WHERE u.`status`='ACTIVE'
-GROUP BY u.userid
-ORDER BY u.userid ASC", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT
+ u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+FROM
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+ON
+ u.userid=d.userid
+WHERE
+ u.`status`='ACTIVE'
+GROUP BY
+ u.userid
+ORDER BY
+ u.userid ASC", __FUNCTION__, __LINE__);
- $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},points={$points}", false);
+ $points = countSumTotalData($content['userid'], 'user_points', 'points') - countSumTotalData($content['userid'], 'user_data', 'used_points');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']},points={$points}", false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid} has depleted points amount!", false);
- $UIDs['uid'][$uid] = $uid;
- $UIDs['points'][$uid] = $points;
- $UIDs['notified'][$uid] = $notified;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']} has depleted points amount!", false);
+ $UIDs['userid'][$content['userid']] = $content['userid'];
+ $UIDs['points'][$content['userid']] = $points;
+ $UIDs['notified'][$content['userid']] = $content['notified'];
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().')', false);
- $result = SQL_QUERY_ESC("SELECT id
-FROM `{!_MYSQL_PREFIX!}_surfbar_stats`
-WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s
-GROUP BY userid",
- array(getConfig('online_timeout')), __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT
+ `id`
+FROM
+ `{?_MYSQL_PREFIX?}_surfbar_stats`
+WHERE
+ (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`last_surfed`)) <= {?online_timeout?}
+GROUP BY
+ `userid` ASC", __FUNCTION__, __LINE__);
// Changes the status of an URL from given to other
function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
// Changes the status of an URL from given to other
function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
- //SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET `status`='%s' WHERE id=%s LIMIT 1",
- // array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
+ //SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `status`='%s' WHERE `id`=%s LIMIT 1",
+ // array($newStatus, bigintval($urlId)), __FUNCTION__, __LINE__);
//if (SQL_AFFECTEDROWS() != 1) {
// // No, something went wrong
// return false;
//} // END - if
//if (SQL_AFFECTEDROWS() != 1) {
// // No, something went wrong
// return false;
//} // END - if
- $data[$urlId]['uid'] = $data[$urlId]['userid'];
- $data[$urlId]['frametester'] = FRAMETESTER($data[$urlId]['url']);
- $data[$urlId]['reward'] = TRANSLATE_COMMA(getConfig('surfbar_static_reward'));
- $data[$urlId]['costs'] = TRANSLATE_COMMA(getConfig('surfbar_static_costs'));
+ $data[$urlId]['userid'] = $data[$urlId]['userid'];
+ $data[$urlId]['frametester'] = generateFrametesterUrl($data[$urlId]['url']);
+ $data[$urlId]['reward'] = translateComma(getConfig('surfbar_static_reward'));
+ $data[$urlId]['costs'] = translateComma(getConfig('surfbar_static_costs'));
// Calculate minimum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
// Calculate minimum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
- $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+ $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
// Calculate maximum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
// Calculate maximum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
- $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+ $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
- id ASC", array($GLOBALS['userid']),
- __FILE__, __LINE__);
+ `id` ASC", array(getUserId()),
+ __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_SURF_LOCK()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['id'].',url='.$content['url_id'].',rest='.(time() - $content['last_surfed']).'/'.SURFBAR_GET_SURF_LOCK().'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$lid},url={$url},last={$last}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'okay - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$lid},url={$url},last={$last}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$lid},url={$url},last={$last}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ignore - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
-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."
-GROUP BY sbu.id", __FILE__, __LINE__);
+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."
+GROUP BY sbu.id", __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".getConfig('db_last_query')."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS().'', false);
// Begin the query
$result = SQL_QUERY_ESC("SELECT u.id, u.userid, u.url, u.views_total, u.views_max, u.views_allowed, u.status, UNIX_TIMESTAMP(u.registered) AS registered, UNIX_TIMESTAMP(u.last_locked) AS last_locked, u.lock_reason AS lock_reason
// Begin the query
$result = SQL_QUERY_ESC("SELECT u.id, u.userid, u.url, u.views_total, u.views_max, u.views_allowed, u.status, UNIX_TIMESTAMP(u.registered) AS registered, UNIX_TIMESTAMP(u.last_locked) AS last_locked, u.lock_reason AS lock_reason
- $result = SQL_QUERY_ESC("SELECT action FROM `{!_MYSQL_PREFIX!}_surfbar_actions` WHERE `status`='%s' ORDER BY `id` ASC",
- array($status), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT action FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `status`='%s' ORDER BY `id` ASC",
+ array($status), __FUNCTION__, __LINE__);
- while (list($action) = SQL_FETCHROW($result)) {
- $returnArray[] = $action;
+ // @TODO This can be somehow rewritten
+ while ($content = SQL_FETCHARRAY($result)) {
+ $returnArray[] = $content['action'];
}
}
// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
}
}
// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
} // END - if
// Determine depleted user account
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
// Get maximum randomness factor
} // END - if
// Determine depleted user account
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
// Get maximum randomness factor
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_SURF_LOCK()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.SURFBAR_GET_SURF_LOCK().'', false);
$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, sbu.fixed_reload
$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, sbu.fixed_reload
-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."
+WHERE sbu.userid NOT IN (".implode(',', $UIDs['userid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
);
} else {
// Get data from specified id number
$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, sbu.fixed_reload
);
} else {
// Get data from specified id number
$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, sbu.fixed_reload
- array($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".getConfig('db_last_query')."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS().'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - BEFORE", false);
- $SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result));
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - AFTER", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', false);
+ $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_salt - FIXED!", false);
- $SURFBAR_CACHE['last_salt'] = "";
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', false);
+ $GLOBALS['surfbar_cache']['last_salt'] = '';
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_surfed - FIXED!", false);
- $SURFBAR_CACHE['last_surfed'] = 0;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false);
+ $GLOBALS['surfbar_cache']['last_surfed'] = 0;
- $SURFBAR_CACHE['reward'] = SURFBAR_DETERMINE_REWARD();
- $SURFBAR_CACHE['costs'] = SURFBAR_DETERMINE_COSTS();
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
+ $GLOBALS['surfbar_cache']['reward'] = SURFBAR_DETERMINE_REWARD();
+ $GLOBALS['surfbar_cache']['costs'] = SURFBAR_DETERMINE_COSTS();
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
- $SURFBAR_CACHE['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
- $SURFBAR_CACHE['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
+ $GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
+ $GLOBALS['surfbar_cache']['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DYNAMIC+ - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "nextId={$nextId}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'nextId='.$nextId.'', false);
-// PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE ELSE THEY "WRAP" THE
-// $SURFBAR_CACHE ARRAY!
+// PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE IF THEY DON'T "WRAP"
+// THE $GLOBALS['surfbar_cache'] ARRAY!
- global $SURFBAR_CACHE;
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "element={$element}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "element={$element}", false);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
// Getter for reward from cache
function SURFBAR_GET_REWARD () {
// Get data element and return its contents
return SURFBAR_GET_DATA('reward');
}
// Getter for reward from cache
function SURFBAR_GET_REWARD () {
// Get data element and return its contents
return SURFBAR_GET_DATA('reward');
}
// Getter for costs from cache
function SURFBAR_GET_COSTS () {
// Get data element and return its contents
return SURFBAR_GET_DATA('costs');
}
// Getter for costs from cache
function SURFBAR_GET_COSTS () {
// Get data element and return its contents
return SURFBAR_GET_DATA('costs');
}
// Getter for URL from cache
function SURFBAR_GET_URL () {
// Get data element and return its contents
return SURFBAR_GET_DATA('url');
}
// Getter for URL from cache
function SURFBAR_GET_URL () {
// Get data element and return its contents
return SURFBAR_GET_DATA('url');
}
// Getter for salt from cache
function SURFBAR_GET_SALT () {
// Get data element and return its contents
return SURFBAR_GET_DATA('salt');
}
// Getter for salt from cache
function SURFBAR_GET_SALT () {
// Get data element and return its contents
return SURFBAR_GET_DATA('salt');
}
// Getter for id from cache
function SURFBAR_GET_ID () {
// Get data element and return its contents
return SURFBAR_GET_DATA('id');
}
// Getter for id from cache
function SURFBAR_GET_ID () {
// Get data element and return its contents
return SURFBAR_GET_DATA('id');
}
// Getter for userid from cache
function SURFBAR_GET_USERID () {
// Get data element and return its contents
return SURFBAR_GET_DATA('userid');
}
// Getter for userid from cache
function SURFBAR_GET_USERID () {
// Get data element and return its contents
return SURFBAR_GET_DATA('userid');
}
// Getter for user reload locks
function SURFBAR_GET_USER_LOCKS () {
// Get data element and return its contents
return SURFBAR_GET_DATA('user_locks');
}
// Getter for user reload locks
function SURFBAR_GET_USER_LOCKS () {
// Get data element and return its contents
return SURFBAR_GET_DATA('user_locks');
}
// Getter for reload time
function SURFBAR_GET_RELOAD_TIME () {
// Get data element and return its contents
return SURFBAR_GET_DATA('time');
}
// Getter for reload time
function SURFBAR_GET_RELOAD_TIME () {
// Get data element and return its contents
return SURFBAR_GET_DATA('time');
}
// Getter for allowed views
function SURFBAR_GET_VIEWS_ALLOWED () {
// Get data element and return its contents
return SURFBAR_GET_DATA('views_allowed');
}
// Getter for allowed views
function SURFBAR_GET_VIEWS_ALLOWED () {
// Get data element and return its contents
return SURFBAR_GET_DATA('views_allowed');
}
// Getter for fixed reload
function SURFBAR_GET_FIXED_RELOAD () {
// Get data element and return its contents
return SURFBAR_GET_DATA('fixed_reload');
}
// Getter for fixed reload
function SURFBAR_GET_FIXED_RELOAD () {
// Get data element and return its contents
return SURFBAR_GET_DATA('fixed_reload');
}
// Getter for surf lock
function SURFBAR_GET_SURF_LOCK () {
// Get data element and return its contents
return SURFBAR_GET_DATA('surf_lock');
}
// Getter for surf lock
function SURFBAR_GET_SURF_LOCK () {
// Get data element and return its contents
return SURFBAR_GET_DATA('surf_lock');
}