在做智能DNS的时候全长VIEW根据请求的IP返回不同的IP,请求的IP是递归DNS的IP,edns-client-subnet附加客户端IP。
PHP JSON解码GBK
发布时间:November 19, 2014 // 分类:PHP // No Comments
在用PHP JSON处理符合标准的GBK编码内容时会返回null,将内容从GBK转换为UTF8再处理正常:
$jsonp = mb_convert_encoding($jsonp, "gbk", "utf-8");
//或
$jsonp = iconv('gbk','utf-8',$jsonp)
跨语言/平台调用
发布时间:November 17, 2014 // 分类: // No Comments
本机跨语言调用可使用IPC通信,跨平台/网络可使用以下:
轻量级:
http://www.phprpc.org/zh_CN/
https://github.com/hprose
重量级:
https://thrift.apache.org/
https://github.com/google/protobuf/
Windows命令行设置永久环境变量
发布时间:November 17, 2014 // 分类:Windows // No Comments
在cmd窗口中set设置的环境变量为临时变量,如:
set PATH=%PATH%;D:\Program Files\
使用setx设置为永久环境变量:
setx PATH "%PATH%;D:\Program Files\"
PHP Curl使用Cookie
发布时间:November 16, 2014 // 分类:PHP // No Comments
发送或保存Cookie:
$ch = curl_init();
$url = 'https://www.haiyun.me/';
$cookiefile = '/tmp/cookie.txt';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); //保存cookie到此文件
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); //发送请求时从此文件获取cookie
curl_setopt($ch, CURLOPT_COOKIE, 'user=user; pass=pass'); //单独设置请求cookie
$content = curl_exec($ch);
curl_close($ch);
解析服务器设置的cookie并保存为变量:
$ch = curl_init('https://www.haiyun.me/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//输出返回head
curl_setopt($ch, CURLOPT_HEADER, 1);
$res = curl_exec($ch);
//切分内容和head
list($header, $body) = explode("\r\n\r\n", $res);
preg_match('/^Set-Cookie:\s*([^;]*)/mi', $header, $match);
parse_str($match[1], $cookies);
print_r($cookies);
从curl保存的cookie文件中解析cookie,文件格式见:http://www.cookiecentral.com/faq/#3.5
domain - The domain that created AND that can read the variable.
flag - A TRUE/FALSE value indicating if all machines within a given domain can access the variable. This value is set automatically by the browser, depending on the value you set for domain.
path - The path within the domain that the variable is valid for.
secure - A TRUE/FALSE value indicating if a secure connection with the domain is needed to access the variable.
expiration - The UNIX time that the variable will expire on. UNIX time is defined as the number of seconds since Jan 1, 1970 00:00:00 GMT.
name - The name of the variable.
value - The value of the variable.
<?php
$lines = file('/tmp/404344922.cookie');
foreach($lines as $line) {
if($line[0] != '#' && substr_count($line, "\t") == 6) {
$tokens = explode("\t", $line);
$tokens = array_map('trim', $tokens);
$cookies[$tokens[5]] = $tokens[6];
}
}
print_r($cookies);
设置保存cookie至文件:
<?php
$file = fopen("/tmp/reg.cookie", "a");
$domain = '.haiyun.me';
$flag = 'TRUE';
$path = '/';
$secure = 'FALSE';
$expiration = 0;
$key = 'key';
$value = 'value';
$cookie = "$domain\t$flag\t$path\t$secure\t$expiration\t$key\t$value\n";
fwrite($file, $cookie);
fclose($file);
分类
- Apache (13)
- Nginx (45)
- PHP (86)
- IIS (8)
- Mail (17)
- DNS (16)
- Cacti (14)
- Squid (5)
- Nagios (4)
- Puppet (7)
- CentOS (13)
- Iptables (23)
- RADIUS (3)
- OpenWrt (41)
- DD-WRT (1)
- VMware (9)
- 网站程序 (2)
- 备份存储 (11)
- 常用软件 (20)
- 日记分析 (10)
- Linux基础 (18)
- 欧诺代理 (0)
- Linux服务 (18)
- 系统监控 (4)
- 流量监控 (7)
- 虚拟化 (28)
- 伪静态 (2)
- LVM (3)
- Shell (18)
- 高可用 (2)
- 数据库 (16)
- FreeBSD (3)
- 网络安全 (25)
- Windows (35)
- 网络工具 (22)
- 控制面板 (3)
- 系统调优 (10)
- Cisco (3)
- VPN (6)
- ROS (20)
- Vim (14)
- KMS (4)
- PXE (2)
- Mac (1)
- Git (1)
- PE (1)
- LNS (2)
- Xshell (7)
- Firefox (13)
- Cygwin (4)
- OpenSSL (9)
- Sandboxie (3)
- StrokesPlus (1)
- AutoHotKey (4)
- Total Commander (3)
- WordPress (3)
- iMacros (6)
- Typecho (2)
- Ollydbg (1)
- Photoshop (1)
- 正则 (3)
- Debian (3)
- Python (8)
- NoSQL (6)
- 消息队列 (4)
- JS (7)
- Tmux (3)
- GO (7)
- HHVM (2)
- 算法 (1)
- Docker (2)
- PT (15)
- N1 (16)
- K2P (6)
- LUKS (4)
最新文章
- 光猫拨号ImmortalWrt/OpenWRT路由获取ipv6遇到的问题
- php-fpm错误error_log日志配置
- debian-12/bookworm安装mariadb10.3和mysql5.6
- smokeping主从配置及遇到的问题
- openwrt/linux使用tcpdump/nflog ulogd记录iptables日志
- tmux bash shell自动保存history
- ImmortalWrt/OpenWRT为guest wifi网络配置ipv6 nat6
- PVE更新upgrade遇到The following packages have been kept back
- openwrt/immortalwrt修改odhcpd ipv6 preferred_lifetime和valid_lifetime
- golang版本udpxy iptv rtp多播转http单播
最近回复
- liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
- 海运: 不好意思,没有。
- zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
- 海运: 恩山有很多。
- swsend: 大佬可以分享一下固件吗,谢谢。
- Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
- 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
- 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
- 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
- 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...