store enabled exts in a config file, rather than moving directories around

This commit is contained in:
Shish 2012-03-31 18:59:28 +01:00
parent 15df989f72
commit 67f1c1c51d
274 changed files with 63 additions and 1885 deletions

64
.gitignore vendored
View file

@ -3,67 +3,3 @@ data
images images
thumbs thumbs
!lib/images !lib/images
ext/admin
ext/amazon_s3
ext/artists
ext/autocomplete
ext/ban_words
ext/blocks
ext/blotter
ext/bookmarks
ext/browser_search
ext/bulk_add
ext/danbooru_api
ext/downtime
ext/emoticons
ext/et
ext/event_log
ext/favorites
ext/featured
ext/forum
ext/handle_archive
ext/handle_flash
ext/handle_ico
ext/handle_mp3
ext/handle_svg
ext/holiday
ext/home
ext/image_hash_ban
ext/ipban
ext/link_image
ext/log_db
ext/log_net
ext/mass_tagger
ext/news
ext/notes
ext/not_a_tag
ext/numeric_score
ext/oekaki
ext/piclens
ext/pm
ext/pools
ext/qr_code
ext/random_image
ext/rating
ext/regen_thumb
ext/report_image
ext/resize
ext/res_limit
ext/rss_comments
ext/rss_images
ext/shimmie_api
ext/simpletest
ext/site_description
ext/sitemap
ext/svn_update
ext/tagger
ext/tag_editcloud
ext/tag_history
ext/text_score
ext/tips
ext/twitter_soc
ext/upload_cmd
ext/update
ext/wiki
ext/word_filter
ext/zoom

View file

@ -42,17 +42,16 @@ Installation
Upgrade from 2.3.X Upgrade from 2.3.X
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
config.php has been moved from /config.php to /data/config/shimmie.conf.php - Backup your current files and database!
- Unzip into a clean folder
The database connection setting in config.php has changed; now using - Copy across the images, thumbs, and data folders
PDO DSN format rather than ADODB URI: - Move old/config.php to new/data/config/shimmie.conf.php
- Edit shimmie.conf.php to use the new database connection format:
OLD: $database_dsn = "<proto>://<username>:<password>@<host>/<database>"; OLD: $database_dsn = "<proto>://<username>:<password>@<host>/<database>";
NEW: define("DATABASE_DSN", "<proto>:user=<username>;password=<password>;host=<host>;dbname=<database>"); NEW: define("DATABASE_DSN", "<proto>:user=<username>;password=<password>;host=<host>;dbname=<database>");
The rest should be automatic, just unzip into a clean folder and copy across The rest should be automatic~
config.php, images and thumbs folders from the old version. This
includes automatically messing with the database -- back it up first!
If there are any errors with the upgrade process, "in_upgrade=true" will If there are any errors with the upgrade process, "in_upgrade=true" will
be left in the config table and the process will be paused for the admin be left in the config table and the process will be paused for the admin
@ -70,10 +69,10 @@ enough to be a pain.
Custom Configuration Custom Configuration
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Various aspects of Shimmie can be configured to suit your site specific Various aspects of Shimmie can be configured to suit your site specific needs
needs via the file "config.php" (created after installation). via the file "data/config/shimmie.conf.php" (created after installation).
Take a look at "core/default_config.inc.php" for the available options Take a look at "core/sys_config.inc.php" for the available options that can
that can used. be used.
Custom User Classes Custom User Classes

View file

@ -1,6 +1,14 @@
<?php <?php
/*
* First, load the user-specified settings
*/
@include_once "data/config/shimmie.conf.php";
@include_once "data/config/extensions.conf.php";
/** /**
* These are the default configuration options for Shimmie. * For any values that aren't defined in the above files, Shimmie
* will set the values to their defaults
* *
* All of these can be over-ridden by placing a 'define' in data/config/shimmie.conf.php * All of these can be over-ridden by placing a 'define' in data/config/shimmie.conf.php
* *
@ -10,7 +18,6 @@
* define("SPEED_HAX", true); * define("SPEED_HAX", true);
* *
*/ */
function _d($name, $value) {if(!defined($name)) define($name, $value);} function _d($name, $value) {if(!defined($name)) define($name, $value);}
_d("DATABASE_DSN", null); // string PDO database connection details _d("DATABASE_DSN", null); // string PDO database connection details
_d("CACHE_DSN", null); // string cache connection details _d("CACHE_DSN", null); // string cache connection details
@ -27,6 +34,15 @@ _d("COMPILE_ELS", false); // boolean pre-build the list of event listeners
_d("NICE_URLS", false); // boolean force niceurl mode _d("NICE_URLS", false); // boolean force niceurl mode
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse _d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
_d("VERSION", 'trunk'); // string shimmie version _d("VERSION", 'trunk'); // string shimmie version
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
_d("TIMEZONE", null); // string timezone _d("TIMEZONE", null); // string timezone
_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable
_d("EXTRA_EXTS", ""); // optional extra extensions
/*
* Calculated settings - you should never need to change these
* directly, only the things they're built from
*/
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS);
?> ?>

