コード例 #1
0
 static function uninstall()
 {
     graphics::remove_rules("watermark");
     module::delete("watermark");
     Database::instance()->query("DROP TABLE `watermarks`");
     dir::unlink(VARPATH . "modules/watermark");
 }
コード例 #2
0
ファイル: packager.php プロジェクト: scarygary/gallery3
 private function _reset()
 {
     $db = Database::instance();
     // Drop all tables
     foreach ($db->list_tables() as $table) {
         $db->query("DROP TABLE IF EXISTS `{$table}`");
     }
     // Clean out data
     dir::unlink(VARPATH . "uploads");
     dir::unlink(VARPATH . "albums");
     dir::unlink(VARPATH . "resizes");
     dir::unlink(VARPATH . "thumbs");
     dir::unlink(VARPATH . "modules");
     dir::unlink(VARPATH . "tmp");
     $db->clear_cache();
     module::$modules = array();
     module::$active = array();
     // Use a known random seed so that subsequent packaging runs will reuse the same random
     // numbers, keeping our install.sql file more stable.
     srand(0);
     gallery_installer::install(true);
     module::load_modules();
     foreach (array("user", "comment", "organize", "info", "rss", "search", "slideshow", "tag") as $module_name) {
         module::install($module_name);
         module::activate($module_name);
     }
 }
