// Define application and system paths define("APPPATH", realpath("application") . "/"); define("MODPATH", realpath("modules") . "/"); define("THEMEPATH", realpath("themes") . "/"); define("SYSPATH", realpath("system") . "/"); // We only accept a few controllers on the command line if (PHP_SAPI == "cli") { switch ($arg_1 = $_SERVER["argv"][1]) { case "install": include("installer/index.php"); exit(0); case "upgrade": case "package": $_SERVER["argv"] = array("index.php", "{$arg_1}r/$arg_1"); define("TEST_MODE", 0); define("VARPATH", realpath("var") . "/"); break; case "test": array_splice($_SERVER["argv"], 1, 1, "gallery_unit_test"); define("TEST_MODE", 1); if (!is_dir("test/var")) { @mkdir("test/var", 0777, true); @mkdir("test/var/logs", 0777, true); } @copy("var/database.php", "test/var/database.php"); define("VARPATH", realpath("test/var") . "/"); break; default: print "To install:\n"; print " php index.php install -d database -h host -u user -p password -x table_prefix \n\n"; print "To upgrade:\n"; print " php index.php upgrade\n\n"; print "Developer-only features:\n"; print " ** CAUTION! THESE FEATURES -WILL- DAMAGE YOUR INSTALL **\n"; print " php index.php package # create new installer files\n"; print " php index.php test # run unit tests\n"; exit(1); } } else { define("TEST_MODE", 0); define("VARPATH", realpath("var") . "/"); } define("TMPPATH", VARPATH . "/tmp/"); if (file_exists("local.php")) { include("local.php"); } // Initialize. require APPPATH . "Bootstrap" . EXT;