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);
 }
示例#2
0
 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");
 }
示例#3
0
 public function index()
 {
     if ($_POST) {
         config::set('akismet.api_key', $this->input->post('akismet_api_key'));
         message::info(__('Settings changed successfully'), 'admin/akismet');
     } else {
         $this->head->title->append(__('Settings'));
         $this->template->title .= __('Settings');
         $this->template->content = new View('akismet/settings');
         $this->template->content->akismet_api_key = config::get('akismet.api_key');
     }
 }
 public function index()
 {
     if ($_POST) {
         config::set('google_analytics.id', $this->input->post('google_analytics_id'));
         message::info('Settings changed successfully', 'admin/google_analytics');
     } else {
         $this->head->title->append('Settings');
         $this->template->title .= 'Settings';
         $this->template->content = new View('google_analytics/settings');
         $this->template->content->google_analytics_id = config::get('google_analytics.id');
     }
 }
示例#5
0
 public function index()
 {
     $this->head->title->append(__('Settings'));
     $this->template->title = __('Settings');
     $form = Formo::factory()->plugin('csrf')->add('text', 'site_title', array('label' => __('Site title'), 'value' => config::get('s7n.site_title')))->add_select('theme', theme::available(), array('label' => __('Theme'), 'value' => config::get('s7n.theme')))->add('submit', 'submit', array('label' => __('Save')));
     if ($form->validate()) {
         config::set('s7n.site_title', $form->site_title->value);
         config::set('s7n.theme', $form->theme->value);
         message::info(__('Settings edited successfully'), 'admin/settings');
     }
     $this->template->content = View::factory('settings/settings', $form->get(TRUE));
 }
示例#6
0
 public function delete($id)
 {
     $user = ORM::factory('user', (int) $id);
     if (!$user->loaded) {
         message::error(__('Invalid ID'), 'admin/user');
     }
     if ($user->id === Auth::instance()->get_user()->id) {
         message::error(__('You can\'t delete yourself'), 'admin/user');
     }
     $user->remove(ORM::factory('role', 'login'));
     $user->remove(ORM::factory('role', 'admin'));
     $user->delete();
     message::info(__('User deleted successfully'), 'admin/user');
 }
示例#7
0
文件: item.php 项目: qboy1987/mooiyou
 static function move($source, $target)
 {
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $source);
     access::required("edit", $target);
     $parent = $source->parent();
     if ($parent->album_cover_item_id == $source->id) {
         if ($parent->children_count() > 1) {
             foreach ($parent->children(2) as $child) {
                 if ($child->id != $source->id) {
                     $new_cover_item = $child;
                     break;
                 }
             }
             item::make_album_cover($new_cover_item);
         } else {
             item::remove_album_cover($parent);
         }
     }
     $orig_name = $source->name;
     $source->parent_id = $target->id;
     $source->save();
     if ($orig_name != $source->name) {
         switch ($source->type) {
             case "album":
                 message::info(t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
             case "photo":
                 message::info(t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
             case "movie":
                 message::info(t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
         }
     }
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         item::make_album_cover($source);
     }
 }
示例#8
0
 public static function checkLogin()
 {
     $username = type::post('username', 'string', '');
     $password = type::post('password', 'string', '');
     if ($username == '' || $password == '') {
         echo message::info(lang::get('login_form_notfull'), true);
         return;
     }
     $sql = sql::factory();
     $sql->query('SELECT password, salt, id FROM ' . sql::table('community_user') . ' WHERE `username` = "' . $sql->escape($username) . '"');
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('login_no_user'), $email), true);
         return;
     }
     $sql->result();
     if (!userLogin::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
         echo message::danger(lang::get('login_pwd_false'), true);
         return;
     }
     $_SESSION['community-login'] = $sql->get('id');
     self::checkSession();
     // Für spätere Foren-Bridges
     extension::get('COMMUNITY_USER_LOGIN', $password);
 }
示例#9
0
 public function uninstall($module)
 {
     require_once MODPATH . $module . '/helpers/' . $module . '_installer.php';
     call_user_func($module . '_installer::uninstall');
     message::info(__('Module uninstalled successfully'), 'admin/modules');
 }
示例#10
0
 private function _save_api_key($form)
 {
     $new_key = $form->sharing->api_key->value;
     if ($new_key) {
         list($connected, $valid) = l10n_client::validate_api_key($new_key);
         if (!$valid) {
             $form->sharing->api_key->add_error($connected ? "invalid" : "no_connection", 1);
         }
     } else {
         $valid = true;
     }
     if ($valid) {
         $old_key = l10n_client::api_key();
         l10n_client::api_key($new_key);
         if ($old_key && !$new_key) {
             message::success(t("Your API key has been cleared."));
         } else {
             if ($old_key && $new_key && $old_key != $new_key) {
                 message::success(t("Your API key has been changed."));
             } else {
                 if (!$old_key && $new_key) {
                     message::success(t("Your API key has been saved."));
                 } else {
                     if ($old_key && $new_key && $old_key == $new_key) {
                         message::info(t("Your API key was not changed."));
                     }
                 }
             }
         }
         log::success(t("gallery"), t("l10n_client API key changed."));
         url::redirect("admin/languages");
     } else {
         // Show the page with form errors
         $this->index($form);
     }
 }
