public function getDispositionForm() { $faxprof = Input::instance()->post('faxprofile'); $faxdisp = Doctrine::getTable('FaxDisposition')->find($faxprof['fxp_fxd_id']); if ($faxdisp) { $packageobj = Doctrine::getTable('package')->find($faxdisp['fxd_package_id']); if ($packageobj) { try { if (!($package = Package_Catalog::getInstalledPackage($packageobj->name))) { echo 'Package not ' . $packageobj->name . ' found.'; exit; } $formfile = $package['directory'] . '/views/' . $packageobj->name . '/' . $faxdisp['fxd_name'] . '.php'; kohana::Log('debug', 'Looking for view ' . $formfile); if (file_exists($formfile)) { $featureFormView = new View($packageobj->name . '/' . $faxdisp['fxd_name']); kohana::Log('debug', 'View file found.'); if (isset($faxprof['fxp_id']) && !empty($faxprof['fxp_id']) && $faxprof['fxp_id'] != '') { $faxprofobj = Doctrine::getTable('FaxProfile')->find($faxprof['fxp_id']); } else { $faxprofobj = new FaxProfile(); } $featureFormView->set_global('faxprofile', $faxprofobj); echo $featureFormView->render(TRUE); } else { kohana::Log('debug', 'View file not found.'); } } catch (Package_Catalog_Exception $e) { echo 'Package not ' . $packageobj->name . ' found.'; } } } exit; }
/** * Create a new comment. * @param Item_MOdel $item the parent item * @param User_Model $author the author User_Model * @param string $text comment body * @param string $guest_name guest's name (if the author is a guest user, default empty) * @param string $guest_email guest's email (if the author is a guest user, default empty) * @param string $guest_url guest's url (if the author is a guest user, default empty) * @return Comment_Model */ static function create($item, $author, $text, $guest_name = null, $guest_email = null, $guest_url = null) { $comment = ORM::factory("comment"); $comment->author_id = $author->id; $comment->guest_email = $guest_email; $comment->guest_name = $guest_name; $comment->guest_url = $guest_url; $comment->item_id = $item->id; $comment->text = $text; $comment->state = "published"; // These values are useful for spam fighting, so save them with the comment. $input = Input::instance(); $comment->server_http_accept = substr($input->server("HTTP_ACCEPT"), 0, 128); $comment->server_http_accept_charset = substr($input->server("HTTP_ACCEPT_CHARSET"), 0, 64); $comment->server_http_accept_encoding = substr($input->server("HTTP_ACCEPT_ENCODING"), 0, 64); $comment->server_http_accept_language = substr($input->server("HTTP_ACCEPT_LANGUAGE"), 0, 64); $comment->server_http_connection = substr($input->server("HTTP_CONNECTION"), 0, 64); $comment->server_http_host = substr($input->server("HTTP_HOST"), 0, 64); $comment->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255); $comment->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128); $comment->server_query_string = substr($input->server("QUERY_STRING"), 0, 64); $comment->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32); $comment->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64); $comment->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16); $comment->save(); return $comment; }
public function saveprefs() { // Process the admin form. // Prevent Cross Site Request Forgery access::verify_csrf(); // Save user specified settings to the database. $str_slideshow_url = Input::instance()->post("slideshow_url"); module::set_var("minislideshow", "slideshow_url", $str_slideshow_url); $str_slideshow_shuffle = Input::instance()->post("shuffle"); module::set_var("minislideshow", "shuffle", $str_slideshow_shuffle); $str_slideshow_dropshadow = Input::instance()->post("dropshadow"); module::set_var("minislideshow", "dropshadow", $str_slideshow_dropshadow); $str_slideshow_show_title = Input::instance()->post("show_title"); module::set_var("minislideshow", "show_title", $str_slideshow_show_title); $str_slideshow_trans_in_type = Input::instance()->post("trans_in_type"); module::set_var("minislideshow", "trans_in_type", $str_slideshow_trans_in_type); $str_slideshow_trans_out_type = Input::instance()->post("trans_out_type"); module::set_var("minislideshow", "trans_out_type", $str_slideshow_trans_out_type); $str_slideshow_mask = Input::instance()->post("mask"); module::set_var("minislideshow", "mask", $str_slideshow_mask); $str_slideshow_use_full_image = Input::instance()->post("use_full_image"); module::set_var("minislideshow", "use_full_image", $str_slideshow_use_full_image); $str_slideshow_delay = Input::instance()->post("delay"); module::set_var("minislideshow", "delay", $str_slideshow_delay); // Display a success message and load the admin screen. message::success(t("Your Settings Have Been Saved.")); $view = new Admin_View("admin.html"); $view->content = new View("admin_minislideshow.html"); $view->content->minislideshow_form = $this->_get_admin_form(); print $view; }
/** * On first session instance creation, sets up the driver and creates session. */ public function __construct() { $this->input = Input::instance(); // This part only needs to be run once if (self::$instance === NULL) { // Load config self::$config = Kohana::config('session'); // Makes a mirrored array, eg: foo=foo self::$protect = array_combine(self::$protect, self::$protect); // Configure garbage collection ini_set('session.gc_probability', (int) self::$config['gc_probability']); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', self::$config['expiration'] == 0 ? 86400 : self::$config['expiration']); // Create a new session $this->create(); if (self::$config['regenerate'] > 0 and $_SESSION['total_hits'] % self::$config['regenerate'] === 0) { // Regenerate session id and update session cookie $this->regenerate(); } else { // Always update session cookie to keep the session alive cookie::set(self::$config['name'], $_SESSION['session_id'], self::$config['expiration']); } // Close the session just before sending the headers, so that // the session cookie(s) can be written. Event::add('system.send_headers', array($this, 'write_close')); // Make sure that sessions are closed before exiting register_shutdown_function(array($this, 'write_close')); // Singleton instance self::$instance = $this; } Kohana::log('debug', 'Session Library initialized'); }
public function sendmail_wrapped_message_test() { $domain = Input::instance()->server("HTTP_HOST"); $expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . "Reply-To: reply_to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "This is a long message that needs to go\n" . "over forty characters If we get lucky we\n" . "might make it long enought to wrap a\n" . "couple of times."; $result = Sendmail_For_Test::factory()->to("*****@*****.**")->subject("Test Email Unit test")->line_length(40)->message("This is a long message that needs to go over forty characters " . "If we get lucky we might make it long enought to wrap a couple " . "of times.")->send()->send_text; $this->assert_equal($expected, $result); }
/** * Fetch a cookie value, using the Input library. * * @param string cookie name * @param mixed default value * @param boolean use XSS cleaning on the value * @return string */ public static function get($name = NULL, $default = NULL, $xss_clean = FALSE) { // Return an array of all the cookies if we don't have a name if ($name === NULL) { $cookies = array(); foreach ($_COOKIE as $key => $value) { $cookies[$key] = cookie::get($key, $default, $xss_clean); } return $cookies; } if (!isset($_COOKIE[$name])) { return $default; } // Get the cookie value $cookie = $_COOKIE[$name]; // Find the position of the split between salt and contents $split = strlen(cookie::salt($name, NULL)); if (isset($cookie[$split]) and $cookie[$split] === '~') { // Separate the salt and the value list($hash, $value) = explode('~', $cookie, 2); if (cookie::salt($name, $value) === $hash) { if ($xss_clean === TRUE and Kohana::config('core.global_xss_filtering') === FALSE) { return Input::instance()->xss_clean($value); } // Cookie signature is valid return $value; } // The cookie signature is invalid, delete it cookie::delete($name); } return $default; }
private function _show($album) { $page_size = module::get_var("gallery", "page_size", 9); $page = Input::instance()->get("page", "1"); $album_defn = unserialize(module::get_var("dynamic", $album)); $children_count = $album_defn->limit; if (empty($children_count)) { $children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all(); } $offset = ($page - 1) * $page_size; $max_pages = ceil($children_count / $page_size); // Make sure that the page references a valid offset if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) { throw new Kohana_404_Exception(); } $template = new Theme_View("page.html", "collection", "dynamic"); $template->set_global("page", $page); $template->set_global("page_size", $page_size); $template->set_global("max_pages", $max_pages); $template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset)); $template->set_global("children_count", $children_count); $template->content = new View("dynamic.html"); $template->content->title = t($album_defn->title); print $template; }
public function save($u = false) { if ($u) { return parent::save($u); } if ($this->loaded) { $p = parent::save($u); $model = ORM::factory($this->object_plural . '_position')->where($this->object_name . '_id', $this->id)->find(); $model->{$this->object_name . '_id'} = $p->id; $model->save(true); return $p; } else { $p = parent::save($u); $type = Input::instance()->post('form_type'); $types = array('insert_as_last_child', 'insert_as_first_child', 'insert_as_next_sibling', 'insert_as_prev_sibling'); if (!in_array($type, $types)) { throw new Exception("Insert type not set", 1); } $parent = Input::instance()->post('form_parent'); if (!is_numeric($parent)) { throw new Exception("Parent id not set", 1); } $model = ORM::factory($this->object_plural . '_position'); $model->{$this->object_name . '_id'} = $this->id; $model->{$this->object_name . '_pid'} = $this->pid; $model->version = $this->version; $model->{$type}($parent); return $p; } }
protected function __construct() { $this->input = Input::instance(); $this->config = CodeIgniter_Config::instance(); $this->db = CodeIgniter_Database::instance(); $this->load = CodeIgniter_Loader::instance(); }
public function index() { $session = Session::instance(); // Make sure we have an upgrade token if (!($upgrade_token = $session->get("upgrade_token", null))) { $session->set("upgrade_token", $upgrade_token = random::hash()); } // If the upgrade token exists, then bless this session if (file_exists(TMPPATH . $upgrade_token)) { $session->set("can_upgrade", true); @unlink(TMPPATH . $upgrade_token); } $available_upgrades = 0; foreach (module::available() as $module) { if ($module->version && $module->version != $module->code_version) { $available_upgrades++; } } $failed = Input::instance()->get("failed"); $view = new View("upgrader.html"); $view->can_upgrade = identity::active_user()->admin || $session->get("can_upgrade"); $view->upgrade_token = $upgrade_token; $view->available = module::available(); $view->failed = $failed ? explode(",", $failed) : array(); $view->done = $available_upgrades == 0; print $view; }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); // Figure out which boxes where checked $linkOptions_array = Input::instance()->post("ContactOwnerLinkTypes"); $ownerLink = false; $userLink = false; for ($i = 0; $i < count($linkOptions_array); $i++) { if ($linkOptions_array[$i] == "ContactOwner") { $ownerLink = true; } if ($linkOptions_array[$i] == "ContactUser") { $userLink = true; } } // Figure out the values of the text boxes $str_contactbutton = Input::instance()->post("owner_button_text"); $str_contactemail = Input::instance()->post("owner_email"); $str_contactname = Input::instance()->post("owner_name"); $str_messageheader = Input::instance()->post("message_header"); // Save Settings. module::set_var("contactowner", "contact_owner_link", $ownerLink); module::set_var("contactowner", "contact_user_link", $userLink); module::set_var("contactowner", "contact_button_text", $str_contactbutton); module::set_var("contactowner", "contact_owner_email", $str_contactemail); module::set_var("contactowner", "contact_owner_name", $str_contactname); module::set_var("contactowner", "contact_owner_header", $str_messageheader); message::success(t("Your Settings Have Been Saved.")); // Load Admin page. $view = new Admin_View("admin.html"); $view->content = new View("admin_contactowner.html"); $view->content->contactowner_form = $this->_get_admin_form(); print $view; }
public static function getInstance() { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); // Save Settings. module::set_var("ratings", "showunderphoto", Input::instance()->post("showunderphoto")); module::set_var("ratings", "showinsidebar", Input::instance()->post("showinsidebar")); module::set_var("ratings", "imageword", Input::instance()->post("imageword")); module::set_var("ratings", "votestring", Input::instance()->post("votestring")); module::set_var("ratings", "castyourvotestring", Input::instance()->post("castyourvotestring")); # module::set_var("ratings", "bgcolor", Input::instance()->post("bgcolor")); module::set_var("ratings", "fillcolor", Input::instance()->post("fillcolor")); module::set_var("ratings", "votedcolor", Input::instance()->post("votedcolor")); module::set_var("ratings", "hovercolor", Input::instance()->post("hovercolor")); module::set_var("ratings", "textcolor", Input::instance()->post("textcolor")); module::set_var("ratings", "regonly", Input::instance()->post("regonly")); $iconset = Input::instance()->post("iconset"); $iconset = preg_replace("/\\/index\\.php/", "", $iconset); module::set_var("ratings", "iconset", $iconset); message::success(t("Your Settings Have Been Saved.")); site_status::clear("ratings_configuration"); // Load Admin page. $view = new Admin_View("admin.html"); $view->content = new View("admin_ratings.html"); $view->content->ratings_form = $this->_get_admin_form(); print $view; }
/** * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. */ static function load_themes() { $input = Input::instance(); $path = $input->server("PATH_INFO"); if (empty($path)) { $path = "/" . $input->get("kohana_uri"); } $config = Kohana_Config::instance(); $modules = $config->get("core.modules"); self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); self::$site_theme_name = module::get_var("gallery", "active_site_theme"); if (self::$is_admin) { // Load the admin theme self::$admin_theme_name = module::get_var("gallery", "active_admin_theme"); array_unshift($modules, THEMEPATH . self::$admin_theme_name); // If the site theme has an admin subdir, load that as a module so that // themes can provide their own code. if (file_exists(THEMEPATH . self::$site_theme_name . "/admin")) { array_unshift($modules, THEMEPATH . self::$site_theme_name . "/admin"); } } else { // Admins can override the site theme, temporarily. This lets us preview themes. if (identity::active_user()->admin && ($override = $input->get("theme"))) { if (file_exists(THEMEPATH . $override)) { self::$site_theme_name = $override; } else { Kohana_Log::add("error", "Missing override theme: '{$override}'"); } } array_unshift($modules, THEMEPATH . self::$site_theme_name); } $config->set("core.modules", $modules); }
public function session($key) { access::verify_csrf(); $input = Input::instance(); Session::instance()->set($key, $input->get("value")); url::redirect($input->server("HTTP_REFERER")); }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); // Figure out the values of the text boxes $str_phpmailer_path = Input::instance()->post("phpmailer_path"); $str_phpmailer_from_addr = Input::instance()->post("phpmailer_from_address"); $str_phpmailer_from_name = Input::instance()->post("phpmailer_from_name"); $str_smtp_server = Input::instance()->post("phpmailer_smtp_server"); $str_use_ssl = Input::instance()->post("phpmailer_use_ssl"); $str_smtp_login = Input::instance()->post("phpmailer_smtp_login"); $str_smtp_pass = Input::instance()->post("phpmailer_smtp_password"); $str_smtp_port = Input::instance()->post("phpmailer_smtp_port"); if (count($str_use_ssl) > 0) { $str_use_ssl = true; } else { $str_use_ssl = false; } // Save Settings. module::set_var("phpmailer", "phpmailer_path", $str_phpmailer_path); module::set_var("phpmailer", "phpmailer_from_address", $str_phpmailer_from_addr); module::set_var("phpmailer", "phpmailer_from_name", $str_phpmailer_from_name); module::set_var("phpmailer", "smtp_server", $str_smtp_server); module::set_var("phpmailer", "use_ssl", $str_use_ssl); module::set_var("phpmailer", "smtp_login", $str_smtp_login); module::set_var("phpmailer", "smtp_password", $str_smtp_pass); module::set_var("phpmailer", "smtp_port", $str_smtp_port); message::success(t("Your Settings Have Been Saved.")); // Load Admin page. $view = new Admin_View("admin.html"); $view->content = new View("admin_phpmailer.html"); $view->content->phpmailer_form = $this->_get_admin_form(); print $view; }
/** * On first session instance creation, sets up the driver and creates session. * * @param string Force a specific session_id */ protected function __construct($session_id = NULL) { $this->input = Input::instance(); // This part only needs to be run once if (Session::$instance === NULL) { // Load config Session::$config = Kohana::config('session'); // Makes a mirrored array, eg: foo=foo Session::$protect = array_combine(Session::$protect, Session::$protect); // Configure garbage collection ini_set('session.gc_probability', (int) Session::$config['gc_probability']); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', Session::$config['expiration'] == 0 ? 86400 : Session::$config['expiration']); // Create a new session $this->create(NULL, $session_id); if (Session::$config['regenerate'] > 0 and $_SESSION['total_hits'] % Session::$config['regenerate'] === 0) { // Regenerate session id and update session cookie $this->regenerate(); } else { // Always update session cookie to keep the session alive cookie::set(Session::$config['name'], $_SESSION['session_id'], Session::$config['expiration']); } // Close the session on system shutdown (run before sending the headers), so that // the session cookie(s) can be written. Event::add('system.shutdown', array($this, 'write_close')); // Singleton instance Session::$instance = $this; } Kohana_Log::add('debug', 'Session Library initialized'); }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); $form = $this->_get_admin_form(); // Figure out which boxes where checked $shareOpts_array = Input::instance()->post("ShareOptions"); $IconsButton = false; $HTMLLinksButton = false; for ($i = 0; $i < count($shareOpts_array); $i++) { if ($shareOpts_array[$i] == "Icons") { $IconsButton = true; } if ($shareOpts_array[$i] == "HTMLLinks") { $HTMLLinksButton = true; } } // Save Settings. module::set_var("sharephoto", "Icons", $IconsButton); module::set_var("sharephoto", "HTMLLinks", $HTMLLinksButton); message::success(t("Your Selection Has Been Saved.")); // Load Admin page. $view = new Admin_View("admin.html"); $view->content = new View("admin_sharephoto.html"); $view->content->sharephoto_form = $form; print $view; }
public function save($module_name, $var_name) { access::verify_csrf(); module::set_var($module_name, $var_name, Input::instance()->post("value")); message::success(t("Saved value for %var (%module_name)", array("var" => $var_name, "module_name" => $module_name))); json::reply(array("result" => "success")); }
public function __call($function, $args) { $input = Input::instance(); $request = new stdClass(); switch ($method = strtolower($input->server("REQUEST_METHOD"))) { case "get": $request->params = (object) $input->get(); break; case "post": $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); } break; } $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); $request->access_token = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); $request->url = url::abs_current(true); rest::set_active_user($request->access_token); $handler_class = "{$function}_rest"; $handler_method = $request->method; if (!method_exists($handler_class, $handler_method)) { throw new Rest_Exception("Bad Request", 400); } try { rest::reply(call_user_func(array($handler_class, $handler_method), $request)); } catch (ORM_Validation_Exception $e) { foreach ($e->validation->errors() as $key => $value) { $msgs[] = "{$key}: {$value}"; } throw new Rest_Exception("Bad Request: " . join(", ", $msgs), 400); } }
function rearrange($target_id, $before_or_after) { access::verify_csrf(); $target = ORM::factory("item", $target_id); $album = $target->parent(); access::required("view", $album); access::required("edit", $album); $source_ids = Input::instance()->post("source_ids", array()); if ($album->sort_column != "weight") { $i = 0; foreach ($album->children() as $child) { // Do this directly in the database to avoid sending notifications db::build()->update("items")->set("weight", ++$i)->where("id", "=", $child->id)->execute(); } $album->sort_column = "weight"; $album->sort_order = "ASC"; $album->save(); $target->reload(); } // Find the insertion point $target_weight = $target->weight; if ($before_or_after == "after") { $target_weight++; } // Make a hole $count = count($source_ids); db::build()->update("items")->set("weight", new Database_Expression("`weight` + {$count}"))->where("weight", ">=", $target_weight)->where("parent_id", "=", $album->id)->execute(); // Insert source items into the hole foreach ($source_ids as $source_id) { db::build()->update("items")->set("weight", $target_weight++)->where("id", "=", $source_id)->execute(); } module::event("album_rearrange", $album); print json_encode(array("grid" => self::_get_micro_thumb_grid($album, 0)->__toString(), "sort_column" => $album->sort_column, "sort_order" => $album->sort_order)); }
public function sendemail() { // Process the data from the form into an email, // then send the email. // Copy the data from the email from into a couple of variables. $str_emailsubject = Input::instance()->post("email_subject"); $str_emailtoid = Input::instance()->post("email_to_id"); $str_emailfrom = Input::instance()->post("email_from"); $str_emailbody = Input::instance()->post("email_body"); // Add in some <br> tags to the message body where ever there are line breaks. $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody); // Gallery's Sendmail library doesn't allow for custom from addresses, // so add the from email to the beginning of the message body instead. $str_emailbody = "Message Sent From " . $str_emailfrom . "\r\n\r\n<br/><br/>" . $str_emailbody; // Figure out where the email is going to. $str_emailto = ""; if ($str_emailtoid == -1) { // If the email id is "-1" send the message to a pre-determined // owner email address. $str_emailto = module::get_var("contactowner", "contact_owner_email"); } else { // or else grab the email from the user table. $userDetails = ORM::factory("user")->where("id", $str_emailtoid)->find_all(); $str_emailto = $userDetails[0]->email; } // Send the email message. Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send(); // Display a message telling the visitor that their email has been sent. $template = new Theme_View("page.html", "Contact"); $template->content = new View("contactowner_emailform.html"); $template->content->sendmail_form = t("Your Message Has Been Sent."); print $template; }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); // Figure out which boxes where checked $dlLinks_array = Input::instance()->post("DownloadLinkOptions"); $fButton = false; $download_original_button = false; for ($i = 0; $i < count($dlLinks_array); $i++) { if ($dlLinks_array[$i] == "fButton") { $fButton = true; } } if (module::is_active("keeporiginal")) { $keeporiginal_array = Input::instance()->post("DownloadOriginalOptions"); for ($i = 0; $i < count($keeporiginal_array); $i++) { if ($keeporiginal_array[$i] == "DownloadOriginalImage") { $download_original_button = true; } } module::set_var("downloadfullsize", "DownloadOriginalImage", $download_original_button); } // Save Settings. module::set_var("downloadfullsize", "fButton", $fButton); message::success(t("Your Selection Has Been Saved.")); // Load Admin page. $view = new Admin_View("admin.html"); $view->content = new View("admin_downloadfullsize.html"); $view->content->downloadlinks_form = $this->_get_admin_form(); print $view; }
public function feed($module_id, $feed_id, $id = null) { $page = (int) Input::instance()->get("page", 1); if ($page < 1) { url::redirect(url::merge(array("page" => 1))); } // Configurable page size between 1 and 100, default 20 $page_size = max(1, min(100, (int) Input::instance()->get("page_size", self::$page_size))); // Run the appropriate feed callback if (module::is_active($module_id)) { $class_name = "{$module_id}_rss"; if (method_exists($class_name, "feed")) { $feed = call_user_func(array($class_name, "feed"), $feed_id, ($page - 1) * $page_size, $page_size, $id); } } if (empty($feed)) { throw new Kohana_404_Exception(); } if ($feed->max_pages && $page > $feed->max_pages) { url::redirect(url::merge(array("page" => $feed->max_pages))); } $view = new View(empty($feed->view) ? "feed.mrss" : $feed->view); unset($feed->view); $view->feed = $feed; $view->pub_date = date("D, d M Y H:i:s T"); $feed->uri = url::abs_site(url::merge($_GET)); if ($page > 1) { $feed->previous_page_uri = url::abs_site(url::merge(array("page" => $page - 1))); } if ($page < $feed->max_pages) { $feed->next_page_uri = url::abs_site(url::merge(array("page" => $page + 1))); } header("Content-Type: application/rss+xml"); print $view; }
public function __call($controller_name, $args) { if (Input::instance()->get("reauth_check")) { return self::_reauth_check(); } if (auth::must_reauth_for_admin_area()) { return self::_prompt_for_reauth($controller_name, $args); } if (request::method() == "post") { access::verify_csrf(); } if ($controller_name == "index") { $controller_name = "dashboard"; } $controller_name = "Admin_{$controller_name}_Controller"; if ($args) { $method = array_shift($args); } else { $method = "index"; } if (!method_exists($controller_name, $method)) { throw new Kohana_404_Exception(); } call_user_func_array(array(new $controller_name(), $method), $args); }
public function processAction(&$controller, $params) { $this->assignEmptyParams($params, 1); list($uuid) = $params; $input = Input::instance(); if (is_array($input->post('submit'))) { if ($input->post('uuid') == '' || current($input->post('submit')) == 'cancel') { $controller->exitQtipAjaxForm(); exit; } $controller->template->content = new View('callmanager/commandresponse'); try { $destobj = Doctrine::getTable('Number')->findOneByforeign_idAndclass_type($input->post('destlot'), 'ValetParkingLotNumber'); $commandresponse = $this->executeAction(array($input->post('uuid'), $destobj->number)); $controller->view->commandresponse = 'Call successfully transfered'; } catch (ESLException $e) { $controller->view->commandresponse = 'An error has occured: ' . $e->getMessage() . '<br>'; } catch (callmanagerException $e) { $controller->view->commandresponse = 'An error has occured: ' . $e->getMessage() . '<br>'; } } else { $controller->template->content = new View('callmanager/valetpark'); $controller->view->uuid = $uuid; } }
public function index() { $view = new Admin_View("admin.html"); $view->page_title = t("Users and groups"); $view->page_type = "collection"; $view->page_subtype = "admin_users"; $view->content = new View("admin_users.html"); // @todo: add this as a config option $page_size = module::get_var("user", "page_size", 10); $page = Input::instance()->get("page", "1"); $builder = db::build(); $user_count = $builder->from("users")->count_records(); // Pagination info $view->page = $page; $view->page_size = $page_size; $view->children_count = $user_count; $view->max_pages = ceil($view->children_count / $view->page_size); $view->content->pager = new Pagination(); $view->content->pager->initialize(array("query_string" => "page", "total_items" => $user_count, "items_per_page" => $page_size, "style" => "classic")); // Make sure that the page references a valid offset if ($page < 1) { url::redirect(url::merge(array("page" => 1))); } else { if ($page > $view->content->pager->total_pages) { url::redirect(url::merge(array("page" => $view->content->pager->total_pages))); } } // Join our users against the items table so that we can get a count of their items // in the same query. $view->content->users = ORM::factory("user")->order_by("users.name", "ASC")->find_all($page_size, $view->content->pager->sql_offset); $view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all(); print $view; }
function save($album_id) { access::verify_csrf(); $album = ORM::factory("item", $album_id); access::required("edit", $album); if (Input::instance()->post("save")) { $titles = Input::instance()->post("title"); $descriptions = Input::instance()->post("description"); $filenames = Input::instance()->post("filename"); $internetaddresses = Input::instance()->post("internetaddress"); $tags = Input::instance()->post("tags"); $enable_tags = module::is_active("tag"); foreach (array_keys($titles) as $id) { $item = ORM::factory("item", $id); if ($item->loaded() && access::can("edit", $item)) { $item->title = $titles[$id]; $item->description = $descriptions[$id]; $item->name = $filenames[$id]; $item->slug = $internetaddresses[$id]; $item->save(); if ($enable_tags) { tag::clear_all($item); foreach (explode(",", $tags[$id]) as $tag_name) { if ($tag_name) { tag::add($item, trim($tag_name)); } } tag::compact(); } } } message::success(t("Captions saved")); } url::redirect($album->abs_url()); }
/** * Attempts to load a view and pre-load view data. * * @throws Kohana_Exception if the requested view cannot be found * @param string $name view name * @param string $page_type page type: album, photo, tags, etc * @param string $theme_name view name * @return void */ public function __construct($name, $page_type) { $theme_name = module::get_var("gallery", "active_site_theme"); if (!file_exists("themes/{$theme_name}")) { module::set_var("gallery", "active_site_theme", "default"); theme::load_themes(); Kohana::log("error", "Unable to locate theme '{$theme_name}', switching to default theme."); } parent::__construct($name); $this->theme_name = module::get_var("gallery", "active_site_theme"); if (user::active()->admin) { $this->theme_name = Input::instance()->get("theme", $this->theme_name); } $this->item = null; $this->tag = null; $this->set_global("theme", $this); $this->set_global("user", user::active()); $this->set_global("page_type", $page_type); $this->set_global("page_title", null); if ($page_type == "album") { $this->set_global("thumb_proportion", $this->thumb_proportion()); } $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); if ($maintenance_mode) { message::warning(t("This site is currently in maintenance mode")); } }
public function processAction(&$controller, $params) { $this->assignEmptyParams($params, 2); list($uuid, $classType) = $params; $input = Input::instance(); if (is_array($input->post('submit'))) { if ($input->post('uuid') == '' || current($input->post('submit')) == 'cancel') { $controller->exitQtipAjaxForm(); exit; } $controller->template->content = new View('callmanager/commandresponse'); try { $destobj = Doctrine::getTable('Number')->findOneByforeign_idAndclass_type($input->post('destlot'), $classType); $commandresponse = $this->executeAction(array($input->post('uuid'), $destobj->number)); $controller->view->commandresponse = 'Call successfully transfered'; } catch (ESLException $e) { $controller->view->commandresponse = '<div class="error">An error has occured: ' . $e->getMessage() . '</div>'; } catch (callmanagerException $e) { $controller->view->commandresponse = '<div class="error">An error has occured: ' . $e->getMessage() . '</div>'; } } else { $controller->template->content = new View('callmanager/transfer'); $controller->view->classType = $classType; $controller->view->uuid = $uuid; $currentuser = users::getCurrentUser(); $userobj = Doctrine::getTable('user')->find($currentuser['user_id']); if (isset($userobj->Device[0]->Number[0])) { $controller->view->userext = $userobj->Device[0]->Number[0]->number; } else { $controller->view->userext = null; } } }