本文整理汇总了PHP中Req类的典型用法代码示例。如果您正苦于以下问题:PHP Req类的具体用法?PHP Req怎么用?PHP Req使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Req类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: photo_urls
public function photo_urls(Req $req, Res $res, $args)
{
$params = $req->getQueryParams();
$jd_id = $args['jd_id'] ?? '0';
$params['jd_id'] = $jd_id;
$m_p = new \App\Model\Photo();
$result = $m_p->get_urls($params);
return $res->output($result);
}
示例2: authorize
public function authorize(Req $req, Res $res, $args)
{
$grant_type = $req->getInput('grant_type');
$client_id = $req->getServerParam('PHP_AUTH_USER');
$client_secret = $req->getServerParam('PHP_AUTH_PW');
$oauth = new Oauth();
$result = $oauth->get_token($client_id, $client_secret, $grant_type);
return $res->authorize_output($result);
}
示例3: main
public function main()
{
$this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
$cookie = Lib::cookie();
$identifier = $cookie->get(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
$this->set('user', $user);
$this->set('isLoggedIn', $isLoggedIn);
$this->js[] = $isLoggedIn ? 'inbox' : 'login';
if ($isLoggedIn) {
array_shift($this->js);
$id = Req::get('id');
if (empty($id)) {
Lib::redirect('index');
}
$report = Lib::table('report');
if (!$report->load($id)) {
$this->template = 'no-report';
return;
}
$report->init();
$assignees = Lib::model('user')->getProjectAssignees($report->project_id);
$projectTable = Lib::table('project');
$projectTable->load($report->project_id);
$this->set('report', $report);
$this->set('assignees', $assignees);
$this->set('project', $projectTable);
}
}
示例4: show
function show()
{
global $page, $db, $user, $fs, $proj;
$page->setTitle($fs->prefs['page_title'] . L('reports'));
$events = array(1 => L('taskopened'), 13 => L('taskreopened'), 2 => L('taskclosed'), 3 => L('taskedited'), 14 => L('assignmentchanged'), 29 => L('events.useraddedtoassignees'), 4 => L('commentadded'), 5 => L('commentedited'), 6 => L('commentdeleted'), 7 => L('attachmentadded'), 8 => L('attachmentdeleted'), 11 => L('relatedadded'), 12 => L('relateddeleted'), 9 => L('notificationadded'), 10 => L('notificationdeleted'), 17 => L('reminderadded'), 18 => L('reminderdeleted'));
$user_events = array(30 => L('created'), 31 => L('deleted'));
$page->assign('events', $events);
$page->assign('user_events', $user_events);
$sort = strtoupper(Get::enum('sort', array('desc', 'asc')));
$where = array();
$params = array();
$orderby = '';
switch (Get::val('order')) {
case 'type':
$orderby = "h.event_type {$sort}, h.event_date {$sort}";
break;
case 'user':
$orderby = "user_id {$sort}, h.event_date {$sort}";
break;
case 'date':
default:
$orderby = "h.event_date {$sort}, h.event_type {$sort}";
}
foreach (Get::val('events', array()) as $eventtype) {
$where[] = 'h.event_type = ?';
$params[] = $eventtype;
}
$where = '(' . implode(' OR ', $where) . ')';
if ($proj->id) {
$where = $where . 'AND (t.project_id = ? OR h.event_type > 29) ';
$params[] = $proj->id;
}
if (($fromdate = Req::val('fromdate')) || Req::val('todate')) {
$where .= ' AND ';
$todate = Req::val('todate');
if ($fromdate) {
$where .= ' h.event_date > ?';
$params[] = Flyspray::strtotime($fromdate) + 0;
}
if ($todate && $fromdate) {
$where .= ' AND h.event_date < ?';
$params[] = Flyspray::strtotime($todate) + 86400;
} else {
if ($todate) {
$where .= ' h.event_date < ?';
$params[] = Flyspray::strtotime($todate) + 86400;
}
}
}
$histories = array();
if (count(Get::val('events'))) {
if (Get::num('event_number') > 0) {
$db->setLimit(Get::num('event_number'));
}
$histories = $db->x->getAll("SELECT h.*, t.*, p.project_prefix\n FROM {history} h\n LEFT JOIN {tasks} t ON h.task_id = t.task_id\n LEFT JOIN {projects} p ON t.project_id = p.project_id\n WHERE {$where}\n ORDER BY {$orderby}", null, $params);
}
$page->assign('histories', $histories);
$page->assign('sort', $sort);
$page->pushTpl('reports.tpl');
}
示例5: saveAssignees
public function saveAssignees()
{
$keys = array('project', 'setting');
if (!Req::haspost($keys)) {
return $this->fail('Insufficient data.');
}
$identifier = Lib::cookie(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
if (!$isLoggedIn || $user->role != USER_ROLE_ADMIN) {
return $this->fail('You are not authorized.');
}
$project = Req::post('project');
$setting = json_decode(Req::post('setting'));
$projectTable = Lib::table('project');
if ($project !== 'all' && $project !== '-1' && !$projectTable->load(array('name' => $project))) {
return $this->fail('No such project.');
}
if ($project !== 'all') {
$projectAssignee = Lib::table('project_assignee');
$projectAssignee->load(array('user_id' => $setting->id, 'project_id' => $projectTable->id));
if ($setting->value) {
$projectAssignee->store();
} else {
$projectAssignee->delete();
}
}
return $this->success();
}
示例6: set_id
/**
* 根据 IP、当前小时、对应的路由、arg 参数、key 限制调用频率
*
* @param Req $req HTTP 请求对象
*/
protected function set_id(Req $req)
{
$ip = $req->getServerParam('REMOTE_ADDR');
$id = $ip . ':' . date('H');
$route = $req->getAttribute('route');
if ($route) {
$id .= ':' . $route->getIdentifier();
if (!empty($this->opts['arg'])) {
$id .= ':' . $route->getArgument($this->opts['arg']);
}
}
if (!empty($this->opts['key'])) {
$id .= ':' . $this->opts['key'];
}
$this->id = $id;
}
示例7: execute
public function execute()
{
$api = Lib::api('admin', array('response' => 'return', 'format' => 'php'));
$type = Req::get('type');
if (!is_callable(array($api, $type))) {
return Lib::redirect('error');
}
$result = $api->{$type}();
$options = array('view' => 'admin');
$ref = Req::post('ref');
if (!$result['state']) {
if (!empty($ref)) {
$options['ref'] = $ref;
}
} else {
$segments = explode('/', base64_decode(urldecode($ref)));
$base = array_shift($segments);
$type = array_shift($segments);
$subtype = array_shift($segments);
if (!empty($type)) {
$options['type'] = $type;
}
if (!empty($subtype)) {
$options['subtype'] = $subtype;
}
}
Lib::redirect('admin', $options);
}
示例8: before
public function before($obj = null)
{
// 推荐商户设置 add by t-btei 2015/05/04
$companyId = Req::args('companyId');
if (isset($companyId)) {
// 保存推荐ID
setcookie('company_affiliate_uid', $companyId);
}
//测试平板或者手机端主题
$clientType = Chips::clientType();
if ($clientType == 'tablet' || $clientType == 'mobile') {
$config_path = APP_CODE_ROOT . 'config/config.php';
$config = (require $config_path);
if (isset($config['themes_mobile'])) {
$themes_mobile = Tiny::app()->setTheme($config['themes_mobile']);
} else {
Tiny::app()->setTheme("default");
}
}
$config = Config::getInstance();
$site = $config->get('globals');
$other = $config->get('other');
$currency_symbol = isset($other['other_currency_symbol']) ? $other['other_currency_symbol'] : '¥';
$site_logo = isset($site['site_logo']) && $site['site_logo'] != '' ? $site['site_logo'] : 'static/images/logo.png';
$site_qr = isset($site['site_qr']) && $site['site_qr'] != '' ? $site['site_qr'] : 'static/images/qr-app.png';
$site_name = isset($site['site_name']) ? $site['site_name'] : 'TinyShop商城';
$site_icp = isset($site['site_icp']) ? $site['site_icp'] : '鲁ICP备00000100号';
$obj->assign('currency_symbol', $currency_symbol);
$obj->assign('site_logo', $site_logo);
$obj->assign('site_qr', $site_qr);
$obj->assign('site_name', $site_name);
$obj->assign('site_icp', $site_icp);
}
示例9: env
public static function env($checkget = true)
{
if ($checkget && Req::hasget('environment')) {
return Req::get('environment');
}
$serverName = $_SERVER['SERVER_NAME'];
return isset(Config::$baseurl[$serverName]) ? Config::$baseurl[$serverName] : 'production';
}
示例10: main
public function main()
{
$filterProject = Req::get('project');
if (empty($filterProject)) {
$this->template = 'empty-project';
return;
}
$projectTable = Lib::table('project');
if (!$projectTable->load(array('name' => $filterProject))) {
$this->set('name', $filterProject);
$this->template = 'new-project';
return;
}
$this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
$cookie = Lib::cookie();
$identifier = $cookie->get(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
$this->set('user', $user);
$this->set('filterProject', $filterProject);
$this->set('filterSettingsProject', $filterProject);
$this->set('isLoggedIn', $isLoggedIn);
if (!$isLoggedIn) {
$this->js[] = 'login';
}
if ($isLoggedIn) {
$this->js[] = 'inbox';
$this->js[] = 'settings';
array_shift($this->js);
$userModel = Lib::model('user');
$assignees = $userModel->getProjectAssignees($projectTable->id);
$users = $userModel->getUsers();
$filterState = $cookie->get('filter-state', 'pending');
$filterAssignee = $cookie->get('filter-assignee', empty($assignees[$user->id]) ? 'all' : $user->id);
$filterSort = $cookie->get('filter-sort', 'asc');
$reportModel = Lib::model('report');
$reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($filterState)), 'assignee_id' => $filterAssignee, 'order' => 'date', 'direction' => $filterSort, 'project_id' => $projectTable->id));
$userSettingsTable = Lib::table('user_settings');
if (!$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => $projectTable->id))) {
$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => 0));
}
$userSettings = $userSettingsTable->getData();
if ($userSettings['color'] !== 'cyan' && $userSettings['color'] !== 'custom') {
$this->css[] = 'theme-' . str_replace(' ', '', $userSettings['color']);
}
$categories = Lib::model('category')->getCategories(['projectid' => $projectTable->id]);
$this->set('filterState', $filterState);
$this->set('filterAssignee', $filterAssignee);
$this->set('filterSort', $filterSort);
$this->set('reports', $reports);
$this->set('assignees', $assignees);
$this->set('userSettings', $userSettings);
$this->set('users', $users);
$this->set('projectTable', $projectTable);
$this->set('categories', $categories);
}
}
示例11: decode
public function decode($segments)
{
foreach ($segments as $index => $value) {
if (empty($value) || !isset($this->segments[$index])) {
continue;
}
Req::set('GET', $this->segments[$index], $value);
}
}
示例12: decode
public function decode($segments = array())
{
$total = count($segments);
foreach ($segments as $index => $value) {
if (!isset($this->segments[$index])) {
continue;
}
Req::set('GET', $this->segments[$index], $value);
}
}
示例13: decode
public function decode($segments)
{
if (count($segments) >= 3) {
$view = array_shift($segments);
$api = array_shift($segments);
$action = array_shift($segments);
Req::set('GET', 'api', $api);
Req::set('GET', 'action', $action);
}
}
示例14: nextReq
public function nextReq()
{
$req = \Req::orderBy('req', 'DESC')->first(array('req'));
if (isset($req)) {
$req->req++;
return $req->req;
} else {
return 1;
}
}
示例15: env
public static function env()
{
if (Req::hasget('development')) {
Lib::cookie()->set('development', Req::get('development'));
}
if (Lib::cookie()->get('development')) {
return 'development';
}
return self::$env;
}