*/
// Implode recursive a multi-dimension array, taken from www.php.net
-function implode_r (string $glue, array $array, string $array_name = NULL) {
+function implode_r (string $glue, array $array, string $array_name = NULL): string {
$return = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
}
// Implode a simple array with a 'call-back' to our escaper function
-function implode_secure (array $array) {
+function implode_secure (array $array): string {
// Return string
$return = '';
}
// Load configuration, if found
-function crackerTrackerLoadConfiguration () {
+function crackerTrackerLoadConfiguration (): void {
// FQFN
$fqfn = sprintf('%s/config/db_config.php', $GLOBALS['ctracker_base_path']);
}
// Getter for ctracker_debug_enabled
-function isCrackerTrackerDebug () {
+function isCrackerTrackerDebug (): bool {
// Is it set?
$result = ((isset($GLOBALS['ctracker_debug_enabled'])) && ($GLOBALS['ctracker_debug_enabled'] === true));
}
// Determines the real remote address
-function determineCrackerTrackerRealRemoteAddress () {
+function determineCrackerTrackerRealRemoteAddress (): string {
// Initial value
$address = '0.0.0.0';
}
// Determine if a proxy was used
-function isCrackerTrackerProxyUsed () {
+function isCrackerTrackerProxyUsed (): bool {
// Check if specific entries are set
$proxyUsed = ((isset($_SERVER['HTTP_X_FORWARDED_FOR'])) || (isset($_SERVER['HTTP_CLIENT_IP'])));
}
// Detects the user-agent string
-function crackerTrackerUserAgent (bool $sanitize = false) {
+function crackerTrackerUserAgent (bool $sanitize = false): string {
// Default is 'unknown'
$ua = 'unknown';
}
// Detects the script name
-function crackerTrackerScriptName (bool $sanitize = false) {
+function crackerTrackerScriptName (bool $sanitize = false): string {
// Default is NULL
$scriptName = NULL;
}
// Detects the query string
-function crackerTrackerQueryString (bool $sanitize = false) {
+function crackerTrackerQueryString (bool $sanitize = false): string {
// Default is NULL
$query = NULL;
}
// Detects the server's name
-function crackerTrackerServerName (bool $sanitize = false) {
+function crackerTrackerServerName (bool $sanitize = false): string {
// Default is NULL
$serverName = NULL;
}
// Detects the referer
-function crackerTrackerReferer (bool $sanitize = false) {
+function crackerTrackerReferer (bool $sanitize = false): string {
// Default is a dash
$referer = '-';
}
// Detects request method
-function crackerTrackerRequestMethod () {
+function crackerTrackerRequestMethod (): string {
// Default is NULL
$method = NULL;
}
// Detects the scripts path
-function crackerTrackerScriptPath () {
+function crackerTrackerScriptPath (): string {
// Should always be there!
$path = dirname(crackerTrackerScriptName()) . '/';
}
// Detects wether we have SSL
-function crackerTrackerSecured () {
+function crackerTrackerSecured (): bool {
// Detect it
$ssl = ((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off'));
}
// Secures a string by escaping it and passing it through strip_tags,htmlentities-chain
-function crackerTrackerSecureString (string $str) {
+function crackerTrackerSecureString (string $str): string {
// First escape it
$str = crackerTrackerEscapeString($str);
}
// Is the file there and readable?
-function isCrackerTrackerFileFound (string $FQFN) {
+function isCrackerTrackerFileFound (string $FQFN): bool {
// Simply check it
return ((file_exists($FQFN)) && (is_readable($FQFN)));
}
// Loads a given "template" (this is more an include file)
-function crackerTrackerLoadTemplate (string $template) {
+function crackerTrackerLoadTemplate (string $template): void {
// Create the full-qualified filename (FQFN)
$FQFN = sprintf('%s/libs/templates/%s.tpl.php',
$GLOBALS['ctracker_base_path'],
crackerTrackerLanguage();
// Load it
- require_once($FQFN);
+ require_once $FQFN;
} else {
// Not found, so die here
crackerTrackerDie();
}
// Loads a given "template" (this is more an include file)
-function crackerTrackerLoadLocalizedTemplate (string $template) {
+function crackerTrackerLoadLocalizedTemplate (string $template): void {
// Create the full-qualified filename (FQFN)
$FQFN = sprintf('%s/libs/templates/%s/%s.tpl.php',
$GLOBALS['ctracker_base_path'],
// Is this template found?
if (isCrackerTrackerFileFound($FQFN)) {
// Load it
- require_once($FQFN);
+ require_once $FQFN;
} else {
// Not found, so die here
crackerTrackerDie();
}
// Detects the browser's language file and tries to load it, fall-back on english!
-function crackerTrackerLanguage () {
+function crackerTrackerLanguage (): void {
// Default is English
$GLOBALS['ctracker_language'] = 'en';
$weight = 1;
}
// Load the language file
- require($FQFN);
+ require $FQFN;
}
// Loads a given email template and passes through $content
-function crackerTrackerLoadEmailTemplate (string $template, array $content = [], string $language = NULL) {
+function crackerTrackerLoadEmailTemplate (string $template, array $content = [], string $language = NULL): string {
// Init language
crackerTrackerLanguage();
}
// Getter for message
-function getCrackerTrackerLocalized (string $message) {
+function getCrackerTrackerLocalized (string $message): string {
// Default message
$output = '!' . $message . '!';
}
// Tries to find a message and outputs it
-function crackerTrackerOutputLocalized (string $message) {
+function crackerTrackerOutputLocalized (string $message): void {
// Output it
print getCrackerTrackerLocalized($message);
}
// Compiles the given code
-function crackerTrackerCompileCode (string $code) {
+function crackerTrackerCompileCode (string $code): string {
// Find all $content[foo]
preg_match_all('/\$(content|GLOBALS)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
}
// "Getter" for language
-function getCrackerTrackerLanguage (string $lang = NULL) {
+function getCrackerTrackerLanguage (string $lang = NULL): string {
// Default is from browser
$language = $GLOBALS['ctracker_language'];
}
// "Getter" for ticket id
-function getCrackerTrackerTicketId () {
+function getCrackerTrackerTicketId (): int {
// Default is zero
$id = 0;
}
// Sends a cookie to the user that he would not see this security warning again
-function sendCrackerTrackerCookie () {
+function sendCrackerTrackerCookie (): void {
// Set the cookie
// @TODO Why can't domain be set to value from crackerTrackerServerName() ?
setcookie('ctracker_ticket', getCrackerTrackerTicketId(), (time() + 60*60*24), '/', '', crackerTrackerSecured(), true);
}
// Is the cookie set?
-function ifCrackerTrackerCookieIsSet () {
+function ifCrackerTrackerCookieIsSet (): bool {
// Is it set and valid?
return ((isset($_COOKIE['ctracker_ticket'])) && ($_COOKIE['ctracker_ticket'] > 0));
}
// Redirects to the same URL
-function crackerTrackerRedirectSameUrl () {
+function crackerTrackerRedirectSameUrl (): void {
// Construct and redirect to same URL
crackerTrackerSendRawRedirect(sprintf('%s://%s%s?%s',
(crackerTrackerSecured() ? 'https' : 'http'),