php中获取真实IP地址与IP地址验证函数

本文章就介绍二个函数一个是验证IP地址,另一个是获取用户的真实IP地址的函数,也是常用的两个IP操作函数.

获取用户真实IP地址,代码如下:

  1. function get_client_ip( )  
  2. {  
  3.         if ( getenv"REMOTE_ADDR" ) && strcasecmpgetenv"REMOTE_ADDR" ), "unknown" ) )  
  4.         {  
  5.                 $onlineip = getenv"REMOTE_ADDR" );  
  6.                 return $onlineip;  
  7.         }  
  8.         if ( isset( $_SERVER['REMOTE_ADDR'] ) && $_SERVER['REMOTE_ADDR'] && strcasecmp$_SERVER['REMOTE_ADDR'], "unknown" ) )  
  9.         {  
  10.                 $onlineip = $_SERVER['REMOTE_ADDR'];  
  11.                 return $onlineip;  
  12.         }  
  13.         if ( getenv"HTTP_CLIENT_IP" ) && strcasecmpgetenv"HTTP_CLIENT_IP" ), "unknown" ) )  
  14.         {  
  15.                 $onlineip = getenv"HTTP_CLIENT_IP" );  
  16.                 return $onlineip;  
  17.         }  
  18.         if ( getenv"HTTP_X_FORWARDED_FOR" ) && strcasecmpgetenv"HTTP_X_FORWARDED_FOR" ), "unknown" ) )  
  19.         {  
  20.                 $onlineip = getenv"HTTP_X_FORWARDED_FOR" );  
  21.         }  
  22.         return $onlineip;  

判断是否为IP地址,代码如下:

  1. function is_ip( $IP )  
  2. {  
  3.         $IP_ARRAY = explode"."$IP );  
  4.         $IP_ARRAY_NUM = sizeof( $IP_ARRAY );  
  5.         if ( $IP_ARRAY_NUM != 4 )  
  6.         {  
  7.                 return FALSE;  
  8.         }  
  9.         $I = 0;  
  10.         for ( ;    $I < $IP_ARRAY_NUM;    ++$I    )  
  11.         {  
  12.                 if ( !is_numeric$IP_ARRAY[$I] ) && $IP_ARRAY[$I] < 0 || 255 < $IP_ARRAY[$I] )  
  13.                 {  
  14.                         return FALSE;  
  15.                 }  
  16.                 if ( !( $I == 3 ) && !( $IP_ARRAY[$I] == 255 ) )  
  17.                 {  
  18.                         continue;  
  19.                 }  
  20.                 return FALSE;  
  21.         }  
  22.         return TRUE;  
  23. }
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php中获取真实IP地址与IP地址验证函数

81 评论

  1. tadalafil 10mg without prescription brand tadalafil 10mg voltaren over the counter

  2. order terazosin 5mg online terazosin brand order azulfidine 500mg generic

  3. metformin 1000mg for sale cost cialis 40mg order tadalafil pills

  4. order norvasc online cheap viagra 100mg uk cialis 5mg cheap

  5. purchase clomiphene sale clomiphene drug online card games

  6. sildenafil 100mg price cost sildalis buy lamictal 200mg for sale

  7. order lasix lasix 40mg brand purchase plaquenil without prescription

  8. buy proventil 100mcg pill cost cipro 1000mg ciprofloxacin online order

  9. order altace 10mg generic arcoxia 120mg us etoricoxib online order

  10. help write my paper azulfidine 500mg drug order sulfasalazine 500 mg without prescription

  11. purchase temovate cheap cordarone generic cordarone 100mg

  12. After all, what a great site and informative posts, I will upload inbound link – bookmark this web site? Regards, Reader. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  13. Thank you for great information. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  14. ropinirole 1mg cost requip online trandate 100mg ca

  15. I really love to read such an excellent article. Helpful article. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  16. minocycline 50mg for sale gabapentin pills hytrin 1mg over the counter

  17. Everything is very open and very clear explanation of issues. was truly information. Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin

  18. order provigil 200mg for sale provigil cheap promethazine order online

  19. prednisone 10mg drug buy amoxil buy amoxicillin 1000mg online cheap

  20. buy isotretinoin 10mg without prescription order azithromycin 250mg buy azithromycin 250mg without prescription

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