• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP validip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中validip函数的典型用法代码示例。如果您正苦于以下问题:PHP validip函数的具体用法?PHP validip怎么用?PHP validip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了validip函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getclientip

function getclientip()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
        return $_SERVER['HTTP_CLIENT_IP'];
    }
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        foreach (explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']) as $ip) {
            if (validip(trim($ip))) {
                return $ip;
            }
        }
    }
    if (!empty($_SERVER['HTTP_X_FORWARDED']) && validip($_SERVER['HTTP_X_FORWARDED'])) {
        return $_SERVER['HTTP_X_FORWARDED'];
    }
    if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && validip($_SERVER['HTTP_FORWARDED_FOR'])) {
        return $_SERVER['HTTP_FORWARDED_FOR'];
    }
    if (!empty($_SERVER['HTTP_FORWARDED']) && validip($_SERVER['HTTP_FORWARDED'])) {
        return $_SERVER['HTTP_FORWARDED'];
    }
    if (!empty($_SERVER['HTTP_X_FORWARDED']) && validip($_SERVER['HTTP_X_FORWARDED'])) {
        return $_SERVER['HTTP_X_FORWARDED'];
    }
    return $_SERVER['REMOTE_ADDR'];
}
开发者ID:carriercomm,项目名称:NeoBill,代码行数:26,代码来源:whois.ip.lib.php


示例2: getip

function getip()
{
    if (isset($_SERVER)) {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
    } else {
        if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
            $ip = getenv('HTTP_X_FORWARDED_FOR');
        } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
            $ip = getenv('HTTP_CLIENT_IP');
        } else {
            $ip = getenv('REMOTE_ADDR');
        }
    }
    return $ip;
}
开发者ID:googlesky,项目名称:QLPM,代码行数:21,代码来源:globalfunction.php


示例3: getip

function getip()
{
    if (validip($_SERVER["HTTP_CLIENT_IP"])) {
        return $_SERVER["HTTP_CLIENT_IP"];
    }
    foreach (explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
        if (validip(trim($ip))) {
            return $ip;
        }
    }
    if (validip($_SERVER["HTTP_X_FORWARDED"])) {
        return $_SERVER["HTTP_X_FORWARDED"];
    } elseif (validip($_SERVER["HTTP_FORWARDED_FOR"])) {
        return $_SERVER["HTTP_FORWARDED_FOR"];
    } elseif (validip($_SERVER["HTTP_FORWARDED"])) {
        return $_SERVER["HTTP_FORWARDED"];
    } elseif (validip($_SERVER["HTTP_X_FORWARDED"])) {
        return $_SERVER["HTTP_X_FORWARDED"];
    } else {
        return $_SERVER["REMOTE_ADDR"];
    }
}
开发者ID:Gerst20051,项目名称:Social-Link,代码行数:22,代码来源:validip.inc.php


示例4: getip

function getip()
{
    if (getenv('HTTP_CLIENT_IP') && long2ip(ip2long(getenv('HTTP_CLIENT_IP'))) == getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
        return getenv('HTTP_CLIENT_IP');
    }
    if (getenv('HTTP_X_FORWARDED_FOR') && long2ip(ip2long(getenv('HTTP_X_FORWARDED_FOR'))) == getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
        return getenv('HTTP_X_FORWARDED_FOR');
    }
    if (getenv('HTTP_X_FORWARDED') && long2ip(ip2long(getenv('HTTP_X_FORWARDED'))) == getenv('HTTP_X_FORWARDED') && validip(getenv('HTTP_X_FORWARDED'))) {
        return getenv('HTTP_X_FORWARDED');
    }
    if (getenv('HTTP_FORWARDED_FOR') && long2ip(ip2long(getenv('HTTP_FORWARDED_FOR'))) == getenv('HTTP_FORWARDED_FOR') && validip(getenv('HTTP_FORWARDED_FOR'))) {
        return getenv('HTTP_FORWARDED_FOR');
    }
    if (getenv('HTTP_FORWARDED') && long2ip(ip2long(getenv('HTTP_FORWARDED'))) == getenv('HTTP_FORWARDED') && validip(getenv('HTTP_FORWARDED'))) {
        return getenv('HTTP_FORWARDED');
    }
    return long2ip(ip2long($_SERVER['REMOTE_ADDR']));
}
开发者ID:ne0lite,项目名称:xbtit-tracker,代码行数:19,代码来源:common.php


