本文整理汇总了PHP中Base::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Base::error方法的具体用法?PHP Base::error怎么用?PHP Base::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
/**
* auth service callback
* @param Base $f3
* @param $params
*/
function callback(\Base $f3, $params)
{
$Opauth = new \Opauth($this->config, false);
switch ($Opauth->env['callback_transport']) {
case 'session':
$response = $f3->get('SESSION.opauth');
$f3->clear('SESSION.opauth');
break;
case 'post':
$response = unserialize(base64_decode($f3->get('POST.opauth')));
break;
case 'get':
$response = unserialize(base64_decode($f3->get('GET.opauth')));
break;
default:
$f3->error(400, 'Unsupported callback_transport');
break;
}
if (isset($response['error'])) {
$f3->call($this->abortFunc, array($response));
return;
}
$data = $response['auth'];
// validate
if (empty($data) || empty($response['timestamp']) || empty($response['signature']) || empty($data['provider']) || empty($data['uid'])) {
$f3->error(400, 'Invalid auth response: Missing key auth response components');
} elseif (!$Opauth->validate(sha1(print_r($data, true)), $response['timestamp'], $response['signature'], $reason)) {
$f3->error(400, 'Invalid auth response: ' . $reason);
} else {
// It's all good
$f3->call($this->successFunc, array($data));
}
}
示例2: viewSingle
/**
* @param \Base $f3
* @param array $params
*/
public function viewSingle(\Base $f3, $params)
{
$web = \Web::instance();
$this->response->data['SUBPART'] = 'larfi_page.html';
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
$this->response->data['POST'] = $this->resource;
if ($this->resource->dry()) {
$f3->error(404, 'LFI Plugin not found');
} else {
$this->response->data['SUBPART'] = 'larfi_page.html';
$url = $f3->get('POST.url');
$blankurl = $f3->devoid('POST.url');
$lfi_type = $f3->get('POST.lType');
$payload = $f3->get('POST.lPayload');
$method = $f3->get('POST.lMethod');
switch ($lfi_type) {
case "Generic":
\Flash::instance()->addMessage('Exploited by injecting into the URL/Body where applicable', 'info');
return $this->uri_based_lfi($method, $blankurl, $url, $payload);
break;
case "Cookie":
\Flash::instance()->addMessage('Exploited by injecting into the cookie', 'info');
return $this->cookie_based_lfi($method, $blankurl, $url, $payload);
break;
default:
\Flash::instance()->addMessage('This is an invalid attack type', 'warning');
}
}
}
}
示例3: contentsMain
function contentsMain()
{
//テンプレートファイル読み込み
if (!($tempHTML = @file_get_contents($this->filename))) {
//テンプレートの内容を取得
Base::error("fileNotFound");
}
return $tempHTML;
}
示例4: logout
/**
* GET|POST /logout
* @param \Base $fw
*/
function logout(\Base $fw)
{
if ($fw->get('COOKIE.session_token') == $fw->get('GET.session')) {
\Helper\Api\User::logout();
$fw->set('COOKIE.session_token', null);
$fw->reroute('/');
} else {
$fw->error(400);
}
}
示例5: run
public function run($event = 'before')
{
if (!isset($this->routes[$event])) {
return true;
}
foreach ($keys = array_keys($this->routes[$event]) as $key) {
$paths[] = str_replace('@', '*@', $key);
}
$vals = array_values($this->routes[$event]);
array_multisort($paths, SORT_DESC, $keys, $vals);
$this->routes[$event] = array_combine($keys, $vals);
// Convert to BASE-relative URL
$req = $this->f3->rel(urldecode($this->f3->URI));
foreach ($this->routes[$event] as $pattern => $routes) {
if (!($args = $this->f3->mask($pattern, $req))) {
continue;
}
ksort($args);
$route = NULL;
if (isset($routes[$ptr = $this->f3->AJAX + 1][$this->f3->VERB])) {
$route = $routes[$ptr];
} elseif (isset($routes[\Base::REQ_SYNC | \Base::REQ_AJAX])) {
$route = $routes[\Base::REQ_SYNC | \Base::REQ_AJAX];
}
if (!$route) {
continue;
}
if ($this->f3->VERB != 'OPTIONS' && isset($route[$this->f3->VERB])) {
$parts = parse_url($req);
if ($this->f3->VERB == 'GET' && preg_match('/.+\\/$/', $parts['path'])) {
$this->f3->reroute(substr($parts['path'], 0, -1) . (isset($parts['query']) ? '?' . $parts['query'] : ''));
}
$handler = $route[$this->f3->VERB][0];
if (is_bool(strpos($pattern, '/*'))) {
foreach (array_keys($args) as $key) {
if (is_numeric($key) && $key) {
unset($args[$key]);
}
}
}
if (is_string($handler)) {
// Replace route pattern tokens in handler if any
$handler = preg_replace_callback('/@(\\w+\\b)/', function ($id) use($args) {
return isset($args[$id[1]]) ? $args[$id[1]] : $id[0];
}, $handler);
if (preg_match('/(.+)\\h*(?:->|::)/', $handler, $match) && !class_exists($match[1])) {
$this->f3->error(500, 'PreRoute handler not found');
}
}
// Call route handler
return $this->f3->call($handler, array($this->f3, $args), 'beforeroute,afterroute') !== FALSE;
}
}
return true;
}
示例6: getSingle
public function getSingle(\Base $f3, $params)
{
$this->response->data['SUBPART'] = 'user_edit.html';
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
if ($this->resource->dry()) {
$f3->error(404, 'User not found');
}
$this->response->data['POST'] = $this->resource;
}
}
示例7: viewSingle
public function viewSingle(\Base $f3, $params)
{
$this->response->data['SUBPART'] = 'payload_view.html';
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
if ($this->resource->dry()) {
$f3->error(404, 'Payload not found');
}
$this->response->data['POST'] = $this->resource;
}
}
示例8: single
/**
* Single tag route (/tag/@tag)
* @param \Base $f3
* @param array $params
*/
public function single($f3, $params)
{
$tag = new \Model\Issue\Tag();
$tag->load(array("tag = ?", $params["tag"]));
if (!$tag->id) {
$f3->error(404);
return;
}
$issue = new \Model\Issue\Detail();
$issue_ids = implode(',', $tag->issues());
$f3->set("title", "#" . $params["tag"] . " - " . $f3->get("dict.issue_tags"));
$f3->set("tag", $tag);
$f3->set("issues.subset", $issue->find("id IN ({$issue_ids})"));
$this->_render("tag/single.html");
}
示例9: viewSingle
/**
* @param \Base $f3
* @param array $params
*/
public function viewSingle(\Base $f3, $params)
{
$web = \Web::instance();
$this->response->data['SUBPART'] = 'webot_control.html';
if (isset($params['id'])) {
$this->resource->load(array('_id = ?', $params['id']));
$this->response->data['POST'] = $this->resource;
if ($this->resource->dry()) {
$f3->error(404, 'Webot not found');
} else {
$this->response->data['SUBPART'] = 'webot_control.html';
$url = $f3->get('POST.zLoc');
$command_key = $f3->get('POST.zParam');
$instruction = $f3->get('POST.instruction');
return $this->bot_master($url, $command_key, $instruction);
}
}
}
示例10: addComment
/**
* add a comment from POST data to current blog post
*/
public function addComment(\Base $f3, $params)
{
if (isset($params['slug'])) {
// you may only comment published posts
$this->resource->load(array('slug = ? and publish_date <= ? and published = ?', $params['slug'], date('Y-m-d'), true));
if ($this->resource->dry()) {
// invalid post ID
$f3->error(404, 'Post not found.');
return false;
}
if (!$this->resource->enable_comments && !$this->resource->enable_comments === NULL) {
$f3->error(403, 'Comments are not allowed for this Post');
return false;
}
$comment = new \Model\Comment();
$comment->copyfrom('POST', 'author_name, author_email, message');
$comment->post = $this->resource->_id;
$comment->approved = \Config::instance()->get('auto_approve_comments') ? 1 : 0;
$comment->save();
if ($f3->get('ERROR')) {
// if posting failed, return to comment form
$this->getSingle($f3, $params);
} else {
// if posting was successful, reroute to the post view
if (\Config::instance()->get('auto_approve_comments')) {
\Flash::instance()->addMessage('Your comment has been added.', 'success');
} else {
\Flash::instance()->addMessage('Your comment has been added, but must be approved first before it becomes public.', 'success');
}
$f3->reroute('/' . $params['slug']);
}
} else {
// invalid URL, no post id given
\Flash::instance()->addMessage('No Post ID specified.', 'danger');
$f3->reroute('/');
}
}
示例11: route
/**
* Route controller code
* @param \Base $f3
* @param array $params
*/
function route($f3, $params)
{
if (PHP_SAPI == 'cli' ? !$this->cli : !$this->web) {
$f3->error(404);
}
if (isset($params['job'])) {
$this->execute($params['job'], FALSE);
} else {
$this->run();
}
}
示例12: getList
/**
* get collection of records
* @param \Mth3l3m3nt $f3
* @param array $params
*/
public function getList(\Base $f3, $params)
{
$f3->error(403);
}
示例13: single_tree
/**
* GET /user/@username/tree
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function single_tree($f3, $params)
{
$this->_requireLogin();
$user = new \Model\User();
$user->load(array("username = ? AND deleted_date IS NULL", $params["username"]));
if ($user->id) {
$f3->set("title", $user->name);
$f3->set("this_user", $user);
$tree = \Helper\Dashboard::instance()->issue_tree();
$f3->set("issues", $tree);
$this->_render($f3->get("AJAX") ? "user/single/tree/ajax.html" : "user/single/tree.html");
} else {
$f3->error(404);
}
}
示例14: file
/**
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function file($f3, $params)
{
$file = new \Model\Issue\File();
$file->load($params["id"]);
if (!$file->id) {
$f3->error(404);
return;
}
$force = true;
if (substr($file->content_type, 0, 5) == "image" || $file->content_type == "text/plain") {
// Don't force download on image and plain text files
// Eventually I'd like to have previews of files some way (more than the existing thumbnails), but for now this is how we do it - Alan
$force = false;
}
if (!$this->_sendFile($file->disk_filename, $file->content_type, $file->filename, $force)) {
$f3->error(404);
}
}
示例15: route
/**
* Route controller code
* @param \Base $f3
* @param array $params
*/
function route($f3, $params)
{
if (PHP_SAPI != 'cli' && !$this->web) {
$f3->error(404);
}
$exec = isset($params['job']) ? array($params['job'] => $this->execute($params['job'], FALSE)) : $this->run();
if (!$this->silent) {
if (PHP_SAPI != 'cli') {
header('Content-Type: text/plain');
}
if (!$exec) {
die('Nothing to do');
}
foreach ($exec as $job => $ok) {
echo sprintf('%s [%s]', $job, $ok ? 'OK' : 'async') . "\r\n";
}
}
}