* @version 3.0.0 * @copyright Copyright (c) 2009 Cracker Tracker Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ 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 = array(); 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 { $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) { // 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 // Remove last char $return = substr($return, 0, -1); // Return this string return $return; } // END - function } // END - if // Getter for ctracker_debug function isCrackerTrackerDebug () { // Is it set? return ((isset($GLOBALS['ctracker_debug'])) && ($GLOBALS['ctracker_debug'] === true)); } // Determines the real remote address function determineRealRemoteAddress () { // Is a proxy in use? if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Proxy was used $address = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Yet, another proxy $address = $_SERVER['HTTP_CLIENT_IP']; } else { // The regular address when no proxy was used $address = $_SERVER['REMOTE_ADDR']; } // This strips out the real address from proxy output if (strstr($address, ',')) { $addressArray = explode(',', $address); $address = $addressArray[0]; } // END - if // Return the result return $address; } // Determine if a proxy was used function isProxyUsed () { // Check if specific entries are set $proxyUsed = ((isset($_SERVER['HTTP_X_FORWARDED_FOR'])) || (isset($_SERVER['HTTP_CLIENT_IP']))); // Return result return $proxyUsed; } // [EOF] ?>