示例#11
0
 /**
  * This is the task code that adds photos and albums.  It first examines all the target files
  * and creates a set of Server_Add_File_Models, then runs through the list of models and adds
  * them one at a time.
  */
 static function add($task)
 {
     $mode = $task->get("mode", "init");
     $start = microtime(true);
     switch ($mode) {
         case "init":
             $task->set("mode", "build-file-list");
             $task->percent_complete = 0;
             $task->status = t("Starting up");
             batch::start();
             break;
         case "build-file-list":
             // 0% to 10%
             // We can't fit an arbitrary number of paths in a task, so store them in a separate table.
             // Don't use an iterator here because we can't get enough control over it when we're dealing
             // with a deep hierarchy and we don't want to go over our time quota.  The queue is in the
             // form [path, parent_id] where the parent_id refers to another Server_Add_File_Model.  We
             // have this extra level of abstraction because we don't know its Item_Model id yet.
             $queue = $task->get("queue");
             $paths = unserialize(module::get_var("videos", "authorized_paths"));
             while ($queue && microtime(true) - $start < 0.5) {
                 list($file, $parent_entry_id) = array_shift($queue);
                 // Ignore the staging directories as directories to be imported.
                 if (empty($paths[$file])) {
                     $entry = ORM::factory("videos_file");
                     $entry->task_id = $task->id;
                     $entry->file = $file;
                     $entry->parent_id = $parent_entry_id;
                     $entry->save();
                     $entry_id = $entry->id;
                 } else {
                     $entry_id = null;
                 }
                 $file = preg_quote($file);
                 foreach (glob("{$file}/*") as $child) {
                     if (is_dir($child)) {
                         $queue[] = array($child, $entry_id);
                     } else {
                         $ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
                         //if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) &&
                         if (in_array($ext, unserialize(module::get_var("videos", "allowed_extensions"))) && filesize($child) > 0) {
                             $child_entry = ORM::factory("videos_file");
                             $child_entry->task_id = $task->id;
                             $child_entry->file = $child;
                             $child_entry->parent_id = $entry_id;
                             $child_entry->save();
                         }
                     }
                 }
             }
             // We have no idea how long this can take because we have no idea how deep the tree
             // hierarchy rabbit hole goes.  Leave ourselves room here for 100 iterations and don't go
             // over 10% in percent_complete.
             $task->set("queue", $queue);
             $task->percent_complete = min($task->percent_complete + 0.1, 10);
             $task->status = t2("Found one file", "Found %count files", ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
             if (!$queue) {
                 $task->set("mode", "add-files");
                 $task->set("total_files", ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
                 $task->percent_complete = 10;
             }
             break;
         case "add-files":
             // 10% to 100%
             $completed_files = $task->get("completed_files", 0);
             $total_files = $task->get("total_files");
             // Ordering by id ensures that we add them in the order that we created the entries, which
             // will create albums first.  Ignore entries which already have an Item_Model attached,
             // they're done.
             $entries = ORM::factory("videos_file")->where("task_id", "=", $task->id)->where("item_id", "IS", null)->order_by("id", "ASC")->limit(10)->find_all();
             if ($entries->count() == 0) {
                 // Out of entries, we're done.
                 $task->set("mode", "done");
             }
             $owner_id = identity::active_user()->id;
             foreach ($entries as $entry) {
                 if (microtime(true) - $start > 0.5) {
                     break;
                 }
                 // Look up the parent item for this entry.  By now it should exist, but if none was
                 // specified, then this belongs as a child of the current item.
                 $parent_entry = ORM::factory("videos_file", $entry->parent_id);
                 if (!$parent_entry->loaded()) {
                     $parent = ORM::factory("item", $task->get("item_id"));
                 } else {
                     $parent = ORM::factory("item", $parent_entry->item_id);
                 }
                 $name = basename($entry->file);
                 $title = item::convert_filename_to_title($name);
                 if (is_dir($entry->file)) {
                     $album = ORM::factory("item");
                     $album->type = "album";
                     $album->parent_id = $parent->id;
                     $album->name = $name;
                     $album->title = $title;
                     $album->owner_id = $owner_id;
                     $album->save();
                     $entry->item_id = $album->id;
                 } else {
                     try {
                         $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
                         if (in_array($extension, unserialize(module::get_var("videos", "allowed_extensions")))) {
                             $movie = ORM::factory("item");
                             $movie->type = "movie";
                             $movie->parent_id = $parent->id;
                             $movie->set_data_file($entry->file);
                             $movie->name = $name;
                             $movie->title = $title;
                             $movie->owner_id = $owner_id;
                             $movie->save();
                             $entry->item_id = $movie->id;
                             $items_video = ORM::factory("items_video");
                             $items_video->item_id = $movie->id;
                             $items_video->save();
                             if (file_exists($entry->file . ".flv")) {
                                 copy($entry->file . ".flv", $movie->resize_path() . ".flv");
                                 list($vid_width, $vid_height, $mime_type) = movie::get_file_metadata($entry->file . ".flv");
                                 $movie->height = $vid_height;
                                 $movie->width = $vid_width;
                                 $movie->save();
                             }
                         } else {
                             // This should never happen, because we don't add stuff to the list that we can't
                             // process.  But just in, case.. set this to a non-null value so that we skip this
                             // entry.
                             $entry->item_id = 0;
                             $task->log("Skipping unknown file type: {$entry->file}");
                         }
                     } catch (Exception $e) {
                         // This can happen if a photo file is invalid, like a BMP masquerading as a .jpg
                         $entry->item_id = 0;
                         $task->log("Skipping invalid file: {$entry->file}");
                     }
                 }
                 $completed_files++;
                 $entry->save();
             }
             $task->set("completed_files", $completed_files);
             $task->status = t("Adding photos / albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files));
             $task->percent_complete = $total_files ? 10 + 100 * ($completed_files / $total_files) : 100;
             break;
         case "done":
             batch::stop();
             $task->done = true;
             $task->state = "success";
             $task->percent_complete = 100;
             db::build()->delete("videos_files")->where("task_id", "=", $task->id)->execute();
             message::info(t2("Successfully added one file", "Successfully added %count files", $task->get("completed_files")));
     }
 }
示例#12
0
 static function move($source, $target)
 {
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $source);
     access::required("edit", $target);
     $parent = $source->parent();
     if ($parent->album_cover_item_id == $source->id) {
         if ($parent->children_count() > 1) {
             foreach ($parent->children(2) as $child) {
                 if ($child->id != $source->id) {
                     $new_cover_item = $child;
                     break;
                 }
             }
             item::make_album_cover($new_cover_item);
         } else {
             item::remove_album_cover($parent);
         }
     }
     $source->parent_id = $target->id;
     // Moving may result in name or slug conflicts.  If that happens, try up to 5 times to pick a
     // random name (or slug) to avoid the conflict.
     $orig_name = $source->name;
     $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
     $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
     $orig_slug = $source->slug;
     for ($i = 0; $i < 5; $i++) {
         try {
             $source->save();
             if ($orig_name != $source->name) {
                 switch ($source->type) {
                     case "album":
                         message::info(t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                     case "photo":
                         message::info(t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                     case "movie":
                         message::info(t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                 }
             }
             break;
         } catch (ORM_Validation_Exception $e) {
             $rand = rand(10, 99);
             $errors = $e->validation->errors();
             if (isset($errors["name"])) {
                 $source->name = $orig_name_filename . "-{$rand}." . $orig_name_extension;
                 unset($errors["name"]);
             }
             if (isset($errors["slug"])) {
                 $source->slug = $orig_slug . "-{$rand}";
                 unset($errors["slug"]);
             }
             if ($errors) {
                 // There were other validation issues-- we don't know how to handle those
                 throw $e;
             }
         }
     }
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         item::make_album_cover($source);
     }
 }
示例#13
0
 public static function logout()
 {
     unset($_SESSION['login']);
     self::$isLogin = false;
     echo message::info(lang::get('login_logout_success'), true);
 }
示例#14
0
 /**
  * This is the task code that adds photos and albums.  It first examines all the target files
  * and creates a set of Server_Add_File_Models, then runs through the list of models and adds
  * them one at a time.
  */
 static function add($task)
 {
     $mode = $task->get("mode", "init");
     $start = microtime(true);
     switch ($mode) {
         case "init":
             $task->set("mode", "build-file-list");
             $task->percent_complete = 0;
             $task->status = t("Starting up");
             batch::start();
             break;
         case "build-file-list":
             // 0% to 10%
             // We can't fit an arbitrary number of paths in a task, so store them in a separate table.
             // Don't use an iterator here because we can't get enough control over it when we're dealing
             // with a deep hierarchy and we don't want to go over our time quota.  The queue is in the
             // form [path, parent_id] where the parent_id refers to another Server_Add_File_Model.  We
             // have this extra level of abstraction because we don't know its Item_Model id yet.
             $queue = $task->get("queue");
             while ($queue && microtime(true) - $start < 0.5) {
                 list($file, $parent_entry_id) = array_shift($queue);
                 $entry = ORM::factory("server_add_file");
                 $entry->task_id = $task->id;
                 $entry->file = $file;
                 $entry->parent_id = $parent_entry_id;
                 $entry->save();
                 foreach (glob("{$file}/*") as $child) {
                     if (is_dir($child)) {
                         $queue[] = array($child, $entry->id);
                     } else {
                         $ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
                         if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
                             $child_entry = ORM::factory("server_add_file");
                             $child_entry->task_id = $task->id;
                             $child_entry->file = $child;
                             $child_entry->parent_id = $entry->id;
                             $child_entry->save();
                         }
                     }
                 }
             }
             // We have no idea how long this can take because we have no idea how deep the tree
             // hierarchy rabbit hole goes.  Leave ourselves room here for 100 iterations and don't go
             // over 10% in percent_complete.
             $task->set("queue", $queue);
             $task->percent_complete = min($task->percent_complete + 0.1, 10);
             $task->status = t2("Found one file", "Found %count files", Database::instance()->where("task_id", $task->id)->count_records("server_add_files"));
             if (!$queue) {
                 $task->set("mode", "add-files");
                 $task->set("total_files", database::instance()->count_records("server_add_files", array("task_id" => $task->id)));
                 $task->percent_complete = 10;
             }
             break;
         case "add-files":
             // 10% to 100%
             $completed_files = $task->get("completed_files", 0);
             $total_files = $task->get("total_files");
             // Ordering by id ensures that we add them in the order that we created the entries, which
             // will create albums first.  Ignore entries which already have an Item_Model attached,
             // they're done.
             $entries = ORM::factory("server_add_file")->where("task_id", $task->id)->where("item_id", null)->orderby("id", "ASC")->limit(10)->find_all();
             if ($entries->count() == 0) {
                 // Out of entries, we're done.
                 $task->set("mode", "done");
             }
             $owner_id = user::active()->id;
             foreach ($entries as $entry) {
                 if (microtime(true) - $start > 0.5) {
                     break;
                 }
                 // Look up the parent item for this entry.  By now it should exist, but if none was
                 // specified, then this belongs as a child of the current item.
                 $parent_entry = ORM::factory("server_add_file", $entry->parent_id);
                 if (!$parent_entry->loaded) {
                     $parent = ORM::factory("item", $task->get("item_id"));
                 } else {
                     $parent = ORM::factory("item", $parent_entry->item_id);
                 }
                 $name = basename($entry->file);
                 $title = item::convert_filename_to_title($name);
                 if (is_dir($entry->file)) {
                     $album = album::create($parent, $name, $title, null, $owner_id);
                     $entry->item_id = $album->id;
                 } else {
                     $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
                     if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
                         $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
                         $entry->item_id = $photo->id;
                     } else {
                         if (in_array($extension, array("flv", "mp4"))) {
                             $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
                             $entry->item_id = $movie->id;
                         } else {
                             // This should never happen, because we don't add stuff to the list that we can't
                             // process.  But just in, case.. set this to a non-null value so that we skip this
                             // entry.
                             $entry->item_id = 0;
                             $task->log("Skipping unknown file type: {$entry->file}");
                         }
                     }
                 }
                 $completed_files++;
                 $entry->save();
             }
             $task->set("completed_files", $completed_files);
             $task->status = t("Adding photos and albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files));
             $task->percent_complete = 10 + 100 * ($completed_files / $total_files);
             break;
         case "done":
             batch::stop();
             $task->done = true;
             $task->state = "success";
             $task->percent_complete = 100;
             ORM::factory("server_add_file")->where("task_id", $task->id)->delete_all();
             message::info(t2("Successfully added one photo", "Successfully added %count photos and albums", $task->get("completed_files")));
     }
 }
 static function create_theme($task)
 {
     try {
         $mode = $task->get("mode", "init");
         $start = microtime(true);
         $theme_name = $task->get("theme_name");
         $is_admin = $task->get("is_admin", false);
         $theme_path = THEMEPATH . "{$theme_name}/";
         $parameters = Cache::instance()->get("create_theme_cache:{$task->id}");
         if ($parameters) {
             $parameters = unserialize($parameters);
         }
         $completed = $task->get("completed", 0);
         switch ($mode) {
             case "init":
                 $task->log(t("Starting theme '%theme' creation", array("theme" => $task->get("display_name"))));
                 $task->set("mode", "create_directory");
                 $parameters = themeroller::get_theme_parameters($task->get("original_name"), $task->get("path"), $is_admin);
                 $task->set("total_activites", 7 + 3 + count($parameters["standard_css"]) + count($parameters["views"]) + count($parameters["js"]) + count($parameters["masks"]) + count($parameters["icons"]) + count($parameters["css_files"]) + count($parameters["gifs"]) + count($parameters["images"]));
                 // number of image files to copy
                 $task->status = t("Starting up");
                 break;
             case "create_directory":
                 $completed = $task->get("completed");
                 foreach (array("", "css", "css/themeroller", "css/themeroller/images", "images", "js", "views") as $dir) {
                     $path = "{$theme_path}{$dir}";
                     $completed++;
                     if (!file_exists($path)) {
                         mkdir($path);
                         chmod($path, 0755);
                         $task->log(t("Created directory: %path", array("path" => $path)));
                     }
                 }
                 $task->status = t("Directories created");
                 $task->set("mode", "copy_views");
                 break;
             case "copy_views":
                 $task->status = t("Copying views");
                 while (!empty($parameters["views"]) && microtime(true) - $start < 1.5) {
                     $view = array_shift($parameters["views"]);
                     $target = "{$theme_path}views/" . basename($view);
                     if (!file_exists($target)) {
                         copy($view, $target);
                         $task->log(t("Copied view: %path", array("path" => basename($view))));
                     }
                     $completed++;
                 }
                 if (empty($parameters["views"])) {
                     $task->status = t("Views copied");
                     $task->set("mode", "copy_themeroller_images");
                 }
                 break;
             case "copy_themeroller_images":
                 $task->status = t("Copying themeroller images");
                 while (!empty($parameters["images"]) && microtime(true) - $start < 1.5) {
                     $image = array_shift($parameters["images"]);
                     $target = "{$theme_path}css/themeroller/images/" . basename($image);
                     if (!file_exists($target)) {
                         copy($image, $target);
                         $task->log(t("Copied themeroller image: %path", array("path" => basename($image))));
                     }
                     $completed++;
                 }
                 if (empty($parameters["views"])) {
                     $task->status = t("Themeroller images copied");
                     $task->set("mode", "copy_gif_images");
                 }
                 break;
             case "copy_gif_images":
                 $task->status = t("Copying gif images");
                 while (!empty($parameters["gifs"]) && microtime(true) - $start < 1.5) {
                     $gif = array_shift($parameters["gifs"]);
                     $target = "{$theme_path}images/" . basename($gif);
                     if (!file_exists($target)) {
                         copy($gif, $target);
                         $task->log(t("Copied gif image: %path", array("path" => basename($gif))));
                     }
                     $completed++;
                 }
                 if (empty($parameters["gifs"])) {
                     $task->status = t("Gif images copied");
                     $task->set("mode", "copy_css");
                 }
                 break;
             case "copy_css":
                 $task->status = t("Copying themeroller css");
                 $target = "{$theme_path}css/themeroller/ui.base.css";
                 copy($parameters["css_files"][0], $target);
                 $completed++;
                 $task->log(t("Copied themeroller css: themeroller/ui.base.css"));
                 $task->status = t("Themeroller css copied");
                 $task->set("mode", "generate_images");
                 break;
             case "generate_images":
                 $task->status = t("Generating gallery images");
                 $target_dir = "{$theme_path}images/";
                 $colors = $task->get("colors");
                 $image_color = $parameters["colors"]["iconColorContent"];
                 while (!empty($parameters["masks"]) && microtime(true) - $start < 1.5) {
                     $mask = array_shift($parameters["masks"]);
                     $basename = basename($mask);
                     if (preg_match("/(.*)_mask(\\[(\\w*)\\])?(\\.png)\$/", $basename, $matches)) {
                         $basename = "{$matches[1]}{$matches[4]}";
                         $image_color = empty($matches[3]) ? $parameters["colors"]["iconColorContent"] : $parameters["colors"][$matches[3]];
                     } else {
                         $image_color = $parameters["colors"]["iconColorContent"];
                     }
                     $image_file = "{$target_dir}{$basename}";
                     themeroller::generate_image($mask, $image_file, $image_color);
                     $completed++;
                     $task->log(t("Generated image: %path", array("path" => $image_file)));
                 }
                 if (empty($parameters["masks"])) {
                     $task->set("mode", "generate_icons");
                     $task->status = t("Gallery images generated");
                 }
                 break;
             case "generate_icons":
                 $task->status = t("Generating icons");
                 $target_dir = "{$theme_path}css/themeroller/images/";
                 $mask_file = $parameters["icon_mask"];
                 while (!empty($parameters["icons"]) && microtime(true) - $start < 1.5) {
                     $color = array_shift($parameters["icons"]);
                     $icon_file = $target_dir . str_replace("mask", $color, basename($mask_file));
                     themeroller::generate_image($mask_file, $icon_file, $color);
                     $completed++;
                     $task->log(t("Generated themeroller icon: %path", array("path" => $icon_file)));
                 }
                 if (empty($parameters["icons"])) {
                     $task->set("mode", "copy_standard_css");
                     $task->status = t("Icons generated");
                 }
                 break;
             case "copy_standard_css":
                 $task->status = t("Copying standard css");
                 while (!empty($parameters["standard_css"]) && microtime(true) - $start < 1.5) {
                     $css = array_shift($parameters["standard_css"]);
                     $target = "{$theme_path}css/" . basename($css);
                     if (!file_exists($target)) {
                         copy($css, $target);
                         $task->log(t("Copied css file: %path", array("path" => basename($target))));
                     }
                     $completed++;
                 }
                 if (empty($parameters["standard_css"])) {
                     $task->status = t("Standard css copied");
                     $task->set("mode", "copy_javascript");
                 }
                 break;
             case "copy_javascript":
                 $task->status = t("Copying javascript");
                 while (!empty($parameters["js"]) && microtime(true) - $start < 1.5) {
                     $js = array_shift($parameters["js"]);
                     $target = "{$theme_path}js/" . str_replace(array("admin_", "site_"), "", basename($js));
                     if (!file_exists($target)) {
                         copy($js, $target);
                         $task->log(t("Copied js file: %path", array("path" => basename($target))));
                     }
                     $completed++;
                 }
                 if (empty($parameters["js"])) {
                     $task->status = t("Javascript copied");
                     $task->set("mode", "generate_screen_css");
                 }
                 break;
             case "generate_screen_css":
                 $file = "{$theme_path}/css/screen.css";
                 foreach (array("screen", "screen-rtl") as $file) {
                     $css_file = "{$theme_path}/css/{$file}.css";
                     $v = new View(($is_admin ? "admin" : "site") . "_{$file}.css");
                     $v->display_name = $task->get("display_name");
                     foreach ($parameters["colors"] as $color => $value) {
                         $v->{$color} = $value;
                     }
                     ob_start();
                     print $v->render();
                     file_put_contents($css_file, ob_get_contents());
                     ob_end_clean();
                 }
                 $completed++;
                 $task->log(t("Generated screen css: %path", array("path" => $file)));
                 $task->status = t("Screen css generated");
                 $task->set("mode", "generate_thumbnail");
                 break;
             case "generate_thumbnail":
                 themeroller::generate_thumbnail($parameters["thumbnail"], $parameters["thumbnail_parts"], "{$theme_path}thumbnail.png");
                 $task->status = t("Thumbnail generated");
                 $task->set("mode", "generate_theme_info");
                 $completed++;
                 $task->log(t("Generated theme thumbnail: %path", array("path" => "{$theme_path}thumbnail.png")));
                 break;
             case "generate_theme_info":
                 $file = "{$theme_path}/theme.info";
                 $v = new View("theme.info");
                 $v->display_name = $task->get("display_name");
                 $v->description = $task->get("description");
                 $v->user_name = $task->get("user_name");
                 $v->author_url = $task->get("author_url");
                 $v->info_url = $task->get("info_url");
                 $v->discuss_url = $task->get("discuss_url");
                 $v->is_admin = $is_admin;
                 $v->definition = json_encode($parameters["colors"]);
                 ob_start();
                 print $v->render();
                 file_put_contents($file, ob_get_contents());
                 ob_end_clean();
                 $completed++;
                 $task->log(t("Generated theme info: %path", array("path" => "{$theme_path}theme.info")));
                 $task->status = t("Theme info generated");
                 $task->set("mode", "done");
                 break;
             case "done":
                 themeroller::recursive_directory_delete($task->get("path"));
                 $display_name = $task->get("display_name");
                 $task->done = true;
                 $task->state = "success";
                 $task->percent_complete = 100;
                 $completed = $task->get("total_activites");
                 Cache::instance()->delete("create_theme_cache:{$task->id}");
                 $message = t("Successfully generated: %name", array("name" => $display_name));
                 message::info($message);
                 $task->log($message);
                 $task->status = t("'%name' generated", array("name" => $display_name));
         }
         $task->set("completed", $completed);
         if (!$task->done) {
             Cache::instance()->set("create_theme_cache:{$task->id}", serialize($parameters));
             $task->percent_complete = $completed / $task->get("total_activites") * 100;
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $task->log((string) $e);
     }
 }
示例#16
0
 public function settings()
 {
     $this->head->title->append(__('Settings'));
     $this->template->title .= __('Settings');
     $form = Formo::factory()->plugin('csrf')->add('text', 'items_per_page', array('label' => __('Blog entries per page'), 'value' => config::get('blog.items_per_page')))->add('checkbox', 'enable_captcha', array('label' => __('Enable captcha'), 'checked' => config::get('blog.enable_captcha') === 'yes'))->add('checkbox', 'enable_tagcloud', array('label' => __('Enable tag cloud'), 'checked' => config::get('blog.enable_tagcloud') === 'yes'))->add('checkbox', 'comment_status', array('label' => __('Enable comments'), 'checked' => config::get('blog.comment_status') === 'open'))->add('submit', 'submit', array('label' => __('Save')))->add_rule('items_per_page', 'required', __('Please enter a number'))->add_rule('items_per_page', 'digit', __('This must be a number'));
     if ($form->validate()) {
         config::set('blog.enable_captcha', $form->enable_captcha->checked ? 'yes' : 'no');
         config::set('blog.enable_tagcloud', $form->enable_tagcloud->checked ? 'yes' : 'no');
         config::set('blog.comment_status', $form->comment_status->checked ? 'open' : 'closed');
         config::set('blog.items_per_page', $form->items_per_page->value);
         message::info(__('Settings changed successfully'), 'admin/blog/settings');
     }
     $this->template->content = new View('blog/settings', $form->get(TRUE));
 }
示例#17
0
 static function evaluate_overlays()
 {
     $overlays = ORM::factory('emboss_overlay')->where('active', '=', 1)->find_all();
     $images = ORM::factory('item')->where('type', '=', 'photo')->find_all();
     $n_new = 0;
     $n_update = 0;
     $n_none = 0;
     $has_changes = 0;
     foreach ($images as $image) {
         $overlay_id = emboss::determine_best_overlay($image, $overlays);
         if ($overlay_id < 0) {
             $n_none++;
         }
         $q = ORM::factory('emboss_mapping')->where('image_id', '=', $image->id)->find();
         if (!$q->loaded()) {
             if ($overlay_id > 0) {
                 $n_new++;
             }
             $q->image_id = $image->id;
             $q->best_overlay_id = $overlay_id;
             $q->cur_overlay_id = -1;
             $q->cur_gravity = 'unset';
             $q->cur_transparency = -1;
             $q->save();
         } else {
             if ($q->best_overlay_id != $overlay_id) {
                 if ($overlay_id > 0) {
                     $n_update++;
                 }
                 $q->best_overlay_id = $overlay_id;
                 $q->save();
             }
         }
     }
     if ($n_none) {
         emboss::info('Cannot find an overlay for ' . $n_none . t2(' image', ' images'));
     }
     if ($n_new) {
         emboss::info($n_new . t2(' image needs', ' images need', $n_new) . ' now have an overlay available');
     }
     if ($n_update) {
         emboss::info(t2('This changes the overlay for 1 image', "This changes the overlay for {$n_update} images", $n_update));
     }
     if ($n_none || $n_new || $n_update) {
     } else {
         message::info('All photos are being embossed with the correct overlay');
     }
 }
示例#18
0
 private function settings()
 {
     if ($_POST) {
         // Available Vews
         config::set('s7n.views', $this->input->post('views'));
         // Default Sidebar Title
         config::set('s7n.default_sidebar_title', $this->input->post('default_sidebar_title'));
         // Default Sidebar Content
         config::set('s7n.default_sidebar_content', $this->input->post('default_sidebar_content'));
         message::info(__('Page Settings edited successfully'), 'admin/page/settings');
     }
     $this->head->title->append(__('Settings'));
     $this->template->title .= __('Settings');
     $this->template->content = View::factory('page/settings', array('views' => config::get('s7n.page_views'), 'default_sidebar_title' => config::get('s7n.default_sidebar_title'), 'default_sidebar_content' => config::get('s7n.default_sidebar_content')));
 }
示例#19
0
 private function change_status($blog_post_id)
 {
     $post = ORM::factory('blog_post', (int) $blog_post_id);
     if (!$post->loaded) {
         message::error(__('Invalid ID'), 'admin/blog');
     }
     $post->comment_status = $status;
     $post->save();
     message::info(__('Comment status changed to "%status"', array('status' => $status)), 'admin/blog');
 }
示例#20
0
 public function sendemail($user_id)
 {
     // Validate the form, then send the actual email.
     // If this page is disabled, show a 404 error.
     if ($user_id == "-1" && module::get_var("contactowner", "contact_owner_link") != true) {
         throw new Kohana_404_Exception();
     } elseif ($user_id >= 0 && module::get_var("contactowner", "contact_user_link") != true) {
         throw new Kohana_404_Exception();
     }
     // Make sure the form submission was valid.
     $form = $this->get_email_form($user_id);
     $valid = $form->validate();
     if ($valid) {
         // Copy the data from the email form into a couple of variables.
         $str_emailsubject = Input::instance()->post("email_subject");
         $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.
         //   Also add in the admin-defined message header.
         $str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
         // Figure out where the email is going to.
         $str_emailto = "";
         if ($user_id == -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", "=", $user_id)->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();
         message::info(t("Your Message Has Been Sent."));
         json::reply(array("result" => "success"));
     } else {
         // Set up and display the actual page.
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
示例#21
0
 /**
  * This is the task code that adds photos and albums.  It first examines all the target files
  * and creates a set of Server_Add_Entry_Models, then runs through the list of models and adds
  * them one at a time.
  */
 static function add($task)
 {
     $mode = $task->get("mode", "init");
     $start = microtime(true);
     switch ($mode) {
         case "init":
             $task->set("mode", "build-file-list");
             $task->set("dirs_scanned", 0);
             $task->percent_complete = 0;
             $task->status = t("Starting up");
             batch::start();
             break;
         case "build-file-list":
             // 0% to 10%
             // We can't fit an arbitrary number of paths in a task, so store them in a separate table.
             // Don't use an iterator here because we can't get enough control over it when we're dealing
             // with a deep hierarchy and we don't want to go over our time quota.
             $paths = unserialize(module::get_var("server_add", "authorized_paths"));
             $dirs_scanned = $task->get("dirs_scanned");
             while (microtime(true) - $start < 0.5) {
                 // Process every directory that doesn't yet have a parent id, these are the
                 // paths that we're importing.
                 $entry = ORM::factory("server_add_entry")->where("task_id", "=", $task->id)->where("is_directory", "=", 1)->where("checked", "=", 0)->order_by("id", "ASC")->find();
                 if ($entry->loaded()) {
                     $child_paths = glob(preg_quote($entry->path) . "/*");
                     if (!$child_paths) {
                         $child_paths = glob("{$entry->path}/*");
                     }
                     foreach ($child_paths as $child_path) {
                         if (!is_dir($child_path)) {
                             $ext = strtolower(pathinfo($child_path, PATHINFO_EXTENSION));
                             if (!legal_file::get_extensions($ext) || !filesize($child_path)) {
                                 // Not importable, skip it.
                                 continue;
                             }
                         }
                         $child_entry = ORM::factory("server_add_entry");
                         $child_entry->task_id = $task->id;
                         $child_entry->path = $child_path;
                         $child_entry->parent_id = $entry->id;
                         // null if the parent was a staging dir
                         $child_entry->is_directory = is_dir($child_path);
                         $child_entry->save();
                     }
                     // We've processed this entry, mark it as done.
                     $entry->checked = 1;
                     $entry->save();
                     $dirs_scanned++;
                 }
             }
             // We have no idea how long this can take because we have no idea how deep the tree
             // hierarchy rabbit hole goes.  Leave ourselves room here for 100 iterations and don't go
             // over 10% in percent_complete.
             $task->set("dirs_scanned", $dirs_scanned);
             $task->percent_complete = min($task->percent_complete + 0.1, 10);
             $task->status = t2("Scanned one directory", "Scanned %count directories", $dirs_scanned);
             if (!$entry->loaded()) {
                 $task->set("mode", "add-files");
                 $task->set("total_files", ORM::factory("server_add_entry")->where("task_id", "=", $task->id)->count_all());
                 $task->percent_complete = 10;
             }
             break;
         case "add-files":
             // 10% to 100%
             $completed_files = $task->get("completed_files", 0);
             $total_files = $task->get("total_files");
             // Ordering by id ensures that we add them in the order that we created the entries, which
             // will create albums first.  Ignore entries which already have an Item_Model attached,
             // they're done.
             $entries = ORM::factory("server_add_entry")->where("task_id", "=", $task->id)->where("item_id", "IS", null)->order_by("id", "ASC")->limit(10)->find_all();
             if ($entries->count() == 0) {
                 // Out of entries, we're done.
                 $task->set("mode", "done");
             }
             $owner_id = identity::active_user()->id;
             foreach ($entries as $entry) {
                 if (microtime(true) - $start > 0.5) {
                     break;
                 }
                 // Look up the parent item for this entry.  By now it should exist, but if none was
                 // specified, then this belongs as a child of the current item.
                 $parent_entry = ORM::factory("server_add_entry", $entry->parent_id);
                 if (!$parent_entry->loaded()) {
                     $parent = ORM::factory("item", $task->get("item_id"));
                 } else {
                     $parent = ORM::factory("item", $parent_entry->item_id);
                 }
                 $name = basename($entry->path);
                 $title = item::convert_filename_to_title($name);
                 if ($entry->is_directory) {
                     $album = ORM::factory("item");
                     $album->type = "album";
                     $album->parent_id = $parent->id;
                     $album->name = $name;
                     $album->title = $title;
                     $album->owner_id = $owner_id;
                     $album->sort_order = $parent->sort_order;
                     $album->sort_column = $parent->sort_column;
                     $album->save();
                     $entry->item_id = $album->id;
                 } else {
                     try {
                         $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
                         if (legal_file::get_photo_extensions($extension)) {
                             $photo = ORM::factory("item");
                             $photo->type = "photo";
                             $photo->parent_id = $parent->id;
                             $photo->set_data_file($entry->path);
                             $photo->name = $name;
                             $photo->title = $title;
                             $photo->owner_id = $owner_id;
                             $photo->save();
                             $entry->item_id = $photo->id;
                         } else {
                             if (legal_file::get_movie_extensions($extension)) {
                                 $movie = ORM::factory("item");
                                 $movie->type = "movie";
                                 $movie->parent_id = $parent->id;
                                 $movie->set_data_file($entry->path);
                                 $movie->name = $name;
                                 $movie->title = $title;
                                 $movie->owner_id = $owner_id;
                                 $movie->save();
                                 $entry->item_id = $movie->id;
                             } else {
                                 // This should never happen, because we don't add stuff to the list that we can't
                                 // process.  But just in, case.. set this to a non-null value so that we skip this
                                 // entry.
                                 $entry->item_id = 0;
                                 $task->log("Skipping unknown file type: {$entry->path}");
                             }
                         }
                     } catch (Exception $e) {
                         // This can happen if a photo file is invalid, like a BMP masquerading as a .jpg
                         $entry->item_id = 0;
                         $task->log("Skipping invalid file: {$entry->path}");
                     }
                 }
                 $completed_files++;
                 $entry->save();
             }
             $task->set("completed_files", $completed_files);
             $task->status = t("Adding photos / albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files));
             $task->percent_complete = $total_files ? 10 + 100 * ($completed_files / $total_files) : 100;
             break;
         case "done":
             batch::stop();
             $task->done = true;
             $task->state = "success";
             $task->percent_complete = 100;
             ORM::factory("server_add_entry")->where("task_id", "=", $task->id)->delete_all();
             message::info(t2("Successfully added one photo / album", "Successfully added %count photos / albums", $task->get("completed_files")));
     }
 }
示例#22
0
    }
}
?>
<form action="index.php" method="post" enctype="multipart/form-data">
    <div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title"><?php 
echo lang::get('sqlimport');
?>
</h3>
				</div>
                <div class="panel-body">
                    <?php 
echo message::info(lang::get('sqlimporttext'));
?>

                    <input name="importfile" type="file" accept="application/octet-stream"/>
                    <input type="hidden" name="page" value="import" class="form-control" />
                    <input type="hidden" name="subpage" value="import" class="form-control" />
                    <input type="hidden" name="action" value="import" class="form-control" />
                    <br>
                    <button type="submit" class="btn-default btn-sm btn" name="save-back"><?php 
echo lang::get('imports');
?>
</button>
                </div>
            </div>
        </div>
    </div>
示例#23
0
        echo html::anchor($task[0], $task[1]);
        ?>
<br />
						<?php 
    }
    ?>
					</p>
				<?php 
}
?>
			</div>
		</div>

		<div id="content">
			<?php 
if ($message = message::info()) {
    ?>
				<div id="info_message">
					<p><?php 
    echo $message;
    ?>
</p>
				</div>
			<?php 
}
?>
			<?php 
if ($message = message::error()) {
    ?>
				<div id="error_message">
					<p><?php 
示例#24
0
文件: login.php 项目: DINKIN/rokket
 public static function logout()
 {
     unset($_SESSION['login']);
     self::$isLogin = false;
     setcookie("remember", "", time() - 3600);
     echo message::info(lang::get('logged_out'), true);
 }