diff --git a/.gitignore b/.gitignore index aee99119b0..997a8d80cd 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ node_modules # test oc-includes/osclass/t/config.php oc-includes/simpletest/test/osclass/custom_config.php +vendor/ +composer.phar +*.swp diff --git a/README.md b/README.md index e2e9370341..87719fb004 100755 --- a/README.md +++ b/README.md @@ -28,10 +28,20 @@ $> git clone --recursive git@github.com:osclass/Osclass.git Go to [our site][installing] to get detailed information on installing Osclass. +## Heroku + +If you are using _Heroku_, you will need to: + +1. Set the `HEROKU_URL` environment variable to the root of your application (eg: `https://foo.herokuapp.com`) +2. Provision a MySQL database and then set one of `CLEARDB_DATABASE_URL`, `JAWSDB_DATABASE_URL` or `DATABASE_URL` +3. Set `OSCLASS_MULTISITE` (eg: `0`) +4. Push this code to heroku +5. Visit the app and follow the original web installation guide. + [osclass]: http://osclass.org/ [preview]: http://osclass.org/wp-content/uploads/2011/01/single_job_board-1024x729.png [code]: https://github.com/osclass/Osclass [mailing]: http://list.osclass.org/listinfo/osc-develop [irc]: http://webchat.freenode.net/?channels=osclass [license]: http://www.apache.org/licenses/LICENSE-2.0 -[installing]: http://osclass.org/installing-osclass/ \ No newline at end of file +[installing]: http://osclass.org/installing-osclass/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000..36e727432d --- /dev/null +++ b/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "ext-gd": "*", + "ext-mbstring": "*" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000000..082dd839d2 --- /dev/null +++ b/composer.lock @@ -0,0 +1,21 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "3dec7a637ff354cb5a684daac1222087", + "content-hash": "680404eab330a3042d64055db105bca1", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "ext-gd": "*", + "ext-mbstring": "*" + }, + "platform-dev": [] +} diff --git a/config-heroku.php b/config-heroku.php new file mode 100755 index 0000000000..269833dc55 --- /dev/null +++ b/config-heroku.php @@ -0,0 +1,45 @@ + diff --git a/oc-includes/osclass/install-functions.php b/oc-includes/osclass/install-functions.php index bd6deaefe3..76147dc92f 100755 --- a/oc-includes/osclass/install-functions.php +++ b/oc-includes/osclass/install-functions.php @@ -284,8 +284,14 @@ function oc_install( ) { unset($comm); unset($master_conn); } - - $conn = new DBConnectionClass($dbhost, $username, $password, $dbname); + $conn = NULL; + if(array_key_exists('HEROKU_URL', $_ENV)){ + require_once ABS_PATH . 'config-heroku.php'; + $conn = new DBConnectionClass(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); + } + else { + $conn = new DBConnectionClass($dbhost, $username, $password, $dbname); + } $error_num = $conn->getErrorConnectionLevel(); if( $error_num == 0 ) { @@ -310,34 +316,38 @@ function oc_install( ) { break; } } - - if( file_exists(ABS_PATH . 'config.php') ) { - if( !is_writable(ABS_PATH . 'config.php') ) { - if( reportToOsclass() ) { - LogOsclassInstaller::instance()->error(__("Can't write in config.php file. Check if the file is writable.") , __FILE__."::".__LINE__); - } - return array('error' => __("Can't write in config.php file. Check if the file is writable.")); - } - create_config_file($dbname, $username, $password, $dbhost, $tableprefix); - } else { - if( !file_exists(ABS_PATH . 'config-sample.php') ) { - if( reportToOsclass() ) { - LogOsclassInstaller::instance()->error(__("config-sample.php doesn't exist. Check if everything is decompressed correctly.") , __FILE__."::".__LINE__); + if(!array_key_exists('HEROKU_URL', $_ENV)){ + if( file_exists(ABS_PATH . 'config.php') ) { + if( !is_writable(ABS_PATH . 'config.php') ) { + if( reportToOsclass() ) { + LogOsclassInstaller::instance()->error(__("Can't write in config.php file. Check if the file is writable.") , __FILE__."::".__LINE__); + } + return array('error' => __("Can't write in config.php file. Check if the file is writable.")); } + create_config_file($dbname, $username, $password, $dbhost, $tableprefix); + } else { + if( !file_exists(ABS_PATH . 'config-sample.php') ) { + if( reportToOsclass() ) { + LogOsclassInstaller::instance()->error(__("config-sample.php doesn't exist. Check if everything is decompressed correctly.") , __FILE__."::".__LINE__); + } - return array('error' => __("config-sample.php doesn't exist. Check if everything is decompressed correctly.")); - } - if( !is_writable(ABS_PATH) ) { - if( reportToOsclass() ) { - LogOsclassInstaller::instance()->error(__('Can\'t copy config-sample.php. Check if the root directory is writable.') , __FILE__."::".__LINE__); + return array('error' => __("config-sample.php doesn't exist. Check if everything is decompressed correctly.")); } + if( !is_writable(ABS_PATH) ) { + if( reportToOsclass() ) { + LogOsclassInstaller::instance()->error(__('Can\'t copy config-sample.php. Check if the root directory is writable.') , __FILE__."::".__LINE__); + } - return array('error' => __('Can\'t copy config-sample.php. Check if the root directory is writable.')); + return array('error' => __('Can\'t copy config-sample.php. Check if the root directory is writable.')); + } + copy_config_file($dbname, $username, $password, $dbhost, $tableprefix); } - copy_config_file($dbname, $username, $password, $dbhost, $tableprefix); - } - require_once ABS_PATH . 'config.php'; + require_once ABS_PATH . 'config.php'; + } + else { + require_once ABS_PATH . 'config-heroku.php'; + } $sql = file_get_contents( ABS_PATH . 'oc-includes/osclass/installer/struct.sql' ); @@ -615,11 +625,15 @@ function copy_config_file($dbname, $username, $password, $dbhost, $tableprefix) function is_osclass_installed( ) { - if( !file_exists( ABS_PATH . 'config.php' ) ) { - return false; + if( array_key_exists('HEROKU_URL', $_ENV) ) { + require_once ABS_PATH . 'config-heroku.php'; + } + else { + if( !file_exists( ABS_PATH . 'config.php' ) ) { + return false; + } + require_once ABS_PATH . 'config.php'; } - - require_once ABS_PATH . 'config.php'; $conn = new DBConnectionClass( osc_db_host(), osc_db_user(), osc_db_password(), osc_db_name() ); $c_db = $conn->getOsclassDb(); @@ -785,6 +799,9 @@ function display_target() { } + if( array_key_exists('HEROKU_URL', $_ENV)) { + echo "