CI_Knight

且行善举,莫问前程。

0%

打开了访客评论,又出现了很多垃圾评论,上次还有个臭名昭著的ip访问站点。

使用 nginx 的 ngx_http_access_module 模块可以封配置内的ip或者ip段。

建立配置文件 blockips.conf ,添加一下内容

1
2
3
4
allow 10.42.0.25;
allow 10.0.43.0/25;
deny 10.0.42.0/25;
# allow all; or deny all;

并且在主配置文件中引入该文件。重启nginx,再次访问403错误。

因为下载了一份JAVA程序源码,在Ubuntu上全是乱码,我想也是用了GBK编码,所以打算用Python处理下。代码写的乱

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# coding = utf-8
import os

def convert(root, target_filePath, from_encode='gbk', to_encode='utf-8'):
if os.path.exists(root) and os.path.exists(target_filePath):
if os.path.isabs(root):
list_dir = os.listdir(root)
for l in list_dir:
if os.path.isdir(os.path.join(root, l)):
if not os.path.exists(os.path.join(target_filePath, l)):
os.mkdir(os.path.join(target_filePath, l))
convert(os.path.join(root, l), os.path.join(target_filePath, l), from_encode, to_encode)
else:
with open(os.path.join(target_filePath, l), 'w') as f:
for i in open(os.path.join(root, l), 'r'):
f.write(i.decode(from_encode).encode(to_encode))
else:
file_pteh = os.path.join(os.getcwd(), root)
convert(file_pteh, target_filePath, from_encode, to_encode)
else:
print 'fuck!'

root = '/home/haining/bbs'
tar = '/home/haining/tmp'
convert(root, tar)

可以实现将一个目录下的所有文件,转换成指定编码,并且保证目录结构.

GET_ICON(获取网站favicon.ico图标)

在cblog中添加了获取网站icon的功能,并且开放出来接口,bug略多,正在优化当中。并且这个接口今后有其他的打算。

接口使用方法

Ver = 2.0 / 2015-05-01

碰上服务器的那种 Bug 我也是没有办法,接口就是接口,规定下使用方法。

1
2
3
4
接口地址:http://www.whnzy.com/tools/get_icon/
添加参数:
http://www.whnzy.com/tools/get_icon/www.cnblogs.com/
http://www.whnzy.com/tools/get_icon/www.baidu.com/?schema=https://

修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1,聚合接口代码。
2,去掉schema,使用get参数传递scheme,默认为 http
3,修改正则获取方式。 #百度因为首页有个奇葩的 .ico 的css 类,目前有bug。
> 影响范围www.baidu.com
> baidu.com无影响
V = 2.1
1,除火狐浏览器外都会下载文件。
2,修复403错误

4,下一版本修改:
> 添加cdn库,无需每次都去请求(服务器,或者OSS缓存)。正则。添加icon错误反馈。
> 修复有些网站403错误,防止爬虫请求。
> 修复跳转连接无法获取icon
> 因为大多网站图像大小规格不正规,加入图像处理。
> 除火狐浏览器外都会下载文件。
> = - = 有人依然会添加schema
> 无icon,使用默认图标

如果站点想要调用接口,请联系[email protected]

Ver = 1.0 / 2015-04-28

1
2
3
4
接口地址:http://www.whnzy.com/tools/get_icon/
添加参数:
http://www.whnzy.com/tools/get_icon/http://www.cnblogs.com/
http://www.whnzy.com/tools/get_icon/www.cnblogs.com/

出错几率比较高。有些网站页面无添加favicon,浏览器会默认去访问 根目录下的该文件,百度,网易云音乐都是如此,功能正在开发中。

该功能可用于友情链接的icon使用. 项目地址

如果你有一台国外的服务器,你就可以直接通过它来翻墙了.小心为好,还是会被GFW ban掉.

连接前可以先做以下简单配置

在家目录的.ssh中创建config,然后做以下配置

1
2
3
4
Host remote-host
HostName 10.0.0.2 #你的ip
User root
Port 22

生成你的公钥私钥对

1
ssh-keygen

上传你的公钥,需要输入登录密码

1
ssh-copy-id -i ~/.ssh/id_rsa.pub root@remote-host

建立连接

1
ssh -D 7878 -f -C -q -N remote-host

之后你就可以通过浏览器代理使用socks5进行连接了.