Example #1
0
 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();
     }
 }
Example #2
0
    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']);
                }
            }
        }
    }
Example #3
0
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"));
}
Example #4
0
 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';
 }
Example #5
0
 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
 }
Example #6
0
    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&apos;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&apos;t exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
        }
    }
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;
}
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();
    }
}
Example #9
0
 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();
     }
 }
Example #10
0
 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;
 }
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);
}
Example #12
0
 $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);
         }
Example #13
0
		// 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 {
Example #14
0
 public function indexAction()
 {
     not_found();
 }
Example #15
0
        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!";
});
Example #16
0
 /** Receive a URL to enable a user account */
 function enableAction()
 {
     global $view, $params;
     if (!isset($params[0])) {
         not_found();
     }
     $id = intval($params[0]);
     $user = mqone("SELECT * FROM user WHERE id={$id};");
     if (!$user) {
         not_found();
     }
     mq("UPDATE user SET enabled=1 WHERE id={$id};");
     $view["message"] = "The user has been enabled successfully";
     $this->indexAction();
 }
    $doc = $prismic->get_document($id);
    if (!$doc) {
        not_found($app);
        return;
    }
    $permalink = $prismic->linkResolver->resolveDocument($doc);
    if ($app->request()->getPath() != $permalink) {
        // The user came from a URL with an older slug
        $app->response->redirect($permalink);
        return;
    }
    $skin = $prismic->get_skin();
    // Do we have a template for this type?
    $file_path = views_dir() . '/' . $doc->getType() . '.php';
    $template = file_exists($file_path) ? $doc->getType() : 'document';
    render($app, $template, array('single_post' => $doc, 'skin' => $skin));
});
// Page
// Since pages can have parent pages, the URL can contains several portions
$app->get('/:path+', function ($path) use($app, $prismic) {
    $page_uid = check_page_path($path, $prismic, $app);
    $skin = $prismic->get_skin();
    if ($page_uid) {
        $page = $prismic->by_uid('page', $page_uid);
        if (!$page) {
            not_found($app, $skin);
            return;
        }
        render($app, 'page', array('single_post' => $page, 'skin' => $skin));
    }
});
Example #18
0
 public function meAction($params)
 {
     global $db;
     check_user_identity();
     $uid = $GLOBALS['me']['uid'];
     $user = $db->qone('SELECT uid, email, enabled, admin, url ' . 'FROM users WHERE uid = :uid', array('uid' => $GLOBALS['me']['uid']));
     if ($user == false) {
         not_found();
     }
     if ($params[0] == 'edit') {
         $errors = array();
         if (!empty($_POST)) {
             $errors = self::verifyForm($_POST, 'meedit');
             if (empty($errors)) {
                 $db->q('UPDATE users SET email=? WHERE uid=?', array($_POST['email'], $user->uid));
                 $old_user = $user;
                 $user = $db->qone('SELECT uid, email, enabled, admin FROM users WHERE uid = ?', array($user->uid));
                 $args = array('old_user' => $old_user, 'new_user' => $user);
                 Hooks::call('users_edit', $args);
                 if (!empty($_POST['pass'])) {
                     $db->q('UPDATE users SET pass=? WHERE uid=?', array(crypt($_POST['pass'], Users::getSalt()), $user->uid));
                     $args = array('uid' => $user->uid, 'email' => $user->email, 'pass' => $_POST['pass']);
                     Hooks::call('users_edit_pass', $args);
                 }
                 // Message + redirection
                 header('Location: ' . BASE_URL . 'users/me?msg=' . _("User account changed..."));
                 exit;
             }
         }
         /*
          * Valeurs pour pré-remplir le formulaire
          *
          * Deux cas possibles...
          * 1/ On vient d'arriver sur la page ( empty($_POST) ):
          * on pré-rempli le formulaire avec les données de l'utilisateur
          *
          * 2/ On à validé le formulaire, mais il y a une erreur:
          * on pré-rempli le formulaire avec les données de la saisie.
          */
         if (empty($_POST)) {
             $form_data = get_object_vars($user);
             // get_object_vars : stdClass -> array
         } else {
             $form_data = $_POST;
         }
         $this->render('form', array('op' => 'meedit', 'data' => $form_data, 'errors' => $errors));
     } else {
         $this->render('me', array('user' => $user, 'contacts' => $contacts));
     }
 }