View file

@ -1006,29 +1006,14 @@ function _sanitise_environment() {
} }
function _get_themelet_files($_theme) { function _get_themelet_files($_theme) {
$themelets = array(); if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php';
$base_themelets[] = 'themes/'.$_theme.'/layout.class.php';
$base_themelets[] = 'themes/'.$_theme.'/themelet.class.php';
if(file_exists('themes/'.$_theme.'/custompage.class.php')) $themelets[] = 'themes/'.$_theme.'/custompage.class.php'; $ext_themelets = glob("ext/{".ENABLED_EXTS."}/theme.php", GLOB_BRACE);
$themelets[] = 'themes/'.$_theme.'/layout.class.php'; $custom_themelets = glob('themes/'.$_theme.'/{'.ENABLED_EXTS.'}.theme.php', GLOB_BRACE);
$themelets[] = 'themes/'.$_theme.'/themelet.class.php';
$themelet_files = glob("ext/*/theme.php"); return array_merge($base_themelets, $ext_themelets, $custom_themelets);
foreach($themelet_files as $filename) {
$themelets[] = $filename;
}
$custom_themelets = glob('themes/'.$_theme.'/*.theme.php');
if($custom_themelets) {
$m = array();
foreach($custom_themelets as $filename) {
if(preg_match('/themes\/'.$_theme.'\/(.*)\.theme\.php/',$filename,$m)
&& in_array('ext/'.$m[1].'/theme.php', $themelets)) {
$themelets[] = $filename;
}
}
}
return $themelets;
} }
function _load_extensions() { function _load_extensions() {

File diff suppressed because it is too large Load diff

View file

Before

Width:  |  Height:  |  Size: 170 B

After

Width:  |  Height:  |  Size: 170 B

View file

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View file

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View file

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View file

Before

Width:  |  Height:  |  Size: 498 B

After

Width:  |  Height:  |  Size: 498 B

View file

Before

Width:  |  Height:  |  Size: 170 B

After

Width:  |  Height:  |  Size: 170 B

View file

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View file

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View file

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View file

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View file

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 336 B

View file

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View file

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 349 B

View file

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View file

Before

Width:  |  Height:  |  Size: 248 B

After

Width:  |  Height:  |  Size: 248 B

View file

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View file

Before

Width:  |  Height:  |  Size: 650 B

After

Width:  |  Height:  |  Size: 650 B

View file

Before

Width:  |  Height:  |  Size: 485 B

After

Width:  |  Height:  |  Size: 485 B

View file

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View file

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View file

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 170 B

After

Width:  |  Height:  |  Size: 170 B

View file

@ -26,8 +26,8 @@ class ExtensionInfo {
$matches = array(); $matches = array();
$lines = file($main); $lines = file($main);
$number_of_lines = count($lines); $number_of_lines = count($lines);
preg_match("#(ext|contrib)/(.*)/main.php#", $main, $matches); preg_match("#ext/(.*)/main.php#", $main, $matches);
$this->ext_name = $matches[2]; $this->ext_name = $matches[1];
$this->name = $this->ext_name; $this->name = $this->ext_name;
$this->enabled = $this->is_enabled($this->ext_name); $this->enabled = $this->is_enabled($this->ext_name);
@ -81,9 +81,12 @@ class ExtensionInfo {
} }
private function is_enabled(/*string*/ $fname) { private function is_enabled(/*string*/ $fname) {
if(file_exists("ext/$fname") && file_exists("contrib/$fname")) return true; // both $core = explode(",", CORE_EXTS);
if(file_exists("contrib/$fname")) return false; // only disabled (optional) $extra = explode(",", EXTRA_EXTS);
return null; // only active (core)
if(in_array($fname, $extra)) return true; // enabled
if(in_array($fname, $core)) return null; // core
return false; // not enabled
} }
} }
@ -93,14 +96,14 @@ class ExtManager extends Extension {
if($event->page_matches("ext_manager")) { if($event->page_matches("ext_manager")) {
if($user->can("manage_extension_list")) { if($user->can("manage_extension_list")) {
if($event->get_arg(0) == "set" && $user->check_auth_token()) { if($event->get_arg(0) == "set" && $user->check_auth_token()) {
if(is_writable("ext")) { if(is_writable("data/config")) {
$this->set_things($_POST); $this->set_things($_POST);
$page->set_mode("redirect"); $page->set_mode("redirect");
$page->set_redirect(make_link("ext_manager")); $page->set_redirect(make_link("ext_manager"));
} }
else { else {
$this->theme->display_error(500, "File Operation Failed", $this->theme->display_error(500, "File Operation Failed",
"The extension folder isn't writable by the web server :("); "The config file (data/config/extensions.conf.php) isn't writable by the web server :(");
} }
} }
else { else {
@ -118,10 +121,6 @@ class ExtManager extends Extension {
$info = new ExtensionInfo("ext/$ext/main.php"); $info = new ExtensionInfo("ext/$ext/main.php");
$this->theme->display_doc($page, $info); $this->theme->display_doc($page, $info);
} }
else if(file_exists("contrib/$ext/main.php")) {
$info = new ExtensionInfo("contrib/$ext/main.php");
$this->theme->display_doc($page, $info);
}
else { else {
$this->theme->display_table($page, $this->get_extensions(false), false); $this->theme->display_table($page, $this->get_extensions(false), false);
} }
@ -142,15 +141,10 @@ class ExtManager extends Extension {
private function get_extensions(/*bool*/ $all) { private function get_extensions(/*bool*/ $all) {
$extensions = array(); $extensions = array();
if($all) { if($all) {
$exts = glob("ext/*/main.php"); $exts = glob("ext/*/main.php", GLOB_BRACE);
foreach(glob("contrib/*/main.php") as $ae) {
if(!in_array("ext".substr($ae, 7), $exts)) {
$exts[] = $ae;
}
}
} }
else { else {
$exts = glob("ext/*/main.php"); $exts = glob("ext/{".ENABLED_EXTS."}/main.php", GLOB_BRACE);
} }
foreach($exts as $main) { foreach($exts as $main) {
$extensions[] = new ExtensionInfo($main); $extensions[] = new ExtensionInfo($main);
@ -160,46 +154,24 @@ class ExtManager extends Extension {
} }
private function set_things($settings) { private function set_things($settings) {
foreach(glob("contrib/*/main.php") as $main) { $core = explode(",", CORE_EXTS);
foreach(glob("ext/*/main.php") as $main) {
$matches = array(); $matches = array();
preg_match("#contrib/(.*)/main.php#", $main, $matches); preg_match("#ext/(.*)/main.php#", $main, $matches);
$fname = $matches[1]; $fname = $matches[1];
if(!isset($settings["ext_$fname"])) $settings["ext_$fname"] = 0; if(!in_array($fname, $core) && isset($settings["ext_$fname"])) {
$this->set_enabled($fname, $settings["ext_$fname"]); $extras[] = $fname;
}
} }
}
private function set_enabled(/*string*/ $fname, /*bool*/ $enabled) { file_put_contents(
if($enabled) { "data/config/extensions.conf.php",
// enable if currently disabled '<'.'?php'."\n".
if(!file_exists("ext/$fname")) { 'define("EXTRA_EXTS", "'.implode(",", $extras).'");'."\n".
if(function_exists("symlink")) { '?'.">"
// yes, even though we are in /, and thus the path to contrib is );
// ./contrib, the link needs to be ../ because it is literal data
// which will be interpreted relative to ./ext/ by the OS
//Because Windows (I know, bad excuse)
if (PHP_OS === 'WINNT') {
symlink(realpath("./contrib/$fname"), realpath("./ext/").'/'.$fname);
}
else {
symlink("../contrib/$fname", "ext/$fname");
}
}
else {
full_copy("contrib/$fname", "ext/$fname");
}
log_info("ext_manager", "Enabling $fname");
}
}
else {
// disable if currently enabled
if(file_exists("ext/$fname")) {
deltree("ext/$fname");
log_info("ext_manager", "Disabling $fname");
}
}
} }
} }
?> ?>

View file

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Some files were not shown because too many files have changed in this diff Show more