コード例 #3
0
ファイル: g2_import.php プロジェクト: squadak/gallery3
 /**
  * Initialize the embedded Gallery 2 instance.  Call this before any other Gallery 2 calls.
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return false;
     }
     // Gallery 2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
     // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
     // and Gallery.class) and munge them so that we can rename the Gallery class to be
     // G2_Gallery.   Is this retarded?  Why yes it is.
     //
     // Store the munged files in a directory that's the md5 hash of the embed path so that
     // multiple import sources don't interfere with each other.
     $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
     if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
         @dir::unlink($mod_path);
         mkdir($mod_path);
         $config_dir = dirname($embed_path);
         if (filesize($embed_path) > 200) {
             // Regular install
             $base_dir = $config_dir;
         } else {
             // Multisite install.  Line 2 of embed.php will be something like:
             //   require('/usr/home/bharat/public_html/gallery2/embed.php');
             $lines = file($embed_path);
             preg_match("#require\\('(.*)/embed.php'\\);#", $lines[2], $matches);
             $base_dir = $matches[1];
         }
         file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
         file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
         file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();", "\$GLOBALS['gallery'] =& new Gallery();", "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$config_dir}');", "\$gallery =& new G2_Gallery();", "\$GLOBALS['gallery'] =& new G2_Gallery();", "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
         file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
     }
     require "{$mod_path}/embed.php";
     if (!class_exists("GalleryEmbed")) {
         return false;
     }
     $ret = GalleryEmbed::init();
     if ($ret) {
         return false;
     }
     $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
     $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
     $admin_id = current(array_flip($admins));
     $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
     $GLOBALS["gallery"]->setActiveUser($admin);
     // Make sure we have an embed location so that embedded url generation comes out ok.  Without
     // this, the Gallery2 ModRewrite code won't try to do url generation.
     $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation"));
     if (empty($g2_embed_location)) {
         $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation"));
         g2(GalleryCoreApi::setPluginParameter("module", "rewrite", "modrewrite.embeddedLocation", $g2_embed_location));
         g2($gallery->getStorage()->checkPoint());
     }
     self::$g2_base_url = $g2_embed_location;
     return true;
 }
コード例 #4
0
ファイル: Dir_Helper_Test.php プロジェクト: kandsten/gallery3
 public function remove_album_test()
 {
     $dirname = VARPATH . "albums/testdir";
     mkdir($dirname, 0777, true);
     $filename = tempnam($dirname, "file");
     touch($filename);
     dir::unlink($dirname);
     $this->assert_boolean(!file_exists($filename), "File not deleted");
     $this->assert_boolean(!file_exists($dirname), "Directory not deleted");
 }
コード例 #5
0
 static function item_before_delete($item)
 {
     // If deleting a photo, make sure the original is deleted as well, if it exists.
     if ($item->is_photo()) {
         $original_file = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
         if (file_exists($original_file)) {
             @unlink($original_file);
         }
     }
     // When deleting an album, make sure its corresponding location in
     //   VARPATH/original/ is deleted as well, if it exists.
     if ($item->is_album()) {
         $original_file = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
         if (file_exists($original_file)) {
             @dir::unlink($original_file);
         }
     }
 }
コード例 #6
0
ファイル: dir.php プロジェクト: Juuro/Dreamapp-Website
 static function unlink($path)
 {
     if (is_dir($path) && is_writable($path)) {
         foreach (new DirectoryIterator($path) as $resource) {
             if ($resource->isDot()) {
                 unset($resource);
                 continue;
             } else {
                 if ($resource->isFile()) {
                     unlink($resource->getPathName());
                 } else {
                     if ($resource->isDir()) {
                         dir::unlink($resource->getRealPath());
                     }
                 }
             }
             unset($resource);
         }
         return @rmdir($path);
     }
     return false;
 }
コード例 #7
0
ファイル: item.php プロジェクト: ChrisRut/gallery3
 public function delete()
 {
     $old = clone $this;
     module::event("item_before_delete", $this);
     $parent = $this->parent();
     if ($parent->album_cover_item_id == $this->id) {
         item::remove_album_cover($parent);
     }
     $path = $this->file_path();
     $resize_path = $this->resize_path();
     $thumb_path = $this->thumb_path();
     parent::delete();
     if (is_dir($path)) {
         @dir::unlink($path);
         @dir::unlink(dirname($resize_path));
         @dir::unlink(dirname($thumb_path));
     } else {
         @unlink($path);
         @unlink($resize_path);
         @unlink($thumb_path);
     }
     module::event("item_deleted", $old);
 }
コード例 #8
0
ファイル: g2_import.php プロジェクト: xafr/gallery3
 /**
  * Initialize the embedded Gallery2 instance.  Call this before any other Gallery2 calls.
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return false;
     }
     // Gallery2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
     // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
     // and Gallery.class) and munge them so that we can rename the Gallery class to be
     // G2_Gallery.   Is this retarded?  Why yes it is.
     //
     // Store the munged files in a directory that's the md5 hash of the embed path so that
     // multiple import sources don't interfere with each other.
     $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
     if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
         @dir::unlink($mod_path);
         mkdir($mod_path);
         $base_dir = dirname($embed_path);
         file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
         file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
         file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$base_dir}');", "\$gallery =& new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
         file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
     }
     require "{$mod_path}/embed.php";
     if (!class_exists("GalleryEmbed")) {
         return false;
     }
     $ret = GalleryEmbed::init();
     if ($ret) {
         return false;
     }
     $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
     $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
     $admin_id = current(array_flip($admins));
     $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
     $GLOBALS["gallery"]->setActiveUser($admin);
     return true;
 }
コード例 #9
0
 static function uninstall()
 {
     dir::unlink(VARPATH . "modules/aws_s3");
 }
コード例 #10
0
ファイル: watermark_installer.php プロジェクト: Okat/gallery3
 static function uninstall()
 {
     Database::instance()->query("DROP TABLE {watermarks}");
     dir::unlink(VARPATH . "modules/watermark");
 }
コード例 #11
0
ファイル: item.php プロジェクト: assad2012/gallery3-appfog
 public function delete($ignored_id = null)
 {
     if (!$this->loaded()) {
         // Concurrent deletes may result in this item already being gone.  Ignore it.
         return;
     }
     if ($this->id == 1) {
         $v = new Validation(array("id"));
         $v->add_error("id", "cant_delete_root_album");
         ORM_Validation_Exception::handle_validation($this->table_name, $v);
     }
     $old = clone $this;
     module::event("item_before_delete", $this);
     $parent = $this->parent();
     if ($parent->album_cover_item_id == $this->id) {
         item::remove_album_cover($parent);
     }
     $path = $this->file_path();
     $resize_path = $this->resize_path();
     $thumb_path = $this->thumb_path();
     parent::delete();
     if (is_dir($path)) {
         // Take some precautions against accidentally deleting way too much
         $delete_resize_path = dirname($resize_path);
         $delete_thumb_path = dirname($thumb_path);
         if ($delete_resize_path == VARPATH . "resizes" || $delete_thumb_path == VARPATH . "thumbs" || $path == VARPATH . "albums") {
             throw new Exception("@todo DELETING_TOO_MUCH ({$delete_resize_path}, {$delete_thumb_path}, {$path})");
         }
         @dir::unlink($path);
         @dir::unlink($delete_resize_path);
         @dir::unlink($delete_thumb_path);
     } else {
         @unlink($path);
         @unlink($resize_path);
         @unlink($thumb_path);
     }
     module::event("item_deleted", $old);
 }
コード例 #12
0
 static function uninstall()
 {
     dir::unlink(VARPATH . "modules/aws_s3");
     Database::instance()->query("DROP TABLE {aws_s3_meta}");
 }
コード例 #13
0
ファイル: access.php プロジェクト: hiwilson/gallery3
 /**
  * Verify that our htaccess based permission system actually works.  Create a temporary
  * directory containing an .htaccess file that uses mod_rewrite to redirect /verify to
  * /success.  Then request that url.  If we retrieve it successfully, then our redirects are
  * working and our permission system works.
  */
 static function htaccess_works()
 {
     $success_url = url::file("var/tmp/security_test/success");
     @mkdir(VARPATH . "tmp/security_test");
     if ($fp = @fopen(VARPATH . "tmp/security_test/.htaccess", "w+")) {
         fwrite($fp, "RewriteEngine On\n");
         fwrite($fp, "RewriteRule verify {$success_url} [L]\n");
         fclose($fp);
     }
     if ($fp = @fopen(VARPATH . "tmp/security_test/success", "w+")) {
         fwrite($fp, "success");
         fclose($fp);
     }
     list($response) = remote::do_request(url::abs_file("var/tmp/security_test/verify"));
     $works = $response == "HTTP/1.1 200 OK";
     @dir::unlink(VARPATH . "tmp/security_test");
     return $works;
 }
