[pLog-svn] r2113 - in plugins/trunk/authimage: . class/action
class/view locale templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Mon May 30 03:28:20 GMT 2005
Author: mark
Date: 2005-05-30 03:28:19 +0000 (Mon, 30 May 2005)
New Revision: 2113
Modified:
plugins/trunk/authimage/class/action/pluginauthimageupdateconfigaction.class.php
plugins/trunk/authimage/class/view/pluginauthimageconfigview.class.php
plugins/trunk/authimage/locale/locale_en_UK.php
plugins/trunk/authimage/locale/locale_zh_TW.php
plugins/trunk/authimage/pluginauthimage.class.php
plugins/trunk/authimage/templates/authimage.template
Log:
Add deleteExpiredAuhtimage to auhtimage plugins. http://bugs.plogworld.net/view.php?id=565
Modified: plugins/trunk/authimage/class/action/pluginauthimageupdateconfigaction.class.php
===================================================================
--- plugins/trunk/authimage/class/action/pluginauthimageupdateconfigaction.class.php 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/class/action/pluginauthimageupdateconfigaction.class.php 2005-05-30 03:28:19 UTC (rev 2113)
@@ -12,6 +12,7 @@
var $_pluginEnabled;
var $_length;
var $_key;
+ var $_expiredTime;
var $_default;
function PluginAuthImageUpdateConfigAction( $actionInfo, $request )
@@ -38,7 +39,15 @@
$this->setCommonData();
return false;
- }
+ }
+ $this->_expiredTime = $this->_request->getValue( "expiredTime" );
+ if( $this->_expiredTime < 0 || $this->_expiredTime > 86400 || !ctype_digit($this->_expiredTime) ) {
+ $this->_view = new PluginAuthImageConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("authimage_error_expiredtime"));
+ $this->setCommonData();
+
+ return false;
+ }
$this->_default = $this->_request->getValue( "default" );
return true;
@@ -51,6 +60,7 @@
$blogSettings->setValue( "plugin_authimage_enabled", $this->_pluginEnabled );
$blogSettings->setValue( "plugin_authimage_length", $this->_length );
$blogSettings->setValue( "plugin_authimage_key", $this->_key );
+ $blogSettings->setValue( "plugin_authimage_expiredtime", $this->_expiredTime );
$blogSettings->setValue( "plugin_authimage_default", $this->_default );
$this->_blogInfo->setSettings( $blogSettings );
Modified: plugins/trunk/authimage/class/view/pluginauthimageconfigview.class.php
===================================================================
--- plugins/trunk/authimage/class/view/pluginauthimageconfigview.class.php 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/class/view/pluginauthimageconfigview.class.php 2005-05-30 03:28:19 UTC (rev 2113)
@@ -21,7 +21,9 @@
$length = $blogSettings->getValue( "plugin_authimage_length" );
if ($length == "") $length = 6;
$key = $blogSettings->getValue( "plugin_authimage_key" );
- if ($key == "") $key = "pLog";
+ if ($key == "") $key = "pLog";
+ $expiredTime = $blogSettings->getValue( "plugin_authimage_expiredtime" );
+ if ($expiredTime == "") $expiredTime = 3600;
$default = $blogSettings->getValue( "plugin_authimage_default" );
if ($default == "") $default = "marble.gif";
@@ -31,6 +33,7 @@
$this->setValue( "pluginEnabled", $pluginEnabled );
$this->setValue( "length", $length );
$this->setValue( "key", $key );
+ $this->setValue( "expiredTime", $expiredTime );
$this->setValue( "default", $default );
$this->setValue( "backgrounds", $backgrounds );
Modified: plugins/trunk/authimage/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/authimage/locale/locale_en_UK.php 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/locale/locale_en_UK.php 2005-05-30 03:28:19 UTC (rev 2113)
@@ -5,6 +5,7 @@
$messages["authimage_length"] = "Authentication Code Length";
$messages["authimage_key"] = "Authentication Code Encryption Key";
+$messages["authimage_expiredtime"] = "Authentication Code Expired Time";
$messages["authimage_default"] = "Choose Default AuthImage Background";
$messages["authimage_background_name"] = "Name";
$messages["authimage_background_image"] = "Image";
@@ -13,6 +14,7 @@
$messages["authimage_error_length"] = "Length should be between 1 and 6";
$messages["authimage_error_key"] = "Encryption Key can not be empty!";
+$messages["authimage_error_expiredtime"] = "The expired time must be >= 0 seconds and <= 86400 seconds (Suggest minimal value is 1800 seconds).";
$messages["authimage_settings_saved_ok"] = "AuthImage settings saved successfully!";
@@ -23,5 +25,6 @@
$messages["label_enable"] = "Enable";
$messages["label_lengthx"] = "Length";
$messages["label_key"] = "Key";
+$messages["label_expiredtime"] = "Expired Time";
$messages["label_default"] = "Default";
?>
Modified: plugins/trunk/authimage/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/authimage/locale/locale_zh_TW.php 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/locale/locale_zh_TW.php 2005-05-30 03:28:19 UTC (rev 2113)
@@ -5,6 +5,7 @@
$messages["authimage_length"] = "驗證碼的長度";
$messages["authimage_key"] = "驗證碼的編碼鑰匙";
+$messages["authimage_expiredtime"] = "驗證碼的暫存檔有效時間";
$messages["authimage_default"] = "選擇預設背景圖";
$messages["authimage_background_name"] = "檔名";
$messages["authimage_background_image"] = "圖像";
@@ -13,6 +14,7 @@
$messages["authimage_error_length"] = "長度必須介於 1 到 6 之間。";
$messages["authimage_error_key"] = "編碼鑰匙錯誤!不可空白。";
+$messages["authimage_error_expiredtime"] = "暫存檔有效時間為 0 秒到 86400 秒(建議不要小於 1800 秒)。";
$messages["authimage_settings_saved_ok"] = "迴響驗證設定儲存成功。";
@@ -23,5 +25,6 @@
$messages["label_enable"] = "啟動";
$messages["label_length"] = "長度";
$messages["label_key"] = "編碼鑰匙";
+$messages["label_expiredtime"] = "暫存";
$messages["label_default"] = "預設";
?>
\ No newline at end of file
Modified: plugins/trunk/authimage/pluginauthimage.class.php
===================================================================
--- plugins/trunk/authimage/pluginauthimage.class.php 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/pluginauthimage.class.php 2005-05-30 03:28:19 UTC (rev 2113)
@@ -64,6 +64,8 @@
$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" );
}
@@ -98,6 +100,9 @@
}
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;
@@ -149,24 +154,20 @@
return $code;
}
-// TBD: currently not used, but we should activate this somehow :)
-//
-// -- 2005-05-23 (ork at devel.plogworld.net)
-//
-// function deleteExpiredAuthImage( $expiretime ) {
-// $path = PLOG_CLASS_PATH . $this->cacheFolder;
-// if ( is_dir($path) )
-// {
-// $handle=opendir($path);
-// while (false!==($file = readdir($handle))) {
-// if ($file != "." && $file != ".." && $file != "index.htm") {
-// $diff = time() - filectime("$path/$file");
-// if ($diff > $expiretime) unlink("$path/$file");
-// }
-// }
-// closedir($handle);
-// }
-// }
+ 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);
+ }
+ }
}
?>
Modified: plugins/trunk/authimage/templates/authimage.template
===================================================================
--- plugins/trunk/authimage/templates/authimage.template 2005-05-30 00:39:52 UTC (rev 2112)
+++ plugins/trunk/authimage/templates/authimage.template 2005-05-30 03:28:19 UTC (rev 2113)
@@ -25,9 +25,16 @@
<span class="required">*</span>
<div class="formHelp">{$locale->tr("authimage_key")}</div>
<input class="text" type="text" name="key" id="key" value="{$key}" width="10" />
- </div>
+ </div>
<div class="field">
+ <label for="expiredTime">{$locale->tr("label_expiredtime")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("authimage_expiredtime")}</div>
+ <input class="text" type="text" name="expiredTime" id="expiredTime" value="{$expiredTime}" width="10" />
+ </div>
+
+ <div class="field">
<label for="default">{$locale->tr("label_default")}</label>
<span class="required"></span>
<div class="formHelp">{$locale->tr("authimage_default")}</div>
More information about the pLog-svn
mailing list