Location: PHPKode > projects > MembersGear > membersgear/member/user_default_page.php
<?php
 require_once "../config/config.php";   
 require_once INCLUDE_DIR."/users_signup_class.php";
 require_once INCLUDE_DIR."/product_class.php";
 require_once INCLUDE_DIR."/product_protection_class.php"; 
 require_once INCLUDE_DIR."/users_class.php";
 $product=new product_protection_class(); 
 $users=new users_class();  
  
 $puserid=$_SESSION[SESSION_PREFIX.'UserID'];
 $objUserSignup=new users_signup_class();
 $objprodcalss=new product_class();
 $userSubscribedProducts=$objUserSignup->getAlluserSubscribedProduct($puserid);
 $arr = $objUserSignup->getProductsToSignupInMemberArea($puserid);
 $arrPayments=$objprodcalss->getUserPaymentHistory($puserid);
 $iuserEmailSubStatus=$objUserSignup->isSubscribedForEmail($puserid); 
 
 
 $singleArrySubscribedProducts=array();
 if(count($userSubscribedProducts) > 0 and $userSubscribedProducts!=false)
  {
     for($i=0;$i<=count($userSubscribedProducts)-1;$i++)
      {
          $singleArrySubscribedProducts[]=$userSubscribedProducts[$i]['id'];
          $proObj=new product_protection_class();
           $result=$proObj->ifIsDripCreated($userSubscribedProducts[$i]['id']);
           //do not show product link and drip lnks if no drips found and donotlink is checked
          if($result==false and $userSubscribedProducts[$i]['is_donotlink']==1)
           {
             if($userSubscribedProducts[$i]['is_linked_with_wp']==1){
                 $userSubscribedProducts[$i]['is_product_link_visible']=true;
                 $userSubscribedProducts[$i]['is_produc_visible']=true;
             }
             else{ 
             
                 $userSubscribedProducts[$i]['is_product_link_visible']=false;
                 $userSubscribedProducts[$i]['is_produc_visible']=false;
              }    
           }
          // only show drip links and product title if drips found and donotlink is checked  
          else if($result==true and $userSubscribedProducts[$i]['is_donotlink']==1)
          {
              $userSubscribedProducts[$i]['is_product_link_visible']=false;
              $userSubscribedProducts[$i]['is_produc_visible']=true;
          } 
         //show product link and drip links both if drips found and donotlink is unchecked    
         else if($result==true and $userSubscribedProducts[$i]['is_donotlink']==0)
          {
              $userSubscribedProducts[$i]['is_product_link_visible']=true;
              $userSubscribedProducts[$i]['is_produc_visible']=true;
          }  
        // show product link only if no drips found and donotlink is unchecked    
        else if($result==false and $userSubscribedProducts[$i]['is_donotlink']==0)
          {
              $userSubscribedProducts[$i]['is_product_link_visible']=true;
              $userSubscribedProducts[$i]['is_produc_visible']=true;
          }   
      } 
      
   
  $impoledValueSubscribedProds=(implode(',',$singleArrySubscribedProducts));   
  $proRequest=$product->getDripsProductsUrls( $impoledValueSubscribedProds);
  if($proRequest!=false and count($proRequest)>0)
  {
    $toatl=count($proRequest);  
    for($i=0;$i<=$toatl-1;$i++)
     {
           

           $tracking=$proRequest[$i]['trackingtype'];
          
           if($tracking==3)
            {
               $todayTimeStemp=strtotime(date("m/d/YH:i:s"));
               $StartDate=$proRequest[$i]['fromfixeddate']; 
               $enddate= $proRequest[$i]['uptofixeddate'];  
             
               if($todayTimeStemp >=  $StartDate  and  $todayTimeStemp<= $enddate)
                 $proRequest[$i]['expired']='no';
               else
                $proRequest[$i]['expired']='yes'; 
                
             }
           else if($tracking==1)
            {
            
                $fromdays=(int)$proRequest[$i]['fromdays'];
                $uptodays=(int)$proRequest[$i]['uptodays'];
                $productUserArr=$product->getProductUserPaidOnDate($proRequest[$i]['product_id'],$puserid);
                $paygearPaidOn=$productUserArr[0]['paygear_paidon'];
                
                $startDate=$paygearPaidOn+($fromdays *  86400); 
                $enddate=$startDate+($uptodays *  86400);
                $todayTimeStemp=strtotime(date("m/d/YH:i:s"));    
                
                
                if($todayTimeStemp>=$startDate and $uptodays=='*' )
                   $proRequest[$i]['expired']='no'; 
                else if($todayTimeStemp>=$startDate and $todayTimeStemp <=$enddate)   
                  $proRequest[$i]['expired']='no';
               else
                  $proRequest[$i]['expired']='yes'; 
                
            }                                                 
           else if($tracking==2) 
            {                                                           
                
                   $totalCLicks=(int)$proRequest[$i]['clicks'];
                   $dripIdArr=$product->getDripInfo($proRequest[$i]['id'],$proRequest[$i]['fileurl']); 
                   $dripId=$dripIdArr[0]['id'];
                   $getProductUserid=$product->getProductUserId($proRequest[$i]['product_id'],$puserid);
                   $userClicks=$product->getuser_clicks_for_drips($getProductUserid[0]['id'],$dripId);
                   if($userClicks==false)
                    {
                      $isAccessible=true;
                      $proRequest[$i]['expired']='no';
                 
                    }
                  else
                   {
                      $clicks=$userClicks[0]['clicks'];
                      if($clicks>=$totalCLicks)
                        $proRequest[$i]['expired']='yes'; 
                     else    
                       $proRequest[$i]['expired']='no'; 
                   }  
               
            
            }
           else if($proRequest[$i]['isfilefree']) 
            {
               $proRequest[$i]['expired']='no'; 
            }   
                                                          
         
         
        }
      
      
    }
 } 
                            
   
  $len=sizeof($arr);
  $allProducts=array();
  $counter=0;
  if($len>0)
   {
      foreach($arr as $key=>$val)
      {
         $specificProdcut=$objprodcalss->GetSpecificProduct($val);
         $allProducts[$counter]=$specificProdcut[0];
         $counter++;
      } 
   }
   
   /* modified by  nikunj for remove expired products */
  $productResultModifiedArray=array();
         
       if(is_array($allProducts) && sizeof($allProducts)>0)
          {
             for($i=0;$i<=sizeof($allProducts)-1;$i++)
               {
                  $productid=$allProducts[$i]['id'];
                  $queryExpireddate="select * from ".TABLE_PREFIX."productpaymentoptions where productid=".$productid;
                  $resultOfExpiredProducts=$objUserSignup->View($queryExpireddate); 
                  if($resultOfExpiredProducts[0]['duration_type']=='Exact date (mm-dd-yyyy)')              
                    {
                       $curentTimeStamp= strtotime(date("m/d/YH:i:s")); 
                       if($resultOfExpiredProducts[0]['duration_exactdate']<$curentTimeStamp)
                         {
                             //unset($productResults[$i]);
                             
                         }
                         else
                          {
                          $productResultModifiedArray[]=$allProducts[$i];  
                          }
                    
                    }
                 else
                  {
                    $productResultModifiedArray[]=$allProducts[$i];
                  
                  }   
                 
               
               }   
           
             $lenofproducts=sizeof($productResultModifiedArray);
          }
      else
         $lenofproducts=0;   
          
     $resetedArray=array(); 
     if($productResultModifiedArray!=false)
      {
     
            $prod_clss_obj=new product_class();
            $upsellProducts=$prod_clss_obj->getAllUpsellSubProducts();
            if($upsellProducts!=false and sizeof($upsellProducts) > 0)
            {
             $upsellProducts=$upsellProducts[0]['products'];
             $len=sizeof($productResultModifiedArray)-1;
             $prductArr=explode(",",$upsellProducts);
             for($i=0;$i<=$len;$i++)
             {
                if(in_array($productResultModifiedArray[$i]['id'],$prductArr))
                {
                   unset($productResultModifiedArray[$i]);
                }
             }

            }
            foreach($productResultModifiedArray as $arr)
            {
                 $proObj=new product_protection_class();
                  $result=$proObj->ifIsDripCreated($arr['id']);
                 
                 if($result==false and $arr['is_donotlink']==1)
                 {
                    if($arr['is_linked_with_wp']=="1"){
                      $resetedArray[]=$arr;   
                    }
                 
                 }
                 else
                     $resetedArray[]=$arr;
               
            }
      }
       
             
  $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('emailsubscription',$iuserEmailSubStatus);  
  $smarty->assign('subscribedProduct',     $userSubscribedProducts);
  $smarty->assign('subscribedDrips',     $proRequest); 
  
  $smarty->assign('products',$resetedArray); 
  $smarty->assign('productlen',$lenofproducts);
  $smarty->assign('msg',$message->GetMessage());
  //unset($_GET['msg']);
  $smarty->assign('payment',     $arrPayments);
  $smarty->assign('username', $lsUsername=$_SESSION[SESSION_PREFIX.'UserName']);  
  $DEFAULTPAGE = $smarty->fetch('user_default_page.tpl');
  $smarty->assign('USER_CONTENT',     $DEFAULTPAGE); 
  $smarty->display('user_page_main.tpl');
?>
Return current item: MembersGear