]> git.mxchange.org Git - ctracker.git/blobdiff - libs/lib_general.php
Continued:
[ctracker.git] / libs / lib_general.php
index 0b1a8fdac0ff9db489d66780b02850be517f34c7..55a0fde12b6ad8b95fcdba8d5da2d5ae2f656c73 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!function_exists('implode_r')) {
-       // Implode recursive a multi-dimension array, taken from www.php.net
-       function implode_r ($glue, $array, $array_name = NULL) {
-               $return = [];
-               while (list($key,$value) = @each($array)) {
-                       if (is_array($value)) {
-                               // Is an array again, so call recursive
-                               $return[] = implode_r($glue, $value, (string) $key);
+// Implode recursive a multi-dimension array, taken from www.php.net
+function implode_r ($glue, $array, $array_name = NULL) {
+       $return = [];
+       while (list($key,$value) = @each($array)) {
+               if (is_array($value)) {
+                       // Is an array again, so call recursive
+                       $return[] = implode_r($glue, $value, (string) $key);
+               } else {
+                       if ($array_name != NULL) {
+                               $return[] = $array_name . '[' . (string) $key . ']=' . $value . "\n";
                        } else {
-                               if ($array_name != NULL) {
-                                       $return[] = $array_name . '[' . (string) $key . ']=' . $value . "\n";
-                               } else {
-                                       $return[] = $key . '=' . $value."\n";
-                               }
+                               $return[] = $key . '=' . $value."\n";
                        }
-               } // END - while
-
-               // Return resulting array
-               return implode($glue, $return);
-       } // END - function
-} // END - if
-
-if (!function_exists('implode_secure')) {
-       // Implode a simple array with a 'call-back' to our escaper function
-       function implode_secure (array $array) {
-               // Return string
-               $return = '';
-
-               // Implode all data
-               foreach ($array as $entry) {
-                       // Don't escape some
-                       if (in_array($entry, array('NOW()'))) {
-                               // Add it with non-string glue
-                               $return .= $entry . ',';
-                       } elseif (empty($entry)) {
-                               // Empty strings need no escaping
-                               $return .= '"",';
-                       } else {
-                               // Secure this string and add it
-                               $return .= '"' . crackerTrackerEscapeString($entry) . '",';
-                       }
-               } // END - foreach
+               }
+       }
+
+       // Return resulting array
+       return implode($glue, $return);
+}
+
+// Implode a simple array with a 'call-back' to our escaper function
+function implode_secure (array $array) {
+       // Return string
+       $return = '';
+
+       // Implode all data
+       foreach ($array as $entry) {
+               // Don't escape some
+               if (in_array($entry, array('NOW()'))) {
+                       // Add it with non-string glue
+                       $return .= $entry . ',';
+               } elseif (empty($entry)) {
+                       // Empty strings need no escaping
+                       $return .= '"",';
+               } else {
+                       // Secure this string and add it
+                       $return .= '"' . crackerTrackerEscapeString($entry) . '",';
+               }
+       }
 
-               // Remove last char
-               $return = substr($return, 0, -1);
+       // Remove last char
+       $return = substr($return, 0, -1);
 
-               // Return this string
-               return $return;
-       } // END - function
-} // END - if
+       // Return this string
+       return $return;
+}
 
 // Load configuration, if found
 function crackerTrackerLoadConfiguration () {
@@ -82,7 +78,7 @@ function crackerTrackerLoadConfiguration () {
        if (!isCrackerTrackerFileFound($fqfn)) {
                // No config file found
                die(__FUNCTION__.': No configuration file found.');
-       } // END - if
+       }
 
        // Load it
        require $fqfn;
@@ -151,13 +147,13 @@ function crackerTrackerUserAgent ($sanitize = FALSE) {
        if (isset($_SERVER['HTTP_USER_AGENT'])) {
                // Then use it securely
                $ua = crackerTrackerSecureString(urldecode($_SERVER['HTTP_USER_AGENT']));
-       } // END - if
+       }
 
        // Sanitize it?
        if ($sanitize === TRUE) {
                // Sanitize ...
                $ua = crackerTrackerSanitize($ua);
-       } // END - if
+       }
 
        // Return it
        return $ua;
@@ -172,13 +168,13 @@ function crackerTrackerScriptName ($sanitize = FALSE) {
        if (!empty($_SERVER['SCRIPT_NAME'])) {
                // Return NULL
                $scriptName = crackerTrackerSecureString($_SERVER['SCRIPT_NAME']);
-       } // END - if
+       }
 
        // Sanitize it?
        if ($sanitize === TRUE) {
                // Sanitize ...
                $scriptName = crackerTrackerSanitize($scriptName);
-       } // END - if
+       }
 
        // Return
        return $scriptName;
