ratisp

ISP configuration panel
git clone http://git.code.weiherhei.de/ratisp.git
Log | Files | Refs | README

mailbox_change_password.php (1821B)


      1 <html>
      2 <head>
      3 </head>
      4 <body>
      5 <?php
      6 
      7 require( 'init.php' );
      8 
      9 if	( HTTP_POST )
     10 {
     11 	if	( strlen($_REQUEST['new_password']) < 6 )
     12 	{
     13 		?><div class="error message">Password too short</div><?php
     14 	}
     15 	elseif( $_REQUEST['new_password'] != $_REQUEST['new_password_repeat'] )
     16 	{
     17 		?><div class="error message">Passwords did not match</div><?php
     18 	}
     19 	else
     20 	{
     21 		$stmtCheck = $db->prepare("SELECT local_part,domain_name FROM mailbox WHERE local_part = ? AND domain_name = ? AND password=MD5(?)");
     22 		@list($requestLocalpart,$requestDomain) = explode('@',$_POST['username']);
     23 		
     24 		$stmtCheck->bind_param('sss',$requestLocalpart,$requestDomain,$_POST['old_password'] );
     25 	    $stmtCheck->execute();
     26 	    $stmtCheck->bind_result($localPart,$domain);
     27 	    if	( $stmtCheck->fetch() )
     28 	    {
     29 	    	$stmtUpdatePW = $db->prepare("UPDATE mailbox SET password=MD5(?) WHERE local_part = ? AND domain_name = ?");
     30 			$stmtCheck->bind_param('sss',$requestLocalpart,$requestDomain,$_POST['new_password'] );
     31 	    	$stmtUpdatePW->execute();
     32 	    	?><div class="success message">New password set</div><?php 
     33 	    }
     34 	    else
     35 	    {
     36 	    	?><div class="error message">Wrong password or not found</div><?php 
     37 	    }
     38 	}
     39 }
     40 	
     41 ?>
     42 
     43 <form method="post">
     44 <p><label for="id_username">E-Mail adress</label><input type="text" id="id_username" name="username" value="<?php echo @$_REQUEST['username'] ?>" /></p>
     45 <p><label for="id_old_password">Old password</label><input type="password" name="old_password" id="id_old_password" />
     46 <p><label for="id_new_password">New Password</label><input type="password" name="new_password"  id="id_new_password"/>
     47 <p><label for="id_new_password_repeat">Repeat new password</label><input type="password" name="new_password_repeat"  id="id_new_password_repeat"/>
     48 <input type="submit" value="Change password">
     49 </form>
     50 
     51 
     52 
     53 </body>
     54 </html>