在做智能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 (5)
- 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)
最新文章
- 编译纯净版k2p padavan支持802.11 kvr固件
- 使用glibc编译的openwrt支持utf8中文显示和输入
- 360t7通过usb tll刷入不死uboot和openwrt系统
- N1盒子/arm64下cups使用兄弟打印机Brother HL-2260D的问题
- pve减少对ssd硬盘的写入量
- 使用PaddleOCR图片文字识别
- sftpgo为ftp/webdav添加支持软链接symlink目录和文件patch
- sftpgo为ftp/webdav/sftp添加匿名anonymous访问
- 使用avahi配置mdns/dns-sd网络发现samba/ftp
- OpenWrt/PandoraBox多网段转发udp广播包
最近回复
- 1: 方法一ngtcp2要改下:./configure PKG_CONFIG_PATH=/usr/l...
- 海运: 关闭服务器
- 海风: override.battery.charge.low以及override.battery.r...
- koldjf: 不能过滤
- 杰迪武士: 此文甚好甚强巨,依照此文在树莓派2 + Rasbian上部署成功 感谢博主美文共赏
- 海运: ups不知有没选项可设置此参数,不过你可以在另外一台电脑上安装nut客户端自动关机。
- kgami: 想请教一下,设置了的电脑自动关机之后,几秒后UPS怎么也跟着关机了,导致另外一台电脑没关机就断...
- 海运: 写的很详细了啊,/etc/nut/hosts.conf用以nut-cgi连接nut服务器参数,...
- ryan: 请问下nginx配置好了,怎么和这个nut链接呢?最后可视化管理这块能给个详细一点的教程么?谢谢。
- 1: /etc/config/fstab配置文件 https://openwrt.org/zh/do...