コード例 #14
0
ファイル: item.php プロジェクト: Juuro/Dreamapp-Website
 public function delete()
 {
     $original_path = $this->file_path();
     $original_resize_path = $this->resize_path();
     $original_thumb_path = $this->thumb_path();
     // If there is no name, the path is invalid so don't try to delete
     if (!empty($this->name)) {
         if ($this->is_album()) {
             dir::unlink(dirname($original_path));
             dir::unlink(dirname($original_resize_path));
             dir::unlink(dirname($original_thumb_path));
         } else {
             unlink($original_path);
             unlink($original_resize_path);
             unlink($original_thumb_path);
         }
     }
     parent::delete();
 }
コード例 #15
0
ファイル: g2_import_installer.php プロジェクト: Okat/gallery3
 static function uninstall()
 {
     @dir::unlink(VARPATH . "modules/g2_import");
 }
コード例 #16
0
 static function uninstall()
 {
     dir::unlink(VARPATH . "modules/strip_exif");
 }
コード例 #17
0
 static function uninstall()
 {
     Database::instance()->query("DROP TABLE {transcode_resolutions}");
     dir::unlink(VARPATH . "modules/transcode");
 }
コード例 #18
0
ファイル: g2_import.php プロジェクト: HarriLu/gallery3
 /**
  * Initialize the embedded Gallery 2 instance.  Call this before any other Gallery 2 calls.
  *
  * Return values:
  *  "ok"      - the Gallery 2 install is fine
  *  "missing" - the embed path does not exist
  *  "invalid" - the install path is not a valid Gallery 2 code base
  *  "broken"  - the embed path is correct, but the Gallery 2 install is broken
  */
 static function init_embed($embed_path)
 {
     if (!is_file($embed_path)) {
         return "missing";
     }
     try {
         // Gallery 2 defines a class called Gallery.  So does Gallery 3.  They don't get along.  So do
         // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc
         // and Gallery.class) and munge them so that we can rename the Gallery class to be
         // G2_Gallery.   Is this retarded?  Why yes it is.
         //
         // Store the munged files in a directory that's the md5 hash of the embed path so that
         // multiple import sources don't interfere with each other.
         $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path);
         if (!file_exists($mod_path) || !file_exists("{$mod_path}/embed.php")) {
             @dir::unlink($mod_path);
             mkdir($mod_path);
             $config_dir = dirname($embed_path);
             if (filesize($embed_path) > 200) {
                 // Regular install
                 $base_dir = $config_dir;
             } else {
                 // Multisite install.  Line 2 of embed.php will be something like:
                 //   require('/usr/home/bharat/public_html/gallery2/embed.php');
                 $lines = file($embed_path);
                 preg_match("#require\\('(.*)/embed.php'\\);#", $lines[2], $matches);
                 $base_dir = $matches[1];
             }
             file_put_contents("{$mod_path}/embed.php", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), array("require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "require('{$base_dir}/modules/core/classes/GalleryEmbed.class');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/embed.php"))));
             file_put_contents("{$mod_path}/main.php", str_replace(array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once(dirname(__FILE__) . '/init.inc');"), array("include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('{$base_dir}/init.inc');"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/main.php"))));
             file_put_contents("{$mod_path}/bootstrap.inc", str_replace(array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();", "\$GLOBALS['gallery'] =& new Gallery();", "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('{$base_dir}/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '{$config_dir}');", "\$gallery =& new G2_Gallery();", "\$GLOBALS['gallery'] =& new G2_Gallery();", "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/bootstrap.inc"))));
             file_put_contents("{$mod_path}/Gallery.class", str_replace(array("class Gallery", "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("{$base_dir}/modules/core/classes/Gallery.class"))));
         } else {
             // Ok, this is a good one.  If you're running a bytecode accelerator and you move your
             // Gallery install, these files sometimes get cached with the wrong path and then fail to
             // load properly.
             // Documented in https://sourceforge.net/apps/trac/gallery/ticket/1253
             touch("{$mod_path}/embed.php");
             touch("{$mod_path}/main.php");
             touch("{$mod_path}/bootstrap.inc");
             touch("{$mod_path}/Gallery.class.inc");
         }
         require "{$mod_path}/embed.php";
         if (!class_exists("GalleryEmbed")) {
             return "invalid";
         }
         $ret = GalleryEmbed::init();
         if ($ret) {
             Kohana_Log::add("error", "Gallery 2 call failed with: " . $ret->getAsText());
             return "broken";
         }
         $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
         $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1));
         $admin_id = current(array_flip($admins));
         $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id));
         $GLOBALS["gallery"]->setActiveUser($admin);
         // Make sure we have an embed location so that embedded url generation comes out ok.  Without
         // this, the Gallery2 ModRewrite code won't try to do url generation.
         $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation"));
         if (empty($g2_embed_location)) {
             $g2_embed_location = g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation"));
             g2(GalleryCoreApi::setPluginParameter("module", "rewrite", "modrewrite.embeddedLocation", $g2_embed_location));
             g2($gallery->getStorage()->checkPoint());
         }
         if ($g2_embed_location) {
             self::$g2_base_url = $g2_embed_location;
         } else {
             self::$g2_base_url = $GLOBALS["gallery"]->getUrlGenerator()->generateUrl(array(), array("forceSessionId" => false, "htmlEntities" => false, "urlEncode" => false, "useAuthToken" => false));
         }
     } catch (ErrorException $e) {
         Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
         return "broken";
     }
     return "ok";
 }
