// Do some pre-checks
if (!IS_ADMIN()) {
// Not an admin
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Not admin.", $url, $limit, $reload));
return false;
} elseif (!isUrlValid($url)) {
// URL invalid
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid URL.", $url, $limit, $reload));
return false;
} elseif (SURFBAR_LOOKUP_BY_URL($url, '0')) {
// URL already found in surfbar!
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Already added.", $url, $limit, $reload));
return false;
} elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
// No more allowed!
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : No more URLs allowed.", $url, $limit, $reload));
return false;
- } elseif (''.($limit + 0).'' != ''.$limit.'') {
- // Invalid amount entered
+ } elseif ('' . ($limit + 0) . '' != '' . $limit . '') {
+ // Invalid limit entered
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid limit entered.", $url, $limit, $reload));
return false;
- } elseif (''.($reload + 0).'' != ''.$reload.'') {
+ } elseif ('' . ($reload + 0) . '' != '' . $reload . '') {
// Invalid amount entered
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid reload entered.", $url, $limit, $reload));
return false;
}
if (!IS_MEMBER()) {
// Not a member
return false;
- } elseif (!isUrlValid($url)) {
+ } elseif ((!isUrlValid($url)) && (!IS_ADMIN())) {
// URL invalid
return false;
} elseif (SURFBAR_LOOKUP_BY_URL($url, getUserId())) {
}
// Load URL data by given search term and column
-function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add = '') {
+function SURFBAR_GET_URL_DATA ($searchTerm, $column='id', $order='id', $sort="ASC", $group='id', $add = '') {
// By default nothing is found
$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
+ // If the column is 'id' there can be only one entry
$limit = '';
- if ($column == "id") {
+ if ($column == 'id') {
$limit = "LIMIT 1";
} // END - if
// Then load all!
while ($dataRow = SQL_FETCHARRAY($result)) {
// Shall we group these results?
- if ($group == "id") {
+ if ($group == 'id') {
// Add the row by id as index
$GLOBALS['last_url_data'][$dataRow['id']] = $dataRow;
} else {
}
// Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
-function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $extraFields = array()) {
+function SURFBAR_REGISTER_URL ($url, $uid, $status = 'PENDING', $addMode = 'reg', $extraFields = array()) {
// Make sure by the user registered URLs are always pending
- if ($addMode == "reg") $status = "PENDING";
+ if ($addMode == 'reg') {
+ $status = 'PENDING';
+ } // END - if
// Prepare content
$content = merge_array($extraFields, array(
));
// Is limit/reload set?
- 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
// Insert the URL into database
$content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
$content['limit'] = surfbarTranslateLimit($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
$templateName = "surfbar_frameset";
// Any frame set? ;-)
- if (REQUEST_ISSET_GET(('frame'))) {
+ if (REQUEST_ISSET_GET('frame')) {
// Use the frame as a template name part... ;-)
$templateName = sprintf("surfbar_frame_%s",
- REQUEST_GET(('frame'))
+ REQUEST_GET('frame')
);
} // END - if
}
// ... and now the validation code
- $valCode = generateRandomCodde($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getUserId());
+ $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getUserId());
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
} // END - while