本文整理汇总了PHP中response类的典型用法代码示例。如果您正苦于以下问题:PHP response类的具体用法?PHP response怎么用?PHP response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Returns some basic info about the current user.
*
* @param $params - ignored, filled for API concurrency.
* @return response array with username, id, fullname
*
*/
function run($params)
{
if (currentuser::getInstance() != null) {
$response = new response('Success');
$user = currentuser::getInstance();
$response->set('name', $user->fullname);
$response->set('user', $user->getUsername());
$response->set('id', $user->getID());
return $response;
} else {
return new error('Access denied', 403);
}
}
示例2: fields
function fields()
{
$res = new response();
$db = $this->params["db"];
$table = $this->params["table"];
//query
$result = Doo::db()->fetchAll("SHOW COLUMNS IN {$table} IN {$db}");
foreach ($result as $row) {
$data[] = array('field' => $row["Field"], 'type' => $row["Type"], 'null' => $row['Null'], 'key' => $row['Key'], 'default' => $row['Default']);
}
$res->data = $data;
$res->success = true;
echo $res->to_json();
}
示例3: getProp
public function getProp()
{
$postCartId = input::get('catId');
try {
$userMdlProp = app::get("syscategory")->model('cat_rel_prop');
$propList = $userMdlProp->getList("*", array('cat_id' => $postCartId));
$pagedata = array();
foreach ($propList as $prop) {
// code...
$propId = $prop["prop_id"];
$propModel = app::get("syscategory")->model('prop_values');
$propValueList = $propModel->getList("*", array('prop_id' => $propId));
foreach ($propValueList as $propvalue) {
$pagedata[] = array("prop_value_id" => $propvalue["prop_value_id"], "prop_value" => $propvalue["prop_value"]);
}
$a = 1;
}
} catch (Exception $e) {
$msg = $e->getMessage();
return $this->splash('error', null, $msg);
} catch (\LogicException $e) {
$msg = $e->getMessage();
return $this->splash('error', null, $msg);
}
$ajaxdata = array('datas' => $pagedata);
return response::json($ajaxdata);
}
示例4: serveUserList
private function serveUserList()
{
$data = array('event' => 'userlist', 'data' => $this->clients);
response::all(json_encode($data), true);
$data['client'] = response::$current_socket_key;
response::me(json_encode($data));
}
示例5: check
public function check()
{
$this->params['app_id'] = $appid = isset($_POST['app_id']) ? $_POST['app_id'] : '';
$this->params['version_id'] = $versionid = isset($_POST['version_id']) ? $_POST['version_id'] : '';
$this->params['version_mini'] = $versionmini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
$this->params['did'] = $did = isset($_POST['did']) ? $_POST['did'] : '';
$this->params['encrypt_did'] = $encryptdid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
// 接口数据校验省略,实际使用时须加
if (!is_numeric($appid)) {
response::getEncode(300, 'params error', '');
exit;
}
// 判断APP是都要加密
$this->app = $this->getApp($appid);
if (!$this->app) {
response::getEncode(500, 'params error', '');
exit;
}
/*
if($encryptdid!=md5($did,$this->app['key'])){
response::getEncode(500,'md5 error','');
exit();
}
*/
}
示例6: execTinyMce
protected function execTinyMce($prm=null) {
$search = 'js/tiny_mce/';
$request = request::get('request');
$pos = strpos($request, $search);
if ($pos === false)
exit;
$tmp = substr($request, $pos+strlen($search));
$file = file::nyroExists(array(
'name'=>'lib'.DS.'tinyMce'.DS.$tmp,
'realName'=>true,
'type'=>'other'
));
if (strpos($file, '.php') !== false) {
array_walk($_GET, create_function('&$v', '$v = urldecode($v);'));
$path = str_replace($tmp, '', $file);
ini_set('include_path', $path);
define('TINYMCEPATH', substr($path, 0, -1));
define('TINYMCECACHEPATH', substr(TMPROOT, 0, -1));
if (ob_get_length())
ob_clean();
include($file);
exit;
} else
response::getInstance()->showFile($file);
}
示例7: afterRoute
/**
* compile and send the json response.
*/
public function afterRoute($f3, $params)
{
$version = (int) $f3->get('GET.version');
if (empty($version)) {
$version = $this->version;
}
if ($version !== $this->version) {
$this->failure(4999, 'Unknown API version requested.', 400);
}
if (empty($this->data['href'])) {
$data['href'] = $this->href();
}
$data = array('service' => 'API', 'api' => $version, 'time' => time()) + $this->data;
// if an OAuthError is set, return that instead of errors array
if (!empty($this->OAuthError)) {
$data['error'] = $this->OAuthError;
} else {
if (count($this->errors)) {
ksort($this->errors);
$data['errors'] = $this->errors;
}
}
$return = $f3->get('GET.return');
switch ($return) {
case 'xml':
$this->response->xml($data, $this->params);
break;
default:
case 'json':
$this->response->json($data, $this->params);
}
}
示例8: ajaxCouponData
public function ajaxCouponData()
{
$filter = input::get();
if (!$filter['pages']) {
$filter['pages'] = 1;
}
$pageSize = 10;
$params = array('page_no' => $pageSize * ($filter['pages'] - 1), 'page_size' => $pageSize, 'fields' => '*', 'user_id' => userAuth::id());
$couponListData = app::get('topm')->rpcCall('user.coupon.list', $params, 'buyer');
$count = $couponListData['count'];
$couponList = $couponListData['coupons'];
//处理翻页数据
$current = $filter['pages'] ? $filter['pages'] : 1;
$filter['pages'] = time();
if ($count > 0) {
$total = ceil($count / $pageSize);
}
$pagedata['pagers'] = array('link' => url::action('topm_ctl_member_coupon@couponList', $filter), 'current' => $current, 'total' => $total, 'token' => $filter['pages']);
$pagedata['couponList'] = $couponList;
$pagedata['count'] = $count;
$pagedata['action'] = 'topm_ctl_member_coupon@couponList';
if (input::get('json')) {
$data['html'] = view::make('topm/member/coupon/list.html', $pagedata)->render();
$data['pagers'] = $pagedata['pagers'];
$data['success'] = true;
return response::json($data);
exit;
}
return view::make('topm/member/coupon/list.html', $pagedata);
}
示例9: updateBusinessInfor
/**
* @param $businessId
* @param $shopfrontPic
* @param $licencePic
* @throws Exception
*/
function updateBusinessInfor($businessId, $shopfrontPic, $licencePic)
{
$businessName = $_REQUEST['$businessName'];
$startTime = $_REQUEST['$startTime'];
$endTime = $_REQUEST['$endTime'];
$lon = $_REQUEST['$lon'];
$lat = $_REQUEST['$lat'];
$mobilePhone = $_REQUEST['$mobilePhone'];
$sortF = $_REQUEST['$sortF'];
$sortS = $_REQUEST['$sortS'];
$privileges = $_REQUEST['$privileges'];
$description = $_REQUEST['$description'];
$serviceindex = $_REQUEST['$serviceindex'];
$province = $_REQUEST['$province'];
$city = $_REQUEST['$city'];
$addresDetail = $_REQUEST['$addresDetail'];
$fixTelephone = $_REQUEST['$fixTelephone'];
// 字符必须添加'',数字不必添加
$sqlUpdate = "UPDATE\n `business`\n SET\n `name` = '{$businessName}',\n `sortF` = {$sortF},\n `sortS` = {$sortS},\n `privileges` = '{$privileges}',\n `picUrl` = '{$shopfrontPic}',\n `description` = '{$description}',\n `businessSTime` = {$startTime},\n `businessETime` = {$endTime},\n `licensePicUrl` = '{$licencePic}',\n `mobilePhone` = '{$mobilePhone}',\n `serviceindex` = {$serviceindex},\n `longitude` = {$lon},\n `latitude` = {$lat},\n `province` = {$province},\n `city` = {$city},\n `addresDetail` = '{$addresDetail}',\n `fixTelephone` = '{$fixTelephone}'\n WHERE\n `business`.`id` = {$businessId}";
$connect = db::getInstance()->connect();
$result = mysqli_query($connect, $sqlUpdate);
if ($result) {
echo '更新基本数据成功';
} else {
echo response::show(201, '更新基本数据失败');
}
}
示例10: toHtml
public function toHtml()
{
if ($this->cfg->useJs) {
$this->cfg->setInArray('html', 'class', $this->cfg->getInArray('html', 'class') . ' date');
$resp = response::getInstance();
$resp->addJs('jqueryui');
if (($lang = request::get('lang')) != 'en') {
$resp->addJs('i18n_ui.datepicker-' . $lang);
}
$jsPrmMin = $this->cfg->jsPrm;
$jsPrmMax = $this->cfg->jsPrm;
$minId = $this->makeId($this->name . '[0]');
$maxId = $this->makeId($this->name . '[1]');
$minDate = $this->dates['min']->getJs(null);
$maxDate = $this->dates['max']->getJs(null);
$jsPrmMin['onSelect'] = 'function(dateText) {$("#' . $maxId . '").datepicker("option", "minDate", $("#' . $minId . '").datepicker("getDate"));}';
if ($maxDate) {
$jsPrmMin['maxDate'] = $maxDate;
}
$jsPrmMax['onSelect'] = 'function(dateText) {$("#' . $minId . '").datepicker("option", "maxDate", $("#' . $maxId . '").datepicker("getDate"));}';
if ($minDate) {
$jsPrmMax['minDate'] = $minDate;
}
$resp->blockJquery('
$("#' . $minId . '").datepicker(' . utils::jsEncode($jsPrmMin) . ');
$("#' . $maxId . '").datepicker(' . utils::jsEncode($jsPrmMax) . ');
');
}
return parent::toHtml();
}
示例11: __construct
public function __construct()
{
$endpoint = $this;
if ($page = page('webmention') and kirby()->path() == $page->uri()) {
if (r::is('post')) {
try {
$endpoint->start();
header::status(202);
tpl::set('status', 'success');
tpl::set('alert', null);
} catch (Exception $e) {
header::status(400);
tpl::set('status', 'error');
tpl::set('alert', $e->getMessage());
}
} else {
tpl::set('status', 'idle');
}
} else {
kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) {
try {
$endpoint->start();
echo response::success('Yay', 202);
} catch (Exception $e) {
echo response::error($e->getMessage());
}
})));
}
}
示例12: sys_sync
/**
* System interfaces syncronization
* @access protected
*/
protected function sys_sync()
{
// Сбросить со всех записей признака проверен (поле check)
$this->_flush();
$this->insert_on_empty = false;
$this->push_args(array('exist' => 0, '_sexist' => 1));
$this->_set();
$this->pop_args();
$ep = data_interface::get_instance('entry_point');
$interfaces = array('ui' => $this->get_di_array(), 'di' => $this->get_ui_array());
$ep->register($interfaces);
// Удаляем все ТВ, которые в процессе синхронизации не были отмечены как существующие
$this->_flush();
$this->insert_on_empty = false;
$this->push_args(array('_sexist' => 0));
$this->_unset();
// Получаем массив ID удалённых записей и удаляем их из таблицы связей с группами
$epg = data_interface::get_instance('entry_point_group');
$ids = (array) $this->get_lastChangedId();
foreach ($ids as $id) {
$epg->remove_entry_point_from_groups($id);
}
$this->pop_args();
response::send(array('success' => true), 'json');
}
示例13: to
public function to($type)
{
if ($type == 'html' && $this->cfg->mode == 'edit') {
response::getInstance()->addJs('checkboxFields');
}
return parent::to($type);
}
示例14: actionImprimirPDF
public function actionImprimirPDF()
{
$tUsuario = TUsuario::whereRaw('nombreUsuario=?', [Session::get('usuario')])->get();
$listaTDirectorio = TDirectorio::whereRaw('idUsuario=?', [$tUsuario[0]->idUsuario])->get();
Fpdf::AddPage();
Fpdf::SetFont('Arial', 'B', 16);
$i = 0;
Fpdf::Cell(40, 3 * $i, 'USUARIO');
Fpdf::Cell(50, 3 * $i, 'NOMBRE ');
Fpdf::Cell(50, 3 * $i, 'DIRECCION ');
Fpdf::Cell(40, 3 * $i, 'TELEFONO ', 0, 1, 'C');
$i++;
Fpdf::Cell(40, 3 * $i, '', 0, 1, 'C');
Fpdf::Cell(40, 3 * $i, '', 0, 1, 'C');
Fpdf::SetFont('Arial', '', 12);
foreach ($listaTDirectorio as $key => $value) {
Fpdf::Cell(40, 3 * $i, $value->tUsuario->nombreUsuario);
Fpdf::Cell(50, 3 * $i, $value->nombreCompleto);
Fpdf::Cell(50, 3 * $i, $value->direccion);
Fpdf::Cell(40, 3 * $i, $value->telefono, 0, 1, 'C');
$i++;
}
//Fpdf::Cell(40,10,'Hello World!');
// Fpdf::Output();
$header = ['Content-Type' => 'appication/pdf'];
return response::make(Fpdf::Output(), 200, $header);
}
示例15: ajaxTrade
/**
* 异步获取数据 图表用
* @param null
* @return array
*/
public function ajaxTrade()
{
$postData = input::get();
//api的参数
$all = $this->__getParams('graphall', $postData, 'trade');
$datas = app::get('topshop')->rpcCall('sysstat.data.get', $all, 'seller');
return response::json($datas);
}