* *
* -------------------------------------------------------------------- *
* File : surfbar_functions.php *
* *
* -------------------------------------------------------------------- *
* File : surfbar_functions.php *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Surfbar *
* -------------------------------------------------------------------- *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Surfbar *
* -------------------------------------------------------------------- *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* 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) {
// Do some pre-checks
// Member has added an URL
function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
// Do some pre-checks
- return SURFBAR_REGISTER_URL($url, getUserId(), "PENDING", "reg", array('limit' => $limit));
+ return SURFBAR_REGISTER_URL($url, getMemberId(), '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(LOAD_TEMPLATE("member_surfbar_list_form", true),
- $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) {
// By default no action is performed
$performed = false;
// Is this a member?
// Do the member form request
function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
// By default no action is performed
$performed = false;
// Is this a member?
// No member!
return false;
} elseif ((!isset($formData['id'])) || (!isset($formData['action']))) {
// Important form elements are missing!
return false;
} elseif (!isset($URLs[$formData['id']])) {
// No member!
return false;
} elseif ((!isset($formData['id'])) || (!isset($formData['action']))) {
// Important form elements are missing!
return false;
} elseif (!isset($URLs[$formData['id']])) {
return false;
} elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $URLs[$formData['id']]['status'])) {
// Action not allowed for current URL status
return false;
} elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $URLs[$formData['id']]['status'])) {
// Action not allowed for current URL status
// 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}");
+ 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));
}
// Return status
return $performed;
}
addFatalMessage(__FUNCTION__, __LINE__, "Invalid member action! action=%s,id=%s,function=%s", array($formData['action'], $formData['id'], $functionName));
}
// Return status
return $performed;
}
// Validate if the requested action can be performed on current URL status
function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
// Search for the requested action/status combination in database
// Validate if the requested action can be performed on current URL status
function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
// Search for the requested action/status combination in database
- $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__);
+ $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?
} // END - if
// Construct function name
$functionName = sprintf("SURFBAR_MEMBER_EXECUTE_%s_ACTION", strtoupper($action));
} // END - if
// 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",
+ 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__);
// All fine
$status = true;
array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FUNCTION__, __LINE__);
// All fine
$status = true;
- $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 () {
// Get all userids
// Alert users which have URLs booked and are low on points amount
function SURFBAR_HANDLE_LOW_POINTS () {
// Get all userids
- '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($userids['points'][$userid]),
+ 'notified' => generateDateTime($userids['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), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET surfbar_low_notified=NOW() WHERE `userid`=%s LIMIT 1",
+ array($userid), __FUNCTION__, __LINE__);
- $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)));
-function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add="") {
- global $lastUrlData;
-
+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), __FUNCTION__, __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?
-function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $extraFields = array()) {
+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']
- ), __FUNCTION__, __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__
- if ((substr($subject, 0, 1) == "!") && (substr($subject, -1, 1) == "!")) {
+ 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
// Translate some data if present
// Set default subject if following eval() wents wrong
$subject = getMessage('ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
} // END - if
// Translate some data if present
- 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
- if ((substr($subject, 0, 1) == "!") && (substr($subject, -1, 1) == "!")) {
+ 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
// Translate some data if present
// Set default subject if following eval() wents wrong
$subject = getMessage('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
} // END - if
// Translate some data if present
- 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']);
- // Set default translated status
- $statusTranslated = "!".$constantName."!";
-
- // Is the constant there?
- if (defined($constantName)) {
- // Then get it's value
- $statusTranslated = constant($constantName);
- } // END - if
+ // Get message
+ $statusTranslated = getMessage($constantName);
// Determine reward
function SURFBAR_DETERMINE_REWARD ($onlyMin=false) {
// Static values are default
$reward = getConfig('surfbar_static_reward');
// Do we have static or dynamic?
// Determine reward
function SURFBAR_DETERMINE_REWARD ($onlyMin=false) {
// Static values are default
$reward = getConfig('surfbar_static_reward');
// Do we have static or dynamic?
// Determine costs
function SURFBAR_DETERMINE_COSTS ($onlyMin=false) {
// Static costs is default
$costs = getConfig('surfbar_static_costs');
// Do we have static or dynamic?
// Determine costs
function SURFBAR_DETERMINE_COSTS ($onlyMin=false) {
// 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() {
- $GLOBALS['cache_array']['surfbar']['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);
- $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
+ $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
+
+ // If we dont get any user ids back, there are no URLs
+ if (count($userids['userid']) == '0') {
+ // No user ids found, no URLs!
+ return 0;
+ } // END - if
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND `status`='%s'",
+ $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt
+FROM `{?_MYSQL_PREFIX?}_surfbar_urls`
+WHERE `userid` NOT IN (".implode(', ', $userids['userid']).") AND `status`='%s'",
- 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')), __FUNCTION__, __LINE__
- );
-
- // Fetch row
- list($cnt) = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
+ $cnt = countSumTotalData($userid, 'surfbar_urls', 'id', 'userid', true, $add);
- $GLOBALS['cache_array']['surfbar']['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);
- $GLOBALS['cache_array']['surfbar']['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 = generateRandomCodde($length, sha1(SURFBAR_GET_SALT().":".$urlId), getUserId());
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
+ $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getMemberId());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valCode='.valCode.'', false);
} // END - while
// Hash it with md5() and salt it with the random string
$hashedCode = generateHash(md5($valCode), SURFBAR_GET_SALT());
// Finally encrypt it PGP-like and return it
} // END - while
// Hash it with md5() and salt it with the random string
$hashedCode = generateHash(md5($valCode), SURFBAR_GET_SALT());
// Finally encrypt it PGP-like and return it
- //* 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(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`userid`, `url_id`) VALUES (%s, %s)",
+ array(getMemberId(), 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), getUserId()), __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), getMemberId()), __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 () {
// Remove it from the URL owner
// 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 () {
// Remove it from the URL owner
- //* 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=".getUserId().",reward=".SURFBAR_GET_REWARD()."", false);
- ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getUserId(), SURFBAR_GET_DATA('reward'));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
+ addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_DATA('reward'));
array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
// Update the stats entry
array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
// Update the stats entry
- 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("UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `count`=`count`+1 WHERE `userid`=%s AND `url_id`=%s LIMIT 1",
+ array(getMemberId(), SURFBAR_GET_ID()), __FUNCTION__, __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__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (userid,url_id,count) VALUES (%s,%s,1)",
+ array(getMemberId(), 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(), getUserId()), __FUNCTION__, __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(), getMemberId()), __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".getUserId()."", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt='.SURFBAR_GET_SALT().',id='.SURFBAR_GET_ID().',userid='.getMemberId().'', false);
- 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__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`url_id`, `userid`, `last_salt`) VALUES (%s, %s, '%s')",
+ array(SURFBAR_GET_ID(), getMemberId(), 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(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
+ array(getMemberId(), 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
// Determine which user hash no more points left
function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Init array
- $UIDs['uid'][getUserId()] = getUserId();
- $UIDs['points'][getUserId()] = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
- $UIDs['notified'][getUserId()] = 0;
+ $userids['userid'][getMemberId()] = getMemberId();
+ $userids['points'][getMemberId()] = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
+ $userids['notified'][getMemberId()] = '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(getUserId()), __FUNCTION__, __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(getMemberId()), __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", __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", __FUNCTION__, __LINE__);
- $points = GET_TOTAL_DATA($content['userid'], "user_points", "points") - GET_TOTAL_DATA($content['userid'], "user_data", "used_points");
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$content['userid']},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={$content['userid']} has depleted points amount!", false);
- $UIDs['uid'][$content['userid']] = $content['userid'];
- $UIDs['points'][$content['userid']] = $points;
- $UIDs['notified'][$content['userid']] = $content['notified'];
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']} has depleted points amount!", false);
+ $userids['userid'][$content['userid']] = $content['userid'];
+ $userids['points'][$content['userid']] = $points;
+ $userids['notified'][$content['userid']] = $content['notified'];
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().")", false);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($userids)." (with own userid=".getMemberId().')', false);
// Determine how many users are Online in surfbar
function SURFBAR_DETERMINE_TOTAL_ONLINE () {
// Count all users in surfbar modue and return the value
// Determine how many users are Online in surfbar
function SURFBAR_DETERMINE_TOTAL_ONLINE () {
// Count all users in surfbar modue and return the value
- $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')), __FUNCTION__, __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()) {
// Make new status always lower-case
$newStatus = strtolower($newStatus);
// Get URL data for status comparison if missing
// Changes the status of an URL from given to other
function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
// Make new status always lower-case
$newStatus = strtolower($newStatus);
// Get URL data for status comparison if missing
// array($newStatus, bigintval($urlId)), __FUNCTION__, __LINE__);
// ---------- Comment out for debugging/developing member actions! ---------
// Was that fine?
// array($newStatus, bigintval($urlId)), __FUNCTION__, __LINE__);
// ---------- Comment out for debugging/developing member actions! ---------
// Was that fine?
//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 () {
// Addon is zero by default
// Calculate minimum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
// Addon is zero by default
- $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 () {
// Addon is zero by default
// Calculate maximum value for dynamic payment model
function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
// Addon is zero by default
- $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+ $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
// Calculate dynamic lock
function SURFBAR_CALCULATE_DYNAMIC_LOCK () {
// Default lock is 30 seconds
// Calculate dynamic lock
function SURFBAR_CALCULATE_DYNAMIC_LOCK () {
// Default lock is 30 seconds
- id ASC", array(getUserId()),
- __FUNCTION__, __LINE__);
+ `id` ASC", array(getMemberId()),
+ __FUNCTION__, __LINE__);
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$content['id']},url={$content['url_id']},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={$content['id']},url={$content['url_id']},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={$content['id']},url={$content['url_id']},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={$content['id']},url={$content['url_id']},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."
+WHERE sbu.userid NOT IN (".implode(',', $userids).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
- //* 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), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT action FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `status`='%s' ORDER BY `id` ASC",
+ array($status), __FUNCTION__, __LINE__);
}
}
// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
}
}
// Determine next id for surfbar or get data for given id, always call this before you call other
// getters below this function!!!
// Get array with lock ids
$USE = SURFBAR_GET_LOCK_IDS();
// Shall we add some URL ids to ignore?
// Get array with lock ids
$USE = SURFBAR_GET_LOCK_IDS();
// Shall we add some URL ids to ignore?
- //* 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(',', $userids['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(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
+ array(getMemberId(), 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($GLOBALS['cache_array']['surfbar']).") - BEFORE", false);
- $GLOBALS['cache_array']['surfbar'] = merge_array($GLOBALS['cache_array']['surfbar'], SQL_FETCHARRAY($result));
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($GLOBALS['cache_array']['surfbar']).") - 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);
- $GLOBALS['cache_array']['surfbar']['last_salt'] = "";
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', false);
+ $GLOBALS['surfbar_cache']['last_salt'] = '';
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_surfed - FIXED!", false);
- $GLOBALS['cache_array']['surfbar']['last_surfed'] = 0;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false);
+ $GLOBALS['surfbar_cache']['last_surfed'] = '0';
- $GLOBALS['cache_array']['surfbar']['reward'] = SURFBAR_DETERMINE_REWARD();
- $GLOBALS['cache_array']['surfbar']['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);
- $GLOBALS['cache_array']['surfbar']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
- $GLOBALS['cache_array']['surfbar']['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 IF THEY DON'T "WRAP"
// -----------------------------------------------------------------------------
// PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE IF THEY DON'T "WRAP"
- //* 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');
}