php 外汇网站首页代码解剖

<?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;
        }

        //后台页面的编辑

}
时间: 2024-11-13 07:51:34

php 外汇网站首页代码解剖的相关文章

添加到收藏夹和设置首页代码大全

<HTML>    <HEAD>        <title>添加到收藏夹和设置首页代码大全</title>        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">        <meta name="CODE_LANGUAGE" Content="C#">   

添加到收藏夹和设为首页代码

设为首页 收藏本站

HTML页面添加到收藏夹和设为首页代码

<a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.smsyun.com/');">设为首页</a> <a href="javascript:window.external.AddFavorite('http://www.smsyun.com/','PHP学习笔记')">收藏本站</a>

BBS项目 注册界面and部分首页代码详解

forms # 创建注册form类class RegForm(forms.Form): #创建注册用户字段 username = forms.CharField( label='用户名', max_length=16, min_length=4, error_messages={ "max_length":"用户名最长不能超过16位", "min_length": "用户名最短不能少于4位", "required&q

2019.12.5-网站首页代码(浮动)

<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <title>布局实例</title></head><style type="text/css"> .menu{ list-style: none; background-color: #55a8ea; padding: 0; wi

wordpress优化之结合prism.js为编辑器自定义按钮转化代码

原文链接 http://ymblog.net/2016/07/24/wordpress-prism/ 继昨天花了一天一夜的时间匆匆写了主题Jiameil3.0之后,心中一直在想着优化加速,体验更好,插件更少,到目前为止,博客插件有多说,Crayon Syntax Highlighter代码高亮插件,super cache缓存插件,百度sitemap.在没有缓存的情况下,首页dom初识加载完成(不是document加载完成)的时间为5-6s左右,有缓存的情况下大概为2s左右,觉得慢了,查看源码,发

如何给WordPress安装百度统计代码

1.注册并登录百度统计,点击页面顶部的“网站中心”,然后点击右上角“+ 新增网站”,填写网站域名确定后,点击“复制代码”:2.登录 WordPress 后台,点击左侧导航栏“外观”里的“编辑”,然后点击右侧“模版”下面的“底部 (footer.php)”,将第一步中复制的访问分析代码粘贴到“”前面并点击“更新文件”:3.回到前面百度统计的“网站中心”,点击“首页代码状态”下面的刷新图标,如果图标左侧的文字从“未检测到代码”变为“代码安装正确”,说明搞定. 原创文章,转载请注明: 转载自 http

html复习第七天 京东首页布局完成

简直神了..代码刚刚好一千行,一行不多,一行不少.写完之后才算得..千分之一的概率..这!也!太!巧!了! 项目文件: index.html 首页代码(529行) images |–index.css 用于控制首页css代码(422行) |–reset.css 用于初始化css代码(49行) index.html代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/

Python黑科技:50行代码运用Python+OpenCV实现人脸追踪+详细教程+快速入门+图像识

嗨,我最亲爱的伙计们,很高兴我们又见面了. 首先先感谢朋友们的关注.当然我更希望认识与计算机相关的领域的朋友咱们一起探讨交流.重点说一下,我是真人,不是那些扒文章的自媒体组织,大家可以相互交流的! 本篇文章我们来讲一下关于AI相关的人脸追踪,人脸识别相关的一些知识.当然本篇教程为(上)部分,讲一下利用python+opencv来实现人脸识别与追踪,明后天出(下)部分,用python来通过指纹对比实现人脸验证.人脸解锁(大家感兴趣的可以提前关注哦). 这两节课呢,代码量都不是很多,鄙人尽量多注释点