コード例 #19
0
ファイル: access.php プロジェクト: HarriLu/gallery3
 /**
  * Verify that our htaccess based permission system actually works.  Create a temporary
  * directory containing an .htaccess file that uses mod_rewrite to redirect /verify to
  * /success.  Then request that url.  If we retrieve it successfully, then our redirects are
  * working and our permission system works.
  */
 static function htaccess_works()
 {
     $success_url = url::file("var/security_test/success");
     @mkdir(VARPATH . "security_test");
     try {
         if ($fp = @fopen(VARPATH . "security_test/.htaccess", "w+")) {
             fwrite($fp, "Options +FollowSymLinks\n");
             fwrite($fp, "RewriteEngine On\n");
             fwrite($fp, "RewriteRule verify {$success_url} [L]\n");
             fclose($fp);
         }
         if ($fp = @fopen(VARPATH . "security_test/success", "w+")) {
             fwrite($fp, "success");
             fclose($fp);
         }
         // Proxy our authorization headers so that if the entire Gallery is covered by Basic Auth
         // this callback will still work.
         $headers = array();
         if (function_exists("apache_request_headers")) {
             $arh = apache_request_headers();
             if (!empty($arh["Authorization"])) {
                 $headers["Authorization"] = $arh["Authorization"];
             }
         }
         list($status, $headers, $body) = remote::do_request(url::abs_file("var/security_test/verify"), "GET", $headers);
         $works = $status == "HTTP/1.1 200 OK" && $body == "success";
     } catch (Exception $e) {
         @dir::unlink(VARPATH . "security_test");
         throw $e;
     }
     @dir::unlink(VARPATH . "security_test");
     return $works;
 }
