diff --git a/README.txt b/README.txt index 97d8955a..622d90a9 100644 --- a/README.txt +++ b/README.txt @@ -40,10 +40,10 @@ Installation Upgrade from 2.3.X ~~~~~~~~~~~~~~~~~~ The database connection setting in config.php has changed; now using -PDO DSN format [1] rather than ADODB URI [2] +PDO DSN format rather than ADODB URI: - [1] :user=;password=;host=;dbname= - [2] ://:@/ + OLD: $database_dsn = "://:@/"; + NEW: define("DATABASE_DSN", ":user=;password=;host=;dbname="); The rest should be automatic, just unzip into a clean folder and copy across config.php, images and thumbs folders from the old version. This diff --git a/core/database.class.php b/core/database.class.php index 53ed4b4d..64123180 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -274,8 +274,6 @@ class Database { * stored in config.php in the root shimmie folder */ public function Database() { - global $database_dsn, $cache_dsn; - # FIXME: detect ADODB URI, automatically translate PDO DSN /* @@ -285,10 +283,10 @@ class Database { * http://stackoverflow.com/questions/237367 */ $matches = array(); $db_user=null; $db_pass=null; - if(preg_match("/user=([^;]*)/", $database_dsn, $matches)) $db_user=$matches[1]; - if(preg_match("/password=([^;]*)/", $database_dsn, $matches)) $db_pass=$matches[1]; + if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1]; + if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1]; - $this->db = new PDO($database_dsn, $db_user, $db_pass); + $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db_proto = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME); @@ -305,9 +303,8 @@ class Database { die("Unknown PDO driver: $db_proto"); } - if(isset($cache_dsn) && !empty($cache_dsn)) { - $matches = array(); - preg_match("#(memcache|apc)://(.*)#", $cache_dsn, $matches); + $matches = array(); + if(CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) { if($matches[1] == "memcache") { $this->cache = new MemcacheCache($matches[2]); } diff --git a/core/util.inc.php b/core/util.inc.php index 97146d25..21343497 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -204,7 +204,7 @@ function make_link($page=null, $query=null) { if(is_null($page)) $page = $config->get_string('main_page'); - if(FORCE_NICE_URLS || $config->get_bool('nice_urls', false)) { + if(NICE_URLS || $config->get_bool('nice_urls', false)) { #$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]; $full = $_SERVER["PHP_SELF"]; $base = str_replace("/index.php", "", $full); diff --git a/index.php b/index.php index 63c3b52c..29cbecca 100644 --- a/index.php +++ b/index.php @@ -57,18 +57,23 @@ if(empty($database_dsn) && !file_exists("config.php")) { require_once "config.php"; // set up and purify the environment -if(!defined("DEBUG")) define("DEBUG", false); -if(!defined("COVERAGE")) define("COVERAGE", false); -if(!defined("CONTEXT")) define("CONTEXT", false); -if(!defined("CACHE_MEMCACHE")) define("CACHE_MEMCACHE", false); -if(!defined("CACHE_DIR")) define("CACHE_DIR", false); -if(!defined("CACHE_HTTP")) define("CACHE_HTTP", false); -if(!defined("VERSION")) define("VERSION", 'trunk'); -if(!defined("SCORE_VERSION")) define("SCORE_VERSION", 's2hack/'.VERSION); -if(!defined("COOKIE_PREFIX")) define("COOKIE_PREFIX", 'shm'); -if(!defined("SPEED_HAX")) define("SPEED_HAX", false); -if(!defined("FORCE_NICE_URLS")) define("FORCE_NICE_URLS", false); -if(!defined("WH_SPLITS")) define("WH_SPLITS", 1); +function _d($name, $value) { + if(!defined($name)) define($name, $value); +} +_d("DATABASE_DSN", null); // string PDO database connection details +_d("CACHE_DSN", null); // string cache connection details +_d("DEBUG", false); // boolean print various debugging details +_d("COVERAGE", false); // boolean activate xdebug coverage monitor +_d("CONTEXT", null); // string file to log performance data into +_d("CACHE_MEMCACHE", false); // boolean store complete rendered pages in memcache +_d("CACHE_DIR", false); // boolean store complete rendered pages on disk +_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers +_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes +_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance +_d("NICE_URLS", false); // boolean force niceurl mode +_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse +_d("VERSION", 'trunk'); // string shimmie version +_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version require_once "core/util.inc.php"; require_once "lib/context.php"; diff --git a/install.php b/install.php index 83a1f2f3..e5f2e5cc 100755 --- a/install.php +++ b/install.php @@ -52,7 +52,7 @@ if(is_readable("config.php")) {

Shimmie Repair Console

"; + $file_content = "<"+"?php\n"+ + "define('DATABASE_DSN', '$database_dsn');\n"+ + "?"+">"; if(is_writable("./") && file_put_contents("config.php", $file_content)) { assert(file_exists("config.php"));