⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pp.inc.php

📁 网络硬盘_支持1GB文件上传和续传_无错版
💻 PHP
字号:
<?/*** in this class,we ignore the Trial checking*/class PP_Validater{    //common payment    var $Amount=0;    //subscriptions data    var $SubsAmount=0;    var $SubsPeriod=0;    var $SubsUnit='D';    var $TrialAmount=0;    var $TrialPeriod=0;    var $TrialUnit='D';        var $Currency='USD';    var $item_name='';    var $item_number='';    var $PaymentType='';    var $PayeeAccount='';    var $BusinissAccount='';    /**    * load gateway setting    */    function PP_Validater(&$db)    {    $db->setQuery("select * from gateway where Provider='PP'");    $db->query();    $gateway=$db->loadRow();    $this->PayeeAccount=$gateway['PayeeAccount'];    $this->BusinissAccount=$gateway['BusinissAccount'];    $this->TestMode=$gateway['TestMode'];    $this->Currency=$gateway['Currency'];    }    /**    * load host plan infomation from groups    */    function LoadClient()    {    global $input,$user,$db;    if(isset($input[uid])) $user->uid=$input[uid];    $plan_id=$input[plan_id];    $info=split('-',$plan_id);    if(!$info[0])    {       die('Data error!');    }    $group_id=$info[0];    $plan_id=$info[1];    $db->setQuery("select * from groups where id='$group_id'");    $db->query();    $row=$db->loadRow();        $periods=split(',',$row[subscr_period]);    $fees=split(',',$row[subscr_fee]);    $this->PaymentType=$row[payment_type];    $this->SubsUnit=$this->TrialUnit=$row[subscr_unit];    $this->SubsPeriod=$periods[$plan_id];    $this->SubsAmount=$this->Amount=$fees[$plan_id];    $this->item_name=$row[name];    $this->item_number=$group_id.'-'.$plan_id;    $this->custom=$user->uid;    }    /**    * load vaild data to verify the IPN Data    */    function LoadServer($ipn)    {    global $db;    $plan_id=$ipn->GetVar('item_number');    $info=split('-',$plan_id);    if(!$info[0])    {        $ipn->SetError('Data error:No Group ID found!');        return false;    }    $group_id=$info[0];    $plan_id=$info[1];    /**    * load data from groups,because this is the first subscription created!    */    if($ipn->GetVar('txn_type')=='subscr_signup'    ||$ipn->GetVar('txn_type')=='subscr_modify'    ||$ipn->GetVar('txn_type')=='web_accept')    {        $db->setQuery("select * from groups where id='$group_id'");        $db->query();        if($db->getNumRows()==0)        {            $ipn->SetError('Data error:Group ID '.$group_id.' can not be found!');            return false;        }                $row=$db->loadRow();        $periods=split(',',$row[subscr_period]);        $fees=split(',',$row[subscr_fee]);                $this->PaymentType=$row[payment_type];        $this->SubsUnit=$row[subscr_unit];        $this->SubsPeriod=$periods[$plan_id];        $this->SubsAmount=$this->Amount=$fees[$plan_id];        $this->TrialUnit=$row[subscr_unit];        $this->TrialPeriod=0;        $this->TrialAmount=0;        return true;    }    /**    * if it is not the subscription created,we compare the ipn data with user's data    */    if($ipn->GetVar('txn_type')=='subscr_payment'      ||$ipn->GetVar('txn_type')=='subscr_cancel'    )    {        $uid=$ipn->GetVar('custom');        /**        * load host plan infomation from this user        */        $db->setQuery("select * from users where id='$uid'");        $db->query();        if($db->getNumRows()==0)        {            $ipn->SetError('Data error:USER ID '.$uid.' can not be found!');            return false;        }        $row=$db->loadRow();        $this->PaymentType=$row[payment_type];        $this->SubsUnit=$row[subscr_unit];        $this->SubsPeriod=$row[subscr_period];        $this->SubsAmount=$this->Amount=$row[subscr_fee];        $this->SubsID=$row[subscr_id];        /**        * the signup subscription was not recieved,        * ie:the subscr_payment is accepted first!        * so we use group data to overite the user's data        */        if($ipn->SubsID!=$this->SubsID&&$ipn->SubsID)        {             $db->setQuery("select * from groups where id='$group_id'");             $db->query();             if($db->getNumRows()==0)             {                 $ipn->SetError('Data error:Group ID '.$group_id.' can not be found!');                 return false;             }             $row=$db->loadRow();             $periods=split(',',$row[subscr_period]);             $fees=split(',',$row[subscr_fee]);             $this->PaymentType=$row[payment_type];             $this->SubsUnit=$row[subscr_unit];             $this->SubsPeriod=$periods[$plan_id];             $this->SubsAmount=$this->Amount=$fees[$plan_id];             $this->SubsID=$ipn->SubsID;        }    }    }    /**    * btach function to retrieve vaild data    */    function GetPayeeAcount()    {    return $this->PayeeAccount;    }    function GetAmount()    {    return $this->Amount;    }    function GetTrialAmount()    {    return $this->TrialAmount;    }    function GetTrialUnit()    {    return $this->TrialUnit;    }    function GetTrialPeriod()    {    return $this->TrialPeriod;    }    function GetSubsID()    {    return $this->SubsID;    }    function GetSubsAmount()    {    return $this->SubsAmount;    }    function GetSubsUnit()    {    return $this->SubsUnit;    }    function GetSubsPeriod()    {    return $this->SubsPeriod;    }    function GetCurrency()    {    return $this->Currency;    }    /**    * Process web accept payment    */    function ProcessWebAccept($ipn)    {    global $db;    $plan_id=$ipn->GetVar('item_number');    $info=split('-',$plan_id);    if(!$info[0])    {        $ipn->SetError('Data error:No Group ID found!');        return false;    }    $group_id=$info[0];            $uid=$ipn->GetVar('custom');    $dateinfo=array('D'=>24*60*60,'M'=>30*24*60*60,'Y'=>12*30*24*60*60);    /**    * load the user    */    $db->setQuery("select * from users where id='$uid'");    $db->query();    $row=$db->loadRow();    /**    * process the payment subscriptions    */    $txn_id=$ipn->GetTXNID();    $expire_date=time()>$row[expire_date]?time()+$dateinfo[$this->SubsUnit]*$this->SubsPeriod:$row[expire_date]+$dateinfo[$this->SubsUnit]*$this->SubsPeriod;    $db->setQuery("update users set expire_date='$expire_date',gid='$group_id' where id='$uid'");    $db->query();    $descr= mysql_escape_string('Payment for '.$ipn->GetVar('item_name').":\$$this->SubsAmount/$this->SubsPeriod $this->SubsUnit");    $db->setQuery("update $ipn->IPNTable set uid='$uid',descr='$descr' where txn_id='$txn_id'");    $db->query();    }    function ProcessCart($ipn)    {    global $db;    }    /**    * Process subscription    */    function ProcessSubscription($ipn)    {    global $db;    $uid=$ipn->GetVar('custom');    $dateinfo=array('D'=>24*60*60,'M'=>30*24*60*60,'Y'=>12*30*24*60*60);    /**    * load the user    */    $db->setQuery("select * from users where id='$uid'");    $db->query();    $row=$db->loadRow();    /**    * process the signup subscriptions    */    if($ipn->GetVar('txn_type')=='subscr_signup')    {        /**        * 1:the first subscrtion,        * or a new subscription where as the old one is expired        */        $db->setQuery("update users set subscr_id='$ipn->SubsID',subscr_period='$this->SubsPeriod',subscr_unit='$this->SubsUnit',subscr_fee='$this->SubsAmount',payment_type='subscriptions' where id='$uid'");        $db->query();        $descr= mysql_escape_string('Subscribed to '.$ipn->GetVar('item_name').":\$$this->SubsAmount/$this->SubsPeriod $this->SubsUnit");        $txn_id=$ipn->GetTXNID();        $db->setQuery("update $ipn->IPNTable set uid='$uid',descr='$descr' where record_id='$ipn->RecordID'");        $db->query();    }    /**    * process the signup subscriptions    */    if($ipn->GetVar('txn_type')=='subscr_modify')    {        /**        * 1:modify the old subscrtion,        */        $db->setQuery("update users set subscr_id='$ipn->SubsID',subscr_period='$this->SubsPeriod',subscr_unit='$this->SubsUnit',subscr_fee='$this->SubsAmount',payment_type='subscriptions' where id='$uid'");        $db->query();        $descr= mysql_escape_string('Upgrade to '.$ipn->GetVar('item_name').":\$$this->SubsAmount/$this->SubsPeriod $this->SubsUnit");        $txn_id=$ipn->GetTXNID();        $db->setQuery("update $ipn->IPNTable set uid='$uid',descr='$descr' where record_id='$ipn->RecordID'");        $db->query();    }    /**    * process the payment subscriptions    */    $txn_id=$ipn->GetTXNID();    $expire_date=time()>$row[expire_date]?time()+$dateinfo[$this->SubsUnit]*$this->SubsPeriod:$row[expire_date]+$dateinfo[$this->SubsUnit]*$this->SubsPeriod;    if($ipn->GetVar('txn_type')=='subscr_payment')    {        $plan_id=$ipn->GetVar('item_number');        $info=split('-',$plan_id);        if(!$info[0])        {           $ipn->SetError('Data error:No Group ID found!');           return false;        }        $group_id=$info[0];                $db->setQuery("update users set subscr_id='$ipn->SubsID',gid='$group_id',expire_date='$expire_date' where id='$uid'");        $db->query();        $descr= mysql_escape_string('Payment for '.$ipn->GetVar('item_name').":\$$this->SubsAmount/$this->SubsPeriod $this->SubsUnit");        $db->setQuery("update $ipn->IPNTable set uid='$uid',descr='$descr' where txn_id='$txn_id'");        $db->query();    }    /**    * process the signup subscriptions    */    if($ipn->GetVar('txn_type')=='subscr_cancel')    {        /**        * 1:empty the subscription infomation,        */        $db->setQuery("update users set subscr_id='',subscr_period='',subscr_unit='',subscr_fee='',payment_type='' where id='$uid' and subscr_id='$ipn->SubsID'");        $db->query();        $descr= mysql_escape_string('Cancel '.$ipn->GetVar('item_name').":\$$this->SubsAmount/$this->SubsPeriod $this->SubsUnit");        $txn_id=$ipn->GetTXNID();        $db->setQuery("update $ipn->IPNTable set uid='$uid',descr='$descr' where record_id='$ipn->RecordID'");        $db->query();    }    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -