本文整理汇总了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'];
}
示例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;
}
示例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"];
}
}
示例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']));
}
示例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));
}
示例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);
}
示例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()) {
示例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;
}
示例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'];
}