<?php //通过GD2创建画布 $im = imagecreate(240, 24); //创建画布 $gray = imagecolorallocate($im, 200, 200, 200); //定义背景色 $color = imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255)); //定义字体颜色 $text = iconv("gb2312", "utf-8", "网站的访问次数"); //对制定文本进行转换 $font = "Fonts/FZHCJW.TTF"; imagettftext($im, 14,0,20,18,$color,$font,$text); //输出中文 imagestring($im, 5, 160, 5, $counter, $color); //输出网站的访问次数 imagepng($im); //以png格式将图片输出到浏览器 imagedestroy($im); //毁掉图像 //文件操作 if($_POST){ $filename = "../filterwords.txt"; if(is_writeable()){ $file = fopen($filename, 'r+'); }else{ echo "文件".$filename."不可写"; } fseek($file, 0, SEEK_END); $word = $_POST[txt_word]; fwrite($file, $word); fwrite($file, '\r\n';); fclose($file); }