<?php
// require_once "../config/config.php";
require_once "peardb_class.php";
require_once INCLUDE_DIR."/master_class.php";
require_once INCLUDE_DIR."/cannedemail_class.php";
require_once INCLUDE_DIR."/autoresponder.php";
require_once INCLUDE_DIR."/users_class.php";
require_once INCLUDE_DIR."/product_class.php";
require_once INCLUDE_DIR."/product_protection_class.php";
require_once INCLUDE_DIR."/passgen.php";
require_once INCLUDE_DIR."/folderProtection.php";
require_once CONFIG_DIR.'/db.php';
class users_signup_class extends peardb_class
{
function listmailStatuscheck()
{
/* 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();
}
/*******************************************************************/
return $listmailProStatus;
}
function aweberStatuscheck()
{
/* update by nikunj for aweber setting **********************/
$aweberStatus=false;
if(function_exists('aweber_check_Plugin_structure') and function_exists('aweber_getAweber_status') and function_exists('aweber_adduserToList') )
{
$aweberStatus=aweber_getAweber_status();
}
/*******************************************************************/
return $aweberStatus;
}
function getresponseStatuscheck()
{
/* update by nikunj for aweber setting **********************/
$getresponseStatus=false;
if(function_exists('getresponse_check_Plugin_structure') and function_exists('getresponse_getAPI_KEY') and function_exists('getresponse_getGetresponse_status') and function_exists('getresponse_adduserToList') )
{
$getresponseStatus=getresponse_getGetresponse_status();
}
/*******************************************************************/
return $getresponseStatus;
}
function imnicamailStatuscheck()
{
/* update by nikunj for aweber setting **********************/
$imnicamailStatus=false;
if(function_exists('imnicamail_check_Plugin_structure') and function_exists('imnicamail_getImnicamail_status') and function_exists('imnicamail_adduserToList') )
{
$imnicamailStatus=imnicamail_getImnicamail_status();
}
/*******************************************************************/
return $imnicamailStatus;
}
function phpbbStatuscheck()
{
/* update by nikunj for phpbb setting **********************/
$phpbbStatus=false;
if(function_exists('phpbb_check_Plugin_structure') and function_exists('phpBB_getPhpbb_status') and function_exists('phpBB_get_product_id') )
{
$phpbbStatus=phpBB_getPhpbb_status();
}
/*******************************************************************/
return $phpbbStatus;
}
function wordpressStatuscheck(){
/* update by nikunj for phpbb setting **********************/
require_once "system_get_set_options_class.php";
$option_obj=new system_get_set_options_class();
$wordpressStatus=false;
if(function_exists('wordpress_check_Plugin_structure') and function_exists('wordpress_getWordpress_status') )
{
$wordpressStatus=wordpress_getWordpress_status();
}
/*******************************************************************/
if($wordpressStatus==true){
$getwordpressAbsPath=$option_obj->get_option('WORDPRESS_ABSPATH');
if($getwordpressAbsPath=="" or $getwordpressAbsPath==null)
$wordpressStatus=false;
}
return $wordpressStatus;
}
function View($pQuery, $pValues=false, $types=true, $pStart=0, $pEnd=0)
{
/*
global $mdb2;
$result;
$query = 'SELECT * FROM tbluser1 t limit 10;';
$resultset = $mdb2->query($query);
if(PEAR::isError($resultset))
{
die("Failed to issue query, error message : " . $resultset->getMessage());
}
while($row = $resultset->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$result[] = $row;
}
return $result;
*/
//print_r($pParameters);
return $this->BaseView($pQuery,$pValues,$types,$pStart,$pEnd);
}
function Update($pQuery, $pValues=false, $types=true)
{
return $this->BaseUpdate($pQuery, $pValues, $types);
}
function Insert($pQuery, $pValues=false, $types=true)
{
return $this->BaseInsert($pQuery, $pValues, $types);
}
function delete($pQuery, $pValues=false, $types=true)
{
return $this->BaseDelete($pQuery, $pValues,null);
}
function getProducts($pScope, $pGroup='0')
{
/*for($i=0;$i<strlen($pGroup)-1;$i++)
{
if((ord(substr($pGroup,$i,1))>=48 and ord(substr($pGroup,$i,1))<=57) or ord(substr($pGroup,$i,1))==44 or ord(substr($pGroup,$i,1))==45)
$pGroup;
else
{
$pGroup=0;
break;
}
} */
$pgroups=explode(',',$pGroup);
/*if(is_array($pgroups))
{
if(substr(strrev($pGroup),0,1)==",")
$pGroup=0;
}
else
$pGroup=0;
$groupFormat="(".$pGroup.")"; */
/*$query = "SELECT * FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='$pScope')
and IFNULL(`requiredanothersubscription`,'') = '' and IFNULL(`disallowedsubscriptions`,'') = ''
and (p.pricegroup=$pGroup) order by sortorder ASC, name ASC"; */
/*Changed By Asmita For OnetimeOffer*/
if($pGroup=='0')
{
if(isset($_GET['product']) and strtolower($_GET['product'])==strtolower("phpbb"))
{
if($this->phpbbStatuscheck())
{
$phpBBProductId=(int)phpBB_get_product_id();
$query = "SELECT * FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and p.`isonetimeoffer`!=1 and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='$pScope')
and IFNULL(`requiredanothersubscription`,'') = '' and IFNULL(`disallowedsubscriptions`,'') = ''
and p.id=$phpBBProductId
order by sortorder ASC, name ASC";
}
}
else
{
$query = "SELECT * FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and p.`isonetimeoffer`!=1 and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='$pScope')
and IFNULL(`requiredanothersubscription`,'') = '' and IFNULL(`disallowedsubscriptions`,'') = ''
and p.pricegroup >=0 order by sortorder ASC, name ASC";
}
}
else
{
$query = "SELECT * FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and p.`isonetimeoffer`!=1 and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='$pScope')
and IFNULL(`requiredanothersubscription`,'') = '' and IFNULL(`disallowedsubscriptions`,'') = ''
order by sortorder ASC, name ASC";
}
$productResults = users_signup_class::View($query);
$pgroups=explode(',',$pGroup);
/* update for 1,-2,-4 values in user signup */
$productArrayGroup="";
if($pGroup!='0')
{
$flag=true;
for($count=0;$count<=sizeof($pgroups)-1;$count++)
{
if(!is_numeric($pgroups[$count]) and !ord($pgroups[$count])==0)
{
$flag=false;
break;
}
}
if($flag==true)
{
if(is_array($productResults))
{
for($i=0;$i<=sizeof($productResults)-1;$i++)
{
$groupvaue=$productResults[$i]['pricegroup'];
$len=sizeof($pgroups);
$splitedGroupValue=explode(',',$groupvaue);
for($j=0;$j<=$len-1;$j++)
{
//if($pgroups[$j]<0)
//{
if(in_array($pgroups[$j],$splitedGroupValue))
{
$productArrayGroup[]=$productResults[$i];
break;
}
//}
}
}
}
}
}
if($pGroup!='0')
$productResults= $productArrayGroup;
$productResultModifiedArray="";
if(is_array($productResults))
{
for($i=0;$i<=sizeof($productResults)-1;$i++)
{
$productid=$productResults[$i]['id'];
$queryExpireddate="select * from ".TABLE_PREFIX."productpaymentoptions where productid=".$productid;
$resultOfExpiredProducts=users_signup_class::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[]=$productResults[$i];
}
}
else
{
$productResultModifiedArray[]=$productResults[$i];
}
}
}
$resetedArray=array();
$prod_clss_obj=new product_class();
$upsellProducts=$prod_clss_obj->getAllUpsellSubProducts();
if($productResultModifiedArray!=false)
{
if( 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;
}
}
return $resetedArray;
}
function getAlluserSubscribedProduct($pUserid,$pIsOneTImeOffer=false)
{
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$lsCurrentTimeStamp=strtotime(date("m/d/YH:i:s"));
if($pIsOneTImeOffer == false)
{
$query="SELECT p.`id`,p.`name`, p.`protectedurl`,p.`is_donotlink`, p.`is_linked_with_wp` FROM ".TABLE_PREFIX."products p
join ".TABLE_PREFIX."product_users tp on tp.productid=p.`id`
WHERE p.`IsApproved`=1
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and tp.userid=$pUserid and (tp.productmembershipstatusid=$masterValuesId) order by IFNULL(p.sortorder,10000),name ASC";
}
else
{
$query="SELECT p.`id`,p.`name`, p.`protectedurl`,p.`is_donotlink`,p.`is_linked_with_wp` FROM ".TABLE_PREFIX."products p
join ".TABLE_PREFIX."product_users tp on tp.productid=p.`id`
WHERE p.`IsApproved`=1
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and tp.userid=$pUserid and (tp.productmembershipstatusid=$masterValuesId) order by IFNULL(p.sortorder,10000),name ASC";
}
$arrUserSubscProducts = $this->BaseView($query);
return $arrUserSubscProducts;
}
/*** added by nikunj for one time offer to remove scope check and market place check ****/
function getProductsToSignupOneTimeOffer($pUserID,$pIsonetimeofferproductid)
{
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$result=array();
$lUser = new users_class();
/******Added By Asmita For One time Signup**********/
$lsonetimeoffer='';
$lsonetimeoffer="p.`isonetimeoffer`=1";
$userallradySubscribed=$this->getAlluserSubscribedProduct($pUserID,true);
$len=0;
if($userallradySubscribed!=false)
{
$len=sizeof($userallradySubscribed);
if($len>0)
{
for($i=0;$i<$len;$i++)
{
$arrAlreasySub[$i]=$userallradySubscribed[$i]['id'];
}
$implodedString=(implode(',',$arrAlreasySub));
}
}
//Get Products which user has not subscribed to
if($pIsonetimeofferproductid!='')
{ if($len>0)
{
/*query For One Time OFfer product select*/
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Signup') and p.id=$pIsonetimeofferproductid
and p.id not in($implodedString)";
}
else
{
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Signup') and p.id=$pIsonetimeofferproductid";
}
}
$arrProductNotSubscribed = $this->BaseView($query);
$arrProductId = $arrProductNotSubscribed[0]['productid'];
$lsStatus = '';
$lsRequiredProductId = 0;
$arrProductItem;
//print "<pre>";
//print_r($arrProductNotSubscribed);
//print "</pre>";
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$disallowedResult="";
if(is_array($arrProductNotSubscribed))
{
foreach($arrProductNotSubscribed as $key=>$productid)
{
//Filter Products if they required additional product subscription by user and if user has no subscription of the product
$query = "select `requiredanothersubscription` from ".TABLE_PREFIX."products p
WHERE p.`id` = ".$productid['productid'].";";
// /echo $query;
$arrRequiredProducts = $this->BaseView($query);
$arrRequiredProducts = $arrRequiredProducts[0]['requiredanothersubscription'];
//$arrRequiredProducts will be ACTIVE-14,EXPIRED-15
/*
print "<pre>";
print_r($arrRequiredProducts);
print "</pre>"; */
if($arrRequiredProducts != null and $arrRequiredProducts!='')
{
if(strpos($arrRequiredProducts,'-'))
{
$arrRequiredProducts = explode(',',$arrRequiredProducts);
/*
print "<pre>";
print_r($arrRequiredProducts);
print "</pre>";
*/
foreach($arrRequiredProducts as $key=>$RequiredProducts)
{
$arrProductItem = explode('-',$RequiredProducts);
if(sizeof($arrProductItem)==2 && is_array($arrProductItem))
{
$lsStatus = $arrProductItem[0]; //required status ie. active, expired
$lsRequiredProductId = $arrProductItem[1]; //This will be product id ie. 14
if(strtoupper(trim($lsStatus))=='ACTIVE')
{
$query = 'select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId. ' and productid='.$lsRequiredProductId.' and userid='.$pUserID;
//$query = 'select * from '.TABLE_PREFIX.'product_users where ((fromdate>='.time().' and uptodate<='.time().') or islifetime=1) and productid='.$lsRequiredProductId.' and userid='.$pUserID;
$arrTemp = $this->View($query,false);
/*
print( $query);
print "<pre>";
print_r($arrTemp);
print "</pre>";
*/
if(sizeof($arrTemp)>0 && is_array($arrTemp) && !in_array($productid,$result))
$result[] = $productid['productid'];
}
else if(strtoupper(trim($lsStatus))=='EXPIRED' && !in_array($productid,$result))
{
$payGearstatusValue="Expire";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$arrTemp = $this->View('select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId .' and productid='.$lsRequiredProductId.' and userid='.$pUserID,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp) && !in_array($productid,$result))
$result[] = $productid['productid'];
}
}
}
}
}
else
{
$result[] = $productid['productid'];
}
//Filter Products if they user is already having additional product subscription
$query = "select `disallowedsubscriptions` from ".TABLE_PREFIX."products p
WHERE p.`id` = ".$productid['productid'].";";
//echo $query;
$arrRequiredProducts = $this->BaseView($query);
$arrRequiredProducts = $arrRequiredProducts[0]['disallowedsubscriptions'];
//$arrRequiredProducts will be ACTIVE-14,EXPIRED-15
if($arrRequiredProducts != null and $arrRequiredProducts!='')
{
if(strpos($arrRequiredProducts,'-'))
{
$arrRequiredProducts = explode(',',$arrRequiredProducts);
foreach($arrRequiredProducts as $key=>$RequiredProducts)
{
$arrProductItem = explode('-',$RequiredProducts);
if(sizeof($arrProductItem)==2 && is_array($arrProductItem))
{
$lsStatus = $arrProductItem[0]; //required status ie. active, expired
$lsRequiredProductId = $arrProductItem[1]; //This will be product id ie. 14
if(strtoupper(trim($lsStatus))=='ACTIVE')
{
$payGearstatusValue="Active";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$query = 'select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId. ' and productid='.$lsRequiredProductId.' and userid='.$pUserID;
$arrTemp = $this->View($query,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp))
//$result = array_diff($result,array(array('productid' => $productid)));
$disallowedResult[] = $productid['productid'];
//array(array([productid] => 12))
}
else if(strtoupper(trim($lsStatus))=='EXPIRED' && !in_array($productid,$result))
{
$payGearstatusValue="Expire";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$arrTemp = $this->View('select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId .' and productid='.$lsRequiredProductId.' and userid='.$pUserID,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp))
$disallowedResult[] = $productid['productid'];
//$result = array_diff($result,array(array('productid' => $productid)));
}
}
}
}
}
}
}
$arrFinalResult;
if(is_array($result) && is_array($disallowedResult))
$arrFinalResult = array_diff($result,$disallowedResult);
else if(is_array($result))
$arrFinalResult = $result;
/*
print "<pre>";
print_r($result);
print_r($disallowedResult);
print "</pre>"; */
return $arrFinalResult;
}
/****************************************************************finish*********************************************************************/
function getProductsToSignupInMemberArea($pUserID,$pIsOneTImeOffer=false,$pIsonetimeofferproductid='')
{
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$result=array();
$lUser = new users_class();
/******Added By Asmita For One time Signup**********/
$lsonetimeoffer='';
if($pIsOneTImeOffer==true)
{
$lsonetimeoffer="IFNULL(p.`isonetimeoffer`,0)=1";
$userallradySubscribed=$this->getAlluserSubscribedProduct($pUserID,true);
}
else
{
$lsonetimeoffer= "IFNULL(p.`isonetimeoffer`,0)!=1";
$userallradySubscribed=$this->getAlluserSubscribedProduct($pUserID);
}
//$arrAlreasySub=array();
$len=0;
if($userallradySubscribed!=false)
{
$len=sizeof($userallradySubscribed);
if($len>0)
{
for($i=0;$i<$len;$i++)
{
$arrAlreasySub[$i]=$userallradySubscribed[$i]['id'];
}
$implodedString=(implode(',',$arrAlreasySub));
}
}
//Get Products which user has not subscribed to
if($pIsonetimeofferproductid=='')
{
if($len>0)
{
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`= 0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Member') and p.id not in($implodedString) ;";
}
else
{
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`= 0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Member') ;";
}
}
else
{ if($len>0)
{
/*query For One Time OFfer product select*/
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Member') and p.id=$pIsonetimeofferproductid
and p.id not in($implodedString)";
}
else
{
$query = "SELECT `id` as `productid` FROM ".TABLE_PREFIX."products p
WHERE p.`IsApproved`=1 and $lsonetimeoffer and p.`productstatusid`!=3
and (p.`IsDeleted`=0 or p.`IsDeleted` is null)
and (p.`isprohibited`=0 or p.`isprohibited` is null)
and p.`islinkedwithpaygear`=1
and (p.`paygear_productid` is not null and p.`paygear_productid`>0)
and (p.`scop` = 'Visible' or p.`scop`='Member') and p.id=$pIsonetimeofferproductid";
}
}
$arrProductNotSubscribed = $this->BaseView($query);
$arrProductId = $arrProductNotSubscribed[0]['productid'];
$lsStatus = '';
$lsRequiredProductId = 0;
$arrProductItem;
//print "<pre>";
//print_r($arrProductNotSubscribed);
//print "</pre>";
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$disallowedResult="";
if(is_array($arrProductNotSubscribed))
{
foreach($arrProductNotSubscribed as $key=>$productid)
{
//Filter Products if they required additional product subscription by user and if user has no subscription of the product
$query = "select `requiredanothersubscription` from ".TABLE_PREFIX."products p
WHERE p.`id` = ".$productid['productid'].";";
// /echo $query;
$arrRequiredProducts = $this->BaseView($query);
$arrRequiredProducts = $arrRequiredProducts[0]['requiredanothersubscription'];
//$arrRequiredProducts will be ACTIVE-14,EXPIRED-15
/*
print "<pre>";
print_r($arrRequiredProducts);
print "</pre>"; */
if($arrRequiredProducts != null and $arrRequiredProducts!='')
{
if(strpos($arrRequiredProducts,'-'))
{
$arrRequiredProducts = explode(',',$arrRequiredProducts);
/*
print "<pre>";
print_r($arrRequiredProducts);
print "</pre>";
*/
$flag_arr=array();
foreach($arrRequiredProducts as $key=>$RequiredProducts)
{
$arrProductItem = explode('-',$RequiredProducts);
if(sizeof($arrProductItem)==2 && is_array($arrProductItem))
{
$lsStatus = $arrProductItem[0]; //required status ie. active, expired
$lsRequiredProductId = $arrProductItem[1]; //This will be product id ie. 14
if(strtoupper(trim($lsStatus))=='ACTIVE')
{
$payGearstatusValue="Active";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$query = 'select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId. ' and productid='.$lsRequiredProductId.' and userid='.$pUserID;
//$query = 'select * from '.TABLE_PREFIX.'product_users where ((fromdate>='.time().' and uptodate<='.time().') or islifetime=1) and productid='.$lsRequiredProductId.' and userid='.$pUserID;
$arrTemp = $this->View($query,false);
/*
print( $query);
print "<pre>";
print_r($arrTemp);
print "</pre>";
*/
if(sizeof($arrTemp)>0 && is_array($arrTemp) && !in_array($productid['productid'],$result))
$flag_arr[]='true';
else
$flag_arr[]='false';
}
else if(strtoupper(trim($lsStatus))=='EXPIRED' && !in_array($productid['productid'],$result))
{
$payGearstatusValue="Expire";
$masterclassObj=new master_class();
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$payGearstatusValue="Expire";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$arrTemp = $this->View('select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId .' and productid='.$lsRequiredProductId.' and userid='.$pUserID,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp) && !in_array($productid['productid'],$result))
$flag_arr[]='true';
else
$flag_arr[]='false';
}
}
}
$flag=true;
foreach($flag_arr as $val)
{
if($val=='false')
{
$flag=false;
break;
}
}
if($flag==true)
$result[] = $productid['productid'];
}
}
else
{
$result[] = $productid['productid'];
}
//Filter Products if they user is already having additional product subscription
$query = "select `disallowedsubscriptions` from ".TABLE_PREFIX."products p
WHERE p.`id` = ".$productid['productid'].";";
//echo $query;
$arrRequiredProducts = $this->BaseView($query);
$arrRequiredProducts = $arrRequiredProducts[0]['disallowedsubscriptions'];
//$arrRequiredProducts will be ACTIVE-14,EXPIRED-15
if($arrRequiredProducts != null and $arrRequiredProducts!='')
{
if(strpos($arrRequiredProducts,'-'))
{
$arrRequiredProducts = explode(',',$arrRequiredProducts);
foreach($arrRequiredProducts as $key=>$RequiredProducts)
{
$arrProductItem = explode('-',$RequiredProducts);
if(sizeof($arrProductItem)==2 && is_array($arrProductItem))
{
$lsStatus = $arrProductItem[0]; //required status ie. active, expired
$lsRequiredProductId = $arrProductItem[1]; //This will be product id ie. 14
if(strtoupper(trim($lsStatus))=='ACTIVE')
{
$payGearstatusValue="Active";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$query = 'select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId. ' and productid='.$lsRequiredProductId.' and userid='.$pUserID;
$arrTemp = $this->View($query,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp))
//$result = array_diff($result,array(array('productid' => $productid)));
$disallowedResult[] = $productid['productid'];
//array(array([productid] => 12))
}
else if(strtoupper(trim($lsStatus))=='EXPIRED' && !in_array($productid,$result))
{
$payGearstatusValue="Expire";
$masterId=$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId=$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$arrTemp = $this->View('select * from '.TABLE_PREFIX.'product_users where productmembershipstatusid='.$masterValuesId .' and productid='.$lsRequiredProductId.' and userid='.$pUserID,false);
if(sizeof($arrTemp)>0 && is_array($arrTemp))
$disallowedResult[] = $productid['productid'];
//$result = array_diff($result,array(array('productid' => $productid)));
}
}
}
}
}
}
}
$arrFinalResult;
if(is_array($result) && is_array($disallowedResult))
$arrFinalResult = array_diff($result,$disallowedResult);
else if(is_array($result))
$arrFinalResult = $result;
/*
print "<pre>";
print_r($result);
print_r($disallowedResult);
print "</pre>"; */
return $arrFinalResult;
}
function getPayGearSalePageUrl($pProdId)
{
$query="select paygear_productpaymentoptionid from ".TABLE_PREFIX."productpaymentoptions where productid=$pProdId";
$result=$this->BaseView($query);
$liPayGearProOptId=$result[0]['paygear_productpaymentoptionid'];
return $liPayGearProOptId;
}
function insertToProductUser($pProductId,$pUserId)
{
global $mdb2;
$masterclassObj =new master_class();
$masterId =$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId =$masterclassObj->getMasterValuesId("Pending",$masterId);
$lsUserid = $pUserId;
$lspriceQuery ="select price from ".TABLE_PREFIX."products where id=$pProductId";
$result =$this->BaseView($lspriceQuery);
$amount =$result[0]['price'];
$liProductId = $pProductId;
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s"));
$lsIsLifeTimeCheckQuery ="select IsLifeTime from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$result =$this->BaseView($lsIsLifeTimeCheckQuery);
$isLifeTimeVal =$result[0]['islifetime'];
$insetQueryTempProdUser ="insert into ".TABLE_PREFIX."product_users(productid,userid,productmembershipstatusid,amount,fromdate, uptodate, islifetime)
values($pProductId,$lsUserid,$masterValuesId,$amount,$liFromDate,$liUptoDate,$isLifeTimeVal)";
$result =$this->Insert($insetQueryTempProdUser);
$lastInsertedId=$mdb2->lastInsertId(TABLE_PREFIX."product_users", 'id');
if($lastInsertedId>0)
return $lastInsertedId;
else
return false;
/*$lastInsertedRec="SELECT LAST_INSERT_ID() as id from ".TABLE_PREFIX ."product_users";
$resultLastRec=$this->View($lastInsertedRec);
$lastRecId=$resultLastRec['id'];
return $lastRecId; */
}
function test115()
{
$getListMailProStatus=$this->listmailStatuscheck();
if($getListMailProStatus)
{
$prod_clss_obj=new product_class();
$getListNum=$prod_clss_obj->getListMailPro_Value_for_product(11);
if($getListNum!=null or $getListNum!="" )
{
$userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array(84);
$laUserData = $this->View($userQuery,$lsUsersValues,null);
$isunsubscribe=$laUserData[0]['isunsubscribedfromemails'];
if($isunsubscribe!=1)
{
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
addUserToListMailPro_addUserToListMailPro($getListNum,$fname,$lname,$email);
}
}
}
}
function updateToProductUser($pPayGearResponse,$pProductId,$pUserId)
{
$queryProductInfo="SELECT * from ".TABLE_PREFIX."products where id=$pProductId";
$result=$this->View($queryProductInfo);
$ipnSecCode=$result[0]['ipnsecretcode'];
$querySubscription="SELECT count(*) as totalRecord FROM ".TABLE_PREFIX."product_users where userid=$pUserId";
$result=$this->View($querySubscription);
$totalCount=$result[0]['totalrecord'];
$ipnSecCode_paygear = trim($pPayGearResponse['pg_secret']);
$lsUserid = $pUserId;
$liProductId = $pProductId;
$payGear_eTranId =$pPayGearResponse['e_txn_id'];
$payGear_payment_gateway =$pPayGearResponse['e_processor_name'];
/* ipn sec code validation */
$is_ipn_sec_code_validate=true;
if($ipnSecCode_paygear!="")
{
if($ipnSecCode!=$ipnSecCode_paygear)
$is_ipn_sec_code_validate=false;
}
$paygear_paymentgetwayresponse ="";
$users=new users_class();
$loProductClass = new product_class();
foreach ($pPayGearResponse as $field=>$value) {
$post_string .= $field.'='.stripslashes($value).'&';
}
$paygear_paymentgetwayresponse =$post_string;
$paygear_paymentgetwayresponse=addslashes($paygear_paymentgetwayresponse);
$payGearE_Payment_Status =$pPayGearResponse['pg_txn_stat'];
if($payGearE_Payment_Status==0)
$payGearstatusValue="Inactive";
else if($payGearE_Payment_Status==1)
$payGearstatusValue="Active";
else if($payGearE_Payment_Status==2)
$payGearstatusValue="Pending";
/* $queryGetPaymentStValue ="select paygear_id from ".TABLE_PREFIX."paygear_mastervalues where paygear_master='ePaymentStatus' and paygear_value='$payGearstatusValue'";
$resultPaygerStValue =$this->BaseView($queryGetPaymentStValue);
$payGearPaymentStat =$resultPaygerStValue[0]['paygear_id']; */
$masterclassObj =new master_class();
$masterId =$masterclassObj->getMasterId("productmembershipstatus");
$masterValuesId =$masterclassObj->getMasterValuesId($payGearstatusValue,$masterId);
$paygearVendorStat =0;
$payGearPayMethod =$pPayGearResponse['payment_type'];
$payGear_orderid =$pPayGearResponse['pg_order_id'];
$paygear_paidon =strtotime(date("m/d/YH:i:s"));
$lsIsLifeTimeCheckQuery ="select IsLifeTime from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$result =$this->BaseView($lsIsLifeTimeCheckQuery);
$isLifeTimeVal =$result[0]['islifetime'];
$prodcalssObj=new product_class();
$prodid=$prodcalssObj->isValidProduct($pProductId);
/* updated by nikunj for renewal group */
$renewal_Prod_id=NULL;
$getSatusRenewal_Or_New_Subscription=$prodcalssObj->getRenwalProductRecord($prodid,$pUserId);
if($getSatusRenewal_Or_New_Subscription!=NULL and $getSatusRenewal_Or_New_Subscription!="")
{
$prodidRenwal=$prodcalssObj->getRenwalProductGroup($getSatusRenewal_Or_New_Subscription);
if($prodidRenwal==NULL or $prodidRenwal=="")
$prodidRenwal=$pProductId;
$is_valid_Product=$prodcalssObj->isValidProduct($prodidRenwal);
$renewal_Prod_id=$is_valid_Product;
}
/************************************************************************************************************/
if(($prodid!="" and isset($prodid) and $prodid!=NULL) and ($is_ipn_sec_code_validate==true))
{
if($renewal_Prod_id!=NULL and $renewal_Prod_id!="")
{
$lsIsLifeTimeCheckQueryRnewalGroup ="select IsLifeTime from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$result =$this->BaseView($lsIsLifeTimeCheckQueryRnewalGroup);
$isLifeTimeVal =$result[0]['islifetime'];
if($isLifeTimeVal!=1)
{
$lsdurationCheckQuery ="select duration_type from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$result =$this->BaseView($lsdurationCheckQuery);
$lsDurationType =$result[0]['duration_type'];
if(isset($lsDurationType) and $lsDurationType=="Months")
{
$igetMonthQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$resultMonthQuery = $this->BaseView($igetMonthQuery);
$lsDurationValue =$resultMonthQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue month");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Days")
{
$igetDayQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$resultDayQuery = $this->BaseView($igetDayQuery);
$lsDurationValue =$resultDayQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue day");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Years")
{
$igetYearQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$resultYearQuery = $this->BaseView($igetYearQuery);
$lsDurationValue =$resultYearQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue year");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Exact date (mm-dd-yyyy)")
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$igetexactdate ="select duration_exactdate from ".TABLE_PREFIX."productpaymentoptions where productid=$renewal_Prod_id";
$resultexactdateQuery = $this->BaseView($igetexactdate);
$lsDurationValue =$resultexactdateQuery[0]['duration_exactdate'];
$liUptoDate =$lsDurationValue;
}
}
else
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s"));
}
/* get max record id for this product user*/
$maxProdIdQuery ="SELECT max(id) as `maxid` FROM ".TABLE_PREFIX."product_users WHERE userid=$pUserId and productid=$pProductId ";
$res=$this->View($maxProdIdQuery);
$maxId=$res[0]['maxid'];
/************************************************/
$updateQueryTempProdUser ="update ".TABLE_PREFIX."product_users set fromdate=$liFromDate,uptodate=$liUptoDate,productmembershipstatusid=$masterValuesId,paygear_etransactionid='$payGear_eTranId', paygear_paymentgetway='$payGear_payment_gateway', paygear_paymentgetwayresponse='$paygear_paymentgetwayresponse',paygear_epaymentstatus=$payGearE_Payment_Status,paygear_vendorpaymentstatus=$paygearVendorStat,paygear_paymentmethod='$payGearPayMethod',paygear_orderid=$payGear_orderid,paygear_paidon=$paygear_paidon,islifetime=$isLifeTimeVal where userid=$pUserId and productid=$pProductId and id=$maxId";
$result =$this->Update($updateQueryTempProdUser);
/* $myFile = "error.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $updateQueryTempProdUser);
fwrite($fh, "\nRenewal\n$isLifeTimeVal");
fclose($fh); */
}
else
{
if($isLifeTimeVal!=1)
{
$lsdurationCheckQuery ="select duration_type from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$result =$this->BaseView($lsdurationCheckQuery);
$lsDurationType =$result[0]['duration_type'];
if(isset($lsDurationType) and $lsDurationType=="Months")
{
$igetMonthQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$resultMonthQuery = $this->BaseView($igetMonthQuery);
$lsDurationValue =$resultMonthQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue month");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Days")
{
$igetDayQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$resultDayQuery = $this->BaseView($igetDayQuery);
$lsDurationValue =$resultDayQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue day");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Years")
{
$igetYearQuery ="select duration from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$resultYearQuery = $this->BaseView($igetYearQuery);
$lsDurationValue =$resultYearQuery[0]['duration'];
if($lsDurationValue>0)
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s")." +$lsDurationValue year");
}
}
else if(isset($lsDurationType) and $lsDurationType=="Exact date (mm-dd-yyyy)")
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$igetexactdate ="select duration_exactdate from ".TABLE_PREFIX."productpaymentoptions where productid=$pProductId";
$resultexactdateQuery = $this->BaseView($igetexactdate);
$lsDurationValue =$resultexactdateQuery[0]['duration_exactdate'];
$liUptoDate =$lsDurationValue;
}
}
else
{
$liFromDate = strtotime(date("m/d/YH:i:s"));
$liUptoDate = strtotime(date("m/d/YH:i:s"));
}
/* get max record id for this product user*/
$maxProdIdQuery ="SELECT max(id) as `maxid` FROM ".TABLE_PREFIX."product_users WHERE userid=$pUserId and productid=$pProductId";
$res=$this->View($maxProdIdQuery);
$maxId=$res[0]['maxid'];
/************************************************/
$updateQueryTempProdUser ="update ".TABLE_PREFIX."product_users set fromdate=$liFromDate,uptodate=$liUptoDate,productmembershipstatusid=$masterValuesId,paygear_etransactionid='$payGear_eTranId', paygear_paymentgetway='$payGear_payment_gateway', paygear_paymentgetwayresponse='$paygear_paymentgetwayresponse',paygear_epaymentstatus=$payGearE_Payment_Status,paygear_vendorpaymentstatus=$paygearVendorStat,paygear_paymentmethod='$payGearPayMethod',paygear_orderid=$payGear_orderid,paygear_paidon=$paygear_paidon where userid=$pUserId and productid=$pProductId and id=$maxId";
$result =$this->Update($updateQueryTempProdUser);
/* $myFile = "error.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $updateQueryTempProdUser);
fclose($fh); */
}
if($payGearE_Payment_Status==1)
{
/* update by nikunj for htacess add new user*/
/*-------------------------------------------------------------------------------------------*/
$objSignupclass=new users_signup_class();
$objProtecfolderProtection_Class=new ProtecfolderProtection_Class();
$larrProtectedFoldersForProduct = $objSignupclass->getProtectedFoldersForProduct($pProductId);
$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);
}
}
}
/*$myFile = "error.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,MEMBER_USE_VALIDATE_INFO);
fclose($fh); */
$userQuery = 'SELECT username,password,secretsalt,email,firstname,lastname,isunsubscribedfromemails,isapproved FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $this->View($userQuery,$lsUsersValues,null);
$isunsubscribe=$laUserData[0]['isunsubscribedfromemails'];
$prod_clss_obj=new product_class();
if($totalCount==1)
{
if(MEMBER_USE_VALIDATE_INFO=='false')
{
$userStatusdupdate = "update " .TABLE_PREFIX."users set isapproved=1 where id=$pUserId";
$result =$this->Update($userStatusdupdate);
$phpBBStatus=false;
$phpBBStatus=$this->phpbbStatuscheck();
if($phpBBStatus)
{
$pro_Id=phpBB_get_product_id();
if($pro_Id==$pProductId)
{
$plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);
phpBB_registerUser($laUserData[0]['username'],$plainpass,$laUserData[0]['email'],0);
}
}
if($this->wordpressStatuscheck()){
$wordpressReqquiredFile= wordpress_physical_path_dir();
if(file_exists($wordpressReqquiredFile)){
$plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);
$createdUserId=wordpress_Register_User($laUserData[0]['username'],$plainpass,$laUserData[0]['email']);
if($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');
if(array_key_exists($pProductId,$savedRoles)){
$rolename=strtolower($savedRoles[$pProductId]);
wordpress_add_user_role($createdUserId,$rolename);
}
else{
$rolename=strtolower($savedRoles[$pProductId]);
wordpress_add_user_role($createdUserId,'subscriber');
}
}
}
}
}
else
{
//$linkid =@mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
//@mysql_select_db(DB_NAME, $linkid);
/*If Validate User =true Then Mail is Send*/
$templateQuery = 'SELECT id,status FROM '.TABLE_PREFIX.'email_templates WHERE name=\'Validate User\' AND productid=0';
$laTemplateData = $users->View($templateQuery);
$userQuery = 'SELECT username,password,secretsalt,email,firstname,lastname,isunsubscribedfromemails,isapproved FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $users->View($userQuery,$lsUsersValues,null);
$productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
$laProductValues = array($liProductId);
$laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
// if($laUserData[0]['isunsubscribedfromemails']=="0" )
SendCannedEmailsAutoresponse($laTemplateData[0]['id'],0,'Validate User','','',$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
$phpBBStatus=false;
$phpBBStatus=$this->phpbbStatuscheck();
if($phpBBStatus)
{
$pro_Id=phpBB_get_product_id();
if($pro_Id==$pProductId)
{
$plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);
phpBB_registerUser($laUserData[0]['username'],$plainpass,$laUserData[0]['email'],1);
}
}
}
/*********update by nikunj for listmailPro Settings ********************/
$getListMailProStatus=$this->listmailStatuscheck();
if($getListMailProStatus)
{
$getListNum=$prod_clss_obj->getListMailPro_Value_for_product($pProductId);
if($getListNum!=null or $getListNum!="" )
{
if($isunsubscribe!=1)
{
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
listmailpro_addUserToListMailPro($getListNum,$fname,$lname,$email);
$listopts = listmailpro_getlistopts($getListNum);
if($listopts[2]=='1') listmailpro_remlists($email,$getListNum,2);
if($listopts[3]=='1') listmailpro_addlists($email,$getListNum,3);
}
}
}
$linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
@mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
/***********************************************************************/
/* aweber add user *****************************************************/
$getawberStatus=$this->aweberStatuscheck();
if($getawberStatus)
{
if($isunsubscribe!=1)
{
$getListName=$prod_clss_obj->getAweber_Value_for_product($pProductId);
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
if(function_exists('curl_exec'))
aweber_adduserToList($email,$fname.' '.$lname,$getListName);
}
}
/***************************************************************************/
/* imnicamail add user *****************************************************/
$getimnicamailStatus=$this->imnicamailStatuscheck();
if($getimnicamailStatus)
{
if($isunsubscribe!=1)
{
$getListName=$prod_clss_obj->getimnicamail_Value_for_product($pProductId);
$getListName=$prod_clss_obj->getimnicamail_Value_for_product($pProductId);
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
if(function_exists('curl_exec'))
imnicamail_adduserToList($email,$fname.' '.$lname,$getListName);
}
}
/***************************************************************************/
/* getresponse add user *****************************************************/
$getrespoStatus=$this->getresponseStatuscheck();
if($getrespoStatus)
{
if($isunsubscribe!=1)
{
$getListName=$prod_clss_obj->getGetResponse_Value_for_product($pProductId);
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
$apiKey=getresponse_getAPI_KEY();
if(function_exists('curl_exec'))
getresponse_adduserToList($email,$fname.' '.$lname,$getListName,$apiKey);
}
}
/***************************************************************************/
}
else
{
/*** update by nikunj for phpbb settings ******************************************/
$phpBBStatus=false;
$phpBBStatus=$this->phpbbStatuscheck();
if($phpBBStatus)
{
$pro_Id=phpBB_get_product_id();
if($pro_Id==$pProductId)
{
$userdata_phpbb=phpBB_IFUser_Exist($laUserData[0]['username']);
if($userdata_phpbb!=null and $userdata_phpbb!="" and $userdata_phpbb!=false)
{
if(isset($userdata_phpbb['username']))
{
if(strtolower($userdata_phpbb['username'])== strtolower($laUserData[0]['username']))
{
phpBB_activate_deactivate_user($userdata_phpbb['username'],0);
}
}
}
else
{
$plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);
phpBB_registerUser($laUserData[0]['username'],$plainpass,$laUserData[0]['email'],0);
}
}
}
/***************************************************************/
/***************************************Wordpress**********************/
if($this->wordpressStatuscheck()){
$wordpressReqquiredFile= wordpress_physical_path();
if(file_exists($wordpressReqquiredFile)){
if($laUserData[0]['isapproved']=='1'){
$user_id = wordpress_username_exists( $laUserData[0]['username'] );
if ( $user_id ) {
$savedRoles=wordpress_get_option('membersgear_roles');
if(array_key_exists($pProductId,$savedRoles)){
$rolename=strtolower($savedRoles[$pProductId]);
wordpress_add_user_role($user_id,$rolename);
}
else{
$rolename=strtolower($savedRoles[$pProductId]);
wordpress_add_user_role($user_id,'subscriber');
}
}
else{
$isemailExist=wordpress_email_exists($laUserData[0]['email']);
if($isemailExist){
$plainpass=decrypt($laUserData[0]['password'],$laUserData[0]['secretsalt']);
$createdUserId=wordpress_Register_User($laUserData[0]['username'],$plainpass,$laUserData[0]['email']);
if($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');
if(array_key_exists($pProductId,$savedRoles)){
$rolename=strtolower($savedRoles[$pProductId]);
wordpress_add_user_role($createdUserId,$rolename);
}
else{
wordpress_add_user_role($createdUserId,'subscriber');
}
}
}
}
}
}
}
/************************************************************************/
/*********update by nikunj for listmailPro Settings ********************/
$getListMailProStatus=$this->listmailStatuscheck();
if($getListMailProStatus)
{
$prod_clss_obj=new product_class();
$getListNum=$prod_clss_obj->getListMailPro_Value_for_product($pProductId);
if($getListNum!=null or $getListNum!="" )
{
if($isunsubscribe!=1)
{
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
listmailpro_addUserToListMailPro($getListNum,$fname,$lname,$email);
$listopts = listmailpro_getlistopts($getListNum);
if($listopts[2]=='1') listmailpro_remlists($email,$getListNum,2);
if($listopts[3]=='1') listmailpro_addlists($email,$getListNum,3);
}
}
}
//here
$linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
@mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
/***********************************************************************/
/* aweber add user *****************************************************/
$getawberStatus=$this->aweberStatuscheck();
if($getawberStatus)
{
if($isunsubscribe!=1)
{
$getListName=$prod_clss_obj->getAweber_Value_for_product($pProductId);
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
if(function_exists('curl_exec'))
aweber_adduserToList($email,$fname.' '.$lname,$getListName);
}
}
/***************************************************************************/
/* getresponse add user *****************************************************/
$getrespoStatus=$this->getresponseStatuscheck();
if($getrespoStatus)
{
if($isunsubscribe!=1)
{
$getListName=$prod_clss_obj->getGetResponse_Value_for_product($pProductId);
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
$apiKey=getresponse_getAPI_KEY();
if(function_exists('curl_exec'))
getresponse_adduserToList($email,$fname.' '.$lname,$getListName,$apiKey);
}
}
/***************************************************************************/
/* imnicamail add user *****************************************************/
$getimnicamailStatus=$this->imnicamailStatuscheck();
if($getimnicamailStatus)
{
if($isunsubscribe!=1)
{
$fname=$laUserData[0]['firstname'];
$lname=$laUserData[0]['lastname'];
$email=$laUserData[0]['email'];
if(function_exists('curl_exec'))
imnicamail_adduserToList($email,$fname.' '.$lname,$getListName);
}
}
/***************************************************************************/
}
if(EMAIL_PRODUCT_SIGNUP=='true')
{
if(EMAIL_PRODUCT_SIGNUP_DAYS==0)
{
$userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $users->View($userQuery,$lsUsersValues,null);
$productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
$laProductValues = array($liProductId);
$laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
// if($laUserData[0]['isunsubscribedfromemails']=="0" )
SendCannedEmailsAutoresponse(EMAIL_PRODUCT_SIGNUP_TEMPLATE_ID,0,EMAIL_PRODUCT_SIGNUP_TEMPLATE_NAME,$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
}
}
if(EMAIL_PAYMENT_COMPLETED == 'true')
{
$userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $users->View($userQuery,$lsUsersValues,null);
$productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
$laProductValues = array($liProductId);
$laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
// if($laUserData[0]['isunsubscribedfromemails']=="0" )
SendCannedEmailsAutoresponse(EMAIL_PAYMENT_COMPLETED_TEMPLATE_ID,0,EMAIL_PAYMENT_COMPLETED_TEMPLATE_NAME,$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
}
}
else if($payGearE_Payment_Status==2)
{
if(EMAIL_PRODUCT_PAYMENT_PENDING == 'true')
{
if(EMAIL_PRODUCT_PAYMENT_PENDING_DAYS==0)
{
$userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $users->View($userQuery,$lsUsersValues,null);
$productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
$laProductValues = array($liProductId);
$laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
// if($laUserData[0]['isunsubscribedfromemails']=="0" )
SendCannedEmailsAutoresponse(EMAIL_PRODUCT_PAYMENT_PENDING_TEMPLATE_ID,0,EMAIL_PRODUCT_PAYMENT_PENDING_TEMPLATE_NAME,$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
}
}
}
else if($payGearE_Payment_Status==0)
{
if(EMAIL_PRODUCT_PAYMENT_FAILED == 'true')
{
if(EMAIL_PRODUCT_PAYMENT_FAILED_DAYS==0)
{
$userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
$lsUsersValues = array($pUserId);
$laUserData = $users->View($userQuery,$lsUsersValues,null);
$productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
$laProductValues = array($liProductId);
$laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
// if($laUserData[0]['isunsubscribedfromemails']=="0" )
SendCannedEmailsAutoresponse(EMAIL_PRODUCT_PAYMENT_FAILED_TEMPLATE_ID,0,EMAIL_PRODUCT_PAYMENT_FAILED_TEMPLATE_NAME,$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
}
}
}
}
return $result;
}
function getProtectedFoldersForProduct($pProductId) {
$result = false;
$lsIPNProductFolders = "select folder,protection_method from ".TABLE_PREFIX."product_protect pp
join ".TABLE_PREFIX."products p on p.`id` = pp.`allowed_productid`
where `allowed_productid`=$pProductId
and ifnull(p.IsApproved,1)=1
and ifnull(IsDeleted,0) != 1
and ifnull(`isProhibited`,0) != 1;";
$result = $this->View($lsIPNProductFolders);
//print "<pre>";
//print_r($result);
//print "</pre>";die;
return $result;
}
function getAllowedProductsFromProtectedFolder($folderPath)
{
$newQuery="select allowed_productid from ".TABLE_PREFIX."product_protect where folder='$folderPath' ";
$prodids=$this->View($newQuery);
if(is_array($prodids))
{
foreach($prodids as $key=>$val)
{
$prodid[]=$val['allowed_productid'];
}
}
return $prodid;
}
function writePostArrayTofile($pPostArr,$fileUrl)
{
$myFile = $fileUrl;
$fh = fopen($myFile, 'a') or die("can't open file");
foreach ($pPostArr as $field=>$value) {
if(is_array($value))
{
$strData='';
foreach($value as $k=>$avalue)
{
$strData.=$avalue."|";
}
$post_string = $field.'='.stripslashes($strData);
}
else
{
$post_string = $field.'='.stripslashes($value);
}
fwrite($fh, $post_string);
fwrite($fh, "\n");
}
fwrite($fh,$_COOKIE["POSTED"]);
fwrite($fh, "---------------------------------------\n");
fclose($fh);
}
function isSubscribedForEmail($spUserId)
{
$query="select isunsubscribedfromemails from ".TABLE_PREFIX ."users where id=$spUserId";
$lsusern=$this->View($query);
$emailSubscribe=$lsusern[0]['isunsubscribedfromemails'];
return $emailSubscribe;
}
function getUserDataByUserName($pUsername)
{
$query="select * from ".TABLE_PREFIX."users where username='$pUsername' limit 0,1";
$res=$this->View($query);
return $res;
}
function getUserActiveSubscriptionProductUrl($puserid,$preqprodurl)
{
$userSubscribedProducts=$this->getAlluserSubscribedProduct($puserid);
$singleArrySubscribedProducts=array();
$producturl=array();
if(count($userSubscribedProducts) > 0 and $userSubscribedProducts!=false)
{
for($i=0;$i<=count($userSubscribedProducts)-1;$i++)
{
$singleArrySubscribedProducts[]=$userSubscribedProducts[$i]['id'];
$producturl[]=$userSubscribedProducts[$i]['protectedurl'];
$proObj=new product_protection_class();
$result=$proObj->ifIsDripCreated($userSubscribedProducts[$i]['id']);
}
$impoledValueSubscribedProds=(implode(',',$singleArrySubscribedProducts));
$product=new product_protection_class();
$proRequest=$product->getDripsProductsUrls( $impoledValueSubscribedProds);
if(count($proRequest) > 0 and $proRequest!=false)
{
for($j=0;$j<=count($proRequest)-1;$j++)
{
$producturl[] =$proRequest[$j]['fileurl'];
}
}
if(count($producturl)>0)
{
if(in_array($preqprodurl,$producturl))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
}
/*
$user_signup = new users_signup_class();
$arr = $user_signup->getProductsToSignupInMemberArea(84);
print "<pre>";
print_r($arr);
print "</pre>"; */
?>