Example #19
0
            }
            $image['thumbs'][] = $row;
        }
        if ($image['author_id']) {
            $image['author'] = User::format($image['author_id'], $image['nickname'], $image['group_id']);
        }
        // TODO: http://www.pixastic.com/lib/
        $image['src'] = 'modules/gallery/images/' . $image['id'] . '.' . $image['file_extension'];
        //list($image['width'], $image['height']) = getimagesize(ROOT.$image['src']);
        $image['prev'] = $y[$image['current'] - 2];
        $image['next'] = $y[$image['current']];
        $sql->putCacheContent('gallery_image_' . u2, $image);
    }
    if ($image['description']) {
        $kio->description = $image['name'] . ' - ' . $image['description'];
    }
    // http://localhost/~kiocms/?images/gallery/15/5-5-0-0-0-0-0-0-0-0-0/biba.jpg
    try {
        $tpl = new PHPTAL('modules/gallery/image.html');
        $tpl->cfg = $cfg;
        $tpl->image = $image;
        $tpl->thumbs = $image['thumbs'];
        $tpl->comments = '';
        $tpl->comments = $plug->comments($image['id'], 'gallery_images', $image['comments'], 'gallery/image/' . $image['id'] . '/' . clean_url($image['name']));
        echo $tpl->execute();
    } catch (Exception $e) {
        echo template_error($e);
    }
} else {
    echo not_found(sprintf('Zdjęcie o numerze <strong>%s</strong> nie istnieje', u2), array('Zdjęcie zostało usunięte z bazy danych', 'Wprowadzony adres jest nieprawidłowy'));
}
Example #20
0
/**
 * 
 * @global type $basedir 
 * @param type $file_path
 * @param type $initial_path
 */
function send_file_by_url_file_path($file_path, $initial_path = '') {
    global $basedir;

    $path_components = explode('/', str_replace('//', chr(1), $file_path));
    $file_info = public_path_to_disk_path($path_components, $initial_path);

    if (!send_file_to_client($basedir . $file_info->path, $file_info->filename, null, false)) {
        not_found($file_path);
    }
    exit;
}
Example #21
0
<?php

$path = $globals['path'];
$globals['submnm'] = preg_replace('/[^\\p{L}\\d_]/u', ':', $path[1]);
include_once 'config.php';
$forbidden_routes = array('m', 'user', 'legal', 'notame', 'mobile', 'register', 'login', 'trends');
if (in_array($path[2], $forbidden_routes)) {
    // syslog(LOG_INFO, "Forbidden in subs: ".$path[2]);
    // Redirect to the root
    $uri = preg_split('/\\/+/', $_SERVER['REQUEST_URI'], 10, PREG_SPLIT_NO_EMPTY);
    $uri = array_slice($uri, 2);
    $uri = '/' . implode('/', $uri);
    header("Location: {$uri}");
    die;
}
$globals['site_shortname'] = $globals['submnm'];
if (empty($globals['submnm']) || !($info = SitesMgr::get_info())) {
    not_found();
}
$globals['path'] = array_slice($path, 2);
$globals['base_url'] .= $path[0] . '/' . $path[1] . '/';
if (!empty($routes[$path[2]])) {
    $res = (include './' . $routes[$path[2]]);
    if ($res === FALSE) {
        not_found($path[1]);
    }
} else {
    // Try with story
    include './story.php';
}
Example #22
0
        $tab_option = 3;
        break;
    case 'log':
        $tab_option = 4;
        break;
    case 'sneak':
        $tab_option = 5;
        break;
    case 'favorites':
        $tab_option = 6;
        break;
    case 'trackbacks':
        $tab_option = 7;
        break;
    default:
        not_found();
}
// When we insert a comment we also modify $link
if ($_POST['process'] == 'newcomment') {
    $new_comment_error = insert_comment();
}
// Set globals
$globals['link'] =& $link;
$globals['link_id'] = $link->id;
$globals['category_id'] = $link->category;
$globals['category_name'] = $link->category_name;
$globals['link_permalink'] = $globals['link']->get_permalink();
// to avoid search engines penalisation
if ($tab_option != 1 || $link->status == 'discard') {
    $globals['noindex'] = true;
}
Example #23
0
function public_path_to_disk_path($path_components, $path = '')
{
    global $group_sql;
    $depth = substr_count($path, '/') + 1;
    foreach ($path_components as $component) {
        $component = urldecode(str_replace(chr(1), '/', $component));
        $r = Database::get()->querySingle("SELECT path, visible, public, format, extra_path,\n                                      (LENGTH(path) - LENGTH(REPLACE(path, '/', ''))) AS depth\n                                      FROM document\n                                      WHERE {$group_sql} AND\n                                            filename = ?s AND\n                                            path LIKE '{$path}%' HAVING depth = {$depth}", $component);
        if (!$r) {
            not_found('/' . implode('/', $path_components));
        }
        $path = $r->path;
        $depth++;
    }
    if (!preg_match("/\\.{$r->format}\$/", $component)) {
        $component .= '.' . $r->format;
    }
    $r->filename = $component;
    return $r;
}
Example #24
0
<?php

