標題 內文 作者 日期 狀態 IP 動作 620q3x6qx6 wmd3koxi 0opbn93z9 11/08/2006 23:57 正常迴響 218.177.126.64 w59tq n8jidwafpot8qbt94lufr884 0ur2h1zs 11/08/2006 23:33 正常迴響 85.155.132.20 3puggcfi d7vsbwm88ddo1vwsyhhzh0955 im02lu6di 11/08/2006 23:32 正常迴響 85.155.132.20 kjgfgj fdlskjfkldsfdjsf hgsdghjg 11/08/2006 23:28 正常迴響 195.234.200.33
<?php include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" ); include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" ); include_once( PLOG_CLASS_PATH."class/net/rawrequestgenerator.class.php" ); include_once( PLOG_CLASS_PATH."class/misc/glob.class.php" ); include_once( PLOG_CLASS_PATH."plugins/authimage/class/security/authimagefilter.class.php" ); //define( "AUTHIMAGE_FILE", "/plugins/authimage/authimage.php" ); //去掉背景图加载文件 //define( "AUTHIMAGE_BACKGROUND_FOLDER", PLOG_CLASS_PATH."plugins/authimage/backgrounds/" );//去掉背景图加载 /** * Plugin that offers comment authentication image for current blog * Original Author: Gudlyf http://www.gudlyf.com/index.php?p=376 * Modified by: Mark Wu */ class PluginAuthImage extends PluginBase { var $pluginEnabled; var $default; var $cacheFolder; function PluginAuthImage() { $this->PluginBase(); $this->id = "authimage"; $this->author = "Mark Wu"; $this->desc = 'This plugin offers extra comment authentication for LifeType. The idea is inspired by <a href="http://www.gudlyf.com/index.php?p=376">WordPress AuthImage Plugin</a> written by Gudlyf.'; $this->version = '1.0.1'; $this->locales = Array( "en_UK" , "zh_TW" , "zh_CN", "es_ES", "de_DE" ); $this->init(); } function init() { include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" ); // register the filter $this->registerFilter( "AuthImageFilter" ); $this->registerAdminAction( "authimage", "PluginAuthImageConfigAction" ); $this->registerAdminAction( "updateAuthImageConfig", "PluginAuthImageUpdateConfigAction" ); $this->registerBlogAction( "AuthImageShow", "PluginAuthImageShowAction" ); $menu =& Menu::getMenu(); if( !$menu->entryExists( "/menu/controlCenter/manageAntiSpamPlugins" )) $this->addMenuEntry( "/menu/controlCenter", "manageAntiSpamPlugins", "", "", true, false ); $this->addMenuEntry( "/menu/controlCenter/manageAntiSpamPlugins", "AuthImage", "?op=authimage", "" ); } function register() { $config =& Config::getConfig(); $this->cacheFolder = $config->getValue('temp_folder'); $this->cacheFolder = $this->cacheFolder.'/authimage/'.$this->blogInfo->getId(); if( !File::exists( $this->cacheFolder )) { File::createDir( $this->cacheFolder ); } $blogSettings = $this->blogInfo->getSettings(); $this->pluginEnabled = $blogSettings->getValue( "plugin_authimage_enabled" ); $this->length = $blogSettings->getValue( "plugin_authimage_length" ); $this->key = $blogSettings->getValue( "plugin_authimage_key" ); $this->expiredTime = $blogSettings->getValue( "plugin_authimage_expiredtime" ); if ($this->expiredTime == "") $this->expiredTime = 3600; $this->default = $blogSettings->getValue( "plugin_authimage_default" ); } function isEnabled() { return $this->pluginEnabled; } function generateImageUrl() { $rg = new RawRequestGenerator($this->blogInfo); $rg->addParameter( "op", "AuthImageShow" ); $rg->addParameter( "blogId", $this->blogInfo->getId()); $imageUrl = $rg->getIndexUrl().$rg->getRequest(); if ( !function_exists ('gd_info') ) { // We don't have gd support compiled in, lets inform the user about it return false; } return $imageUrl; } function show() { $authImageUrl = $this->generateImageUrl(); if ( $authImageUrl ) return '<img src="'.$authImageUrl.'" style="vertical-align:middle;" "width:70px;" "height:20px;" alt="authimage" />'; else return 'You don\'t have GD support compiled in, we cannot create an authimage. Please activate GD Support.'; } function showImage() { // Delete those cached authimage files that never used $this->deleteExpiredAuthImage($this->expiredTime); $code = $this->generateCode(); $encrypt = $this->encrypt($code, $this->key); //$background = AUTHIMAGE_BACKGROUND_FOLDER.$this->default; $tempFile = $this->cacheFolder."/".$encrypt.".gif";//生成图形样式设置 $image = @imagecreate (70, 20) or die ("Cannot initialize new GD image stream!"); $background = imagecolorallocate ($image, 232, 238, 247); //random points for ($i = 0; $i <= 128; $i++) { $background = imagecolorallocate ($image, rand(0,255), rand(0,255), rand(0,255)); imagesetpixel($image, rand(2,128), rand(2,38), $background); } //output characters for ($i = 0; $i < strlen($code); $i++) { $textColor = imagecolorallocate ($image, rand(0,255), rand(0,128), rand(0,255)); $x = 5 + $i * 18; //控制生成的文字的间距,可以根据后台设置 $y = rand(1, 4); imagechar ($image, 5, $x, $y, $code{$i}, $textColor); } //改变了生成图形的种类 //ouput png header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); // Let it more flexible! if (function_exists("imagepng")) { header("Content-type: image/png"); Imagepng($image, $tempFile); imagepng($image); } elseif (function_exists("imagegif")) { header("Content-type: image/gif"); Imagegif($image, $tempFile); imagegif($image); } elseif (function_exists("imagejpeg")) { header("Content-type: image/jpeg"); Imagejpeg($image, $tempFile); imagejpeg($image); } else { die("No image support in this PHP server!"); } imagedestroy ($image); exit;} // encrypt string function encrypt($string, $key) { $plainText = $string.$key; $encodeText = md5($plainText); return $encodeText; } function generateCode() { $code = ""; $code .= str_replace(array('0', 'a'), array('9', 'z'), strtolower(substr(md5(rand()), 20, $this->length))); //改后的生成文字方式,使可以生成英文 // for($i=0; $i < $this->length; $i++) $code .= rand(0,9); //只生成数字被去掉 return $code; } function deleteExpiredAuthImage( $expiretime ) { $path = $this->cacheFolder; if ( is_dir($path) ) { $handle=opendir($path); while (false!==($file = readdir($handle))) { if ($file != "." && $file != "..") { $diff = time() - filectime("$path/$file"); if ($diff > $expiretime) unlink("$path/$file"); } } closedir($handle); } } } ?>