]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
'what','action','module' and 'output_mode' wrapped into functions (WARNUNG: Code...
[mailer.git] / inc / libs / surfbar_functions.php
index d9585d024b8677874ec192ce614615a5a09dcf67..bbf56465680a37f68c9e57b727d58a3b0472e1a2 100644 (file)
@@ -51,21 +51,27 @@ function SURFBAR_ADMIN_ADD_URL ($url, $limit, $reload) {
        // 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;
        }
 
@@ -159,7 +165,7 @@ function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
        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())) {
@@ -534,19 +540,19 @@ function SURFBAR_LOOKUP_BY_URL ($url, $uid) {
 }
 
 // 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
 
@@ -563,7 +569,7 @@ ORDER BY %s %s
                // 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 {
@@ -581,9 +587,11 @@ ORDER BY %s %s
 }
 
 // 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(
@@ -594,8 +602,12 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        ));
 
        // 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);
@@ -610,7 +622,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        $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
@@ -797,10 +809,10 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
        $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
 
@@ -963,7 +975,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
                }
 
                // ... 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