C设计思路理念

<?php
error_reporting(0);
abstract class Controller {
    protected $registry;

    public function __construct($registry)
    {
        //设计思路理念
        $this->registry = $registry;

        $_SERVER['REQUEST_URI'];

        $str = http_build_query($_REQUEST);

        $_SERVER['REMOTE_ADDR'];
    }

    public function __get($key) {}

    public function __set($key, $value) {}
    public function exit( $json ) {
        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }
    /*
     *  检测必填参数*/
    public function must_params($data) {
        $return = true;
        foreach($data as $val) {
            if(empty($this->request->post[$val])) {         //必填参数不能为空
                $return = false;
                break;
            }
        }
        return $return;
    }
    /*
     *  需要登录的构造函数*/
    public function _construct($data) {
        foreach($data as $val) {
            if(empty($this->request->post[$val])) {         //必填参数不能为空
                return array('code'=>0,'message'=>'参数错误!');
                break;
            }
        }
        //验证token checkExpire()) //token有效期
        //token 是否正确
    }
    /*
     * 输出返回数据*/
    public function return_output($data,$type = 'JSON') {
        /*$this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($data));*/
        if(empty($type)) $type =  'JSON';
        if(strtoupper($type)=='JSON') {
            // 返回JSON数据格式到客户端 包含状态信息
//            header('Content-Type:text/html; charset=utf-8');
            header('Content-Type: application/json');
            exit(json_encode($data));
        }elseif(strtoupper($type)=='XML'){
            // 返回xml格式数据
            header('Content-Type:text/xml; charset=utf-8');
            exit(xml_encode($data));
        }elseif(strtoupper($type)=='EVAL'){
            // 返回可执行的js脚本
            header('Content-Type:text/html; charset=utf-8');
            exit($data);
        }else{
            // TODO 增加其它格式
        }
    }
        //获取距离
        //在线时间
        $online_time = formatOnlineTime($rVal['heartbeat']);
        $rVal = array_merge($rVal,$online_time);
        //当前位置数据
        //获取距离
        //当前位置
        //距离
        //经度
        //维度
        //地址
        //直播ID
        unset($rVal['heartbeat']);
    /*
     * 获取两点距离
     * */
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值