用于ajax跨域提交post或者get请求的代理程序
局限性:1.服务器必须配置有cURL 2.增加一次服务器的请求 代码如下: [crayon-5ad9df7b7… Read More »
局限性:1.服务器必须配置有cURL 2.增加一次服务器的请求 代码如下: [crayon-5ad9df7b7… Read More »
记录一下,省得每次都到处找。 几个关键地方都有注释,基本看得懂了 nginx.conf [crayon-5ad… Read More »
TCT支持的追加参数: mode: bnum: 桶数组元素个数,如果不大于0,使用默认值, 默认值是13107… Read More »
自带那个不太喜欢,于是另外折腾了个
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class vcode extends CI_Model { // private $charset = "abcdefghizklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; //随机因子 private $charset = "1234567890"; //随机因子 private $code; //验证码文字 private $codelen = 4; //验证码显示几个文字 private $width = 75; //验证码宽度 private $height = 25; //验证码高度 private $img; //验证码资源句柄 private $font; //指定的字体 private $fontsize = 16; //指定的字体大小 private $fontcolor; //字体颜色 随机 //构造类 编写字体 public function __construct() { parent::__construct(); $this->font = APPPATH . 'font/LiberationSans-Bold.ttf'; } //创建4个随机码 private function createCode() { $_leng = strlen($this->charset) - 1; for ($i = 0; $i < $this->codelen; $i++) { $this->code.=$this->charset[mt_rand(0, $_leng)]; } return $this->code; } //创建背景 private function createBg() { //创建画布 给一个资源jubing $this->img = imagecreatetruecolor($this->width, $this->height); //背景颜色 $color = imagecolorallocate($this->img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); //画出一个矩形 imagefilledrectangle($this->img, 0, $this->height, $this->width, 0, $color); } //创建字体 private function createFont() { $_x = ($this->width / $this->codelen); //字体长度 for ($i = 0; $i < $this->codelen; $i++) { //文字颜色 $color = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156)); //资源句柄 字体大小 倾斜度 字体长度 字体高度 字体颜色 字体 具体文本 imagettftext($this->img, $this->fontsize, mt_rand(-18, 18), $_x * $i + mt_rand(1, 5), $this->height/1.2, $color, $this->font, $this->code[$i]); } } //随机线条 private function createLine() { //随机线条 for ($i = 0; $i < 6; $i++) { $color = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156)); imageline($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color); } // //随机雪花 // for ($i = 0; $i < 45; $i++) { // $color = imagecolorallocate($this->img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255)); // imagestring($this->img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '.', $color); // } } //输出背景 private function outPut() { //生成标头 header("Expires: -1"); header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); header("Pragma: no-cache"); header('Content-Type:image/png'); //输出图片 imagepng($this->img); //销毁结果集 imagedestroy($this->img); } //对外输出 public function doimg() { //加载背景 $this->createBg(); //加载文件 $this->createCode(); //加载线条 $this->createLine(); //加载字体 $this->createFont(); //加载背景 $this->outPut(); } //获取验证码 public function getCode() { return strtolower($this->code); } } |
使用方法… Read More »
前段时间对短域名做了点小研究,其实大体上无非是用更大的进制来对10进制数值进行缩短,并存入一个kvdb中,到时… Read More »
速度还算不错,挺好用的,处理个10来M的文本没啥问题。根据各自需要改吧 [crayon-5ad9df7b77d… Read More »
呵呵,很久没写blog了,把最近总结的一些东西打算都写一下。 前段时间做一个项目,需要上传文件,差不多需要20… Read More »
有一台服务器老是交换扇区占满然后失去响应,很烦,因为加载了以前别人写的一个php扩展,效率低,资源占用大,悲剧… Read More »
smarty中文截取,其实网上那些并不是太好。。翻了翻手册,发现个现成的代码,挺好用 [crayon-5ad9… Read More »
Bing.com每天都会有新的壁纸放出来,质量都很好,就是可惜小了点。我的Milestone需要960*845… Read More »