示例5: getip

function getip()
{
    if (getenv('HTTP_CLIENT_IP') && long2ip(ip2long(getenv('HTTP_CLIENT_IP'))) == getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
        return getenv('HTTP_CLIENT_IP');
    }
    if (getenv('HTTP_X_FORWARDED_FOR') && long2ip(ip2long(getenv('HTTP_X_FORWARDED_FOR'))) == getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
        return getenv('HTTP_X_FORWARDED_FOR');
    }
    if (getenv('HTTP_X_FORWARDED') && long2ip(ip2long(getenv('HTTP_X_FORWARDED'))) == getenv('HTTP_X_FORWARDED') && validip(getenv('HTTP_X_FORWARDED'))) {
        return getenv('HTTP_X_FORWARDED');
    }
    if (getenv('HTTP_FORWARDED_FOR') && long2ip(ip2long(getenv('HTTP_FORWARDED_FOR'))) == getenv('HTTP_FORWARDED_FOR') && validip(getenv('HTTP_FORWARDED_FOR'))) {
        return getenv('HTTP_FORWARDED_FOR');
    }
    if (getenv('HTTP_FORWARDED') && long2ip(ip2long(getenv('HTTP_FORWARDED'))) == getenv('HTTP_FORWARDED') && validip(getenv('HTTP_FORWARDED'))) {
        return getenv('HTTP_FORWARDED');
    }
    $ip = htmlspecialchars($_SERVER['REMOTE_ADDR']);
    /* Added support for IPv6 connections. otherwise ip returns null */
    if (strpos($ip, '::') === 0) {
        $ip = substr($ip, strrpos($ip, ':') + 1);
    }
    return long2ip(ip2long($ip));
}
开发者ID:fchypzero,项目名称:cybyd,代码行数:24,代码来源:common.php


