Location: PHPKode > projects > MembersGear > membersgear/admin/admin_users_m.php
<?php
require_once "../config/config.php";
require_once INCLUDE_DIR."/users_class.php";
require_once INCLUDE_DIR."/roles_class.php";
require_once INCLUDE_DIR."/usersinroles_class.php";
require_once INCLUDE_DIR."/users_signup_class.php"; 
require_once INCLUDE_DIR."/master_class.php";
require_once INCLUDE_DIR."/folderProtection.php";
require_once INCLUDE_DIR."/fields_class.php";


$users_signup_class=new users_signup_class();     

if($_SERVER['REQUEST_METHOD']=="GET")
        $_SESSION[SESSION_PREFIX.'page_referrer']=$_SERVER['HTTP_REFERER'];

/* update by nikunj for list mail pro setting **********************/
//$listMailProPlugin=PHYSICAL_DIR."/admin/plugins/listmailpro/plugin.php";
$listmailProStatus=false;   
if(function_exists('listmailpro_check_Plugin_structure') and function_exists('listmailpro_getListMailPro_status') and function_exists('listmailpro_getListMailPro_table_Prefix') and function_exists('listmailpro_connect_to_db') and function_exists('listmailpro_disconnect_db') and function_exists('listmailpro_get_list_mailpro_user') and function_exists('listmailpro_get_all_list_mailpro_lists') and function_exists('listmailpro_addUserToListMailPro') and function_exists('listmailpro_updateUserToListMailPro') and function_exists('listmailpro_updateUserToListMailProAndEmail') and function_exists('listmailpro_deleteUserFromListMailPro') and function_exists('listmailpro_unique_id') and function_exists('listmailpro_remlists') and function_exists('listmailpro_getlistopts') and function_exists('listmailpro_addlists'))
 {
    $listmailProStatus=listmailpro_getListMailPro_status();
   
 }  
/*******************************************************************/   
 
   
$users = new users_class();
$userrole=new roles_class();
$userinrole=new usersinroles_class();
                                   

