public function save() { access::verify_csrf(); $form = $this->_get_edit_form_admin(); if ($form->validate()) { module::set_var("gallery", "page_size", $form->edit_theme->page_size->value); $thumb_size = $form->edit_theme->thumb_size->value; if (module::get_var("gallery", "thumb_size") != $thumb_size) { graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize"); graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100); module::set_var("gallery", "thumb_size", $thumb_size); } $resize_size = $form->edit_theme->resize_size->value; if (module::get_var("gallery", "resize_size") != $resize_size) { graphics::remove_rule("gallery", "resize", "gallery_graphics::resize"); graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100); module::set_var("gallery", "resize_size", $resize_size); } module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); // Sanitize values that get placed directly in HTML output by theme. module::set_var("gallery", "header_text", html::purify($form->edit_theme->header_text->value)); module::set_var("gallery", "footer_text", html::purify($form->edit_theme->footer_text->value)); module::set_var("gallery", "favicon_url", html::purify($form->edit_theme->favicon_url->value)); module::set_var("gallery", "apple_touch_icon_url", html::purify($form->edit_theme->apple_touch_icon_url->value)); module::event("theme_edit_form_completed", $form); message::success(t("Updated theme details")); url::redirect("admin/theme_options"); } else { $view = new Admin_View("admin.html"); $view->content = new View("admin_theme_options.html"); $view->content->form = $form; print $view; } }
public function index() { $form = $this->_get_form(); if (request::method() == "post") { access::verify_csrf(); if ($form->validate()) { module::set_var("strip_exif", "exiv_path", $_POST['exiv_path']); if ($_POST['exif_tags'] != "") { module::set_var("strip_exif", "exif_remove", isset($_POST['exif_remove']) ? $_POST['exif_remove'] : false); module::set_var("strip_exif", "exif_tags", $_POST['exif_tags']); } else { module::set_var("strip_exif", "exif_remove", false); module::set_var("strip_exif", "exif_tags", self::$defExifTags); } if ($_POST['iptc_tags'] != "") { module::set_var("strip_exif", "iptc_remove", isset($_POST['iptc_remove']) ? $_POST['iptc_remove'] : false); module::set_var("strip_exif", "iptc_tags", $_POST['iptc_tags']); } else { module::set_var("strip_exif", "iptc_remove", false); module::set_var("strip_exif", "iptc_tags", self::$defIptcTags); } if (isset($_POST['verbose'])) { module::set_var("strip_exif", "verbose", $_POST['verbose']); } message::success(t("Settings have been saved")); url::redirect("admin/strip_exif"); } else { message::error(t("There was a problem with the submitted form. Please check your values and try again.")); } } print $this->_get_view(); }
/** * 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")); } }
static function upgrade($version) { $db = Database::instance(); if ($version == 1) { $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); module::set_version("comment", $version = 2); } if ($version == 2) { module::set_var("comment", "access_permissions", "everybody"); module::set_version("comment", $version = 3); } if ($version == 3) { // 40 bytes for server_remote_addr is enough to swallow the longest // representation of an IPv6 addy. // // 255 bytes for server_remote_host is enough to swallow the longest // legit DNS entry, with a few bytes to spare. $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); module::set_version("comment", $version = 4); } if ($version == 4) { module::set_var("comment", "rss_visible", "all"); module::set_version("comment", $version = 5); } // In version 5 we accidentally set the installer variable to rss_available when it should // have been rss_visible. Migrate it over now, if necessary. if ($version == 5) { if (!module::get_var("comment", "rss_visible")) { module::set_var("comment", "rss_visible", module::get_var("comment", "rss_available")); } module::clear_var("comment", "rss_available"); module::set_version("comment", $version = 6); } }
private function _dump_database() { // We now have a clean install with just the packages that we want. Make sure that the // database is clean too. $i = 1; foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) { $blocks = array(); foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) { $blocks[++$i] = $value; } module::set_var("gallery", "blocks_{$key}", serialize($blocks)); } Database::instance()->query("TRUNCATE {caches}"); Database::instance()->query("TRUNCATE {sessions}"); Database::instance()->query("TRUNCATE {logs}"); db::build()->update("users")->set(array("password" => ""))->where("id", "in", array(1, 2))->execute(); $dbconfig = Kohana::config('database.default'); $conn = $dbconfig["connection"]; $sql_file = DOCROOT . "installer/install.sql"; if (!is_writable($sql_file)) { print "{$sql_file} is not writeable"; return; } $command = sprintf("mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > {$sql_file}", escapeshellarg("-h{$conn['host']}"), escapeshellarg("-u{$conn['user']}"), $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "", escapeshellarg($conn['database'])); exec($command, $output, $status); if ($status) { print "<pre>"; print "{$command}\n"; print "Failed to dump database\n"; print implode("\n", $output); return; } // Post-process the sql file $buf = ""; $root = ORM::factory("item", 1); $root_created_timestamp = $root->created; $root_updated_timestamp = $root->updated; $table_name = ""; foreach (file($sql_file) as $line) { // Prefix tables $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line); if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) { $table_name = $matches[1]; } // Normalize dates $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line); $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line); // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM if ($table_name != "search_records") { $line = preg_replace("/ENGINE=\\S+ /", "", $line); } // Null out ids in the vars table since it's an auto_increment table and this will result in // more stable values so we'll have less churn in install.sql. $line = preg_replace("/^INSERT INTO {vars} VALUES \\(\\d+/", "INSERT INTO {vars} VALUES (NULL", $line); $buf .= $line; } $fd = fopen($sql_file, "wb"); fwrite($fd, $buf); fclose($fd); }
static function api_key($api_key = null) { if ($api_key !== null) { module::set_var("gallery", "l10n_client_key", $api_key); } return module::get_var("gallery", "l10n_client_key", ""); }
public function saveprefs() { // Prevent Cross Site Request Forgery access::verify_csrf(); $form = $this->_get_admin_form(); if ($form->validate()) { Kohana_Log::add("error", print_r($form, 1)); module::set_var("tag_albums", "tag_page_title", $form->Tag_Albums_Tag_Sort->tag_page_title->value); module::set_var("tag_albums", "tag_index", $form->Tag_Albums_Tag_Sort->tag_index->value); module::set_var("tag_albums", "tag_index_scope", count($form->Tag_Albums_Tag_Sort->tag_index_scope->value)); module::set_var("tag_albums", "tag_index_filter_top", count($form->Tag_Albums_Tag_Sort->tag_index_filter_top->value)); module::set_var("tag_albums", "tag_index_filter_bottom", count($form->Tag_Albums_Tag_Sort->tag_index_filter_bottom->value)); module::set_var("tag_albums", "tag_sort_by", $form->Tag_Albums_Tag_Sort->tag_sort_by->value); module::set_var("tag_albums", "tag_sort_direction", $form->Tag_Albums_Tag_Sort->tag_sort_direction->value); module::set_var("tag_albums", "subalbum_sort_by", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_by->value); module::set_var("tag_albums", "subalbum_sort_direction", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_direction->value); message::success(t("Your settings have been saved.")); url::redirect("admin/tag_albums"); } // Else show the page with errors $view = new Admin_View("admin.html"); $view->content = new View("admin_tag_albums.html"); $view->content->tag_albums_form = $form; print $view; }
static function upgrade($version) { if ($version == 2) { module::set_var("tagsmap", "restrict_maps", "0"); module::set_version("tagsmap", 3); } }
static function upgrade($version) { // Set the default value for this module's behavior. module::set_var("albumpassword", "hideonly", true); // Set the module's version number. module::set_version("albumpassword", 2); }
public function handler() { access::verify_csrf(); $form = $this->_get_form(); if ($form->validate()) { module::set_var("sitemap_xtra", "path", $form->sitemap->sitemap_path->value); module::set_var("sitemap_xtra", "base_url", $form->sitemap->sitemap_base_url->value); module::set_var("sitemap_xtra", "zip", $form->sitemap->sitemap_zip->value); module::set_var("sitemap_xtra", "ping_yandex", $form->sitemap->sitemap_ping_yandex->value); module::set_var("sitemap_xtra", "ping_google", $form->sitemap->sitemap_ping_google->value); module::set_var("sitemap_xtra", "ping_bing", $form->sitemap->sitemap_ping_bing->value); module::set_var("sitemap_xtra", "ping_ask", $form->sitemap->sitemap_ping_ask->value); module::set_var("sitemap_xtra", "robots_txt", $form->sitemap->sitemap_robots_txt->value); module::set_var("sitemap_xtra", "albums", $form->albums->sitemap_albums->value); module::set_var("sitemap_xtra", "albums_freq", $form->albums->sitemap_albums_freq->value); module::set_var("sitemap_xtra", "albums_prio", $form->albums->sitemap_albums_prio->value); module::set_var("sitemap_xtra", "photos", $form->photos->sitemap_photos->value); module::set_var("sitemap_xtra", "photos_freq", $form->photos->sitemap_photos_freq->value); module::set_var("sitemap_xtra", "photos_prio", $form->photos->sitemap_photos_prio->value); module::set_var("sitemap_xtra", "movies", $form->movies->sitemap_movies->value); module::set_var("sitemap_xtra", "movies_freq", $form->movies->sitemap_movies_freq->value); module::set_var("sitemap_xtra", "movies_prio", $form->movies->sitemap_movies_prio->value); module::set_var("sitemap_xtra", "pages", $form->pages->sitemap_pages->value); module::set_var("sitemap_xtra", "pages_freq", $form->pages->sitemap_pages_freq->value); module::set_var("sitemap_xtra", "pages_prio", $form->pages->sitemap_pages_prio->value); if ($form->build_sitemap->sitemap_build->value) { if ($status = $this->_build_sitemap()) { message::info($status); } } message::success(t("Settings have been saved")); url::redirect("admin/sitemap_xtra"); } print $this->_get_view($form); }
private function _get_admin_view($form, $errors) { $v = new Admin_View("admin.html"); $v->content = new View("admin_register.html"); $v->content->action = "admin/register/update"; $v->content->policy_list = array("admin_only" => t("Only site administrators can create new user accounts."), "visitor" => t("Visitors can create accounts and no administrator approval is required."), "admin_approval" => t("Visitors can create accounts but administrator approval is required.")); $admin = identity::admin_user(); $v->content->disable_email = empty($admin->email) || $form["policy"] == "admin_only" ? "disabled" : ""; if (empty($admin->email)) { module::set_var("registration", "email_verification", false); } $v->content->group_list = array(); foreach (identity::groups() as $group) { if ($group->id != identity::everybody()->id && $group->id != identity::registered_users()->id) { $v->content->group_list[$group->id] = $group->name; } } $hidden = array("csrf" => access::csrf_token()); if (count($v->content->group_list)) { $v->content->group_list = array("" => t("Choose the default group")) + $v->content->group_list; } else { $hidden["group"] = ""; } $v->content->hidden = $hidden; $v->content->pending = ORM::factory("pending_user")->find_all(); $v->content->activate = "admin/register/activate"; $v->content->form = $form; $v->content->errors = $errors; return $v; }
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 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; }
static function install() { $formats = movie_tools::get_formats(); foreach ($formats as $id => $data) { module::set_var("movie_tools", "allow_{$id}", 0); } }
static function initialize() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {users} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `full_name` varchar(255) NOT NULL,\n `password` varchar(64) NOT NULL,\n `login_count` int(10) unsigned NOT NULL DEFAULT 0,\n `last_login` int(10) unsigned NOT NULL DEFAULT 0,\n `email` varchar(64) default NULL,\n `admin` BOOLEAN default 0,\n `guest` BOOLEAN default 0,\n `hash` char(32) default NULL,\n `url` varchar(255) default NULL,\n `locale` char(10) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`hash`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups} (\n `id` int(9) NOT NULL auto_increment,\n `name` char(64) default NULL,\n `special` BOOLEAN default 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (\n `group_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`group_id`, `user_id`),\n UNIQUE KEY(`user_id`, `group_id`))\n DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); $everybody->name = "Everybody"; $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); $registered->name = "Registered Users"; $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; $guest->full_name = "Guest User"; $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; $admin->full_name = "Gallery Administrator"; $admin->password = "******"; $admin->email = "*****@*****.**"; $admin->admin = true; $admin->save(); $root = ORM::factory("item", 1); access::allow($everybody, "view", $root); access::allow($everybody, "view_full", $root); access::allow($registered, "view", $root); access::allow($registered, "view_full", $root); module::set_version("user", 2); module::set_var("user", "mininum_password_length", 5); }
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; }
public function save() { access::verify_csrf(); $form = theme::get_edit_form_admin(); if ($form->validate()) { module::set_var("gallery", "page_size", $form->edit_theme->page_size->value); $thumb_size = $form->edit_theme->thumb_size->value; $thumb_dirty = false; if (module::get_var("gallery", "thumb_size") != $thumb_size) { graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize"); graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100); module::set_var("gallery", "thumb_size", $thumb_size); } $resize_size = $form->edit_theme->resize_size->value; $resize_dirty = false; if (module::get_var("gallery", "resize_size") != $resize_size) { graphics::remove_rule("gallery", "resize", "gallery_graphics::resize"); graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100); module::set_var("gallery", "resize_size", $resize_size); } module::set_var("gallery", "header_text", $form->edit_theme->header_text->value); module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); message::success(t("Updated theme details")); url::redirect("admin/theme_options"); } else { $view = new Admin_View("admin.html"); $view->content = $form; print $view; } }
static function install() { $defaults = array('jpg' => '1', 'png' => '2', 'gif' => '1'); foreach ($defaults as $type => $optlevel) { // set default path as the pre-compiled versions in the lib module::set_var("image_optimizer", "path_" . $type, MODPATH . "image_optimizer/lib/" . image_optimizer::tool_name($type)); // check config status (also sets configstatus_ variables and ensures that the permissions are set correctly) image_optimizer::tool_status($type); // set default optimization levels module::set_var("image_optimizer", "optlevel_thumb_" . $type, $optlevel); module::set_var("image_optimizer", "optlevel_resize_" . $type, $optlevel); } module::set_var("image_optimizer", "rotate_jpg", true); module::set_var("image_optimizer", "enable_thumb", true); module::set_var("image_optimizer", "enable_resize", true); module::set_var("image_optimizer", "update_mode_thumb", false); module::set_var("image_optimizer", "update_mode_resize", false); module::set_var("image_optimizer", "metastrip_thumb", true); module::set_var("image_optimizer", "convert_thumb_png", "jpg"); module::set_var("image_optimizer", "convert_resize_png", false); module::set_var("image_optimizer", "convert_thumb_gif", "jpg"); module::set_var("image_optimizer", "convert_resize_gif", false); module::set_var("image_optimizer", "metastrip_resize", false); module::set_var("image_optimizer", "progressive_thumb", false); module::set_var("image_optimizer", "progressive_resize", true); module::set_version("image_optimizer", 1); image_optimizer::add_image_optimizer_rule("thumb"); image_optimizer::add_image_optimizer_rule("resize"); }
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 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 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; }
static function update_installed($locales) { // Ensure that the default is included... $default = module::get_var("gallery", "default_locale"); $locales = array_merge($locales, array($default)); module::set_var("gallery", "installed_locales", join("|", $locales)); }
private function _dump_database() { // We now have a clean install with just the packages that we want. Make sure that the // database is clean too. $i = 1; foreach (array("blocks_dashboard_sidebar", "blocks_dashboard_center") as $key) { $blocks = array(); foreach (unserialize(module::get_var("gallery", $key)) as $rnd => $value) { $blocks[++$i] = $value; } module::set_var("gallery", $key, serialize($blocks)); } $db = Database::instance(); $db->query("TRUNCATE {sessions}"); $db->query("TRUNCATE {logs}"); $db->query("DELETE FROM {vars} WHERE `module_name` = 'core' AND `name` = '_cache'"); $db->update("users", array("password" => ""), array("id" => 1)); $db->update("users", array("password" => ""), array("id" => 2)); $dbconfig = Kohana::config('database.default'); $conn = $dbconfig["connection"]; $pass = $conn["pass"] ? "-p{$conn['pass']}" : ""; $sql_file = DOCROOT . "installer/install.sql"; if (!is_writable($sql_file)) { print "{$sql_file} is not writeable"; return; } $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} {$pass} {$conn['database']} > {$sql_file}"; exec($command, $output, $status); if ($status) { print "<pre>"; print "{$command}\n"; print "Failed to dump database\n"; print implode("\n", $output); return; } // Post-process the sql file $buf = ""; $root = ORM::factory("item", 1); $root_created_timestamp = $root->created; $root_updated_timestamp = $root->updated; $table_name = ""; foreach (file($sql_file) as $line) { // Prefix tables $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line); if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) { $table_name = $matches[1]; } // Normalize dates $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line); $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line); // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM if ($table_name != "search_records") { $line = preg_replace("/ENGINE=\\S+ /", "", $line); } $buf .= $line; } $fd = fopen($sql_file, "wb"); fwrite($fd, $buf); fclose($fd); }
public function saveprefs() { // Save user preferences to the database. // Prevent Cross Site Request Forgery access::verify_csrf(); // Make sure the user filled out the form properly. $form = $this->_get_admin_form(); if ($form->validate()) { Kohana_Log::add("error", print_r($form, 1)); // Save settings to Gallery's database. foreach (iptc::keys() as $keyword => $iptcvar) { $checkbox = false; for ($i = 0; $i < count($form->Global->{$keyword}); $i++) { if ($form->Global->{$keyword}->value[$i] == $keyword) { $checkbox = true; } } module::set_var("iptc", "show_" . $keyword, $checkbox); } // Display a success message and redirect back to the TagsMap admin page. message::success(t("Your settings have been saved.")); url::redirect("admin/iptc"); } // Else show the page with errors $view = new Admin_View("admin.html"); $view->content = new View("admin_iptc.html"); $view->content->iptc_form = $form; print $view; }
public function handler() { access::verify_csrf(); $form = $this->_get_form(); if ($form->validate()) { module::set_var("social_share", "general_impage_only", $form->general_settings->general_impage_only->value); module::set_var("social_share", "facebook_share_enabled", $form->facebook_share_settings->facebook_share_enabled->value); module::set_var("social_share", "facebook_share_layout", $form->facebook_share_settings->facebook_share_layout->value); module::set_var("social_share", "facebook_share_link_text", $form->facebook_share_settings->facebook_share_link_text->value); module::set_var("social_share", "facebook_like_enabled", $form->facebook_like_settings->facebook_like_enabled->value); module::set_var("social_share", "facebook_like_appId", $form->facebook_like_settings->facebook_like_appId->value); module::set_var("social_share", "facebook_like_adminId", $form->facebook_like_settings->facebook_like_adminId->value); module::set_var("social_share", "facebook_like_site_name", $form->facebook_like_settings->facebook_like_site_name->value); module::set_var("social_share", "facebook_like_code_type", $form->facebook_like_settings->facebook_like_code_type->value); module::set_var("social_share", "facebook_like_show_faces", $form->facebook_like_settings->facebook_like_show_faces->value, true); module::set_var("social_share", "facebook_like_send", $form->facebook_like_settings->facebook_like_send->value, true); module::set_var("social_share", "facebook_like_action", $form->facebook_like_settings->facebook_like_action->value); module::set_var("social_share", "facebook_like_layout", $form->facebook_like_settings->facebook_like_layout->value); module::set_var("social_share", "google_enabled", $form->google_settings->google_enabled->value); module::set_var("social_share", "google_size", $form->google_settings->google_size->value); module::set_var("social_share", "google_annotation", $form->google_settings->google_annotation->value); module::set_var("social_share", "pinterest_enabled", $form->pinterest_settings->pinterest_enabled->value); module::set_var("social_share", "pinterest_count_location", $form->pinterest_settings->pinterest_count_location->value); module::set_var("social_share", "twitter_enabled", $form->twitter_settings->twitter_enabled->value); module::set_var("social_share", "twitter_count_location", $form->twitter_settings->twitter_count_location->value); module::set_var("social_share", "twitter_size", $form->twitter_settings->twitter_size->value); message::success(t("Your settings have been saved.")); url::redirect("admin/social_share"); } print $this->_get_view($form); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {comments} (\n `author_id` int(9) default NULL,\n `created` int(9) NOT NULL,\n `guest_email` varchar(128) default NULL,\n `guest_name` varchar(128) default NULL,\n `guest_url` varchar(255) default NULL,\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `server_http_accept_charset` varchar(64) default NULL,\n `server_http_accept_encoding` varchar(64) default NULL,\n `server_http_accept_language` varchar(64) default NULL,\n `server_http_accept` varchar(128) default NULL,\n `server_http_connection` varchar(64) default NULL,\n `server_http_host` varchar(64) default NULL,\n `server_http_referer` varchar(255) default NULL,\n `server_http_user_agent` varchar(128) default NULL,\n `server_query_string` varchar(64) default NULL,\n `server_remote_addr` varchar(32) default NULL,\n `server_remote_host` varchar(64) default NULL,\n `server_remote_port` varchar(16) default NULL,\n `state` varchar(15) default 'unpublished',\n `text` text,\n `updated` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); module::set_var("comment", "spam_caught", 0); module::set_version("comment", 2); }
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; }
public function edit() { access::verify_csrf(); $form = $this->_get_admin_form(); if ($form->validate()) { $options = $form->tag_cloud_options; $valid = true; if (preg_match("/^0x[0-9A-Fa-f]{6}\$/", $options->tagcolor->value) == 0) { $options->tagcolor->add_error("not_valid", 1); $valid = false; } if (preg_match("/^0x[0-9A-Fa-f]{6}\$/", $options->background_color->value) == 0) { $options->background_color->add_error("not_valid", 1); $valid = false; } if ($valid) { module::set_var("tag_cloud", "tagcolor", $options->tagcolor->value); module::set_var("tag_cloud", "mouseover", $options->mouseover->value); module::set_var("tag_cloud", "background_color", $options->background_color->value); module::set_var("tag_cloud", "transparent", $options->transparent->value); module::set_var("tag_cloud", "speed", $options->speed->value); module::set_var("tag_cloud", "distribution", $options->distribution->value); message::success(t("Tag cloud options updated successfully")); url::redirect("admin/tag_cloud"); } } $view = new Admin_View("admin.html"); $view->content = new View("admin_tag_cloud.html"); $view->content->form = $form; print $view; }
static function upgrade($version) { if ($version == 1) { module::set_var("slideshow", "max_scale", 0); module::set_version("slideshow", $version = 2); } }
public function change() { access::verify_csrf(); $active_provider = module::get_var("gallery", "identity_provider", "user"); $providers = identity::providers(); $new_provider = Input::instance()->post("provider"); if ($new_provider != $active_provider) { module::deactivate($active_provider); // Switch authentication identity::reset(); module::set_var("gallery", "identity_provider", $new_provider); module::install($new_provider); module::activate($new_provider); module::event("identity_provider_changed", $active_provider, $new_provider); module::uninstall($active_provider); message::success(t("Changed to %description", array("description" => $providers->{$new_provider}))); try { Session::instance()->destroy(); } catch (Exception $e) { // We don't care if there was a problem destroying the session. } url::redirect(item::root()->abs_url()); } message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider}))); url::redirect("admin/identity"); }