* 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 () {
if (!isCrackerTrackerFileFound($fqfn)) {
// No config file found
die(__FUNCTION__.': No configuration file found.');
- } // END - if
+ }
// Load it
require $fqfn;
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;
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;
if ((!empty($query)) && ($sanitize === TRUE)) {
// Sanitize ...
$query = crackerTrackerSanitize($query);
- } // END - if
+ }
// Return it
return $query;
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;
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;
if (!empty($_SERVER['REQUEST_METHOD'])) {
// Then use it
$method = $_SERVER['REQUEST_METHOD'];
- } // END - if
+ }
// Return it
return $method;
// 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',
// Construct FQFN again
$FQFN = sprintf('%s/libs/language/en.php', $GLOBALS['ctracker_base_path']);
- } // END - if
+ }
// Load the language file
require($FQFN);
if (isset($GLOBALS['ctracker_localized'][$message])) {
// Use this instead
$output = $GLOBALS['ctracker_localized'][$message];
- } // END - if
+ }
// Return it
return $output;
// $content
$code = str_replace($match, "\" . \$content['" . $matches[4][$key] . "'] . \"", $code);
}
- } // END - foreach
+ }
// Return it
return $code;
if (!is_null($lang)) {
// Then use this instead
$language = $lang;
- } // END - if
+ }
// Return it
return $language;
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;
) as $key) {
// Unset it
unset($GLOBALS[$key]);
- } // END - foreach
+ }
}
// Sanitizes string