Esempio n. 1
0
 public function index()
 {
     //http://cpanel.com/index.php?module=api&action=index
     $public = $this->_GET['token'];
     if ($public == '') {
         dd(11);
         exit;
     } else {
         $code = '';
         $AgentApiModule = new AgentApiModule();
         $where = "where public='{$public}'";
         $AgentoInfo = $AgentApiModule->GetLists($where);
         if (!empty($AgentoInfo)) {
             $code = $AgentoInfo[0]['code'];
             $update['code_temp'] = $code;
             $time = time();
             $str = $AgentoInfo[0]['private'] . $time . $AgentoInfo[0]['AgentID'];
             $update['code'] = sha1($str);
             $AgentApiModule->UpdateArrayByKeyID($update, $AgentoInfo[0]['id']);
         }
         echo $code;
         exit;
     }
 }
Esempio n. 2
0
 public function Lists()
 {
     include 'Include/LevelArray.php';
     $MysqlWhere = ' where 1';
     $Page = intval($this->_GET['Page']);
     $Page = $Page ? $Page : 1;
     $AgentModule = new AgentModule();
     $AgentApiModule = new AgentApiModule();
     $ListsNum = $AgentModule->GetListsNum($MysqlWhere);
     $Rscount = $ListsNum['Num'];
     $PageSize = 20;
     if ($Rscount) {
         $Data['RecordCount'] = $Rscount;
         $Data['PageSize'] = $PageSize ? $PageSize : $Data['RecordCount'];
         $Data['PageCount'] = ceil($Data['RecordCount'] / $PageSize);
         $Data['Page'] = min($Page, $Data['PageCount']);
         $Offset = ($Page - 1) * $Data['PageSize'];
         if ($Page > $Data['PageCount']) {
             $Page = $Data['PageCount'];
         }
         $Data['Data'] = $AgentModule->GetLists($MysqlWhere, $Offset, $Data['PageSize']);
         $AgentAccountModule = new AgentAccountModule();
         foreach ($Data['Data'] as $Key => $Value) {
             $Array['AgentID'] = $Value['AgentID'];
             $AgentApiInfo = $AgentApiModule->GetOneInfoByForID($Value['AgentID']);
             if (!empty($AgentApiInfo)) {
                 $Data['Data'][$Key]['Api']['url'] = $AgentApiInfo['url'];
                 $Data['Data'][$Key]['Api']['token'] = $AgentApiInfo['token'];
             }
             $AgentAccountInfo = $AgentAccountModule->GetLists('where AgentID=' . $Array['AgentID']);
             $Num = count($AgentAccountInfo);
             if ($Num == 0) {
                 $Data['Data'][$Key]['Total'] = '0';
                 $Data['Data'][$Key]['Balance'] = '0';
             } else {
                 foreach ($AgentAccountInfo as $V) {
                     $Data['Data'][$Key]['Total'] += $V['Total'];
                     $Data['Data'][$Key]['Balance'] += $V['Balance'];
                 }
             }
         }
         MultiPage($Data, 10);
         //dd($Data);
         $this->Data = $Data;
     }
 }
Esempio n. 3
0
 public function grenewals()
 {
     $public = array();
     $AgentID = $this->_POST['agentid'];
     $token = $this->_POST['_token'];
     $timemap = $this->_POST['timemap'];
     $public['AgentID'] = $AgentID;
     $public['timemap'] = $timemap;
     $AgentApiModule = new AgentApiModule();
     $AgentApiInfo = $AgentApiModule->GetOneInfoByForID($AgentID);
     if ($AgentID == '' || $token == '' || ($timemap = '' || empty($AgentApiInfo))) {
         die(jsonp(array('0', '数据提供错误'), 'JSONP'));
     }
     $type = $this->_POST['type'];
     $years = $this->_POST['years'];
     $id = $this->_POST['pid'];
     $public['private'] = $AgentApiInfo['private'];
     $verify = $this->verify($public, $token);
     if ($verify && $id != '') {
         $CustProModule = new CustProModule();
         $where = "where CustomersProjectID={$id} and AgentID={$AgentID}";
         $CustProInfo = $CustProModule->GetInfoByWhere($where);
         $OldEndTime = $CustProInfo['EndTime'];
         if (strtotime($OldEndTime) < time()) {
             $NewEndTime = date('Y-m-d H:i:s', strtotime("now + {$years} Years"));
         } else {
             $NewEndTime = date('Y-m-d H:i:s', strtotime("{$OldEndTime} + {$years} Years"));
         }
         $Update['EndTime'] = $NewEndTime;
         $filter['CustomersProjectID'] = $id;
         $filter['AgentID'] = $AgentID;
         if ($CustProModule->UpdateArray($Update, $filter)) {
             die(jsonp(array('0', '续费成功'), 'JSONP'));
         } else {
             die(jsonp(array('1001', '续费失败'), 'JSONP'));
         }
     } else {
         die(jsonp(array('1001', '数据提供错误'), 'JSONP'));
     }
 }