Changeset 154 for trunk/globals/functions.php
- Timestamp:
- 03/09/2006 08:07:26 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/globals/functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals/functions.php
r151 r154 238 238 } 239 239 240 function correct_ip_min($ip, $ret_null=TRUE, $pad=3) { 241 if ($ip == '' && $ret_null === TRUE) return ''; 242 $t = explode(".", $ip, 4); 243 for ($i=0;$i<4;$i++) { 244 if(!isset($t[$i+1]) && $t[$i] != null) { 245 switch (substr($t[$i], 0, 1)) { 246 case '0': 247 break; 248 case '1': 249 case '2': 250 $t[$i] = intval(str_pad($t[$i], (substr($t[$i], 1, 1) >= 6?2:$pad), "0")); 251 break; 252 default: 253 $t[$i] = intval(str_pad($t[$i], ($pad==3?2:$pad), "0")); 254 } 255 }elseif($t[$i] == null) { 256 $t[$i] = 0; 257 }else{ 258 $t[$i] = (integer)($t[$i]); 259 } 260 } 261 return implode(".", $t); 262 } 263 264 function correct_ip_max($ip, $ret_null=TRUE, $pad=3) { 265 if ($ip == '' && $ret_null === TRUE) return ''; 266 $t = explode(".", $ip, 4); 267 for ($i=0;$i<4;$i++) { 268 if(!isset($t[$i+1]) && $t[$i] != null) { 269 switch (substr($t[$i], 0, 1)) { 270 case '0': 271 break; 272 case '1': 273 case '2': 274 $t[$i] = intval(str_pad($t[$i], (substr($t[$i], 1, 1) >= 6?2:$pad), "9")); 275 break; 276 default: 277 $t[$i] = intval(str_pad($t[$i], ($pad==3?2:$pad), "9")); 278 } 279 if ($t[$i] > 255) $t[$i] = 255; 280 }elseif($t[$i] == null) { 281 $t[$i] = 255; 282 }else{ 283 $t[$i] = (integer)($t[$i]); 284 } 285 } 286 return implode(".", $t); 287 } 288 240 289 function generate_account_code() { 241 290 for ($i=1;$i<=20;$i++) { … … 377 426 } 378 427 428 function replace_sql_wildcards($str) { 429 $str = str_replace("*", "%", $str); 430 $str = str_replace("?", "_", $str); 431 return $str; 432 } 433 379 434 ?>
Note: See TracChangeset
for help on using the changeset viewer.