コード例 #20
0
ファイル: scaffold.php プロジェクト: xafr/gallery3
 public function package()
 {
     $this->auto_render = false;
     $db = Database::instance();
     // Drop all tables
     foreach ($db->list_tables() as $table) {
         $db->query("DROP TABLE IF EXISTS `{$table}`");
     }
     // Clean out data
     dir::unlink(VARPATH . "uploads");
     dir::unlink(VARPATH . "albums");
     dir::unlink(VARPATH . "resizes");
     dir::unlink(VARPATH . "thumbs");
     dir::unlink(VARPATH . "modules");
     dir::unlink(VARPATH . "tmp");
     $db->clear_cache();
     module::$modules = array();
     module::$active = array();
     // Use a known random seed so that subsequent packaging runs will reuse the same random
     // numbers, keeping our install.sql file more stable.
     srand(0);
     try {
         gallery_installer::install(true);
         module::load_modules();
         foreach (array("user", "comment", "organize", "info", "rss", "search", "slideshow", "tag") as $module_name) {
             module::install($module_name);
             module::activate($module_name);
         }
     } catch (Exception $e) {
         Kohana::log("error", $e->getTraceAsString());
         print $e->getTrace();
         throw $e;
     }
     url::redirect("scaffold/dump_database");
 }
コード例 #21
0
 static function install()
 {
     /** UNTIL RELEASED LET'S CLEAN UP EVERYTHING **/
     $clearit = "";
     if ($clearit) {
         Database::instance()->query("DROP TABLE IF EXISTS ratables;");
         Database::instance()->query("DROP TABLE IF EXISTS ratings;");
         module::clear_all_vars("ratings");
         dir::unlink(VARPATH . "modules/ratings");
     }
     /** ---------------------------------------- **/
     $dbvarpath = VARPATH . "modules/ratings";
     if (!is_dir($dbvarpath)) {
         @mkdir($dbvarpath);
     }
     module::set_version("ratings", 20);
     $iconset = url::file("modules/ratings/vendor/img/stars.png");
     $iconset = preg_replace("/\\/index\\.php/", "", $iconset);
     if (!module::get_var("ratings", "iconset")) {
         module::set_var("ratings", "iconset", $iconset);
     }
     if (!module::get_var("ratings", "imageword")) {
         module::set_var("ratings", "imageword", "star");
     }
     if (!module::get_var("ratings", "votestring")) {
         module::set_var("ratings", "votestring", "vote");
     }
     if (!module::get_var("ratings", "castyourvotestring")) {
         module::set_var("ratings", "castyourvotestring", "Click on a star to cast your vote:");
     }
     if (!module::get_var("ratings", "showinsidebar")) {
         module::set_var("ratings", "showinsidebar", "1");
     }
     if (!module::get_var("ratings", "showunderphoto")) {
         module::set_var("ratings", "showunderphoto", "0");
     }
     if (!module::get_var("ratings", "bgcolor")) {
         module::set_var("ratings", "bgcolor", "#FFFFFF");
     }
     if (!module::get_var("ratings", "fillcolor")) {
         module::set_var("ratings", "fillcolor", "#FF0000");
     }
     if (!module::get_var("ratings", "hovercolor")) {
         module::set_var("ratings", "hovercolor", "#FFA800");
     }
     if (!module::get_var("ratings", "votedcolor")) {
         module::set_var("ratings", "votedcolor", "#0069FF");
     }
     if (!module::get_var("ratings", "textcolor")) {
         module::set_var("ratings", "textcolor", "#000000");
     }
     if (!module::get_var("ratings", "regonly")) {
         module::set_var("ratings", "regonly", "0");
     }
     /**
      * Can we have duplicate weights for the modules?  
      * may want to adjust this and copy moduleorder module for reordering...
      */
     // get comment block weight, so we can adjust ratings weight - see below
     $commentweight = db::build()->select("weight")->from("modules")->where("name", "=", "comment")->execute()->current();
     // set ratings weight to one below comments so we can display right
     // under the photo
     $newratingsweight = $commentweight->weight - 1;
     db::build()->update("modules")->set("weight", $newratingsweight)->where("name", "=", "ratings")->execute();
 }