PHP檢測IP是否內網地址、保留地址
/**
* @param string $ip 被檢測的IP
* @return bool 是否內網或者保留IP
*/
public function isInternalIp($ip)
{
$ip = ip2long($ip);
if (!$ip) {
//非法IP,直接算true吧
return true;
}
$net_a = ip2long('10.255.255.255') >> 24; //A類網預留ip的網路地
$net_b = ip2long('172.31.255.255') >> 20; //B類網預留ip的網路地址
$net_c = ip2long('192.168.255.255') >> 16; //C類網預留ip的網路地址
$net_local127 = ip2long('127.255.255.255') >> 24; //127保留地址
$net_local169 = ip2long('169.254.255.255') >> 16; //169保留地址
return $ip >> 24 === $net_a || $ip >> 20 === $net_b || $ip >> 16 === $net_c || $net_local127 === $ip >> 24 || $net_local169 === $ip >> 16;
}
這個是我網上找來的,具體地址我忘了,然后自己加了保留地址的檢測
PHP獲取HTTP包流量整個HTTP請求包流量
public function http()
{
$row = $_SERVER['REQUEST_URI'] . "\r\r";
$header = getallheaders();
foreach ($header as $k => $v) {
$row .= $k . ': ' . $v . "\r";
}
$row .= "\r\r" . file_get_contents("php://input");
return $row;
}
vue差量更新包-PHP處理
public function test()
{
$config = json_decode(file_get_contents('vueconfig.json'), true); //配置目錄,初次使用要先建立配置
$path = 'D:\\web\\project\\vue\\dist\\static\\'; // 打包的靜態地址
foreach ($config as $dir => $type) {
foreach (scandir($path . $dir) as $fkey => $fva) {
if ($fva == '.' || $fva == '..') {
continue;
} else {
if (in_array($fva, $type)) {
//沒有更新就洗掉該檔案
unlink($path . $dir . '\\' . $fva);
} else {
echo '新增檔案:' . $path . $dir . '\\' . $fva . "<br>";
//有更新就把新檔案加入到配置表里記錄
$config[$dir][$fkey] = $fva;
}
}
}
}
//更新配置表
file_put_contents('vueconfig.json', json_encode($config));
}
直接運行即可洗掉沒有改變的檔案,保留更新的檔案,實作差量更新
本文來自博客園,作者:小楓同學,未經作者許可,禁止轉載、復制、重新發布完整或者部分文字、代碼、圖片等資訊,否則將保留追究法律責任的權利,查閱文章的同學,由于網路爬蟲嚴重,有些代碼并不會完整貼出來或者存在bug,不過你可以發送郵件到[email protected]獲取新代碼,記得附上文章鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/499731.html
標籤:PHP
上一篇:java中==和equals區別
