[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
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 $cidr = explode('/', $cidr); 49 $ip = $cidr[0]; 50 $mask = empty($cidr[1]) ? 32 : $cidr[1]; 51 $mask = pow(2,32) - pow(2, (32 - $mask)); 52 $output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); 53 } 54 return $output; 55 } 56 57 // Obtain all the HTTP headers. 58 // NB: on PHP-CGI we have to fake it out a bit, since we can't get the REAL 59 // headers. Run PHP as Apache 2.0 module if possible for best results. 60 function bb2_load_headers() { 61 if (!is_callable('getallheaders')) { 62 $headers = array(); 63 foreach ($_SERVER as $h => $v) 64 if (ereg('HTTP_(.+)', $h, $hp)) 65 $headers[str_replace("_", "-", uc_all($hp[1]))] = $v; 66 } else { 67 $headers = getallheaders(); 68 } 69 return $headers; 70 } 71 72 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |