Location: PHPKode > projects > MembersGear > membersgear/member/user_change_password.php
<?php
 require_once "../config/config.php";
 require_once INCLUDE_DIR."/functions.php"; 
 require_once INCLUDE_DIR."/users_signup_class.php"; 
 //**********************************************Begin Page code**********************************************     
require_once INCLUDE_DIR."/users_class.php"; 
$users=new users_class();
$users_signup_class=new users_signup_class();

$affiliateSettings=$users->getAffiliateSettings($_SESSION[SESSION_PREFIX."UserID"]); 

if(isset($_REQUEST['action']))
    $_action = $_REQUEST['action']; 
else
  $_action="";
     
$_action = strtoupper($_action);

 if(function_exists('wordpress_check_Plugin_structure') and function_exists('wordpress_getWordpress_status')  )
 {
  
    $wordpressStatus=wordpress_getWordpress_status();
    if($wordpressStatus){

        $dirWordpress=wordpress_physical_path_dir()."wp-config.php";
        if(file_exists($dirWordpress)){
            require_once($dirWordpress);  
            assign_sessions();  
        }
        
     }
   
 }
switch($_action)
{
    case 'UPDATE':
    
    $lsUserid=$_SESSION[SESSION_PREFIX.'UserID']; 
    $key=$users->getSecretsaltById($lsUserid);
    $oldpass=encrypt($_POST['oldPassword'],$key);

    if($_POST['newpass']!=$_POST['oldPassword'])
    {
     
                        $laedituserinfo = $users->view("SELECT username FROM ".TABLE_PREFIX ."users where id=$lsUserid",null);  
                        if($laedituserinfo!=FALSE)
                          $username= $laedituserinfo[0]['username'];
                          
                        $newpassword=encrypt($_POST['newpass'],$key);
                        $query="update ".TABLE_PREFIX ."users set password=? where id=? and password=?";  
                        $arr=array();
                        $arr[0]=$newpassword;
                        $arr[1]=$lsUserid;
                        $arr[2]=$oldpass;
                        $lsUpdatedrows = $users->Update($query,$arr,null); 
                        if($lsUpdatedrows>0)
                        {
                            $smarty->assign('msg','Password updated successfully');
                              if(is_array($affiliateSettings))
                                $smarty->assign('affiliate_text','Your Affiliate Link');     
                               else
                                $smarty->assign('affiliate_text','Become An Affiliate');
                            $CHNAGEPASSWORD = $smarty->fetch('user_change_password.tpl');
                            
                            if($users_signup_class->phpbbStatuscheck()){
                            
                                phpBB_user_change_password($username,$_POST['newpass']);
                                
                            }
                            
                           if($users_signup_class->wordpressStatuscheck()){
                     
                              $wordpressReqquiredFile= wordpress_physical_path_dir();
                           
                              if(file_exists($wordpressReqquiredFile)){
                          
                                wordpress_change_user_password($username,$_POST['newpass']); 
                              }        
                            }
                        }
                       else
                        {
                          $smarty->assign('msg','Invalid old password.'); 
                           $smarty->assign('err','true');  
                           if(is_array($affiliateSettings))
                            $smarty->assign('affiliate_text','Your Affiliate Link');     
                           else
                            $smarty->assign('affiliate_text','Become An Affiliate'); 
                          $CHNAGEPASSWORD = $smarty->fetch('user_change_password.tpl');      
                        
                        } 
    }
    else
     {
          $affiliateSettings=$users->getAffiliateSettings($_SESSION[SESSION_PREFIX."UserID"]); 
          if(is_array($affiliateSettings))
            $smarty->assign('affiliate_text','Your Affiliate Link');     
          else
            $smarty->assign('affiliate_text','Become An Affiliate');
         $smarty->assign('msg','Old password and new password can not be same.'); 
         $smarty->assign('err','true'); 
         $CHNAGEPASSWORD = $smarty->fetch('user_change_password.tpl');      
         
     }                   
           break;
       
        DEFAULT:
    
             $lsUserid=$_SESSION[SESSION_PREFIX.'UserID'];
              $key=$users->getSecretsaltById($lsUserid);
             $laedituserinfo = $users->view("SELECT password FROM ".TABLE_PREFIX ."users where id=$lsUserid",null);  
             if($laedituserinfo!=FALSE)
               $password=decrypt($laedituserinfo[0]['password'],$key);
             $smarty->assign('smpassword',$password);
             $affiliateSettings=$users->getAffiliateSettings($_SESSION[SESSION_PREFIX."UserID"]); 
                if(is_array($affiliateSettings))
                   $smarty->assign('affiliate_text','Your Affiliate Link');     
               else
                 $smarty->assign('affiliate_text','Become An Affiliate'); 
              
             $CHNAGEPASSWORD = $smarty->fetch('user_change_password.tpl');
         
}
     
//**********************************************End Page code**********************************************
//Common Line
$smarty->assign('USER_CONTENT',     $CHNAGEPASSWORD); 
$smarty->display('user_page_main.tpl');
?>
Return current item: MembersGear