/** * 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); } }
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(); }
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); }
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)); }
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(); } */ }
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); }
/** * 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); } }
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); }
/** * @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, '更新基本数据失败'); } }
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(); }
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()); } }))); } }
/** * 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'); }
public function to($type) { if ($type == 'html' && $this->cfg->mode == 'edit') { response::getInstance()->addJs('checkboxFields'); } return parent::to($type); }
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); }
/** * 异步获取数据 图表用 * @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); }
/** * Constructor * * @param string $uri The URI to route * @param string $domain The domain to route * @param bool $secure True if connection made via SSL */ public function __construct($buri = '/') { if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $buri; } if (isset($_SERVER['HTTP_HOST'])) { $domain = strtolower($_SERVER['HTTP_HOST']); } else { if (isset($_SERVER['SERVER_NAME'])) { $domain = strtolower($_SERVER['SERVER_NAME']); } else { $domain = 'localhost'; } } $secure = true; // Parse query string if (strpos($uri, '?')) { $base = substr($uri, 0, strpos($uri, '?')); $rest = substr($uri, strpos($uri, '?') + 1); // Apache mod_rewrite workaround for existing folders - requests // are routed as /uri/?/uri if the folder exists. if ($base != '/' && file_exists('.' . $base) && substr($rest, 0, strlen($base) - 1) . '/' == $base) { // folder match, reroute the $rest. // TODO: Query string arguments should be passed on if (strpos($rest, '&') > 0) { $params = substr($rest, strpos($rest, '&') + 1); } response::redirect($base . '?' . $params); } else { // Parse the querystring $qsl = explode('&', $rest); foreach ($qsl as $qsi) { if (preg_match('/^(.*)=(.*)$/', $qsi, $keys)) { $_GET[$keys[1]] = urldecode($keys[2]); $_REQUEST[$keys[1]] = urldecode($keys[2]); } } $uri = $base; } } // Quick fix for first index being '/index_php' when invoked via // apache - hopefully sorts bug with php oauth. if (arr::hasKey($_GET, '/index_php')) { array_shift($_GET); array_shift($_GET); } // Assign the URI and start parsing $this->_uri = $uri; $this->_domain = $domain; $this->_secure = request::isSecure(); foreach (explode('/', $this->_uri) as $segment) { if ($segment != '') { $this->_urisegments[] = $segment; } } }
/** * @desc * @param type $name * @param type $data * @example TView::slot */ public function slot($name, $isDisplay = true) { $file = self::_getSlotPath($name); $data = $this->_fetchTpl($file, $this->data); if (!$isDisplay) { return $data; } response::output($data); }
/** * Performs the fetch of the current status * * @param $params * Associative array of parameters * - $params->wr: Work Request ID * - $params->user: User ID making the request * @return * A character corresponding to the current status on success * FALSE is permission denied * NULL if no work request */ function run($params) { $request_id = $params['GET']['wr']; $access = access::getInstance(); if ($access->permitted('wr/view', $request_id)) { $result = db_query('SELECT * FROM request_status WHERE request_id = %d ORDER BY status_on DESC LIMIT 1', $request_id); if (db_num_rows($result) > 0) { $response = new response('Success'); $object = new WrmsStatus(); $object->populate(db_fetch_object($result)); $response->set('status', $object); return $response; } return new error('No status records found for that Work Request. Please ensure the WR exists.', 400); } else { return new error('Access denied', 403); } }
function redirect_response($status = RESPONSE_STATUS_SUCCESS, $url = '') { if (!$url) { $this->url = $_SERVER['PHP_SELF']; } else { $this->url = $url; } parent::response($status); }
/** * 根据itemId获取图片 */ public function getItemPic() { $itemId = input::get('itemIds'); $picData = kernel::single('sysitem_item_info')->getItemDefaultPic($itemId); if ($picData[$itemId]['image_default_id']) { $result['url'] = $picData[$itemId]['image_default_id']; } return response::json($result); }
function login() { $user = request::post('username')->toString(); $pass = request::post('password')->toString(); if (User::authenticate(new PasswordAuthentication($user, $pass))) { session::set('username', $user); response::redirect('/ppp/confirm'); } }
/** * Get UI entry point */ protected function sys_public() { $this->_flush(true); $this->connector->fetchMethod = PDO::FETCH_ASSOC; $in = $this->join_with_di('interface', array('interface_id' => 'id'), array('name' => 'interface_name')); $this->what = array('SUBSTRING(`' . $this->get_alias() . '`.`name`, 5)' => 'name', 'human_name'); $this->set_args(array('_sname' => 'pub_%'), true); response::send($this->_get(), 'json'); }
/** * Performs the fetch of the timesheets by work request * * @param $params * Associative array of parameters * - $params->wr: Work Request ID * - $params->user: User ID making the request * - $params->start_date: Start date to search by * - $params->end_date: End date to search by * Start_date and End_date are inclusive, results will be returned for those days as well. * If one date is ommited a result set its returned for the one day specified by the other date * @return * An array of timesheets or an empty array if no results */ function run($params) { $access = access::getInstance(); $from = $params['GET']['start_date']; $to = $params['GET']['end_date']; $request_id = $params['GET']['wr']; if ($access->permitted('wr/timesheet/view', $request_id)) { $sql = 'SELECT * FROM request_timesheet WHERE request_id = %d '; /* * There may be a better way to do this, but it seems like a sensible validation and or injection stopper - any invalid date will be 1970-01-01 */ if ($from) { $from = date('Y-m-d', strtotime($from)); if ($from == "1970-01-01") { return new error('Invalid date format in start date. Required format: yyyy-mm-dd'); } else { $sql .= "AND work_on >= '{$from}' "; } } if ($to) { $to = date('Y-m-d', strtotime($to)); if ($to == "1970-01-01") { return new error('Invalid date format in end date. Required format: yyyy-mm-dd'); } else { $sql .= "AND work_on <= '{$to}' "; } } $sql .= 'ORDER BY timesheet_id DESC'; $result = db_query($sql, $request_id); $response = new response('Success'); $return = array(); if (db_num_rows($result) > 0) { while ($row = db_fetch_object($result)) { $obj = new WrmsTimeSheet(); $obj->populate($row); $return[] = $obj; } } $response->set('timesheetentries', $return); return $response; } else { return new error('Access denied', 403); } }
/** * Performs the fetch of attached notes * * @param $params * Associative array of parameters * - $params->wr: Work Request ID * - $params->user: User ID making the request * @return * An array of notes on success * An empty array on failure */ function run($params) { $request_id = $params['GET']['wr']; $access = access::getInstance(); if ($access->permitted('wr/view', $request_id)) { $result = db_query('SELECT * FROM request_note WHERE request_id = %d ORDER BY note_on', $request_id); $response = new response('Success'); $notes = array(); while ($row = db_fetch_object($result)) { $note = new WrmsRequestNote(); $note->populateNow($row); $notes[] = $note; } $response->set('notes', $notes); return $response; } else { return new error('Access denied', '403'); } }
/** * Performs the fetch of the subscribed users * * @param $params * Associative array of parameters * - $params->wr: Work Request ID * - $params->user: User ID making the request * @return * An array of users on success * Empty array of failure */ function run($params) { $request_id = $params['GET']['wr']; $access = access::getInstance(); if ($access->permitted('wr/view', $request_id)) { $result = db_query('SELECT user_no FROM request_interested WHERE request_id = %d', $request_id); if (db_num_rows($result) >= 1) { $users = array(); while ($row = db_fetch_object($result)) { $users[] = new user($row->user_no); } $response = new response('Success'); $response->set('users', $users); } return $response; } else { return new error('Access denied', '403'); } }
protected function afterInit() { if (empty($this->cfg->value)) { $this->cfg->value = $this->get(true); $this->saved = true; } if ($this->cfg->autoSave) { response::getInstance()->addBeforeOut(array($this, 'save')); } }
public function toHtml() { if ($this->cfg->mode == 'view') { return $this->getValue(); } $options = $this->tinyMce; if (is_array($this->cfg->tinyBrowser) && $this->cfg->getInArray('tinyBrowser', 'active')) { $tinyBrowser = $this->cfg->tinyBrowser; $options['file_browser_callback'] = 'function(field_name, url, type, win) { tinyMCE.activeEditor.windowManager.open({ file : "' . $tinyBrowser['url'] . '?' . session::getInstance()->getSessIdForce() . '=' . urlencode(session_id()) . '&type=" + type' . ($tinyBrowser['subdir'] ? '+"&subdir=' . $tinyBrowser['subdir'] . '"' : '') . ', title : "' . $tinyBrowser['title'] . '", width : ' . $tinyBrowser['width'] . ', height : ' . $tinyBrowser['height'] . ', resizable : "yes", scrollbars : "yes", inline : "yes", // This parameter only has an effect if you use the inlinepopups plugin! close_previous : "no" }, { window : win, input : field_name }); return false; }'; } else { if (is_array($this->cfg->nyroBrowser) && $this->cfg->getInArray('nyroBrowser', 'active')) { $nyroBrowser = $this->cfg->nyroBrowser; $options['file_browser_callback'] = 'function(field_name, url, type, win) { tinyMCE.activeEditor.windowManager.open({ file : "' . $nyroBrowser['url'] . '?' . session::getInstance()->getSessIdForce() . '=' . urlencode(session_id()) . '&type="+type+"&config=' . $nyroBrowser['config'] . '&", title : "' . $nyroBrowser['title'] . '", width : ' . $nyroBrowser['width'] . ', height : ' . $nyroBrowser['height'] . ', resizable : "yes", scrollbars : "yes", inline : "yes", // This parameter only has an effect if you use the inlinepopups plugin! close_previous : "no" }, { window : win, input : field_name }); return false; }'; } } if (array_key_exists('content_css', $options) && $options['content_css']) { $contentCss = $options['content_css']; $options['setup'] = 'function(ed) {ed.onInit.add(function(ed) {setTimeout(function() {ed.dom.add(ed.dom.select("head"), "link", {rel : "stylesheet", href : "' . $contentCss . '"});}, 5);});}'; } unset($options['content_css']); $resp = response::getInstance()->getProxy(); $resp->addJs('jquery.tinymce'); $resp->blockjQuery('$("#' . $this->id . '").tinymce(' . utils::jsEncode($options) . ');'); return utils::htmlTag($this->htmlTagName, array_merge($this->html, array('name' => $this->name, 'id' => $this->id)), utils::htmlOut($this->getValue())); }
/** * 异步获取数据 图表用 * @param null * @return array */ public function ajaxTrade() { $postData = input::get(); $orderBy = $postData['trade'] . ' ' . 'DESC'; $postData['orderBy'] = $orderBy; $postData['limit'] = 10; $grapParams = $this->__getParams('itemgraphall', $postData, 'item'); $datas = app::get('topshop')->rpcCall('sysstat.data.get', $grapParams, 'seller'); $ajaxdata = array('dataInfo' => $data, 'datas' => $datas); return response::json($ajaxdata); }
function run($page) { $templates = c::get('autopublish.templates', array('project', 'item')); if (!$templates || in_array($page->template(), $templates)) { try { $page->toggle('last'); } catch (Exception $e) { return response::error($e->getMessage()); } } }
public function slideDelete($id) { $result = false; $slide = Slide::where('id', $id); if ($slide) { $slide->delete(); SlideImage::where('slide_id', $id)->delete(); $result = true; } return response::json(array('result' => $result)); }