/*//$randompass= createRandomPassword();
//echo "$randompass<br>";

$random=createRandomusername();

echo $random;
die;        */
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can browse user profiles')==false)
{
    Redirect('admin_nopermission.php',true);  
   
    
}  

 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);  
            require_once(wordpress_physical_path_dir()."wp-admin/includes/user.php");  
            assign_sessions();     
        }
        
     }
   
 }    

 switch($_action)
{     
    case 'insert':
                
                $lstokenKey=createToken();  
                if($_POST['gen_username']=="1")   
                {
                   $lsValues1[0]=createRandomusername();
                   $lsusername=trim(strtolower($lsValues1[0]));  
                
                } 
                else
                {   
                
                    $lsValues1[0] = $_POST['username'];
                    $lsusername=trim(strtolower($lsValues1[0])); 
           
                } 
                if($_POST['gen_password']=="1")   
                {
                   $lspassword=encrypt(createRandomPassword(),$lstokenKey);
                    
                }
                else
                {
                   $lspassword=encrypt($_POST['password'],$lstokenKey);
                }    
                 $liUseravialble=$users->IsUserAvailable("SELECT * FROM ".TABLE_PREFIX ."users where username=?",$lsValues1,null);
                
                if($liUseravialble==false)
                {    
                           if(MEMBER_USE_ADDRESS_INFO=='invisible')
                           {
                               
                                  /*$query="INSERT INTO ".TABLE_PREFIX ."users (username,`password`,secretsalt,firstname,lastname, Email,
                                  phone_main,createdon,createdby,createdipaddress, billing_country, billing_state,billing_city, billing_address, billing_name,billing_phone, billing_zip,isapproved,islockedout,isunsubscribedfromemails) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; */          
                                  
                                  $query="INSERT INTO ".TABLE_PREFIX ."users 
                                  (username,`password`,secretsalt,firstname,lastname, Email,
                                  billing_name,createdon,createdby,createdipaddress,
                                  isapproved,islockedout,isunsubscribedfromemails) 
                                  VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";           
                                         
                           
                           }
                           else
                           {    
                                   $lTypes=null;   
                                   $query="INSERT INTO ".TABLE_PREFIX ."users (username,`password`,secretsalt,firstname,
                                                                                lastname, Email,country,state,city,address1,address2, 
                                                                                zipcode,phone_main,billing_country, billing_state, 
                                                                                billing_city,billing_address,billing_zip,billing_phone,
                                                                                billing_name,createdon,createdby,createdipaddress,isapproved,
                                                                                islockedout,isunsubscribedfromemails) VALUES 
                                                                                (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                           }   
                                   
                                     $lsValues = array();
                                   //  $lsValues[]= $_POST['username'];
                                     $lsValues[]=trim($lsusername);
                                     $lsValues[]=$lspassword;
                                     $lsValues[]=$lstokenKey;
                                     $lsValues[]=$_POST['fname'];
                                     $lsValues[]= $_POST['lname'];
                                     $lsValues[]=$_POST['email'];
                                     if(MEMBER_USE_ADDRESS_INFO!='invisible')
                                     {
                                             $lsValues[]=$_POST['country'];
                                             $lsValues[]=$_POST['state'];
                                             $lsValues[]=$_POST['city'];
                                             $lsValues[]=$_POST['address'];
                                             $lsValues[]=' ';
                                             $lsValues[]=$_POST['zipcode'];
                                             $lsValues[]=$_POST['phone'];
                                             $lsValues[]=$_POST['billing_country'];
                                             $lsValues[]=$_POST['bllling_state'];
                                             $lsValues[]=$_POST['billcity'];
                                             $lsValues[]=$_POST['billaddress'];
                                             $lsValues[]=$_POST['billzipcode']; 
                                             $lsValues[]=$_POST['billphone']; 
                                             
                                     }    
                                     $lsValues[]=$_POST['billname']; 
                                     $lsValues[]=mktime();
                                     $lsValues[]=$_SESSION[SESSION_PREFIX.'Admin_UserID'];
                                     $lsValues[]=$_SERVER['REMOTE_ADDR'];
                                     if($_POST['isapproved']=="1")
                                     {
                                        $lsValues[]=$_POST['isapproved'];
                                     }
                                     else
                                     {
                                        $lsValues[]=0; 
                                     } 
                                     $lsValues[]=$_POST['islockedout']; 
                                     $lsValues[]=$_POST['isUnsubscribe']=="1"?$_POST['isUnsubscribe']:0; 
                                      $lsInsertedrows = $users->Insert($query,$lsValues,null);   
                                        if($lsInsertedrows>0)
                                       {
                                             $lauserinfovalue=array();
                                             $lauserinfovalue[0] = $lsusername; 
                                             $lauserinfo = $users->view("SELECT * FROM ".TABLE_PREFIX ."users where username=?",$lauserinfovalue,null);    
                                             $lsValuesrole=array();
                                             $lsValuesrole[0]='customer';
                                             $laroleid=$userrole->GetRoleID($lsValuesrole,null);
                                            
                                             $lauserinrolevalue=array();
                                             $lauserinrolevalue[0]=$lauserinfo[0]['id'];
                                             $lauserinrolevalue[1]=$laroleid[0]['id'];
                                             $lauserinrolevalue[2]=mktime();
                                             $lauserinrolevalue[3]=$_SESSION[SESSION_PREFIX.'Admin_UserID'];
                                             $lauserinrolevalue[4]=$_SERVER['REMOTE_ADDR'];   
                                             $user= $userinrole->Insert('',$lauserinrolevalue,null);
                                             
                                               /************************************************************************************************************/                                              
                                                /* Entry For Dyanmic Control*/
                                              
                                               $loManageFields = new fields_class();     
                                               $ladyncltValues=$_POST;   
                                               $loManageFields->insertsignupformdata('profile',$ladyncltValues,$lauserinfo[0]['id']);  
                                             /*End*/  
                                             
                                             
                                              if($users_signup_class->wordpressStatuscheck()){
                                                                     
                                                  $wordpressReqquiredFile= wordpress_physical_path();
                                                
                                                  if(file_exists($wordpressReqquiredFile)){
                                                         
                                                         $plainpass=decrypt($lauserinfo[0]['password'],$lauserinfo[0]['secretsalt']); 
                                                          
                                                         $createdUserId=wordpress_Register_User($lauserinfo[0]['username'],$plainpass,$lauserinfo[0]['email']);
                                                         if(!is_array($createdUserId) and !is_object($createdUserId)){
                                                         
                                                             wordpress_add_user_meta( $createdUserId, 'first_name', $lauserinfo[0]['firstname'],false);
                                                             wordpress_add_user_meta( $createdUserId, 'last_name', $lauserinfo[0]['lastname'],false);
                                                             wordpress_add_user_meta( $createdUserId, 'nickname', $lauserinfo[0]['username'],false);
                                                            
                                                             wordpress_add_user_role($createdUserId,'subscriber');
                                                                
                                                          }
                                                 
                                                      } 
                                                     
                                                }
                                  
                                             
                                         }    
                                         $smarty->assign('msg','New User is Inserted...');  
                                         $message->SetMessage('User is successfully inserted.');
                                       if($_GET['from']=="searchPage")
                                         {
                                             
                                              if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                                                     Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                                                else  
                                                   Redirect('./admin_search_user.php?action=search');      
                                         }  
                                       else
                                       {
                                              // Redirect('./admin_users_v.php');   
                                                Redirect("./admin_user_subscription_m.php?userid=".$lauserinfo[0]['id']."",true);  
                                       }
        
                             
                             
                }
                else
                {           $iaPostdata = array();
                            $i=0;           
                            foreach($_POST as $key=>$value)
                            {   
                                    $iaPostdata[$key]=$value;
                                    $i++;
                            }        
                               
                             $smarty->assign('post',$iaPostdata);
                             $smarty->assign('msg','User Name Already Exist...');                       
                             require_once INCLUDE_DIR."/fill_states.php";
                            $query= "SELECT id,name FROM ".TABLE_PREFIX."location where ifnull(parentid,0)=0 and status=1 order by name asc";
                            $result = $users->View($query);
                            $smarty->assign('country',$result); 
                            $smarty->assign('billing_country',$result);
                            $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$_POST[country] and status=1 order by name asc";
                            $Stateresult = $users->View($query);
                            $smarty->assign('state',$Stateresult);
                            $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$_POST[billing_country] and status=1 order by name asc";
                            $Stateresult = $users->View($query);
                            $lauserstatus = $users->GetUserStatus();
                            $smarty->assign('userstatus',$lauserstatus); 
                            $smarty->assign('billing_state',$Stateresult);
                            $smarty->display('admin_users_m.tpl');  
                    
                } 

           
     
           
       
           break;
    case 'update':                     
           //Update
           $key=$users->getSecretsaltById(trim($_POST['uid']));  
           if(MEMBER_USE_ADDRESS_INFO=='invisible')
            {    
            $query="update ".TABLE_PREFIX ."users set password=?,firstname=?,lastname=?, Email=?,
                                             modifiedon=?,modifiedby=?,modifiedipaddress=?,billing_name=?,
                                             isapproved=?,islockedout=?,isunsubscribedfromemails=? where id=?";  
            }
            else
            {
                      $query="update ".TABLE_PREFIX ."users set password=?,firstname=?,lastname=?, Email=?,
                                        modifiedon=?,modifiedby=?,modifiedipaddress=?,country=?,state=?,city=?,
                                        address1=?,address2=?,zipcode=?,phone_main=?,billing_country=?,billing_state=?,
                                        billing_city=?,billing_address=?,billing_zip=?,billing_phone=?,billing_name=?,
                                        isapproved=?,islockedout=?,isunsubscribedfromemails=?  where id=?"; 
            }            
   
           
            $lsValues = array(); 
             if($_POST['gen_password']=="1")   
             {
                 $lspassword=createRandomPassword();  
                
             }
             else
             {     
                    $lspassword=$_POST['password'];
             }
            $lsnewpassword=encrypt($lspassword,$key);   
            $lsValues[]=$lsnewpassword;
            $lsValues[]=$_POST['fname'];
            $lsValues[]= $_POST['lname'];
            $lsValues[]=$_POST['email'];
                  
            $lsValues[]=mktime();
            $lsValues[]=$_SESSION[SESSION_PREFIX.'Admin_UserID'];
            $lsValues[]=$_SERVER['REMOTE_ADDR'];
            if(MEMBER_USE_ADDRESS_INFO!='invisible')
            {
                $lsValues[]=$_POST['country'];
                $lsValues[]=$_POST['state'];
                $lsValues[]=$_POST['city'];
                $lsValues[]=$_POST['address'];
                $lsValues[]=' ';
                $lsValues[]=$_POST['zipcode'];
                $lsValues[]=$_POST['phone'];
                $lsValues[]=$_POST['billing_country'];
                $lsValues[]=$_POST['bllling_state'];
                $lsValues[]=$_POST['billcity'];
                $lsValues[]=$_POST['billaddress'];
                $lsValues[]=$_POST['billzipcode']; 
                $lsValues[]=$_POST['billphone'];
             
            }
            $lsValues[]=$_POST['billname']; 
            if($_POST['isapproved']=="1")
            {                          
                 $lsValues[]=$_POST['isapproved'];
            
            }
            else
            {
                 $lsValues[]=0; 
            } 
            $lsValues[]=$_POST['islockedout'];    
            $lsValues[]=$_POST['isUnsubscribe']=="1"?$_POST['isUnsubscribe']:0;      
            $lsValues[]=$_POST['uid'];  
            $lsUpdatedrows = $users->Update($query,$lsValues,$lTypes); 
            
             $query="select productid from ".TABLE_PREFIX."product_users where userid=".$_POST['uid'];
             $laresult=$users->View($query);
             
            
             
               /* update by nikunj for htacess add new user*/
                                          /*-------------------------------------------------------------------------------------------*/
             /*
               if(is_array($laresult))
                {                           
                          foreach($laresult as $key=>$val)
                            {
                                                      $prodid=$val['productid'];   
                                                     $objSignupclass=new users_signup_class();
                                                      $objProtecfolderProtection_Class=new ProtecfolderProtection_Class(); 
                                                      $larrProtectedFoldersForProduct = $objSignupclass->getProtectedFoldersForProduct($prodid);
                                                      $masterclassObj=new master_class();
                                           
                                                              
                                                         if(is_array($larrProtectedFoldersForProduct)) {
                                                                foreach($larrProtectedFoldersForProduct as $key=>$folderpath) {
                                                                      //print $folderpath['folder'].'<br />';
                                                                         $lsUrl=trim(PHYSICAL_DIR.$folderpath['folder']."/");  
                                                                         
                                                                          $mastervalue=$masterclassObj->getValueFromID($folderpath['protection_method']); 
                                                                          if($mastervalue=='.htaccess')
                                                                           {
                                                                              $objProtecfolderProtection_Class->createHtaccess($lsUrl);
                                                                              $products=$objSignupclass->getAllowedProductsFromProtectedFolder($folderpath['folder']);
                                                                              $objProtecfolderProtection_Class->createPasswdfile($lsUrl,$products); 
                                                                           }  
                                                                  }
                                                              }
                            } 
                            
                }                                              
                   
          */   
           
                                             
            if($lsUpdatedrows>0)
            {
                /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                { 
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($_POST['uid']);
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $userOldEmail=$laUserData[0]['email'];

                    listmailpro_updateUserToListMailProAndEmail($_POST['fname'],$_POST['lname'],$userOldEmail,$_POST['email']); 
                    
                    $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                    @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
                }
                /*****************************************************************************************************************************/
               
                if($_POST['isapproved']=="1")
                {                          
                 
                    $userQuery = 'SELECT *  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($_POST['uid']);
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);          
                    if($users_signup_class->phpbbStatuscheck())
                      {
                            $phpBBProduct=phpBB_get_product_id();
                            mysql_select_db(MEMBERSGEAR_DB_NAME);
                            $proId=$productobj->checkForActiveSubscription($_POST['uid'],$phpBBProduct);
                            if($phpBBProduct==$proId)
                            {
                              phpBB_activate_deactivate_user($laUserData[0]['username'],0);
                              phpBB_user_change_password($laUserData[0]['username'],$plainpass);     
                              mysql_select_db(MEMBERSGEAR_DB_NAME);
                            }
                      }
                    
                      if($users_signup_class->wordpressStatuscheck()){
                                                                     
                          $wordpressReqquiredFile= wordpress_physical_path();
                        
                          if(file_exists($wordpressReqquiredFile)){
                                 
                                 
                                 $createdUserId = wordpress_username_exists( $laUserData[0]['username'] );
                                  $isemailExist=wordpress_email_exists($laUserData[0]['email']);            
                                  if(!$createdUserId and !$isemailExist){  
                                  
                                      $createdUserId=wordpress_Register_User($laUserData[0]['username'],$plainpass,$laUserData[0]['email']);
                                      if(!is_array($createdUserId) and !is_object($createdUserId)){
                                     
                                         wordpress_add_user_meta( $createdUserId, 'first_name', $laUserData[0]['firstname'],false);
                                         wordpress_add_user_meta( $createdUserId, 'last_name', $laUserData[0]['lastname'],false);
                                         wordpress_add_user_meta( $createdUserId, 'nickname', $laUserData[0]['username'],false);
                                         
                                         $savedRoles=wordpress_get_option('membersgear_roles'); 
                                         $wp_role=array('subscriber'=>0,'contributor'=>1,'author'=>4,'editor'=>7,'administrator'=>10);
                                         $wp_role_byname=array(0=>'subscriber',1=>'contributor',4=>'author',7=>'editor',10=>'administrator');
                                        
                                         
                                         $userSubscribedProducts=$users_signup_class->getAlluserSubscribedProduct( $_POST['uid']); 
                                         $rolArr=array();
                                          if(count($userSubscribedProducts) > 0 and $userSubscribedProducts!=false)
                                          {
                                             for($i=0;$i<=count($userSubscribedProducts)-1;$i++)
                                              {
                                                  if(array_key_exists($userSubscribedProducts[$i]['id'],$savedRoles)){
                                                  
                                                    if(array_key_exists($savedRoles[$userSubscribedProducts[$i]['id']],$wp_role)){
                                                    
                                                        $rolArr[]=$wp_role[$savedRoles[$userSubscribedProducts[$i]['id']]];
                                                    
                                                     }
                                                  
                                                  }
                                              }
                                          } 
                                         $maxRole=max($rolArr);
                                         $roleName=$wp_role_byname[$maxRole];  
                                            
                                         if($roleName!=''){
                                        
                                            wordpress_add_user_role($createdUserId,$roleName);
                                         }
                                        else{
                                        
                                            wordpress_add_user_role($createdUserId,'subscriber');
                                          
                                        }
                                            
                                     }
                                   
                                 }
                                else{
                                      wordpress_change_user_password($laUserData[0]['username'],$plainpass);  
                                     
                                
                                }      
                                 
                           } 
                              
                     }
                      
                }
                else
                {
                
                    $userQuery = 'SELECT *  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($_POST['uid']);
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);          
                 
                       if($users_signup_class->phpbbStatuscheck())
                       {
                          
                            $phpBBProduct=phpBB_get_product_id();
                            mysql_select_db(MEMBERSGEAR_DB_NAME);
                            $proId=$productobj->checkForActiveSubscription($_POST['uid'],$phpBBProduct);
                            if($phpBBProduct==$proId)
                            {
                              
                              phpBB_activate_deactivate_user($laUserData[0]['username'],1);
                              phpBB_user_change_password($laUserData[0]['username'],$plainpass);   
                              mysql_select_db(MEMBERSGEAR_DB_NAME);
                            }
                       }
                       
                        if($users_signup_class->wordpressStatuscheck()){

                            $wordpressReqquiredFile= wordpress_physical_path();

                            if(file_exists($wordpressReqquiredFile)){
                
                               $siteAdminsArr=wordpress_get_siteAdmin();
                               $adminId=$siteAdminsArr[0]->ID;
                               
                               $user_id = wordpress_username_exists( $laUserData[0]['username'] );  
                               if($user_id>0){
                               
                                  wordpress_delete_user( $user_id, $adminId );   
                               
                                }
                               
                            }
                             
                       }
 
                }
                $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          if(strtoupper($keyname)!='ACTION')
                             $quest.=$keyname."=".$value."&";
                        }     
                 
                 }
                $message->SetMessage('User is successfully updated.'); 
                /************************************************************************************************************/                                              
                /* Entry For Dyanmic Control*/
               $loManageFields = new fields_class();     
               $ladyncltValues=$_POST;   
               $loManageFields->insertsignupformdata('profile',$ladyncltValues,$_POST['uid']);  
             /*End*/
                if($_GET['from']=="searchPage") 
                 { 
                     
                     if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                          Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                      else  
                        Redirect('./admin_search_user.php?action=search');  
                    
                      
                 }                
                else   
                {
                  
                 
                     if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                         Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                     else  
                          Redirect('./admin_users_v.php');     
                }
                   //echo("<script language='javascript'>\n" .
//                            "javascript:history.go(-1)\n" .
//                           "</script>");  
//          
            } 
            

                 
           break;
           
   case 'delete':
             if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can delete users')==false)
             {
                    Redirect('admin_nopermission.php',true); 
                      
             }
            $laduser[0]= $_GET['id'];  
            
            
            
                /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                { 
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($_GET['id']);
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $userEmail=$laUserData[0]['email'];
                    
                }
                
              /**********************************************************************************************************************************/     
             
             //phpBB delete user .
             
             if($users_signup_class->phpbbStatuscheck())
              {
                    $phpBBProduct=phpBB_get_product_id();
                    mysql_select_db(MEMBERSGEAR_DB_NAME);
                    $uId=(int) $_GET['id'];   
                    $proId=$productobj->checkForSubscription($uId,$phpBBProduct);
                    if($phpBBProduct==$proId)
                    {
                      $query="select username from ".TABLE_PREFIX."users where id=".$uId;
                      $laresult=$users->View($query);
                      phpBB_delete_user($laresult[0]['username']);
                      mysql_select_db(MEMBERSGEAR_DB_NAME);
                    }
              }
             
            
               if($users_signup_class->wordpressStatuscheck()){

                    $wordpressReqquiredFile= wordpress_physical_path();

                    if(file_exists($wordpressReqquiredFile)){
        
                       $siteAdminsArr=wordpress_get_siteAdmin();
                       $adminId=$siteAdminsArr[0]->ID;
                      
                        
                       $query="select username from ".TABLE_PREFIX."users where id=".(int)$_GET['id'];
                       $laresult=$users->View($query);
                    
                       $user_id = wordpress_username_exists( $laresult[0]['username'] );  
                       if($user_id>0){
                       
                          wordpress_delete_user( $user_id, $adminId );   
                       
                        }
                       
                    }
                     
               }           
              
            /*$query="delete from ".TABLE_PREFIX."users where id=?";
            $lsdeletedrows = $users->delete($query, $laduser,null);
            if($lsdeletedrows>0)
            { 
               $query="delete  from  ".TABLE_PREFIX."users_in_roles  where userid=?";
               $lsdeletedrows = $users->delete($query,$laduser,null);
               $query="delete from ".TABLE_PREFIX."emails_log  where sentto_userid=?";
               $lsdeletedrows = $users->delete($query, $laduser,null);
               $query="delete from  ".TABLE_PREFIX."users_log where userid=?";
               $lsdeletedrows = $users->delete($query, $laduser,null);
               $query="delete from ".TABLE_PREFIX."product_users where userid=?";
               $lsdeletedrows = $users->delete($query, $laduser,null);
               
            
            } */
            $users->deleteuser($laduser[0]);    
            $message->SetMessage('User is successfully deleted.'); 
            
          
          
                /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                { 
                    
                    listmailpro_deleteUserFromListMailPro($userEmail); 
                    $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                    @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
                 
                }
                /*****************************************************************************************************************************/
           
           
           //Redirect('./admin_users_v.php');
            $quest="&";
            if(isset($_GET) && !empty($_GET))
             {
                 foreach($_GET as $keyname => $value) {
                      if(strtoupper($keyname)!='ACTION')
                         $quest.=$keyname."=".$value."&";
                    }     
             
             }
              
            if($_GET['from']=="searchPage")
             {
                    if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                          Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                      else  
                       Redirect("./admin_search_user.php?action=search$quest&action=search");  
                        
             }  
             else
                {
                  
                    if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                          Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                      else  
                          Redirect("./admin_users_v.php?$quest");  
                  
                }
                
           break;                                        
    case 'delete_selected':
            
           $uId=(int) $_GET['id'];    
           if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can delete users')==false)
             {
                    Redirect('admin_nopermission.php',true); 
                      
             }
            $lauserlen=count($_POST['chkDeleteItem']);
            $lauserlist=implode(",",$_POST['chkDeleteItem']);
            
            /* update by nikunj for listmailpro setiing ***********************************************************************************/   
              if($listmailProStatus)  
              {        
                for($i=0;$i<=$lauserlen-1;$i++)
                {
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($_POST['chkDeleteItem'][$i]);
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $userEmail=$laUserData[0]['email'];
                    listmailpro_deleteUserFromListMailPro($userEmail); 
                    
                    $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                    @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
                 }
              }   
             /*****************************************************************************************************************************/   
             
             
             //phpBB delete user .
             
             if($users_signup_class->phpbbStatuscheck())
              {
                    $phpBBProduct=phpBB_get_product_id();
                    mysql_select_db(MEMBERSGEAR_DB_NAME);
                    
                    for($i=0;$i<=$lauserlen-1;$i++)
                    {
                        $uId=(int) $_POST['chkDeleteItem'][$i];
                        $proId=$productobj->checkForSubscription($uId,$phpBBProduct);
                        if($phpBBProduct==$proId)
                        {
                          $query="select username from ".TABLE_PREFIX."users where id=".$uId;
                          $laresult=$users->View($query);
                          phpBB_delete_user($laresult[0]['username']);
                          mysql_select_db(MEMBERSGEAR_DB_NAME);
                        } 
                    }    
              } 
              
            
            if($users_signup_class->wordpressStatuscheck()){

                    $wordpressReqquiredFile= wordpress_physical_path();

                    if(file_exists($wordpressReqquiredFile)){
        
                       $siteAdminsArr=wordpress_get_siteAdmin();
                       $adminId=$siteAdminsArr[0]->ID;
                      
                        
                       $query="select username from ".TABLE_PREFIX."users where id=".$uId;
                       $laresult=$users->View($query);
                    
                       $user_id = wordpress_username_exists( $laresult[0]['username'] );  
                       if($user_id>0){
                       
                           wordpress_delete_user( $user_id, $adminId );   
                       
                        }
                       
                    }
                     
               }   
             
            /*$query="delete from ".TABLE_PREFIX."users where id in ($lauserlist)";
            $lsdeletedrows = $users->delete($query);
            //if($lsdeletedrows>0)
            { 
               $query="delete  from  ".TABLE_PREFIX."users_in_roles  where userid in ($lauserlist)";
               $lsdeletedrows = $users->delete($query);
               $query="delete from ".TABLE_PREFIX."emails_log  where sentto_userid in ($lauserlist)";
               $lsdeletedrows = $users->delete($query);
               $query="delete from  ".TABLE_PREFIX."users_log where userid in ($lauserlist)";
               $lsdeletedrows = $users->delete($query);
               $query="delete from ".TABLE_PREFIX."product_users where userid in ($lauserlist)";
               $lsdeletedrows = $users->delete($query);
               
            
            } */
            $users->deleteuser($lauserlist);
            
            if($lauserlen==1)
            {
                $message->SetMessage('User is successfully deleted.');     
            }
            else
            {
                   $message->SetMessage('Users are successfully deleted.'); 
            }    
            //Redirect('./admin_users_v.php');
            $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          if(strtoupper($keyname)!='ACTION')
                             $quest.=$keyname."=".$value."&";
                        }     
                 
                 }
            if($_GET['from']=="searchPage")
              {
                       
               
                    if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                          Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                      else  
                          Redirect("./admin_search_user.php?$quest&action=search",true);  
              }
            else
             {
                 
               
                  if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
                          Redirect($_SESSION[SESSION_PREFIX.'page_referrer'],true);
                  else  
                     Redirect("./admin_users_v.php?$quest",true);  
                 
             }   
           
            
           break;
              
    case 'edit':
             
            if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can edit users')==false)
             {
                      Redirect('admin_nopermission.php',true);
                      //break;
                    
             }
               $key=$users->getSecretsaltById(trim($_GET['id'])); 
             $lsupdateid[0]=$_GET['id'];
            
             $laedituserinfo = $users->view("SELECT *,last_login_date 'LastLoginTime' FROM ".TABLE_PREFIX ."users a where a.id=?",$lsupdateid,null);
