Tadashi Okoshi
slash****@users*****
2005年 12月 19日 (月) 22:40:50 JST
Index: affelio/lib/Affelio/App/Admin/ConfigAffelio.pm
diff -u affelio/lib/Affelio/App/Admin/ConfigAffelio.pm:1.2 affelio/lib/Affelio/App/Admin/ConfigAffelio.pm:1.3
--- affelio/lib/Affelio/App/Admin/ConfigAffelio.pm:1.2 Wed Nov 23 13:00:19 2005
+++ affelio/lib/Affelio/App/Admin/ConfigAffelio.pm Mon Dec 19 22:40:50 2005
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: ConfigAffelio.pm,v 1.2 2005/11/23 04:00:19 slash5234 Exp $
+# $Id: ConfigAffelio.pm,v 1.3 2005/12/19 13:40:50 slash5234 Exp $
package Affelio::App::Admin::ConfigAffelio;
{
@@ -25,10 +25,12 @@
use lib("../../../");
use Affelio;
use Affelio::misc::CGIError;
+ use Affelio::misc::MyCrypt;
use Affelio::misc::Debug qw(debug_print);
use Affelio::misc::Encoding qw(db_encode db_decode);
use Affelio::misc::Time qw(timestamp2string);
use Affelio::misc::WebInput;
+ use Affelio::exception::InvalidInputException();
use Exporter;
@Affelio::App::Admin::ConfigAffelio::ISA = "Exporter";
@@ -42,17 +44,20 @@
my $af = shift;
my $out_ref = shift;
+ my $ret_msg="";
+
my $wi = new Affelio::misc::WebInput();
my $sub_mode = $wi->PTN_mode($cgi->url_param("action"));
try{
if($sub_mode eq "submit" ){
- configure($af, $cgi);
+ $ret_msg = configure($af, $cgi);
}
}catch Error with{
my $e = shift;
$out_ref->{err_msg} .= $e->stacktrace . '<BR>';
};
+ $out_ref->{ret_msg} = $ret_msg;
$out_ref->{tmpl_file}
= "$af->{site__fs_root}/templates/"
@@ -73,6 +78,44 @@
my $wi = new Affelio::misc::WebInput;
##############################################
+ #Password
+ ##############################################
+ my $old_password = $wi->PTN_through($cgi->param("old_password"));
+ my $new_password1 = $wi->PTN_through($cgi->param("new_password1"));
+ my $new_password2 = $wi->PTN_through($cgi->param("new_password2"));
+ debug_print("Config::conf: old_pw = [$old_password]");
+ debug_print("Config::conf: new_pw1 = [$new_password1]");
+ debug_print("Config::conf: new_pw2 = [$new_password2]");
+
+ if($old_password ne ""){
+ if( verify_password($old_password, $af->{site__password}) < 1) {
+ return('<AF_M text="Current password is not correct.">');
+ }
+
+ if(length($new_password1) < 8){
+ return('<AF_M text="New password needs to be more than 8 characters.">');
+ }
+
+ if($new_password1 !~ /[0-9]/){
+ return('<AF_M text="New password needs to include at least 1 number.">');
+ }
+
+ if($new_password1 ne $new_password2){
+ return('<AF_M text="New passwords does not match each other.">');
+ }
+
+ my @salts = ( "A".."Z", "a".."z", "0".."9", ".", "/" );
+ my $salt = $salts[int(rand(64))] . $salts[int(rand(64))];
+ my $crypted_password = crypt($new_password1, $salt);
+
+ require Affelio::misc::InitAffelio;
+ Affelio::misc::InitAffelio::create_login_cfg($af->{site__user_dir} . "/login.cfg", $af->{site__username}, $crypted_password);
+
+ return('<AF_M text="Password has been changed!">');
+ }
+
+
+ ##############################################
#Top page
##############################################
my $toppage = $wi->PTN_word($cgi->param("toppage"));
@@ -98,6 +141,8 @@
$af->write_user_prefs();
debug_print("Config::conf: end.");
+
+ return("");
}