示例6: long2ip

         } else {
             $first = long2ip($row["first"]);
             $last = long2ip($row["last"]);
         }
         write_log("IP Ban ({$first} - {$last}) was removed by {$CURUSER['id']} ({$CURUSER['username']})");
     }
     show_error_msg(T_("SUCCESS"), "Ban(s) deleted.", 0);
 }
 if ($do == "add") {
     $first = trim($_POST["first"]);
     $last = trim($_POST["last"]);
     $comment = trim($_POST["comment"]);
     if ($first == "" || $last == "" || $comment == "") {
         show_error_msg(T_("ERROR"), T_("MISSING_FORM_DATA") . ". Go back and try again", 1);
     }
     if (!validip($first) || !validip($last)) {
         show_error_msg(T_("ERROR"), "Bad IP address.");
     }
     $comment = sqlesc($comment);
     $added = sqlesc(get_date_time());
     SQL_Query_exec("INSERT INTO bans (added, addedby, first, last, comment) VALUES({$added}, {$CURUSER['id']}, '{$first}', '{$last}', {$comment})");
     switch (mysql_errno()) {
         case 1062:
             show_error_msg(T_("ERROR"), "Duplicate ban.", 0);
             break;
         case 0:
             show_error_msg(T_("SUCCESS"), "Ban added.", 0);
             break;
         default:
             show_error_msg(T_("ERROR"), T_("THEME_DATEBASE_ERROR") . " " . htmlspecialchars(mysql_error()), 0);
     }
开发者ID:lavanoid,项目名称:TorrentTrader3,代码行数:31,代码来源:admincp.php


示例7: elseif

} elseif (isset($self)) {
    if ($event == "completed") {
        //sql_query("UPDATE snatched SET  finished  = 'yes', completedat = $dt WHERE torrentid = $torrentid AND userid = $userid");
        $finished = ", finishedat = " . TIMENOW;
        $finished_snatched = ", completedat = " . $dt . ", finished  = 'yes'";
        $updateset[] = "times_completed = times_completed + 1";
    }
    sql_query("UPDATE peers SET ip = " . sqlesc($ip) . ", port = {$port}, uploaded = {$uploaded}, downloaded = {$downloaded}, to_go = {$left}, prev_action = last_action, last_action = {$dt}, seeder = '{$seeder}', agent = " . sqlesc($agent) . " {$finished} WHERE {$selfwhere}") or err("PL Err 1");
    if (mysql_affected_rows()) {
        if ($seeder != $self["seeder"]) {
            $updateset[] = $seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1";
        }
        sql_query("UPDATE snatched SET uploaded = uploaded + {$trueupthis}, downloaded = downloaded + {$truedownthis}, to_go = {$left}, {$announcetime}, last_action = " . $dt . " {$finished_snatched} WHERE torrentid = {$torrentid} AND userid = {$userid}") or err("SL Err 2");
    }
} else {
    if (validip($ip)) {
        $sockres = @pfsockopen("[" . $ip . "]", $port, $errno, $errstr, 5);
        //可连接否解决
    } else {
        $sockres = @pfsockopen($ip, $port, $errno, $errstr, 5);
    }
    if ($errno == "111") {
        $connectable = "no";
    } else {
        $connectable = "yes";
    }
    @fclose($sockres);
    //	file_put_contents("out.txt",$ip.':'.$port.'--'.$errno.'--'.$errstr."\n",FILE_APPEND);
    //	$connectable = "yes";
    sql_query("INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ({$torrentid}, {$userid}, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", {$port}, '{$connectable}', {$uploaded}, {$downloaded}, {$left}, {$dt}, {$dt}, '{$seeder}', " . sqlesc($agent) . ", {$downloaded}, {$uploaded}, " . sqlesc($passkey) . ")") or err("PL Err 2");
    if (mysql_affected_rows()) {
开发者ID:chenrizhi,项目名称:mtpt,代码行数:31,代码来源:announce.php


示例8: getip

 protected static function getip()
 {
     $result = "0.0.0.0";
     if (isset($_SERVER)) {
         if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && validip($_SERVER["HTTP_X_FORWARDED_FOR"])) {
             $result = $_SERVER["HTTP_X_FORWARDED_FOR"];
         } elseif (isset($_SERVER["HTTP_CLIENT_IP"]) && validip($_SERVER["HTTP_CLIENT_IP"])) {
             $result = $_SERVER["HTTP_CLIENT_IP"];
         } else {
             $result = $_SERVER["REMOTE_ADDR"];
         }
     } else {
         if (getenv("HTTP_X_FORWARDED_FOR") && validip(getenv("HTTP_X_FORWARDED_FOR"))) {
             $result = getenv("HTTP_X_FORWARDED_FOR");
         } elseif (getenv("HTTP_CLIENT_IP") && validip(getenv("HTTP_CLIENT_IP"))) {
             $result = getenv("HTTP_CLIENT_IP");
         } else {
             $result = getenv("REMOTE_ADDR");
         }
     }
     return $result;
 }
开发者ID:rgllm,项目名称:Diary,代码行数:22,代码来源:functions.php


示例9: getip

function getip() {
	if (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP']))
		return $_SERVER['HTTP_CLIENT_IP'];
	elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
		$forwarded=str_replace(",","",$_SERVER['HTTP_X_FORWARDED_FOR']);
		$forwarded_array=split(" ",$forwarded);
		foreach($forwarded_array as $value)
			if (validip($value))
				return $value;
	}
	return $_SERVER['REMOTE_ADDR'];
}
开发者ID:herrag33k,项目名称:TomTorrent,代码行数:12,代码来源:bittorrent.php



注:本文中的validip函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP validusername函数代码示例发布时间:2022-05-23
下一篇:
PHP validemail函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap