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

 /* update by nikunj for list mail pro setting **********************/

$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();
   
 }  
/*******************************************************************/ 

//$key="projMemsite"; 
//echo encrypt('nik00726',$key)."<br>" ;
//echo decrypt('',$key) ;die;   
     
$themeClass=new themes_class();

if(isset($_GET['secSalt']))
   $lsuser  = trim(urldecode($_GET['secSalt']));
else
   $lsuser  = $_POST['username']; 
    
$_action    = $_GET['action'];
$_action    = strtoupper($_action);
$lsUserName = $lsuser;

switch($_action)
{
    case 'UNSUBSCRIBE':
            
            
            $query="update ".TABLE_PREFIX ."users set isunsubscribedfromemails=1 where username='$lsUserName'";  
            $lsUpdatedrows = $users->Update($query,null);
            
            $lsupdateRowSuccQuery="select username,id from ".TABLE_PREFIX."users where isunsubscribedfromemails=1 and username='$lsUserName'";
            $lsUpdatedSuccRows=$users->View($lsupdateRowSuccQuery);
            
            $lsUpdateUser=$lsUpdatedSuccRows[0]['username'];
            $lsUserId=$lsUpdatedSuccRows[0]['id']; 
             
            if(isset($lsUpdateUser))
            {
                
                
                $lsUsername=$_SESSION[SESSION_PREFIX.'UserName'];
              
               /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                { 
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($lsUpdatedSuccRows[0]['id']);
                    $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);
                    
                }
                
              /**********************************************************************************************************************************/ 
                
                
                $message->SetMessage('You are successfully unsubscribed from mailing list.');
                Redirect("user_default_page.php",true);
                
               
            }
            else
            {
                
              $UNSUBSCIBE= "<div id=\"formlayout\">   
                            <div id=\"formlayout-top\"></div>
                            <div id=\"formlayout-bg\">
                            <div  id=\"divunsubscribesubscribe\">
                                          <table cellpadding=\"0\" cellspacing=\"5\" align=\"center\" id=\"tableunsubscibe_maling\">         
                                             <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                           <center><label>You are successfully unsubscribed from mailing list</label></label></center>
                                                         </td>
                                                 </tr>
                                                 <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                           <center><label>".MESSAGE_SYSTEM_ERROR."</label>
                                                           </center>
                                                         </td>
                                                   </tr>
                                             </table>
                                       </div>

                      <div id=\"formlayout-bottom\"></div>
                </div>";
            }
           break; 
           
           case 'SUBSCRIBE':
            
            
            $query="update ".TABLE_PREFIX ."users set isunsubscribedfromemails=0 where username='$lsUserName'";  
            $lsUpdatedrows = $users->Update($query,null);
            
            $lsupdateRowSuccQuery="select username,id from ".TABLE_PREFIX."users where isunsubscribedfromemails=0 and username='$lsUserName'";
            $lsUpdatedSuccRows=$users->View($lsupdateRowSuccQuery);
            
            $lsUpdateUser=$lsUpdatedSuccRows[0]['username'];
            
            
            
             
            if(isset($lsUpdateUser))
            {
                
                $lsUsername=$_SESSION[SESSION_PREFIX.'UserName'];
                
                 /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                  {
                      
                      $objUserSignup=new users_signup_class();
                      $userSubscribedProducts=$objUserSignup->getAlluserSubscribedProduct($lsUpdatedSuccRows[0]['id']);
                      foreach($userSubscribedProducts as $k=>$item)
                      {
                          $prodId=$item['id'];
        
                            $prod_clss_obj=new product_class(); 
                            $getListNum=$prod_clss_obj->getListMailPro_Value_for_product($prodId);
                            if($getListNum!=null or $getListNum!="" )
                               {     
                                    $userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
                                    $lsUsersValues = array($lsUpdatedSuccRows[0]['id']);
                                    $laUserData = $prod_clss_obj->View($userQuery,$lsUsersValues,null);
                                    $isunsubscribe=$laUserData[0]['isunsubscribedfromemails'];
                                     
                                     if($isunsubscribe!=1)
                                       {
                                            $fname=$laUserData[0]['firstname'];
                                            $lname=$laUserData[0]['lastname']; 
                                            $email=$laUserData[0]['email'];
                                             listmailpro_addUserToListMailPro($getListNum,$fname,$lname,$email);                                                         
                                             $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                                              @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);                                              
                                        }            
                                                                                         
                                 }
                
                      }
                      
                      $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                      @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid); 
                      
                  }
              
                /********************************************************************************************************************************/
                
                
                
                /*$liDefaultThemeId=$themeClass->getDefaultTheme();
                $liThemeId=$liDefaultThemeId[0]['id'];
             
                $getThemeContect=$themeClass->getSubscribeContent($liThemeId);
                $lsThemeCon=$getThemeContect[0]['content'];
             
                $UNSUBSCIBE=$lsThemeCon;
                //$UNSUBSCIBE=html_entity_decode($UNSUBSCIBE);*/
                $message->SetMessage('You are successfully subscribed for mailing list.');
                Redirect("user_default_page.php",true);
            }
            else
            {
                
                 $UNSUBSCIBE= "<div id=\"formlayout\">   
                            <div id=\"formlayout-top\"></div>
                            <div id=\"formlayout-bg\">
                                 <div  id=\"divunsubscribesubscribe\" >
                                          <table cellpadding=\"0\" cellspacing=\"5\" align=\"center\" id=\"tableunsubscibe_maling\">         
                                             <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                           <center><label>\".MESSAGE_SYSTEM_ERROR.\"</label></label></center>
                                                         </td>
                                                 </tr>
                                                 <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                              <center><label><a href=\"user_default_page.php\">Click here to Countinue</a></label>    
                                                           </center>
                                                         </td>
                                                   </tr>
                                             </table>
                                       </div>

                      <div id=\"formlayout-bottom\"></div>
                </div>";  
               
               
               
               
            }
           break;
       
        DEFAULT:
    
             $key="";
             $user=decrypt($lsuser,$key);  
             $lsUsername=$user;
             $ValidRequest="select username from ".TABLE_PREFIX."users where username='$lsUsername'";
             $result=$users->View($ValidRequest);
             $user=$result[0]['username'];
             if(isset($user))
              {
                 $smarty->assign('user',     $lsUsername);  
                 $UNSUBSCIBE = $smarty->fetch('user_unsubscribe_malling.tpl');
              }
             else
              {
                  
                 $UNSUBSCIBE= "<div id=\"formlayout\">   
                            <div id=\"formlayout-top\"></div>
                            <div id=\"formlayout-bg\">
                                 <div id=\"divunsubscribesubscribe\" >
                                          <table cellpadding=\"0\" cellspacing=\"5\" align=\"center\" id=\"tableunsubscibe_maling\">         
                                             <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                           <center><label>".MESSAGE_NO_SUCH_USER."</label></label></center>
                                                         </td>
                                                 </tr>
                                                 <tr>
                                                   <td>&nbsp;</td>
                                                      <td class=\"left-side-text\" >
                                                            <center><label><a href=\"user_default_page.php\">Click here to Countinue</a></label>
                                                           </center>
                                                         </td>
                                                   </tr>
                                             </table>
                                       </div>

                      <div id=\"formlayout-bottom\"></div>
                </div>";  
              
              
              }   
         
}
     
//**********************************************End Page code**********************************************
//Common Line
$smarty->assign('USER_CONTENT',     $UNSUBSCIBE);
$smarty->display('user_page_main.tpl');
?>
Return current item: MembersGear