//             echo "SELECT *,
//                                                (select max(visitedon) from prefix_users_log pul where pul.userid= a.id) as `LastLoginTime` 
//                                            FROM ".TABLE_PREFIX ."users a where a.id=".$lsupdateid[0];die;                                                                           
            // $password=decrypt($laedituserinfo[0]['password'],$key); 
          //   print_r($laedituserinfo);
             
             $laedituserinfo[0]['password']=decrypt( $laedituserinfo[0]['password'],$key);  
             $lastate=$laedituserinfo[0]['country'];
             $Stateresult=array();
             if($lastate!=null)
             {
                 if($lastate==0)
                    $lastate=-1;
                //$query= "SELECT id,name FROM ".TABLE_PREFIX."location where ifnull(parentid,0)=0 and status=1 order by name asc";
                  $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$lastate  and status=1 order by name asc";
                $Stateresult = $users->View($query);
             }
             $smarty->assign('state',$Stateresult);
             if(isset($_GET['from']))
             $smarty->assign('from',$_GET['from']);
             $labilling_state=$laedituserinfo[0]['billing_country'];
             $Stateresult=array();  
             if($labilling_state!=null)
             {
               //$query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$labilling_state and status=1 order by name asc";
               if($labilling_state==0)
                    $labilling_state=-1;
                $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$labilling_state  and status=1 order by name asc";
               $Stateresult = $users->View($query);
             }
             
            
             $smarty->assign('billing_state',$Stateresult);
             $smarty->assign('userdata',$laedituserinfo);   
             
             $smarty->assign('IsEdit','yes');
           
    default:       
               if($_action!="edit")
               {
                        if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can add users')==false)
                    {
                        Redirect('admin_nopermission.php',true);  
                        //break;
                    }
               }
               
              
           
           $lsValues = array();
           
            $lTypes=null;
            $query= "SELECT * FROM ".TABLE_PREFIX."location  WHERE name='United States' AND status=1 AND IFNULL(parentid,0)=0
                    UNION
                    SELECT * FROM (SELECT * FROM ".TABLE_PREFIX."location WHERE name <> 'United States' AND status=1 AND IFNULL(parentid,0)=0 ORDER BY name)  t;";
            $result = $users->View($query);
            $laLockedout=array(0=>'No',1=>'Yes',2=>'Disable auto-lock for this user');
             if(isset($_GET['from']))
             $smarty->assign('from',$_GET['from']);
          
            if($_action=="edit")
               { 
                 $loManageFields = new fields_class(); 
                 
                 $controlresult=$loManageFields->renderDynamiControlOnPage_admin_user_edit_profile('profile',0,$_GET['id']);
                 $lsvalidationresult=$loManageFields->renderDynamiControlvalidation('signup',"myform",'frmvalidator');
                 $smarty->assign('controlvalidationresult',$lsvalidationresult);;
                 $smarty->assign('controlresult',$controlresult);
               }
              else
               { 
     
                  $loManageFields = new fields_class(); 
                  $controlresult=$loManageFields->renderDynamiControlOnPage('signup',0);
                  $lsvalidationresult=$loManageFields->renderDynamiControlvalidation('signup',"myform",'frmvalidator');
                  $smarty->assign('controlvalidationresult',$lsvalidationresult);;
                  $smarty->assign('controlresult',$controlresult);
               }
            $smarty->assign('laLockedout',$laLockedout);
            $smarty->assign('country',$result); 
            $smarty->assign('billing_country',$result);
            $smarty->display('admin_users_m.tpl');  
                       
}
    
    
?>
Return current item: MembersGear