Exemplo n.º 1
0
 function view()
 {
     COMFilter::$_jump = false;
     $clientmac = $_COOKIE['CLIENTMAC'];
     if (!$clientmac) {
         $boxmac = new COMGetmac();
         // print 'getmac';
         $clientmac = 'M' . $boxmac->getmac();
         setcookie("CLIENTMAC", $clientmac);
     }
     // print $clientmac;
     $clientboxid = intval($_COOKIE['CLIENTBOXID']);
     if (!$clientboxid) {
         $clientbox = new Boxs();
         $one = $clientbox->getOne("mac=?", $clientmac);
         if ($one) {
             $clientboxid = $one->id;
             setcookie("CLIENTMAC", $clientmac);
         }
     }
     // print 'id:'.$clientboxid;
     //实例化模板
     $tp = PHP_Templates::factory();
     $LOGGEDUSER = $_COOKIE['LOGGEDUSER'];
     if ($LOGGEDUSER) {
         $tp->title = "后台";
         //设置模板文件
         $tp->setFiles('default_back');
     } else {
         $tp->title = "测试";
         //设置模板文件
         $tp->setFiles('default');
         //统计
         Statistics::hitscounter(intval($clientboxid), "login", "login");
     }
     //输出页面
     $tp->execute();
     //释放模板变量
     unset($tp, $dataFilter);
 }
Exemplo n.º 2
0
 /**
  * 功能号:12080
  * 订单接口
  * */
 public function order_create()
 {
     COMFilter::$_jump = false;
     $clientmac = $_COOKIE['CLIENTMAC'];
     if (!$clientmac) {
         $boxmac = new COMGetmac();
         // print 'getmac';
         $clientmac = 'M' . $boxmac->getmac();
         setcookie("CLIENTMAC", $clientmac);
     }
     // print $clientmac;
     $clientboxid = intval($_COOKIE['CLIENTBOXID']);
     if (!$clientboxid) {
         $clientbox = new Boxs();
         $one = $clientbox->getOne("mac=?", $clientmac);
         if ($one) {
             $clientboxid = $one->id;
             setcookie("CLIENTMAC", $clientmac);
         }
     }
     $phone = Core::$_dataFilter->valueCheck(Core::get("phone"), "Require,Limit", "手机号不能为空,手机号最多11个字符", false, 11);
     $goodsid = 10001;
     if ($phone) {
         //统计
         Statistics::hitscounter(intval($clientboxid), "logined", "logined");
         $user = new Users();
         $addate = COMCommon::sysTime();
         $one = $user->getOne('user_name=?', $phone);
         if (empty($one)) {
             $id = $user->add($phone, $addate);
         } else {
             $id = $one->id;
         }
         setcookie("CLIENTPHONE", $phone);
         $token = new Users_token();
         //$host = '115.28.92.216';
         $host = $this->_host;
         $network = Core::connect_check($host);
         if ($network) {
             $param = array("m" => 12080, "phone" => $phone, "goods" => $goodsid);
             if (!$clientboxid) {
                 $param['mac'] = $clientmac;
             } else {
                 $param['box'] = $clientboxid;
             }
             $param['at'] = $_SERVER['REQUEST_TIME'];
             $one = $token->getOne("id = ? and end_time - UNIX_TIMESTAMP() > 0", $id);
             if (empty($one)) {
                 $param['pal'] = 1;
             }
             $sign = Core::get_signature($param);
             $param["sign"] = $sign;
             $url = "http://{$host}/tvmv/?m=12080";
             $temp = Core::request_url($url, $param, 1);
             $return = json_decode($temp);
             if ($return->status === 1) {
                 $data = $return->data;
                 if ($data->token) {
                     if (!$data->status) {
                         $order = new Orders();
                         $one = $order->getOne("order_sn=?", $data->ordersn, "pay_time desc");
                         if ($one) {
                             $one->status = 1;
                             $one->pay_time = date("Y-m-d H:i:s", $data->start_time);
                             $flag = $one->save();
                             if ($flag) {
                                 $one = $token->getOne("id = ?", $id);
                                 if ($one) {
                                     $flag = $token->edit(1, $data->ordersn, $data->token, $data->start_time, $data->end_time, 1, $data->code, $id);
                                 } else {
                                     $flag = $token->add($id, 1, $data->ordersn, $data->token, $data->start_time, $data->end_time, 1, $data->code);
                                 }
                                 if ($flag) {
                                     $this->notify_server($one, $data->token);
                                 }
                             }
                         }
                     }
                     setcookie("CLIENTTOKEN", $data->token);
                     $retval['token'] = $data->token;
                     Core::json_result($retval, '已支付');
                 } elseif ($data->ordersn) {
                     $order = new Orders();
                     $one = $order->getOne("order_sn=?", $data->ordersn, "pay_time desc");
                     if (empty($one)) {
                         $orderid = $order->add($data->ordersn, $id, 0, $clientboxid, 0, "", $goodsid, 0, 0, "", 1);
                         if ($orderid) {
                             $ordersn = $data->ordersn;
                         }
                     } else {
                         $ordersn = $one->order_sn;
                     }
                     setcookie("CLIENTORDERSN", $ordersn);
                     $retval['ordersn'] = $ordersn;
                     Core::json_result($retval, '订单生成');
                 }
             } else {
                 $msg = $return->msg;
                 Core::json_error($msg);
             }
         } else {
             $flag = $token->del("id = {$id} and end_time - UNIX_TIMESTAMP() < 0");
             $one = $token->getOne("id = ? and end_time - UNIX_TIMESTAMP() > 0", $id);
             if ($one) {
                 if ($one->status == 1) {
                     $flag = $this->notify_server($one, $one->token_id);
                 }
                 setcookie("CLIENTTOKEN", $one->token_id);
                 $retval['token'] = $one->token_id;
                 Core::json_result($retval, '已支付');
             } else {
                 $msg = "请购买观影服务!";
                 Core::json_error($msg);
             }
         }
     }
 }