public function __index() { $request = @json_decode(\Gini\CGI::content(), true); if ($request === null) { $response = ['jsonrpc' => '2.0', 'error' => ['code' => -32700, 'message' => 'Parse error'], 'id' => $id]; } else { $response = \Gini\API::dispatch((array) $request); } return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', $response); }
public static function url($url = null, $query = null, $fragment = null) { if (!$url) { $url = \Gini\CGI::route(); } $ui = parse_url($url); if ($ui['scheme'] == 'mailto') { //邮件地址 return 'mailto:' . $ui['user'] . '@' . $ui['host']; } if ($query) { if ($ui['query']) { if (is_string($query)) { parse_str($query, $query); } parse_str($ui['query'], $old_query); $ui['query'] = http_build_query(array_merge($old_query, $query)); } else { $ui['query'] = is_string($query) ? $query : http_build_query($query); } } if ($fragment) { $ui['fragment'] = $fragment; } if ($ui['host']) { $url = $ui['scheme'] ?: 'http'; $url .= '://'; if ($ui['user']) { if ($ui['pass']) { $url .= $ui['user'] . ':' . $ui['pass'] . '@'; } else { $url .= $ui['user'] . '@'; } } $url .= $ui['host']; if ($ui['port']) { $url .= ':' . $ui['port']; } $url .= '/'; } else { $url = self::base(); } if ($ui['path']) { $url .= ltrim($ui['path'], '/'); } if ($ui['query']) { $url .= '?' . $ui['query']; } if ($ui['fragment']) { $url .= '#' . $ui['fragment']; } return $url; }
public function __index($page = 1) { $me = _G('ME'); $group = _G('GROUP'); if (!$me->id || !$group->id || !$me->isAllowedTo('设置')) { $this->redirect('error/401'); } $rpc = \Gini\Module\HazardousControlOrders::getRPC('chemical-limits'); $limits = $rpc->admin->inventory->getGroupLimits($group->id); $page = (int) $page; $vars = ['limits' => $limits, 'requestsHTML' => \Gini\CGI::request("ajax/settings/chemical-limits/requests-more/{$page}", $this->env)->execute()->content()]; $this->view->body = V('settings/chemical-limits', $vars); }
public static function setup() { //获取系统维护模块的状态信息 $config = \Gini\Config::get('maintenance'); $route = \Gini\CGI::route(); $path = 'maintain'; //维护模块开启 if ($config['status'] && $config['status'] == 'on') { //判断$route是防止后续的模块不给他机会直接跳转,判断$route != $path是防止重定向跳转 if ($route && $route != $path) { \Gini\CGI::redirect($path); } } }
public function actionRequest($args) { if (count($args) < 1) { die("Usage: gini cgi request <URL>\n"); } $route = array_shift($args); array_map(function ($arg) { list($k, $v) = explode('=', $arg); $_GET[$k] = $v; }, $args); $env = ['get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'route' => $route]; echo "Requesting {$route}...\n"; $content = \Gini\CGI::request($route, $env)->execute()->content(); if (is_string($content)) { echo $content; } else { echo yaml_emit($content, YAML_UTF8_ENCODING); } }
public static function tearDownAfterClass() { \Gini\CGI::shutdown(); }