{"id":765,"date":"2011-07-15T11:28:39","date_gmt":"2011-07-15T03:28:39","guid":{"rendered":"http:\/\/www.awaysoft.com\/taor\/?p=765"},"modified":"2013-12-23T11:10:58","modified_gmt":"2013-12-23T03:10:58","slug":"php%e9%aa%8c%e8%af%81%e7%a0%81%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/actom.me\/blog\/php%e9%aa%8c%e8%af%81%e7%a0%81%e4%bb%a3%e7%a0%81.html","title":{"rendered":"PHP\u9a8c\u8bc1\u7801\u4ee3\u7801"},"content":{"rendered":"<p>\u4e3aOJ\u5199\u7684\u4e00\u4e2a\u9a8c\u8bc1\u7801\u4ee3\u7801\u3002<\/p>\n<pre class=\"lang:php decode:true brush: [php] crayon-selected\">&lt;?php\r\n\/****************************************\r\n*  \u9a8c\u8bc1\u7801 v0.9\r\n*  Powerd by awaysoft.com\r\n*  \u672c\u7ec4\u4ef6\u91c7\u7528GPLv3\u53d1\u5e03\r\n*  2011-07-15\r\n****************************************\/\r\n\/* $len \u4e3a\u968f\u673a\u5b57\u7b26\u4e32\u957f\u5ea6\uff0c$type\u4e3a\u7c7b\u578b\uff0ca\u4e3a\u5b57\u7b26\u6570\u5b57\uff0cc\u4e3a\u5b57\u7b26,n\u4e3a\u6570\u5b57\uff0c \u5df2\u7ecf\u53bb\u9664\u53ef\u80fd\u8bef\u5bfc\u7684\u5b57\u7b26 *\/\r\nfunction get_rand_string($len=4, $type=\"n\"){\r\nif ($len &lt; 0) $len = 4;\r\nif ($type == 'a') $chars = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz023456789';\r\nelse if ($type == 'c') $chars = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz';\r\nelse if ($type == 'n') $chars = '0123456789';\r\nelse $chars = '0123456789';\r\n\r\n$result = '';\r\nfor ($i = 0; $i &lt; $len; $i ++){\r\n$index = mt_rand(0, strlen($chars) - 1);\r\n$result .= substr($chars, $index, 1);\r\n}\r\nreturn $result;\r\n}\r\n\r\nsession_start();\r\n\r\n\/* \u8f93\u51fa\u56fe\u7247\u7c7b\u578b\uff0c\u5b57\u7b26\u957f\u5ea6\uff0c\u7c7b\u578b *\/\r\n$imgtype = 'gif';\r\n$len = 4;\r\n$vcodetype = 'n';\r\n\r\n$width = 15 * $len;\r\n$height = 24;\r\n\/* \u751f\u6210\u968f\u673a\u5b57\u7b26\u4e32\u5e76\u5199\u5165SESSION *\/\r\n$vcode = get_rand_string($len, $vcodetype);\r\n$_SESSION['vcode'] = $vcode;\r\nheader(\"Content-type: image\/\".$imgtype);\r\n\r\nif($imgtype != 'gif' &amp;&amp; function_exists('imagecreatetruecolor')){\r\n$im = imagecreatetruecolor($width, $height);\r\n}else{\r\n$im = imagecreate($width, $height);\r\n}\r\n\r\n$r = mt_rand(0, 255);\r\n$g = mt_rand(0, 255);\r\n$b = mt_rand(0, 255);\r\n\/* \u751f\u6210\u80cc\u666f\u989c\u8272 *\/\r\n$backColor = ImageColorAllocate($im, $r, $g, $b);\r\n\/* \u751f\u6210\u8fb9\u6846\u989c\u8272 *\/\r\n$borderColor = ImageColorAllocate($im, 0, 0, 0);\r\n\/* \u751f\u6210\u5e72\u6270\u70b9\u989c\u8272 *\/\r\n$pointColor = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));\r\n\r\n\/* \u80cc\u666f\u4f4d\u7f6e *\/\r\nimagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);\r\n\/* \u8fb9\u6846\u4f4d\u7f6e *\/\r\nimagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);\r\n\r\n\/* \u5b57\u7b26\u4e32\u989c\u8272(\u80cc\u666f\u53cd\u8272) *\/\r\n$stringColor = ImageColorAllocate($im, 255 - $r, 255 - $g, 255 - $b);\r\n\r\n\/* \u4ea7\u751f\u5e72\u6270\u70b9 *\/\r\n$pointNumber = mt_rand($len * 25, $len * 50);\r\nfor($i=0; $i&lt;=$pointNumber; $i++){\r\n$pointX = mt_rand(2,$width-2);\r\n$pointY = mt_rand(2,$height-2);\r\nimagesetpixel($im, $pointX, $pointY, $pointColor);\r\n}\r\n\r\nimagettftext($im, 15, 0, 4, 20, $stringColor, \"Vera.ttf\", $vcode);\r\n$image_out = 'Image' . $imgtype;\r\n$image_out($im);\r\n@ImageDestroy($im);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3aOJ\u5199\u7684\u4e00\u4e2a\u9a8c\u8bc1\u7801\u4ee3\u7801\u3002 &lt;?php \/**************** &#8230; <a class=\"more-link\" href=\"https:\/\/actom.me\/blog\/php%e9%aa%8c%e8%af%81%e7%a0%81%e4%bb%a3%e7%a0%81.html\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/765"}],"collection":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/comments?post=765"}],"version-history":[{"count":7,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/765\/revisions"}],"predecessor-version":[{"id":919,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/posts\/765\/revisions\/919"}],"wp:attachment":[{"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/media?parent=765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/categories?post=765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actom.me\/blog\/wp-json\/wp\/v2\/tags?post=765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}