[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php if (!defined('BB2_CORE')) die("I said no cheating!"); 2 3 // Miscellaneous helper functions. 4 5 // stripos() needed because stripos is only present on PHP 5 6 if (!function_exists('stripos')) { 7 function stripos($haystack,$needle,$offset = 0) { 8 return(strpos(strtolower($haystack),strtolower($needle),$offset)); 9 } 10 } 11 12 // str_split() needed because str_split is only present on PHP 5 13 if (!function_exists('str_split')) { 14 function str_split($string, $split_length=1) 15 { 16 if ($split_length < 1) { 17 return false; 18 } 19 20 for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length) { 21 $chunks[] = substr($string, $pos, $split_length); 22 } 23 return $chunks; 24 } 25 } 26 27 // Convert a string to mixed-case on word boundaries. 28 function uc_all($string) { 29 $temp = preg_split('/(\W)/', str_replace("_", "-", $string), -1, PREG_SPLIT_DELIM_CAPTURE); 30 foreach ($temp as $key=>$word) { 31 $temp[$key] = ucfirst(strtolower($word)); 32 } 33 return join ('', $temp); 34 } 35 36 // Determine if an IP address resides in a CIDR netblock or netblocks. 37 function match_cidr($addr, $cidr) { 38 $output = false; 39 40 if (is_array($cidr)) { 41 foreach ($cidr as $cidrlet) { 42 if (match_cidr($addr, $cidrlet)) { 43 $output = true; 44 } 45 } 46 } else { 47 list($ip, $mask) = explode('/', $cidr); 48 if (!$mask) $mask = 32; 49 $mask = pow(2,32) - pow(2, (32 - $mask)); 50 $output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); 51 } 52 return $output; 53 } 54 55 // Obtain all the HTTP headers. 56 // NB: on PHP-CGI we have to fake it out a bit, since we can't get the REAL 57 // headers. Run PHP as Apache 2.0 module if possible for best results. 58 function bb2_load_headers() { 59 if (!is_callable('getallheaders')) { 60 $headers = array(); 61 foreach ($_SERVER as $h => $v) 62 if (ereg('HTTP_(.+)', $h, $hp)) 63 $headers[str_replace("_", "-", uc_all($hp[1]))] = $v; 64 } else { 65 $headers = getallheaders(); 66 } 67 return $headers; 68 } 69 70 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |