码迷,mamicode.com
首页 > Web开发 > 详细

php 外汇网站首页代码解剖

时间:2015-02-10 15:12:14      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

<?php if ( ! defined(‘BASEPATH‘)) exit(‘No direct script access allowed‘);



class Xwhcommonweal extends CI_Controller {
        
        //var $appUrl = ‘ ‘;
        var $appUrl = ‘http:// ‘;
        var $serviceUrl = ‘ /‘;
        var $appName = ‘ ‘;
        var $appTitle = ‘ ‘;
        var $appkey = ‘gongyi‘;
        var $language = ‘zh-CN‘;
        var $debug = false;
        /*
        var $data = array(
            ‘index‘=> ‘ ‘,
            ‘rule‘=> ‘http://1 ule‘,
            ‘updowm‘=> ‘h dowm‘,
            ‘commonweal‘=> ‘http: weal‘,
            ‘trading‘=> ‘htt g‘,
        );
        */
        var $data = array(
            //切换卡信息
            ‘index‘=> ‘ l‘,
            ‘rule‘=> ‘htt l/rule‘,
            ‘updowm‘=> ‘http://w monweal/updowm‘,
            ‘commonweal‘=> ‘http://we eal/commonweal‘,
            ‘trading‘=> ‘http://web. mmonweal/trading‘,
            //登录注册信息
            ‘loginUrl‘=> ‘http://web.so l/login‘,
            ‘registerUrl‘=> ‘http://we ation‘,
            ‘code‘=> ‘http://web.soc tion_code‘,
            ‘check_phone‘=> ‘http://web. heck_phone‘,
        );
        
    function __construct() {
        parent::__construct();
                // 保存一天
        //$lifeTime = 24 * 3600;
        //session_set_cookie_params($lifeTime);
        //session_start();
    }
        //首页
    public function index() {
                $data = $this->data;
                if($_SESSION[‘token‘]==‘‘){
                    $data[‘trading‘] = ‘‘;
                }
                $data[‘logininfo‘] = $this->exist_user();
                $welfare = $this->public_information();
                if($welfare[‘re‘]){
                    $data[‘total_balance‘] = $welfare[‘total_balance‘];
                    $data[‘total_profit‘] = $welfare[‘total_profit‘];
                    }else{
                    $data[‘total_balance‘] = ‘-‘;
                    $data[‘total_profit‘] = ‘-‘;    
                        }
                $data[‘headTitle‘] = $this->appTitle;
                $datas[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/index‘, $data,true);               
                $this->parser->parse($this->appName . ‘/layout‘, $datas);
    }
        //规则
        public function rule() {
                $data = $this->data;
                if($_SESSION[‘token‘]==‘‘){
                    $data[‘trading‘] = ‘‘;
                }
                $data[‘headTitle‘] = $this->appTitle;
                
                $data[‘logininfo‘] = $this->exist_user();
                $welfare = $this->public_information();
                if($welfare[‘re‘]){
                    $data[‘total_balance‘] = $welfare[‘total_balance‘];
                    $data[‘total_profit‘] = $welfare[‘total_profit‘];
                    }else{
                    $data[‘total_balance‘] = ‘-‘;
                    $data[‘total_profit‘] = ‘-‘;    
                        }
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/rule‘, $data,true);

                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        //获取经济商列表
        public function interdealerlist(){
            $url = $this->serviceUrl . ‘trusteeship/broker_list?token=‘.$_SESSION[‘token‘].‘&lang=‘.$this->lang.‘&source=‘. $this->appkey;
            $json = $this->getfunction($url);
            $array = json_decode($json, TRUE);
            var_dump($array);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
                $re = $array[‘data‘];
            }else{
                $re[‘re‘] = FALSE;
                $re[‘msg‘] = $array[‘msg‘];
            }
            var_dump($array);
            echo json_encode($re,TRUE);
            exit;
        }
        //涨跌
        public function updowm() {
                $data = $this->data;
                if($_SESSION[‘token‘]==‘‘){
                    $data[‘trading‘] = ‘‘;
                }
                $data[‘headTitle‘] = $this->appTitle;
                
                $data[‘logininfo‘] = $this->exist_user();
                $welfare = $this->public_information();
                if($welfare[‘re‘]){
                    $data[‘total_balance‘] = $welfare[‘total_balance‘];
                    $data[‘total_profit‘] = $welfare[‘total_profit‘];
                    }else{
                    $data[‘total_balance‘] = ‘-‘;
                    $data[‘total_profit‘] = ‘-‘;    
                        }
                $masterdata = $this->follow_master();
                if($masterdata->status == 200){
                    $list = $masterdata->data->tickets;
                    $sum = count($list);
                    for($i = 0;$i<$sum-1;$i++){
                         if(10>$i && $i>0){
                        $listdata[‘symbol‘] = $list[$i]->symbol;
                        $listdata[‘name‘] = $list[$i]->name;
                        //操作
                        if (strpos($list[$i]->cmd, ‘buy‘) != ‘flase‘) {//买涨
                            $listdata[‘cmd‘] = ‘做多‘;
                            $listdata[‘style‘] = ‘up‘;
                        } else if (strpos($list[$i]->cmd, ‘sell‘) != ‘flase‘) {//买跌
                            $listdata[‘cmd‘] = ‘做空‘;
                            $listdata[‘style‘] = ‘down‘;
                        }
                        $listdata[‘open_price‘] = $list[$i]->open_price;
                        $listdata[‘open_time‘] = $list[$i]->open_time;
                        $listdata[‘stoploss‘] = $list[$i]->stoploss;
                        $listdata[‘takeprofit‘] = $list[$i]->takeprofit;
                        $listdata[‘close_price‘] = $list[$i]->close_price;
                        $listdata[‘close_time‘] = $list[$i]->close_time;
                        $listdata[‘profit‘] = $list[$i]->profit;
                        $listdata[‘margin‘] = $list[$i]->margin;
                        $listdata[‘ror‘] = $list[$i]->ror;
                        $data[‘masterdata‘] .= $this->parser->parse($this->appName . ‘/mdl/updowmmdl‘, $listdata,true);
                         }
                    }
                    if($sum%10==0){
                        $pagenum = floor($sum/10);
                    }else{
                        $pagenum = floor($sum/10)+1;
                    }
                    $data[‘page‘] = $this->num_page($pagenum,0);
                    $data[‘pageurl‘] = $this->appUrl . ‘/masterpage‘;
                }else{
                    $data[‘masterdata‘] = ‘‘;
                    $data[‘page‘] = ‘‘;
                    $data[‘pageurl‘] = ‘‘;
                }
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/updowm‘, $data,true);

                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        public function num_page($num,$page){
                    
                    //显示分页
                    if($page<5){
                        for($i=1;$i<=$num;$i++){
                            $pages[‘num‘] = $i;
                            if($pages[‘num‘]<=5){
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }else if($num == $i){
                                $pages[‘num‘] = ‘...‘;
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                                $pages[‘num‘] = $i;
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                                }
                        }
                    }else if($page>=5&&$page<$num-5){
                        for($i=1;$i<=$num;$i++){
                            $pages[‘num‘] = $i;
                            if($pages[‘num‘]==1){
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                                $pages[‘num‘] = ‘...‘;
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }else if($pages[‘num‘] >= $page-2 && $pages[‘num‘] <= $page+2){
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }else if($num == $i){
                                $pages[‘num‘] = ‘...‘;
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                                $pages[‘num‘] = $i;
                                $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }
                        }
                    }else if($page>=$num-5 && $page<=$num){
                        for($i=1;$i<=$num;$i++){
                        $pages[‘num‘] = $i;
                            if($pages[‘num‘]==1){
                                    $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                                    $pages[‘num‘] = ‘...‘;
                                    $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }else if($pages[‘num‘]>$num-5 && $pages[‘num‘]<=$num){
                                    $data .= $this->parser->parse($this->appName . ‘/mdl/page‘, $pages,true);
                            }
                        }
                    }
                    
                    return $data;
        }
        //涨跌分页
        public function masterpage(){
                $request = $this->input->get();
                $masterdata = $this->follow_master();
                if($masterdata->status == 200){
                    $list = $masterdata->data->tickets;
                    $sum = count($list)-1;
                    for($i = 0;$i<$sum;$i++){
                        if($request[‘page‘]*10>$i && $i>($request[‘page‘]-1)*10){
                            $listdata[‘symbol‘] = $list[$i]->symbol;
                            $listdata[‘name‘] = $list[$i]->name;
                            //操作
                            if (strpos($list[$i]->cmd, ‘buy‘) != ‘flase‘) {//买涨
                                $listdata[‘cmd‘] = ‘做多‘;
                                $listdata[‘style‘] = ‘up‘;
                            } else if (strpos($list[$i]->cmd, ‘sell‘) != ‘flase‘) {//买跌
                                $listdata[‘cmd‘] = ‘做空‘;
                                $listdata[‘style‘] = ‘down‘;
                            }
                            $listdata[‘open_price‘] = $list[$i]->open_price;
                            $listdata[‘open_time‘] = $list[$i]->open_time;
                            $listdata[‘stoploss‘] = $list[$i]->stoploss;
                            $listdata[‘takeprofit‘] = $list[$i]->takeprofit;
                            $listdata[‘close_price‘] = $list[$i]->close_price;
                            $listdata[‘close_time‘] = $list[$i]->close_time;
                            $listdata[‘profit‘] = $list[$i]->profit;
                            $listdata[‘margin‘] = $list[$i]->margin;
                            $listdata[‘ror‘] = $list[$i]->ror;
                            $data[‘masterdata‘] .= $this->parser->parse($this->appName . ‘/mdl/updowmmdl‘, $listdata,true);  
                        }
                        
                    }
                    if($sum%10==0){
                        $pagenum = floor($sum/10);
                    }else{
                        $pagenum = floor($sum/10)+1;
                    }
                    $data[‘page‘] = $this->num_page($pagenum,$request[‘page‘]);
                }else{
                    $data[‘masterdata‘] = ‘‘;
                }
                echo json_encode($data,TRUE);
                exit;
        }
        //公益
        public function commonweal() {
                $data = $this->data;
                if($_SESSION[‘token‘]==‘‘){
                    $data[‘trading‘] = ‘‘;
                }
                $data[‘headTitle‘] = $this->appTitle;
                
                $data[‘logininfo‘] = $this->exist_user();
                $welfare = $this->public_information();
                if($welfare[‘re‘]){
                    $data[‘total_balance‘] = $welfare[‘total_balance‘];
                    $data[‘total_profit‘] = $welfare[‘total_profit‘];
                    }else{
                    $data[‘total_balance‘] = ‘-‘;
                    $data[‘total_profit‘] = ‘-‘;    
                        }
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/commonweal‘, $data,true);

                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        //我的交易
        public function trading() {
                $data = $this->data;
                $data[‘headTitle‘] = $this->appTitle;
                
                $data[‘logininfo‘] = $this->exist_user();
                //我的信息
                $myinfo = $this->myinfo();
                if($myinfo->status == 200){
                    $data[‘equity‘] = $myinfo->data->equity;
                    $data[‘balance‘] = $myinfo->data->balance;
                    $data[‘last_balance‘] = $myinfo->data->last_balance;
                    $data[‘ror‘] = $myinfo->data->ror;
                    $data[‘position‘] = $myinfo->data->position;
                    $data[‘profit‘] = $myinfo->data->profit;
                    $data[‘this_month_profit‘] = $myinfo->data->this_month_profit;
                    $data[‘following‘] = $myinfo->data->following;
                    $data[‘history‘] = $myinfo->data->history;
                    $data[‘account_type‘] = $myinfo->data->account_type;
                    $data[‘valid‘] = $myinfo->valid;
                    $data[‘history_balance‘] = $myinfo->history_balance;
                }
                //我的历史记录
                $mydata = $this->my_history();
                $data[‘listpage‘] = ‘none‘;
                if($mydata->status == 200){
                    $trader = $mydata->data->trader;
                    $position = $trader[0]->position;
                    $sum = count($position);
                    for($i = 0;$i<$sum;$i++){
                        if(10>$i && $i>0){
                            $listdata[‘ticket‘] = $position[$i]->ticket;
                            $listdata[‘id‘] = $position[$i]->id;
                            //操作
                            if (strpos($position[$i]->type, ‘buy‘) != ‘flase‘) {//买涨
                                $listdata[‘cmd‘] = ‘做多‘;
                                $listdata[‘style‘] = ‘up‘;
                            } else if (strpos($position[$i]->type, ‘sell‘) != ‘flase‘) {//买跌
                                $listdata[‘cmd‘] = ‘做空‘;
                                $listdata[‘style‘] = ‘down‘;
                            }
                            $listdata[‘symbol‘] = $position[$i]->symbol;
                            $listdata[‘volume‘] = $position[$i]->volume;
                            $listdata[‘open_price‘] = $position[$i]->open_price;
                            $listdata[‘open_time‘] = $position[$i]->open_time;
                            $listdata[‘close_price‘] = $position[$i]->close_price;
                             $listdata[‘close_time‘] = $position[$i]->close_time;
                            $listdata[‘profit‘] = $position[$i]->profit;
                            $listdata[‘margin‘] = $position[$i]->margin;
                            $listdata[‘ror‘] = $position[$i]->ror;
                            if($listdata[‘profit‘]<=0){
                                $listdata[‘donation‘] = ‘-‘;
                            }else{
                                $listdata[‘donation‘] = $listdata[‘profit‘]*0.2;
                            }
                            $data[‘masterdata‘] .= $this->parser->parse($this->appName . ‘/mdl/mytradingmdl‘, $listdata,true);
                        }
                    }
                    if($sum%10==0){
                        $pagenum = floor($sum/10);
                    }else{
                        $pagenum = floor($sum/10)+1;
                    }
                    $data[‘page‘] = $this->num_page($pagenum,0);
                    $data[‘pageurl‘] = $this->appUrl . ‘/historypage‘;
                }else{
                    $data[‘masterdata‘] = ‘‘;
                }
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/trading‘, $data,true);

                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        //我的历史交易分页
        public function historypage(){
                $request = $this->input->get();
                $mydata = $this->my_history();
                $data[‘listpage‘] = ‘none‘;
                if($mydata->status == 200){
                    $trader = $mydata->data->trader;
                    $position = $trader[0]->position;
                    $sum = count($position);
                    for($i = 0;$i<$sum;$i++){
                        if($request[‘page‘]*10>$i && $i>($request[‘page‘]-1)*10){
                            $listdata[‘ticket‘] = $position[$i]->ticket;
                            $listdata[‘id‘] = $position[$i]->id;
                            //操作
                            if (strpos($position[$i]->type, ‘buy‘) != ‘flase‘) {//买涨
                                $listdata[‘cmd‘] = ‘做多‘;
                                $listdata[‘style‘] = ‘up‘;
                            } else if (strpos($position[$i]->type, ‘sell‘) != ‘flase‘) {//买跌
                                $listdata[‘cmd‘] = ‘做空‘;
                                $listdata[‘style‘] = ‘down‘;
                            }
                            $listdata[‘symbol‘] = $position[$i]->symbol;
                            $listdata[‘volume‘] = $position[$i]->volume;
                            $listdata[‘open_price‘] = $position[$i]->open_price;
                            $listdata[‘open_time‘] = $position[$i]->open_time;
                            $listdata[‘close_price‘] = $position[$i]->close_price;
                             $listdata[‘close_time‘] = $position[$i]->close_time;
                            $listdata[‘profit‘] = $position[$i]->profit;
                            $listdata[‘margin‘] = $position[$i]->margin;
                            $listdata[‘ror‘] = $position[$i]->ror;
                            if($listdata[‘profit‘]<=0){
                                $listdata[‘donation‘] = ‘-‘;
                            }else{
                                $listdata[‘donation‘] = $listdata[‘profit‘]*0.2;
                            }
                            $data[‘masterdata‘] .= $this->parser->parse($this->appName . ‘/mdl/mytradingmdl‘, $listdata,true);
                        }
                    }
                    if($sum%10==0){
                        $pagenum = floor($sum/10);
                    }else{
                        $pagenum = floor($sum/10)+1;
                    }
                    $data[‘page‘] = $this->num_page($pagenum,$request[‘page‘]);
                    $data[‘pageurl‘] = $this->appUrl . ‘/masterpage‘;
                }else{
                    $data[‘masterdata‘] = ‘‘;
                }
                echo json_encode($data[‘masterdata‘],TRUE);
                exit;
        }
        /*
        //修改账号
        public function reviseuser() {
                $data = $this->data;
                $data[‘headTitle‘] = $this->appTitle;
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/revise-user‘, $data,true);
                $data[‘body-class‘] = ‘js-height‘;
                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
         */
        //修改密码
        public function revisepw() {
                $data = $this->data;
                $data[‘headTitle‘] = $this->appTitle;
                $data[‘logininfo‘] = $this->exist_user();
                $data[‘changepwd‘] = $this->appUrl.‘/changepwd‘;
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/revisepw‘, $data,true);
                $data[‘body-class‘] = ‘js-height‘;
                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        public function changepwd(){
            $request = $this->input->post();
            $data[‘token‘] = $_SESSION[‘token‘];
            $data[‘oldpwd‘] = $request[‘oldpwd‘];
            $data[‘newpwd‘] = $request[‘newpwd‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘user/changepwd‘;
            $json = $this->postfunction($data, $url);
            $array = json_decode($json, TRUE);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
            }else{
                $re[‘re‘] = FALSE;
            }
            echo json_encode($re,TRUE);
            exit;
        }
         //修改名字
        public function revisenike() {
                $data = $this->data;
                $data[‘headTitle‘] = $this->appTitle;
                $data[‘logininfo‘] = $this->exist_user();
                $data[‘changenike‘] = $this->appUrl.‘/changenike‘;
                $data[‘bodyHtml‘] = $this->parser->parse($this->appName . ‘/revisenike‘, $data,true);
                $data[‘body-class‘] = ‘js-height‘;
                $this->parser->parse($this->appName . ‘/layout‘, $data);
    }
        public function changenike(){
            $request = $this->input->post();
            $data[‘token‘] = $_SESSION[‘token‘];
            $data[‘nickname‘] = $request[‘username‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘user/‘;
            $json = $this->postfunction($data, $url);
            $array = json_decode($json, TRUE);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
                $_SESSION[‘name‘] = $request[‘username‘];
            }else{
                $re[‘re‘] = FALSE;
            }
            echo json_encode($re,TRUE);
            exit;
        }
        //判断用户是否登录,登录后显示用户信息
        public function exist_user() {
            if($_SESSION[‘token‘]==‘‘){
                $login = $this->parser->parse($this->appName . ‘/login/not_logged‘,‘‘,true);
            }else{
                //$data[‘reviseuser‘]=$this->appUrl . ‘/reviseuser‘;
                $data[‘revisepw‘]=$this->appUrl . ‘/revisepw‘;
                $data[‘revisenike‘]=$this->appUrl . ‘/revisenike‘;
                $data[‘signout‘]=$this->appUrl . ‘/signout‘;
                $data[‘index‘]=$this->appUrl;
                $data[‘name‘]=$_SESSION[‘name‘];
                $login = $this->parser->parse($this->appName . ‘/login/are_logged‘, $data,true);
            }
            return $login;
    }
        //判断用户是否登录,登录后显示用户信息
        public function exist_user_power() {
            if($_SESSION[‘token‘]==‘‘){
                $login = $this->parser->parse($this->appName . ‘/login/not_logged‘,‘‘,true);
            }else{
                //$data[‘reviseuser‘]=$this->appUrl . ‘/reviseuser‘;
                $data[‘revisepw‘]=$this->appUrl . ‘/revisepw‘;
                $data[‘revisenike‘]=$this->appUrl . ‘/revisenike‘;
                $data[‘signout‘]=$this->appUrl . ‘/signout‘;
                $login = $this->parser->parse($this->appName . ‘/login/are_logged‘, $data,true);
            }
            return $login;
    }
        //退出登录
        public function signout() {
            session_unset();
            session_destroy();
            $re[‘re‘]= TRUE;
            echo json_encode($re,TRUE);
            exit;
        }
        //手机号+邮箱+呢称注册
        //手机号+验证码注册
        public function registration(){
            $request = $this->input->post();
            
            if($request[‘type‘]==‘mobile‘){
                $data[‘mobile‘] = $request[‘phone‘];
                $data[‘captcha‘] = $request[‘verify‘];
                $data[‘password‘] = $request[‘password‘];
            }else{
                $data[‘mobile‘] = $request[‘phone‘];
                $data[‘email‘] = $request[‘email‘];
                $data[‘username‘] = $request[‘username‘];
                $data[‘password‘] = $request[‘password‘];
            }
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘user/register‘;
            $json = $this->postfunction($data, $url);
            $array = json_decode($json, TRUE);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
                $_SESSION[‘token‘] = $array[‘data‘][‘token‘];
                $_SESSION[‘uid‘] = $array[‘data‘][‘uid‘];
                $_SESSION[‘name‘] = $array[‘data‘][‘nikename‘];
            }else{
                $re[‘re‘] = FALSE;
            }
            echo json_encode($re,TRUE);
            exit;
        }
        
        //手机号+密码登录
        public function login(){
            $request = $this->input->post();
            $data[‘username‘] = $request[‘username‘];
            $data[‘password‘] = $request[‘password‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘user/login‘;
            $json = $this->postfunction($data, $url);
            $array = json_decode($json, TRUE);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
                $_SESSION[‘token‘] = $array[‘data‘][‘token‘];
                $_SESSION[‘uid‘] = $array[‘data‘][‘uid‘];
                $_SESSION[‘name‘] = $array[‘data‘][‘nickname‘];
            }else{
                $re[‘re‘] = FALSE;
            }
            echo json_encode($re,TRUE);
            exit;
        }
        //检测手机号是否已经被注册
        public function check_phone(){
            $phone = $this->input->get(‘phone‘);
            $url = $this->serviceUrl . ‘user/check/phone‘ . $phone;
            $json = $this->getfunction($url);
            $array = json_decode($json, TRUE);
            echo $array[‘data‘];
            exit;
        }
        //获取验证码
        public function verification_code(){
            $request = $this->input->get();
            $data[‘source‘] = $this->appkey;
            $param = ‘mobile=‘.$request[‘phone‘].‘&type=‘.$request[‘type‘].‘&Lang=‘.$this->lang.‘&source=‘. $this->appkey;
            $url = $this->serviceUrl . ‘user/captcha?‘ . $param;
            $json = $this->getfunction($url);
            $array = json_decode($json, TRUE);
            if($array[‘status‘] == 200){
                $re[‘re‘] = TRUE;
                $re = $array[‘data‘];
            }else{
                $re[‘re‘] = FALSE;
                $re[‘msg‘] = $array[‘msg‘];
            }
            echo json_encode($re,TRUE);
            exit;
        }
        /**
         * 
         *  公益信息
         * 
         *          
         */
        public function public_information(){
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘activity/gongyi_data?Lang=‘.$data[‘lang‘].‘&source=‘.$data[‘source‘];
            $json = $this->getfunction($url);
            $array = json_decode($json);
            if($array->status == 200){
                $re[‘re‘] = TRUE;
                $re[‘total_balance‘] = $array->data->total_balance;
                $re[‘total_profit‘] = $array->data->total_profit;
            }else{
                $re[‘re‘] = FALSE;
            }
            return $re;
        }
            /**
            *   订单信息
            * 
            */
        //我的信息
        public function myinfo(){
            $data[‘token‘] = $_SESSION[‘token‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘account?token=‘.$data[‘token‘].‘&lang=‘.$data[‘lang‘].‘&source=‘.$data[‘source‘];
            $json = $this->getfunction($url);
            return json_decode($json);
        }
        //我的历史记录
        public function my_history(){
            $data[‘token‘] = $_SESSION[‘token‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘position/history?token=‘.$data[‘token‘].‘&lang=‘.$data[‘lang‘].‘&source=‘.$data[‘source‘];
            $json = $this->getfunction($url);
            return json_decode($json);
        }
        //跟随高手
        public function follow_master(){
            $data[‘token‘] = $_SESSION[‘token‘];
            $data[‘lang‘] = $this->language;
            $data[‘source‘] = $this->appkey;
            $url = $this->serviceUrl . ‘activity/gongyi/ace_history?token=‘.$data[‘token‘].‘&lang=‘.$data[‘lang‘].‘&source=‘.$data[‘source‘];
            $json = $this->getfunction($url);
            return json_decode($json);
        } 
        //get请求接口
        public function getfunction($url) {

            $ch = curl_init();
            $timeout = 5;
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            $file_contents = curl_exec($ch);
            curl_close($ch);
            return $file_contents;
        }
        //post请求接口
        public function postfunction($post_data, $url) {
            if (is_array($post_data)) {
                $post_data = http_build_query($post_data);
            }
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, 1);
            // 把post的变量加上
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // 设为TRUE把curl_exec()结果转化为字符串,而不是直接输出
            $result = curl_exec($ch);
            curl_close($ch);
            return $result;
        }
        //put请求接口
        public function putfunction($url, $data, $method) {
            $ch = curl_init(); //初始化CURL句柄 
            curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //设为TRUE把curl_exec()结果转化为字串,而不是直接输出 
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //设置请求方式
            curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-HTTP-Method-Override: $method")); //设置HTTP头信息
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //设置提交的字符串
            $document = curl_exec($ch); //执行预定义的CURL 
            if (!curl_errno($ch)) {
                $info = curl_getinfo($ch);
                //echo ‘Took ‘ . $info[‘total_time‘] . ‘ seconds to send a request to ‘ . $info[‘url‘]; 
            } else {
                //echo ‘Curl error: ‘ . curl_error($ch); 
            }
            curl_close($ch);
            return $document;
        }
        
        //后台页面的编辑
        
        
}

 

php 外汇网站首页代码解剖

标签:

原文地址:http://www.cnblogs.com/leong/p/4283613.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!