@@ -202,7 +198,7 @@ function crackerTrackerQueryString ($sanitize = FALSE) {
        if ((!empty($query)) && ($sanitize === TRUE)) {
                // Sanitize ...
                $query = crackerTrackerSanitize($query);
-       } // END - if
+       }
 
        // Return it
        return $query;
@@ -217,13 +213,13 @@ function crackerTrackerServerName ($sanitize = FALSE) {
        if (!empty($_SERVER['SERVER_NAME'])) {
                // Return NULL
                $serverName = crackerTrackerSecureString($_SERVER['SERVER_NAME']);
-       } // END - if
+       }
 
        // Sanitize it?
        if ($sanitize === TRUE) {
                // Sanitize ...
                $serverName = crackerTrackerSanitize($serverName);
-       } // END - if
+       }
 
        // Return it
        return $serverName;
@@ -238,13 +234,13 @@ function crackerTrackerReferer ($sanitize = FALSE) {
        if (!empty($_SERVER['HTTP_REFERER'])) {
                // Then use it securely
                $referer = crackerTrackerSecureString(urldecode($_SERVER['HTTP_REFERER']));
-       } // END - if
+       }
 
        // Sanitize it?
        if ($sanitize === TRUE) {
                // Sanitize ...
                $referer = crackerTrackerSanitize($referer);
-       } // END - if
+       }
 
        // Return it
        return $referer;
@@ -259,7 +255,7 @@ function crackerTrackerRequestMethod () {
        if (!empty($_SERVER['REQUEST_METHOD'])) {
                // Then use it
                $method = $_SERVER['REQUEST_METHOD'];
-       } // END - if
+       }
 
        // Return it
        return $method;
@@ -359,9 +355,9 @@ function crackerTrackerLanguage () {
                                // Use this language/weight instead
                                $GLOBALS['ctracker_language'] = $langArray[0];
                                $weight   = $langArray[1];
-                       } // END - if
-               } // END - foreach
-       } // END - if
+                       }
+               }
+       }
 
        // Construct FQFN
        $FQFN = sprintf('%s/libs/language/%s.php',
@@ -376,7 +372,7 @@ function crackerTrackerLanguage () {
 
                // Construct FQFN again
                $FQFN = sprintf('%s/libs/language/en.php', $GLOBALS['ctracker_base_path']);
-       } // END - if
+       }
 
        // Load the language file
        require($FQFN);
@@ -420,7 +416,7 @@ function getCrackerTrackerLocalized ($message) {
        if (isset($GLOBALS['ctracker_localized'][$message])) {
                // Use this instead
                $output = $GLOBALS['ctracker_localized'][$message];
-       } // END - if
+       }
 
        // Return it
        return $output;
@@ -450,7 +446,7 @@ function crackerTrackerCompileCode ($code) {
                        // $content
                        $code = str_replace($match, "\" . \$content['" . $matches[4][$key] . "'] . \"", $code);
                }
-       } // END - foreach
+       }
 
        // Return it
        return $code;
@@ -465,7 +461,7 @@ function getCrackerTrackerLanguage ($lang = NULL) {
        if (!is_null($lang)) {
                // Then use this instead
                $language = $lang;
-       } // END - if
+       }
 
        // Return it
        return $language;
@@ -480,7 +476,7 @@ function getCrackerTrackerTicketId () {
        if (isset($GLOBALS['ctracker_last_ticket']['ctracker_ticket'])) {
                // Then use it
                $id = $GLOBALS['ctracker_last_ticket']['ctracker_ticket'];
-       } // END - if
+       }
 
        // Return the number
        return $id;
@@ -585,7 +581,7 @@ function unsetCtrackerData () {
                ) as $key) {
                        // Unset it
                        unset($GLOBALS[$key]);
-       } // END - foreach
+       }
 }
 
 // Sanitizes string