當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::sendJSON方法代碼示例

本文整理匯總了PHP中Response::sendJSON方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::sendJSON方法的具體用法?PHP Response::sendJSON怎麽用?PHP Response::sendJSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Response的用法示例。


在下文中一共展示了Response::sendJSON方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: elseif

 /**
  * 提交地址
  * 
  * @param Request $request
  * @param Response $response
  */
 function post_address(Request $request, Response $response)
 {
     $uid = $GLOBALS['user']->uid;
     if ($request->is_post()) {
         //送花獎勵階梯
         $sendmoney_phases = [30, 50, 100];
         $address_id = $request->post('address_id', 0);
         $match_id = $request->post('match_id', 0);
         $player_id = $request->post('player_id', 0);
         $order_id = $request->post('order_id', 0);
         $sendmoney = $request->post('sendmoney', 0);
         $backurl = $request->post('backurl', 0);
         $consignee = $request->post('consignee', '');
         $mobile = $request->post('mobile', '');
         $province = $request->post('province', 0);
         $city = $request->post('city', 0);
         $address = $request->post('address', '');
         $zipcode = $request->post('zipcode', '');
         $res = ['flag' => 'FAIL', 'msg' => '', 'match_id' => $match_id, 'backurl' => $backurl];
         if (empty($uid)) {
             $res['msg'] = '未登錄,請先登錄';
             $response->sendJSON($res);
         }
         if ('' == $consignee) {
             $res['msg'] = '姓名不能為空';
             $response->sendJSON($res);
         }
         if ('' == $mobile) {
             $res['msg'] = '手機不能為空';
             $response->sendJSON($res);
         } elseif (!preg_match('/^\\d{11,14}$/', $mobile)) {
             $res['msg'] = '手機號碼不正確';
             $response->sendJSON($res);
         }
         if (empty($province)) {
             $res['msg'] = '身份地址不能為空';
             $response->sendJSON($res);
         }
         $province_name = Match_Model::getLocationName($province);
         if (empty($city)) {
             $res['msg'] = '城市地址不能為空';
             $response->sendJSON($res);
         }
         $city_name = Match_Model::getLocationName($city);
         if ('' == $address) {
             $res['msg'] = '詳細地址不能為空';
             $response->sendJSON($res);
         }
         if ('' != $zipcode && !preg_match('/^\\d{6}$/', $zipcode)) {
             $res['msg'] = '郵政編碼不正確';
             $response->sendJSON($res);
         }
         $tbname = 'member_address';
         $tbdata = ['address_name' => '', 'user_id' => $uid, 'consignee' => $consignee, 'country' => 2, 'country_name' => '中國', 'province' => $province, 'province_name' => $province_name, 'city' => $city, 'city_name' => $city_name, 'district' => 0, 'district_name' => '', 'address' => $address, 'zipcode' => $zipcode, 'mobile' => $mobile];
         if (!$address_id) {
             // Insert mode
             $address_id = D()->insert($tbname, $tbdata);
         } else {
             // Edit mode
             D()->update($tbname, $tbdata, ['address_id' => $address_id]);
         }
         //送獎品記錄
         if ($address_id && $sendmoney >= $sendmoney_phases[0] && $player_id && $order_id) {
             $phasemoney = $sendmoney_phases[0];
             if ($sendmoney >= $sendmoney_phases[1] && $sendmoney < $sendmoney_phases[2]) {
                 $phasemoney = $sendmoney_phases[1];
             } elseif ($sendmoney >= $sendmoney_phases[2]) {
                 $phasemoney = $sendmoney_phases[2];
             }
             $tbdata = ['user_id' => $uid, 'address_id' => $address_id, 'player_id' => $player_id, 'order_id' => $order_id, 'phase_money' => $phasemoney, 'true_money' => $sendmoney, 'timeline' => simphp_time()];
             $rid = D()->from("member_giftpay")->where("`user_id`=%d AND `player_id`=%d AND `order_id`=%d", $uid, $player_id, $order_id)->select('`rid`')->result();
             if (!$rid) {
                 //一個訂單隻有沒有生成過記錄時才記錄,避免重複
                 D()->insert('member_giftpay', $tbdata);
             } else {
                 $res['flag'] = 'SUC';
                 $res['msg'] = '當前訂單之前申請過禮物,不能重複申請';
                 $response->sendJSON($res);
             }
         }
         $res['flag'] = 'SUC';
         $res['msg'] = '地址保存成功!';
         $response->sendJSON($res);
     } else {
         $this->v->set_tplname('mod_match_post_address');
         $this->v->set_page_render_mode(View::RENDER_MODE_GENERAL);
         $this->nav_flag1 = 'match_address';
         $this->topnav_no = 1;
         $match_id = $request->arg(1);
         $sendmoney = $request->get('sendmoney', 0);
         $player_id = $request->get('player_id', 0);
         $order_id = $request->get('order_id', 0);
         $backurl = $request->get('backurl', '');
         $this->v->assign('match_id', $match_id);
//.........這裏部分代碼省略.........
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:101,代碼來源:Match_Controller.php

示例2: import

 /**
  * action 'import'
  * @param Request $request
  * @param Response $response
  */
 public function import(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $source_id = $request->post('source_id');
         $source_url = $request->post('source_url');
         $ret = ['flag' => 'ERR', 'msg' => ''];
         if (!$source_id || !in_array($source_id, Node_Model::getSourceList('music', true))) {
             $ret['msg'] = '請選擇有效的來源';
             $response->sendJSON($ret);
         }
         if (!$source_url || !preg_match('!^http://.{4,}!i', $source_url)) {
             $ret['msg'] = '請輸入有效的URL地址';
             $response->sendJSON($ret);
         }
         Node_Model::importMusic($source_id, $source_url);
         $ret = ['flag' => 'OK', 'msg' => '導入成功!'];
         $response->sendJSON($ret);
     } else {
         // Node Info
         $import_ntype = $request->arg(2);
         $this->v->assign('nav_second', $import_ntype);
         // Music Source List
         $sourceList = Node_Model::getSourceList('music');
         $this->v->set_tplname('mod_node_import');
         $this->v->assign('sourceList', $sourceList);
         $response->send($this->v);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:33,代碼來源:Node_Controller.php

示例3: collect_cancel

 public function collect_cancel(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $res = ['flag' => 'FAIL', 'msg' => '取消失敗'];
         $ec_user_id = $GLOBALS['user']->ec_user_id;
         if (!$ec_user_id) {
             $res['msg'] = '未登錄, 請登錄';
             $response->sendJSON($res);
         }
         $rec_id = $request->post('rec_id', 0);
         if (!$rec_id) {
             $res['msg'] = '記錄id為空';
             $response->sendJSON($res);
         }
         $b = Goods::goodsCollectCancel($rec_id);
         if ($b) {
             $res = ['flag' => 'SUC', 'msg' => '取消成功'];
         }
         $response->sendJSON($res);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:21,代碼來源:User_Controller.php

示例4: upfile

 /**
  * 簡單上傳一個文件,然後用標準JSON格式返回文件的地址,不記錄數據庫數據
  * @param Request $request
  * @param Response $response
  */
 public function upfile(Request $request, Response $response)
 {
     if ($request->has_files()) {
         $upfile = $request->files('upfile');
         $dbsave = $request->get('dbsave', 0);
         $isplayer = $request->get('isplayer', 0);
         $extpart = strtolower(strrchr($upfile['name'], '.'));
         $fileext = substr($extpart, 1);
         $filetype = 'attach';
         if ('swf' == $fileext) {
             $filetype = 'flash';
         } elseif (in_array($fileext, array('jpg', 'jpeg', 'png', 'gif'))) {
             $filetype = 'pic';
         } elseif ('apk' == $fileext) {
             $filetype = 'android';
         } elseif ('ipa' == $fileext) {
             $filetype = 'ios';
         } elseif ('xap' == $fileext || 'cab' == $fileext) {
             $filetype = 'wp';
         } elseif (in_array($fileext, array('mp3'))) {
             $filetype = 'audio';
         }
         if ($isplayer) {
             $filetype = 'player';
         }
         //~ create directory
         $targetfilecode = date('d_His') . '_' . randchar();
         $targetfile = $targetfilecode . $extpart;
         $targetdir = ltrim($this->_uproot_dir, '/') . "{$filetype}/" . date('Ym') . '/';
         if ($isplayer) {
             $targetdir .= 'original/';
         }
         if (!is_dir($targetdir)) {
             mkdirs($targetdir, 0777, TRUE);
         }
         //~ move upload file to target dir
         $filepath = $targetdir . $targetfile;
         move_uploaded_file($upfile['tmp_name'], $filepath);
         chmod($filepath, 0644);
         if (file_exists($filepath)) {
             $mid = 0;
             $width = 0;
             $height = 0;
             $size = filesize($filepath);
             if ($filetype == 'pic') {
                 list($width, $height, $type, $attr) = getimagesize($filepath);
             }
             $filepath_site = C('env.contextpath', '/') . $filepath;
             //要補上網站的根路徑
             if ($dbsave) {
                 $data = ['mtype' => $filetype, 'filesize' => $size, 'path' => $filepath_site];
                 $mid = Media::save($data);
             }
             if ($isplayer) {
                 $rt = Upload_Model::makeImgThumb($filepath_site);
                 if (is_numeric($rt)) {
                     $response->sendJSON(['flag' => 'ERR', 'msg' => 'make thumb fail']);
                 } else {
                     $mid = Upload_Model::savePlayerGallery(0, $rt);
                 }
             }
             $response->sendJSON(['flag' => 'OK', 'msg' => 'upload file success', 'mid' => $mid, 'path' => $filepath_site, 'type' => $filetype, 'width' => $width, 'height' => $height, 'size' => $size]);
         }
         $response->sendJSON(['flag' => 'ERR', 'msg' => 'upload file error']);
     }
     $response->sendJSON(['flag' => 'ERR_NOFILES', 'msg' => 'no files upload']);
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:72,代碼來源:Upload_Controller.php

示例5: order_confirm_shipping

 /**
  * 取消訂單
  *
  * @param Request $request
  * @param Response $response
  */
 public function order_confirm_shipping(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $ret = ['flag' => 'FAIL', 'msg' => '取消失敗'];
         $ec_user_id = $GLOBALS['user']->ec_user_id;
         if (!$ec_user_id) {
             $ret['msg'] = '未登錄, 請登錄';
             $response->sendJSON($ret);
         }
         $order_id = $request->post('order_id', 0);
         if (!$order_id) {
             $ret['msg'] = '訂單id為空';
             $response->sendJSON($ret);
         }
         $b = Order::confirm_shipping($order_id);
         if ($b) {
             $ret = ['flag' => 'SUC', 'msg' => '確認成功', 'order_id' => $order_id];
         }
         $response->sendJSON($ret);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:27,代碼來源:Trade_Controller.php

示例6: show_jsonmsg

 function show_jsonmsg($content)
 {
     Response::sendJSON($content);
     exit;
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:5,代碼來源:fst.php

示例7: cities

 /**
  * 獲取省下的城市名列表
  *
  * @param Request $request
  * @param Response $response
  */
 function cities(Request $request, Response $response)
 {
     $parent_id = $request->get('parent_id', 0);
     $res = ['flag' => 'FAIL', 'msg' => ''];
     if (empty($parent_id)) {
         $res['msg'] = 'parent_id empty';
         $response->sendJSON($res);
     }
     $cities = Member_Model::getCities($parent_id);
     if (empty($cities)) {
         $res['msg'] = 'parent_id invalid';
         $response->sendJSON($res);
     }
     $res['flag'] = 'SUC';
     $res['msg'] = '';
     $res['data'] = $cities;
     $response->sendJSON($res);
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:24,代碼來源:Member_Controller.php

示例8: delete

 public function delete(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $ids = $request->post('rids');
         $ret = News_Model::delete($ids);
         $response->sendJSON(['flag' => 'OK', 'rids' => $ret]);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:8,代碼來源:News_Controller.php

示例9: ad_del

 public function ad_del(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $ids = $request->post('rids');
         $ret = Other_Model::deleteAdList($ids);
         $response->sendJSON(['flag' => 'OK', 'rids' => $ret]);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:8,代碼來源:Other_Controller.php

示例10: join

 public function join(Request $request, Response $response)
 {
     $res = ['flag' => 'FAIL', 'msg' => ''];
     if (Member::isLogined()) {
         $user = Member::getUser();
         $uid = $user['uid'];
     } else {
         $res['msg'] = '請先登錄';
         $response->sendJSON($res);
     }
     $aid = $request->post('aid', 0);
     $act = $request->post('act', '');
     $info = Activity_Model::getActivityByAid($aid);
     if (empty($info)) {
         $res['msg'] = '該活動不存在';
         $response->sendJson($res);
     }
     if (!in_array($act, ['join', 'vote'])) {
         $res['msg'] = '未知操作';
         $response->sendJson($res);
     }
     $inc = 1;
     if ($act == 'join') {
         $cur_time = time();
         if ($info['start_time'] > $cur_time) {
             $res['msg'] = '活動還沒有開始';
             $response->sendJson($res);
         }
         if ($info['end_time'] < $cur_time) {
             $res['msg'] = '活動已結束';
             $response->sendJson($res);
         }
         if (Activity_Model::isJoin($aid, $uid, 'join')) {
             $inc = -1;
             $res['msg'] = '您已經參與過本次活動了';
             $response->sendJson($res);
         }
     } elseif ($act == 'vote') {
         if (Activity_Model::isJoin($aid, $uid, 'vote')) {
             $inc = -1;
             /*
                     $res['msg'] = '已讚'; 
                     $response->sendJson($res);*/
         }
     }
     $jid = Activity_Model::joinActivity(['aid' => $aid, 'uid' => $uid, 'act' => $act, 'timeline' => time()], $inc);
     if ($jid > 0) {
         $res['flag'] = 'SUC';
         if ($act == 'join') {
             $res['msg'] = '參與成功';
         } elseif ($act == 'vote') {
             if ($inc > 0) {
                 $res['msg'] = '已讚';
             } else {
                 $res['msg'] = '已取消讚';
             }
         }
     } else {
         $res['msg'] = '係統繁忙,請稍後再試';
     }
     $response->sendJson($res);
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:62,代碼來源:Activity_Controller.php

示例11: relatedRank

 /**
  * 更新關聯數據的排序值
  * @param  Request  $request  [description]
  * @param  Response $response [description]
  * @return [type]             [description]
  */
 public function relatedRank(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $res = ['flag' => 'FAIL', 'msg' => ''];
         $aid = $request->post('aid', '');
         $nid = $request->post('nid', '');
         $new_rank = $request->post('new_rank', 0);
         if (Activity_Model::updateRelatedRank($aid, $nid, $new_rank)) {
             $res['flag'] = 'SUC';
             $res['msg'] = '更新成功';
         } else {
             $res['msg'] = '係統繁忙,請稍後再試';
         }
         $response->sendJSON($res);
     }
 }
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:22,代碼來源:Activity_Controller.php

示例12: checkLogin_ajax

/**
 * 檢測用戶是否登錄
 */
function checkLogin_ajax()
{
    $res = ['flag' => 'FAIL', 'msg' => '請先登錄'];
    if (!Member::isLogined()) {
        Response::sendJSON($res);
    }
}
開發者ID:GavinLai,項目名稱:SimMatch,代碼行數:10,代碼來源:func.common.php


注:本文中的Response::sendJSON方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。