$titles[] = 'User';
switch (True) {
    case !isset($path[1]):
        not_found();
        break;
    default:
        $user = $model['user']['by_name']($path[1]);
        $user = $user ? $user : not_found();
}
$titles[] = $user['name'];
include get_tpl('user');
Example #25
0
/**
 * Returns not found error output
 *
 * @access private
 * @param string $msg
 * @return string
 */
function error_not_found_output($errno, $errstr, $errfile, $errline)
{
    if (!function_exists('not_found')) {
        /**
         * Default not found error output
         *
         * @param string $errno
         * @param string $errstr
         * @param string $errfile
         * @param string $errline
         * @return string
         */
        function not_found($errno, $errstr, $errfile = null, $errline = null)
        {
            option('views_dir', option('error_views_dir'));
            $msg = h(rawurldecode($errstr));
            return html("<h1>Page not found:</h1><p><code>{$msg}</code></p>", error_layout());
        }
    }
    return not_found($errno, $errstr, $errfile, $errline);
}
Example #26
0
            if (!$date) {
                $date = $globals['now'];
            }
            $id = (int) $db->get_var("select post_id from posts, users where user_login = '******' and post_user_id = user_id and post_date < FROM_UNIXTIME({$date}) order by post_date desc limit 1");
        }
        if (!$id > 0) {
            // Check if the user exists
            $uid = (int) $db->get_var("select user_id from users where user_login = '******' limit 1");
            if (!$uid) {
                not_found('<strong>Error: </strong>' . _('usuario inexistente'));
            } else {
                header('Location:  http://' . get_server_name() . post_get_base_url($user));
                die;
            }
            die;
        }
    } else {
        $id = intval($_GET['id']);
    }
} else {
    die;
}
$post = new Post();
$post->id = $id;
$post->read();
if (!$post->read) {
    not_found('<strong>Error: </strong>' . _('nota no encontrada'));
    die;
}
header('Location:  http://' . get_server_name() . post_get_base_url($post->id));
echo $link;
    // force download of all attachments
}
// security: some protection of hidden resource files
// warning: it may break backwards compatibility
if (!empty($CFG->preventaccesstohiddenfiles) and count($args) >= 2 and !(strtolower($args[1]) == 'moddata' and strtolower($args[2]) != 'resource') and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
    $rargs = $args;
    array_shift($rargs);
    $reference = implode('/', $rargs);
    $sql = "SELECT COUNT(r.id) " . "FROM {$CFG->prefix}resource r, " . "{$CFG->prefix}course_modules cm, " . "{$CFG->prefix}modules m " . "WHERE r.course    = '{$course->id}' " . "AND m.name      = 'resource' " . "AND cm.module   = m.id " . "AND cm.instance = r.id " . "AND cm.visible  = 0 " . "AND r.type      = 'file' " . "AND r.reference = '{$reference}'";
    if (count_records_sql($sql)) {
        error('Access not allowed');
    }
}
// check that file exists
if (!file_exists($pathname)) {
    not_found($course->id);
}
// ========================================
// finally send the file
// ========================================
session_write_close();
// unlock session during fileserving
$filename = $args[count($args) - 1];
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
function not_found($courseid)
{
    global $CFG;
    header('HTTP/1.0 404 not found');
    print_error('filenotfound', 'error', $CFG->wwwroot . '/course/view.php?id=' . $courseid);
    //this is not displayed on IIS??
}
Example #28
0
    private function getEntries()
    {
        global $sql;
        $pager_url = 'news';
        $category_id = 0;
        if (u1 == 'category') {
            $category_id = (int) u2;
        }
        $total = Kio::getStat('entries', 'news');
        if ($category_id) {
            $category = $sql->setCache('news_categories_' . $category_id)->query('
				SELECT id, name, description, entries
				FROM ' . DB_PREFIX . 'news_categories
				WHERE id = ' . $category_id)->fetch(PDO::FETCH_ASSOC);
            if ($category) {
                $total = $category['entries'];
                if ($category['description']) {
                    Kio::setDescription($category['name'] . ' - ' . $category['description']);
                }
                Kio::addTitle($category['name']);
                Kio::addBreadcrumb($category['name'], 'news/category/' . $category_id . '/' . clean_url($category['name']));
                $pager_url = 'news/category/' . $category_id . '/' . clean_url($category['name']);
            } else {
                return not_found(t('Selected category does not exists.'), array(t('Category was moved or deleted.'), t('Entered URL is invalid.')));
            }
        }
        if (!empty($category) || empty($category)) {
            $this->subcodename = 'entries';
            $pager = new Pager($pager_url, $total, Kio::getConfig('limit', 'news'));
            $stmt = $sql->setCache('news_' . $category_id . '_' . $pager->current)->query('
				SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.*
				FROM ' . DB_PREFIX . 'news n
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = n.author_id
				LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id
				WHERE ' . ($category_id ? 'c.id = ' . $category_id . '
					AND ' : '') . (LOGGED ? 'n.publication > 0' : 'n.publication = 1') . '
					AND n.added < ' . TIMESTAMP . '
				ORDER BY ' . Kio::getConfig('order_by', 'news') . '
				LIMIT ' . $pager->limit . '
				OFFSET ' . $pager->offset);
            while ($row = $stmt->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                }
                $row['url_title'] = ($row['c_name'] ? clean_url($row['c_name']) . '/' : '') . clean_url($row['title']);
                $row['content'] = parse($row['content'], Kio::getConfig('parsers', 'news'));
                $entries[] = $row;
            }
            try {
                $tpl = new PHPTAL('modules/news/news.tpl.html');
                $tpl->entries = $entries;
                $tpl->pagination = $pager->getLinks();
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        }
    }
Example #29
0
function get_author($name)
{
    $names = get_author_name();
    $username = '******' . $name . '.ini';
    $tmp = array();
    if (!empty($names)) {
        foreach ($names as $index => $v) {
            $author = new stdClass();
            // Replaced string
            $replaced = substr($v, 0, strrpos($v, '/')) . '/';
            // Author string
            $str = explode('/', $replaced);
            $profile = $str[count($str) - 2];
            if ($name === $profile) {
                // Profile URL
                $url = str_replace($replaced, '', $v);
                $author->url = site_url() . 'author/' . $profile;
                // Get the contents and convert it to HTML
                $content = file_get_contents($v);
                // Extract the title and body
                $author->name = get_content_tag('t', $content, $author);
                $author->about = MarkdownExtra::defaultTransform(remove_html_comments($content));
                $tmp[] = $author;
            }
        }
    }
    if (!empty($tmp) || file_exists($username)) {
        return $tmp;
    } else {
        not_found();
    }
}
Example #30
0
<?php

// The source code packaged with this file is Free Software, Copyright (C) 2009 by
// Ricardo Galli <gallir at uib dot es>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
include '../config.php';
if ($globals['url_shortener_mobile_to'] && $globals['mobile']) {
    $server_to = $globals['url_shortener_mobile_to'];
} else {
    $server_to = $globals['url_shortener_to'];
}
if (preg_match('/^\\/*$/', $_SERVER['PATH_INFO'])) {
    header('Location: http://' . $server_to);
    die;
}
$url_args = preg_split('/\\/+/', $_SERVER['PATH_INFO']);
// If the first argument are only numbers, redirect to the story with that id
$link = new Link();
if (preg_match('/^[\\da-z]+$/', $url_args[1])) {
    $link->id = intval(base_convert($url_args[1], 36, 10));
    if ($link->read_basic('id')) {
        header('HTTP/1.1 301 Moved');
        header('Location: http://' . $server_to . $link->get_relative_permalink());
        die;
    }
}
not_found('Link not found');
die;