* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Surfbar *
* -------------------------------------------------------------------- *
- * $Revision:: 856 $ *
- * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009) $ *
+ * $Revision:: $ *
+ * $Date:: $ *
* $Tag:: 0.2.1-FINAL $ *
- * $Author:: stelzi $ *
+ * $Author:: $ *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
require($INC);
}
// Is the lock reason empty?
if (empty($urlData['lock_reason'])) {
// Fix it to three dashes
- $urlData['lock_reason'] = "---";
+ $urlData['lock_reason'] = '---';
} // END - if
// Include fields only for action 'edit'
if ($action == "edit") {
// Default is not limited
- $urlData['limited_yes'] = "";
- $urlData['limited_no'] = " checked=\"checked\"";
+ $urlData['limited_yes'] = '';
+ $urlData['limited_no'] = ' chkecked="checked"';
$urlData['limited'] = "false";
// Is this URL limited?
if ($urlData['views_max'] > 0) {
// Then rewrite form data
- $urlData['limited_yes'] = " checked=\"checked\"";
- $urlData['limited_no'] = "";
+ $urlData['limited_yes'] = ' chkecked="checked"';
+ $urlData['limited_no'] = '';
$urlData['limited'] = "true";
} // END - if
} // END - if
$executed = false;
// Is limitation "no" and "limit" is > 0?
- if ((isset($urlData[$action]['limited'])) && ($urlData[$action]['limited'] == "N") && ((isset($urlData[$action]['limit'])) && ($urlData[$action]['limit'] > 0)) || (!isset($urlData[$action]['limit']))) {
+ if ((isset($urlData[$action]['limited'])) && ($urlData[$action]['limited'] == 'N') && ((isset($urlData[$action]['limit'])) && ($urlData[$action]['limit'] > 0)) || (!isset($urlData[$action]['limit']))) {
// Set it to unlimited
$urlData[$action]['limit'] = 0;
} // END - if
// 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;
-
// By default nothing is found
- $lastUrlData = array();
+ $GLOBALS['last_url_data'] = array();
// Is the column an id number?
- if (($column == "id") || ($column == "userid")) {
+ if (($column == "id") || ($column == 'userid')) {
// Extra secure input
$searchTerm = bigintval($searchTerm);
} // END - if
// If the column is "id" there can be only one entry
- $limit = "";
+ $limit = '';
if ($column == "id") {
$limit = "LIMIT 1";
} // END - if
// Shall we group these results?
if ($group == "id") {
// Add the row by id as index
- $lastUrlData[$dataRow['id']] = $dataRow;
+ $GLOBALS['last_url_data'][$dataRow['id']] = $dataRow;
} else {
// Group entries
- $lastUrlData[$dataRow[$group]][$dataRow['id']] = $dataRow;
+ $GLOBALS['last_url_data'][$dataRow[$group]][$dataRow['id']] = $dataRow;
}
} // END - while
} // END - if
SQL_FREERESULT($result);
// Return the result
- return $lastUrlData;
+ return $GLOBALS['last_url_data'];
}
// Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
$content['limit'] = SURFBAR_TRANSLATE_LIMIT($content['limit']);
// If in reg-mode we notify admin
- if (($addMode == "reg") || (getConfig('surfbar_notify_admin_unlock') == "Y")) {
+ if (($addMode == "reg") || (getConfig('surfbar_notify_admin_unlock') == 'Y')) {
// Notify admin even when he as unlocked an email
SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
} // END - if
// Check wether the user is allowed to book more URLs
function SURFBAR_IF_USER_BOOK_MORE_URLS ($uid=0) {
// Is this admin and userid is zero or does the user has some URLs left to book?
- return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < getConfig('surfbar_max_order')));
+ return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, '', array("REJECTED")) < getConfig('surfbar_max_order')));
}
// Get total amount of URLs of given status for current user
function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") {
}
// Default is all URLs
- $ADD = "";
+ $add = '';
// Is the status set?
if (is_array($status)) {
// Only URLs with these status
- $ADD = sprintf(" AND status IN('%s')", implode("','", $status));
+ $add = sprintf(" AND status IN('%s')", implode("','", $status));
} elseif (!empty($status)) {
// Only URLs with this status
- $ADD = sprintf(" AND `status`='%s'", $status);
+ $add = sprintf(" AND `status`='%s'", $status);
} elseif (is_array($exclude)) {
// Exclude URLs with these status
- $ADD = sprintf(" AND status NOT IN('%s')", implode("','", $exclude));
+ $add = sprintf(" AND status NOT IN('%s')", implode("','", $exclude));
} elseif (!empty($exclude)) {
// Exclude URLs with this status
- $ADD = sprintf(" AND status != '%s'", $exclude);
+ $add = sprintf(" AND status != '%s'", $exclude);
}
// Get amount from database
$result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid=%s".$ADD."
+WHERE userid=%s".$add."
LIMIT %s",
array($uid, getConfig('surfbar_max_order')), __FUNCTION__, __LINE__
);
if ($length == 0) $length = 10;
// Generate a code until the length matches
- $valCode = "";
+ $valCode = '';
while (strlen($valCode) != $length) {
// Is the salt set?
if (empty($salt)) {
$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__, '---'.$code."|".$check.'---', false);
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++", false);
return (($code == $check) && ($salt == SURFBAR_GET_DATA('last_salt')));
}
// Updates the statistics of current URL/userid
function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
// Init add
- $ADD = "";
+ $add = '';
// Get allowed views
$allowed = SURFBAR_GET_VIEWS_ALLOWED();
// Do we have a limit?
if ($allowed > 0) {
// Then count views_max down!
- $ADD .= ",views_max=views_max-1";
+ $add .= ",views_max=views_max-1";
} // END - if
// Update URL stats
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET views_total=views_total+1".$ADD." WHERE id=%s LIMIT 1",
+ 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__);
// Update the stats entry
// ---------- Comment out for debugging/developing member actions! ---------
// Was that fine?
+ // ---------- Comment out for debugging/developing member actions! ---------
//if (SQL_AFFECTEDROWS() != 1) {
// // No, something went wrong
// return false;
//} // END - if
+ // ---------- Comment out for debugging/developing member actions! ---------
// Prepare content for notification routines
$data[$urlId]['uid'] = $data[$urlId]['userid'];
$percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
// Get total users
- $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+ $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", 'userid', "status", true);
// Get online users
$onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
$percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
// Get total users
- $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+ $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", 'userid', "status", true);
// Calculate addon
$addon += abs($max * $percent * $totalUsers);
return $USE;
}
// "Getter" for maximum random number
-function SURFBAR_GET_MAX_RANDOM ($UIDs, $ADD) {
+function SURFBAR_GET_MAX_RANDOM ($UIDs, $add) {
// Count max availabe entries
$result = SQL_QUERY("SELECT sbu.id AS cnt
FROM `{!_MYSQL_PREFIX!}_surfbar_urls` AS sbu
ON sbu.id=sbs.url_id
LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
ON sbu.id=l.url_id
-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(",", $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__);
// Log last query
$USE = SURFBAR_GET_LOCK_IDS();
// Shall we add some URL ids to ignore?
- $ADD = "";
+ $add = '';
if (count($USE) > 0) {
// Ignore some!
- $ADD = " AND sbu.id NOT IN (";
+ $add = " AND sbu.id NOT IN (";
foreach ($USE as $url_id => $lid) {
// Add URL id
- $ADD .= $url_id.",";
+ $add .= $url_id.",";
} // END - foreach
// Add closing bracket
- $ADD = substr($ADD, 0, -1) . ")";
+ $add = substr($add, 0, -1) . ")";
} // END - if
// Determine depleted user account
$UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
// Get maximum randomness factor
- $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['uid'], $ADD);
+ $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['uid'], $add);
// If more than one URL can be called generate the random number!
if ($maxRand > 1) {
ON sbu.id=sbs.url_id
LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
ON sbu.id=l.url_id
-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['uid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
GROUP BY sbu.id
ORDER BY l.last_surfed ASC, sbu.id ASC
LIMIT %s,1",
if (is_null($GLOBALS['cache_array']['surfbar']['last_salt'])) {
// Then repair it wit the static!
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_salt - FIXED!", false);
- $GLOBALS['cache_array']['surfbar']['last_salt'] = "";
+ $GLOBALS['cache_array']['surfbar']['last_salt'] = '';
} // END - if
// Fix missing last_surfed