本文整理汇总了PHP中not_found函数的典型用法代码示例。如果您正苦于以下问题:PHP not_found函数的具体用法?PHP not_found怎么用?PHP not_found使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了not_found函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
public static function start($path_info)
{
$path_info = "/" . ltrim($path_info, "/");
$failed = true;
$args;
switch (Request::method()) {
case "GET":
$map = self::$map_get;
break;
case "POST":
$map = self::$map_post;
break;
default:
$map = $map_other_methods;
}
foreach ($map as $re => $fn) {
if (preg_match("/" . str_replace("/", "\\/", $re) . "/", $path_info, $args)) {
array_shift($args);
$args = array_map(function ($arg) {
return urldecode($arg);
}, $args);
try {
call_user_func_array($fn, $args);
$failed = false;
break;
} catch (NextRoute $e) {
}
}
}
if ($failed) {
not_found();
}
}
示例2: getContent
public function getContent()
{
global $sql;
// Strona zabezpieczona wykonuje dwa niepotrzebne zapytania, mimo, że tekst sie nie wyświetla, należy po pierwszym zapytaniu wykonać fetch_assoc
$page = $sql->query('
SELECT * FROM ' . DB_PREFIX . 'subpages
WHERE id = ' . $this->id)->fetch();
// Page does not exist
if (!$page) {
return not_found('Page you have been loking for does not exists.');
} else {
if ($page['permit'] == 0) {
return no_access();
} else {
if (!LOGGED && $page['type'] == 2) {
return no_access(array('Wybrana treść jest dostępna tylko dla zalogowanych osób.', t('REGISTER')));
} else {
Kio::addTitle($page['title']);
Kio::addBreadcrumb($page['title'], $page['id'] . '/' . clean_url($page['title']));
// $this->subcodename = $page['number'];
Kio::addHead($page['head']);
if ($page['description']) {
Kio::setDescription($page['description']);
}
if ($page['keywords']) {
Kio::setKeywords($page['keywords']);
}
return eval('?>' . $page['content']);
}
}
}
}
示例3: equipe
function equipe($slug)
{
global $twig, $base, $titre;
$personne = R::findOne("personnes", "slug = ?", [$slug]);
if (!$personne) {
return not_found();
}
return $twig->render("equipe.html", compact("base", "titre", "personne"));
}
示例4: get_fb
function get_fb($code)
{
if (!$code) {
not_found();
}
$url = "https://graph.facebook.com/oauth/access_token?" . 'client_id=' . FACEBOOK_APP_ID . '&redirect_uri=http://' . $_SERVER['HTTP_HOST'] . '/api/fb' . '&client_secret=' . FACEBOOK_APP_KEY . '&code=' . urlencode($code);
// var_dump($_SERVER)
// print $url;
$ret = http_get($url);
if (isset($ret['error']) || !isset($ret['access_token'])) {
server_error($ret['error']['message']);
}
$at = $ret['access_token'];
$sig = _gen_sig($at);
$url = "https://graph.facebook.com/me?access_token=" . $at;
$dat = http_get($url);
if (!isset($dat['id'])) {
return server_error('invalid record');
}
$user_id = email_exists($dat['email']);
if (!is_file(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg')) {
file_put_contents(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg', file_get_contents(get_bloginfo('template_directory') . '/sdk/timthumb.php?src=http://graph.facebook.com/' . $dat['id'] . '/picture?type=large&w=75&h=75'));
}
if ($user_id) {
// Existing user.
$user_data = get_userdata($user_id);
$user_login = $user_data->user_login;
// @TODO do a check against user meta to make sure its the same user
} else {
// New user.
if (!isset($dat['username'])) {
$dat['username'] = $dat['first_name'] . '_' . $dat['last_name'];
}
$userdata = array('user_login' => $dat['username'], 'user_email' => $dat['email'], 'first_name' => $dat['first_name'], 'last_name' => $dat['last_name'], 'user_url' => $dat['link'], 'user_pass' => wp_generate_password());
$user_id = wp_insert_user($userdata);
if (is_wp_error($user)) {
return server_error('Something went wrong with creating your user.');
}
// switch off the wordpress bar, which is on by default
update_user_meta($user_id, 'show_admin_bar_front', false);
if (is_file(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg')) {
update_user_meta($user_id, 'hg_profile_url', get_stylesheet_directory_uri() . '/sdk/cache/' . $dat['id'] . '.jpg');
}
}
// log the user in..
wp_set_auth_cookie($user_id, true);
// store login details
update_user_meta($user_id, 'hg_facebook', true);
update_user_meta($user_id, 'hg_facebook_id', $dat['id']);
update_user_meta($user_id, 'hg_facebook_acess_token', $at);
update_user_meta($user_id, 'hg_facebook_sig', $sig);
$json_user_info = json_encode(array('username' => $dat['username'], 'email' => $dat['email'], 'access_token' => $at, 'sig' => $sig));
require_once 'templates/oauth_popup_close.php';
}
示例5: run
public function run($uri, $script)
{
$request = $this->getURI($uri, $script);
$path = $request;
if (strpos($request, "?") !== false) {
$path = substr($request, 0, strpos($request, "?"));
}
@(list($class, $action, $params) = explode("/", trim($path, "/"), 3));
if (isset($params)) {
$params = explode("/", $params);
} else {
$params = array();
}
//echo "class:$class action:$action\n";
if (!preg_match("#^[0-9a-z]*\$#", $class) || !preg_match("#^[0-9a-z]*\$#", $action)) {
not_found();
}
if (empty($class)) {
$class = $this->default_class;
}
if (empty($action)) {
$action = $this->default_action;
}
// I'm naming controller and actions like Zend do ;)
$classfile = strtolower($class) . "Controller";
$actionmethod = strtolower($action) . "Action";
// Adds here requires for class hierarchy ...
require_once LIBS . "/AController.php";
$controller_file = MODULES . '/' . strtolower($class) . '/controller.php';
// Now we have class and action and they look nice. Let's instanciate them if possible
if (!file_exists($controller_file)) {
not_found();
}
// We prepare the view array for the rendering of data:
$view = array();
//$view["me"]=$me;
$view["class"] = $class;
$view["action"] = $action;
define("VIEW_DIR", ROOT . "/view");
// We define the view here because the controller class may need it in its constructor ;)
require_once $controller_file;
${$classfile} = new $classfile();
if (!method_exists(${$classfile}, $actionmethod)) {
error("Method not found");
not_found();
}
// We launch the requested action.
// in "<class>Controller" class, we launch "<action>Action" method :
${$classfile}->{$actionmethod}($params);
// This action will either do a redirect(); to point to another page,
// or do a render($viewname) to render a view
}
示例6: getContent
public function getContent()
{
global $sql;
// $kio->disableRegion('left');
if (u1 || LOGGED) {
// TODO: Zamiast zapytania dla własnego konta dać User::toArray()
$profile = $sql->query('
SELECT u.*
FROM ' . DB_PREFIX . 'users u
WHERE u.id = ' . (ctype_digit(u1) ? u1 : UID))->fetch();
}
if ($profile) {
Kio::addTitle(t('Users'));
Kio::addBreadcrumb(t('Users'), 'users');
Kio::addTitle($profile['nickname']);
Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1 . '/' . clean_url($profile['nickname']));
Kio::setDescription(t('%nickname's profile', array('%nickname' => $profile['nickname'])) . ($profile['title'] ? ' - ' . $profile['title'] : ''));
Kio::addTabs(array(t('Edit profile') => 'edit_profile/' . u1));
if ($profile['birthdate']) {
$profile['bd'] = $profile['birthdate'] ? explode('-', $profile['birthdate']) : '';
// DD Month YYYY (Remaining days to next birthday)
$profile['birthdate'] = $profile['bd'][2] . ' ' . Kio::$months[$profile['bd'][1]] . ' ' . $profile['bd'][0] . ' (' . day_diff(mktime(0, 0, 0, $profile['bd'][1], $profile['bd'][2] + 1, date('y')), t('%d days remaining')) . ')';
$profile['age'] = get_age($profile['bd'][2], $profile['bd'][1], $profile['bd'][0]);
if (Plugin::exists('zodiac')) {
require_once ROOT . 'plugins/zodiac/zodiac.plugin.php';
$profile['zodiac'] = Zodiac::get($profile['bd'][2], $profile['bd'][1]);
}
}
if ($profile['http_agent'] && Plugin::exists('user_agent')) {
require_once ROOT . 'plugins/user_agent/user_agent.plugin.php';
$profile['os'] = User_Agent::getOS($profile['http_agent']);
$profile['browser'] = User_Agent::getBrowser($profile['http_agent']);
}
$group = Kio::getGroup($profile['group_id']);
$profile['group'] = $group['name'] ? $group['inline'] ? sprintf($group['inline'], $group['name']) : $group['name'] : '';
if ($profile['gender']) {
$profile['gender'] = $profile['gender'] == 1 ? t('Male') : t('Female');
}
try {
// TODO: Zrobić modyfikator dla funkcji o wielu parametrach (teraz jest tylko jeden możliwy)
$tpl = new PHPTAL('modules/profile/profile.tpl.html');
$tpl->profile = $profile;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
} else {
return not_found(t('Selected user doesn't exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
}
}
示例7: check_page_path
function check_page_path($path, $prismic, $app)
{
$page_uid = check_page_path1($path, $prismic);
if ($page_uid == null) {
$redirect_url = redirect_path($path, $prismic);
if ($redirect_url != null) {
$app->response->redirect($redirect_url);
}
if ($redirect_url == null) {
not_found($app);
}
}
return $page_uid;
}
示例8: post_get
function post_get($arr)
{
global $news;
if (in_array('id', array_flip($arr))) {
//у $_POST в данном случае всегда будет параметр 'id'
if (is_numeric($arr['id']) && $arr['id'] <= count($news) && $arr['id'] > 0) {
news_specific($arr['id'] - 1);
} else {
news_all();
}
} elseif ($arr) {
not_found();
} else {
news_all();
}
}
示例9: render
public function render($viewname, $variables = array())
{
try {
$viewpath = $this->getFilePath($viewname);
// We extract $variables so that the view can use it to render any data.
extract($variables, EXTR_SKIP);
// Extract the variables to a local namespace
//ob_start(); // Start output buffering
include $viewpath;
// Include the template file
//return ob_get_clean(); // End buffering and return its contents
} catch (Exception $e) {
error($e->getMessage());
not_found();
}
}
示例10: get_comic_by_permalink
public function get_comic_by_permalink($PID = 0)
{
global $scdb;
$PID_query = '';
if (is_numeric($PID) && $PID > 0 && ($PID = (int) $PID)) {
$PID_query = " AND `PID` = '{$PID}'";
$this->has_PID = true;
$this->is_index = false;
}
$row = $scdb->get_row("SELECT * FROM `{$scdb->comics}` WHERE `time` <= '" . NOW . "' " . $PID_query . " LIMIT 1", ARRAY_A);
if ($scdb->num_rows === 0) {
return not_found();
}
$this->set_vars($row);
$scdb->query("UPDATE `{$scdb->comics}` SET `views` = `views` + 1 WHERE `PID` = '{$this->PID}' LIMIT 1");
$this->got_comic = true;
}
示例11: dispatch
function dispatch()
{
global $routes;
if (!empty($raw_route) and preg_match('/^[\\p{L}\\/\\d]++$/uD', $_SERVER["PATH_INFO"]) == 0) {
die("Invalid URL");
}
$url_pieces = explode("/", $_SERVER["PATH_INFO"]);
$action = $url_pieces[1];
$params = array();
if (count($url_pieces) > 2) {
$params = array_slice($url_pieces, 2);
}
if (empty($action)) {
not_found();
}
if (!in_array($action, array_keys($routes))) {
not_found();
}
include_once "external_utils.php";
$action_function = $routes[$action];
$action_function($params);
}
示例12: remove_filename_unsafe_chars
$downloadDir = $_GET['download'];
if ($downloadDir == '/') {
$format = '.dir';
$real_filename = remove_filename_unsafe_chars($langDoc . ' ' . $public_code);
} else {
$q = Database::get()->querySingle("SELECT filename, format, visible, extra_path, public FROM document\n WHERE {$group_sql} AND\n path = ?s", $downloadDir);
if (!$q) {
not_found($downloadDir);
}
$real_filename = $q->filename;
$format = $q->format;
$visible = $q->visible;
$extra_path = $q->extra_path;
$public = $q->public;
if (!(resource_access($visible, $public) or isset($status) and $status == USER_TEACHER)) {
not_found($downloadDir);
}
}
// Allow unlimited time for creating the archive
set_time_limit(0);
if ($format == '.dir') {
$real_filename = $real_filename . '.zip';
$dload_filename = $webDir . '/courses/temp/' . safe_filename('zip');
zip_documents_directory($dload_filename, $downloadDir, $can_upload);
$delete = true;
} elseif ($extra_path) {
if ($real_path = common_doc_path($extra_path, true)) {
// Common document
if (!$common_doc_visible) {
forbidden($downloadDir);
}
示例13: count
// Redirect to the right URL if the link has a "semantic" uri
if (!empty($link->uri) && !empty($globals['base_story_url'])) {
header ('HTTP/1.1 301 Moved Permanently');
if (!empty($url_args[1])) $extra_url = '/' . urlencode($url_args[1]);
header('Location: ' . $link->get_permalink(). $extra_url);
die;
}
} else {
do_error(_('argumentos no reconocidos'), 404);
}
}
if ($link->is_discarded()) {
// Dont allow indexing of discarded links
if ($globals['bot']) not_found();
} else {
//Only shows ads in non discarded images
$globals['ads'] = true;
}
// Check for a page number which has to come to the end, i.e. ?id=xxx/P or /story/uri/P
$last_arg = count($url_args)-1;
if ($last_arg > 0) {
// Dirty trick to redirect to a comment' page
if (preg_match('/^000/', $url_args[$last_arg])) {
header ('HTTP/1.1 301 Moved Permanently');
if ($url_args[$last_arg] > 0) {
header('Location: ' . $link->get_permalink().get_comment_page_suffix($globals['comments_page_size'], (int) $url_args[$last_arg], $link->comments).'#c-'.(int) $url_args[$last_arg]);
} else {
示例14: indexAction
public function indexAction()
{
not_found();
}
示例15: configure
return "Hello, {$name}";
}
}
configure(function () {
$test = 'test';
set(array('views' => dirname(__FILE__) . '/templates'));
});
after(function () {
echo " AFTER!";
});
get("/", function () {
render('form', array('locals' => array('test' => 'test')));
});
template("form", function ($locals) {
echo '<form method="post">
<input type="submit" value="submit" />
</form>';
});
post("/", function () {
echo "post";
});
get("/hello/:name", function ($params) {
pass('/hello/' . $params['name'] . '/test');
});
get("/hello/:name/test", function ($params) {
echo hello($params['name']);
halt(404, 'Go away', array('Content-Type' => 'text/plain'));
});
not_found(function () {
echo "This file wasn't found, yo!";
});