public function end($route) { if (!$route->controller instanceof MainController or in_array($this->url, Config::current()->cache_exclude) or $this->cancelled or $this->cacher->url_available() or Flash::exists()) { return; } $this->cacher->set(ob_get_contents()); }
public function end($route) { if (!$route->controller instanceof MainController or in_array($this->url, Config::current()->cache_exclude) or $this->cancelled or file_exists($this->file) or Flash::exists()) { return; } if (DEBUG) { error_log("GENERATING cache file for " . $this->url . "..."); } # Generate the user's directory. if (!file_exists($this->path)) { mkdir($this->path); } file_put_contents($this->file, ob_get_contents()); }
/** * Function: login * Process logging in. If the username and password are incorrect or if the user is already logged in, it will error. */ public function login() { if (logged_in()) { error(__("Error"), __("You're already logged in.")); } if (!empty($_POST)) { fallback($_POST['login']); fallback($_POST['password']); $trigger = Trigger::current(); if ($trigger->exists("authenticate")) { return $trigger->call("authenticate"); } if (!User::authenticate($_POST['login'], $_POST['password'])) { if (!count(User::find(array("where" => array("login" => $_POST['login']))))) { Flash::warning(__("There is no user with that login name.")); } else { Flash::warning(__("Password incorrect.")); } } if (!Flash::exists("warning")) { $user = new User(array("login" => $_POST['login'])); $_SESSION['user_id'] = $user->id; $redirect = @$_SESSION['redirect_to']; unset($_SESSION['redirect_to']); Flash::notice(__("Logged in."), oneof($redirect, "/")); } } $this->display("forms/user/login", array(), __("Log In")); }
/** * Function: login * Process logging in. If the username and password are incorrect or if the user is already logged in, it will error. */ public function login() { if (logged_in()) { error(__("Error"), __("You're already logged in.")); } if (!empty($_POST)) { fallback($_POST['login']); fallback($_POST['password']); $trigger = Trigger::current(); if ($trigger->exists("authenticate")) { return $trigger->call("authenticate"); } if (!User::authenticate($_POST['login'], $_POST['password'])) { Flash::warning(__("Incorrect username and/or password, please try again.")); } if (!Flash::exists("warning")) { $user = new User(array("login" => $_POST['login'])); $_SESSION['user_id'] = $user->id; if (!isset($redirect)) { $redirect = oneof(@$_SESSION['redirect_to'], "/"); unset($_SESSION['redirect_to']); } Flash::notice(__("Logged in."), $redirect); } } $this->display("forms/user/login", array(), __("Log In")); }
public function add_ticket() { if (!Visitor::current()->group->can("add_ticket")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to create tickets.", "progress")); } if (empty($_POST['title'])) { Flash::warning(__("Please provide a summary of the ticket in the form of a title.", "progress")); } if (empty($_POST['milestone_id'])) { Flash::warning(__("No milestone selected.", "progress")); } $milestone = new Milestone($_POST['milestone_id']); if ($milestone->no_results) { error(__("Error"), __("Invalid milestone.", "progress")); } if (Flash::exists()) { redirect($milestone->url()); } $ticket = Ticket::add($_POST['title'], $_POST['description'], "new", $_POST['milestone_id'], $_POST['owner_id']); $files = array(); foreach ($_FILES['attachment'] as $key => $val) { foreach ($val as $file => $attr) { $files[$file][$key] = $attr; } } foreach ($files as $attachment) { if ($attachment['error'] != 4) { $path = upload($attachment, null, "attachments"); Attachment::add(basename($path), $path, "ticket", $ticket->id); } } $domain = parse_url(Config::current()->url, PHP_URL_HOST); if (!empty($ticket->owner->email) and Visitor::current()->id != $ticket->owner->id) { mail($ticket->owner->email, _f("Ticket #%d Created! (%s)", array($ticket->id, $ticket->title), "progress"), _f("%s has created the ticket \"%s\" and assigned the owner to you. Description:<br />\n<br />\n%s", array(oneof($ticket->user->full_name, $ticket->user->login), $ticket->title, $ticket->description)), "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=utf-8\r\n" . "From: no-reply@" . $domain); } Flash::notice(__("Ticket added.", "progress"), $ticket->url()); }
public function new_version() { $extension = new Extension(array("url" => $_GET['url'])); if (!$extension->editable()) { show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this extension.", "extend")); } if ($extension->no_results) { exit; } # TODO if (!empty($_POST)) { if ($_FILES['extension']['error'] == 4) { Flash::warning(__("You forgot the extension file, silly!", "extend")); } if (empty($_POST['number'])) { Flash::warning(__("Please enter a version number.", "extend")); } if (empty($_POST['compatible'])) { Flash::warning(__("Please list the Chyrp versions you know to be compatible with this extension.", "extend")); } if (!Flash::exists()) { return $this->add_version(); } } $this->display("extend/version/new", array("extension" => $extension), __("New Version", "extend")); }