public function out() { if (!Core::checkRequiredGetVars("permalink")) { Go::to404(); } $m = new ModelPost(); $post = $m->oneByPermalink($_GET["permalink"]); Header::location($post['url_post']); }
/** * Méthode permettant de redimensionner une image uploadée (enregistrée en base) * http://www.site.com/statique/resize/id:2/w:200/h:200/ * * $_GET["id"] int Id de l'upload * $_GET["w"] int largeur max souhaitée * $_GET["h"] int hauteur max souhaitée * @return void */ public function resize() { if (!Form::isNumeric($_GET["id"]) || !Form::isNumeric($_GET["w"]) || !Form::isNumeric($_GET["h"])) { Go::to404(); } if (!file_exists($image = ModelUpload::getPathById($_GET["id"]))) { Go::to404(); } preg_match(File::REGEXP_EXTENSION, $image, $extract); $ext = $extract[1]; $folder_cache = "includes/applications/" . Core::$application . "/_cache/imgs/"; $file_cache = $folder_cache . "resize_" . $_GET["id"] . "_" . $_GET["w"] . "_" . $_GET["h"] . "." . $ext; if ($app != "main") { Configuration::$server_url .= "../"; } if (file_exists($file_cache)) { Header::location(Configuration::$server_url . $file_cache); } Image::createCopy($image, $file_cache, $_GET["w"], $_GET["h"]); Header::location(Configuration::$server_url . $file_cache); }
/** * Méthode de parsing de l'url en cours * récupère le controller, l'action, la langue (si multilangue) ainsi que les paramètres $_GET * @param $pUrl * @return void */ public static function parseURL($pUrl = null) { Configuration::$server_domain = $_SERVER["SERVER_NAME"]; $protocol = "http" . (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 's' : '') . "://"; Configuration::$server_folder = preg_replace('/\\/(index).php$/', "", $_SERVER["SCRIPT_NAME"]); Configuration::$server_folder = preg_replace('/^\\//', "", Configuration::$server_folder); Configuration::$server_url = $protocol . Configuration::$server_domain . "/"; if (!empty(Configuration::$server_folder)) { Configuration::$server_url .= Configuration::$server_folder . "/"; } /** * Définition de l'url + suppression des paramètres GET ?var=value */ $url = isset($pUrl) && !is_null($pUrl) ? $pUrl : $_SERVER["REQUEST_URI"]; if (preg_match("/([^\\?]*)\\?.*\$/", $url, $matches)) { $url = $matches[1]; } $application_name = RoutingHandler::extractApplication($url); self::$application = Application::getInstance()->setup($application_name); self::$application->setModule(RoutingHandler::extractModule($url, self::$application->getModulesAvailable())); self::$module = self::$application->getModule()->name; Configuration::$server_url .= self::$application->getUrlPart(); $access = self::$application->getPathPart(); self::$path_to_components = Configuration::$server_url . $access . self::$path_to_components; self::defineGlobalObjects(); if (self::$application->multiLanguage) { self::$application->currentLanguage = RoutingHandler::extractLanguage($url); if (empty(self::$application->currentLanguage)) { self::$application->currentLanguage = self::$application->defaultLanguage; Header::location(Configuration::$server_url . self::$application->currentLanguage . "/" . $url); } } self::$path_to_application = Autoload::$folder . "/includes/applications/" . $application_name; self::setDictionary(); $parsedURL = RoutingHandler::parse($url); self::$url = $url; self::$controller = str_replace("-", "_", $parsedURL["controller"]); self::$action = str_replace("-", "_", $parsedURL["action"]); $_GET = array_merge($parsedURL["parameters"], $_GET); self::$path_to_theme = Configuration::$server_url . $access . self::$application->getThemePath(); self::$path_to_templates = self::$application->getThemePath() . "/views"; }
public function create() { $m = new ModelList(); $perma = $m->create(AuthenticationHandler::$data['id_user']); Header::location(Configuration::$server_url . 'list/' . $perma . '/edit'); }