當前位置: 首頁>>代碼示例>>PHP>>正文


PHP validip函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。