diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php index af826d084..58ea7b80e 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -14,19 +14,33 @@ class DBLayer{ * Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var) * @param $db String, the name of the databases entry in the $cfg global var. */ - function __construct($db) + function __construct($db, $dbn = null) { - global $cfg; - $dsn = "mysql:"; - $dsn .= "host=". $cfg['db'][$db]['host'].";"; - $dsn .= "dbname=". $cfg['db'][$db]['name'].";"; - $dsn .= "port=". $cfg['db'][$db]['port'].";"; - - $opt = array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC - ); - $this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt); + if ($db != "install"){ + + global $cfg; + $dsn = "mysql:"; + $dsn .= "host=". $cfg['db'][$db]['host'].";"; + $dsn .= "dbname=". $cfg['db'][$db]['name'].";"; + $dsn .= "port=". $cfg['db'][$db]['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt); + } else { + global $cfg; + $dsn = "mysql:"; + $dsn .= "host=". $cfg['db'][$dbn]['host'].";"; + $dsn .= "port=". $cfg['db'][$dbn]['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$_POST['Username'],$_POST['Password'], $opt); + } } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 8f1f9379b..865a842c4 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -1,6 +1,10 @@ ; This is a sample configuration file ; Comments start with ';', as in php.ini +[install] +login_info = "Please enter your MySQL Username and Password to install the database." +login_here = "here" + [dashboard] home_title = "Introduction" home_info = "Welcome to the Ryzom Core - Account Management System" diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.default.php b/code/ryzom/tools/server/ryzom_ams/www/config.default.php index c559b8b2c..91a370a4d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.default.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.default.php @@ -88,8 +88,8 @@ $AMS_CACHEDIR = $AMS_LIB . '/cache'; $SITEBASE = dirname( __FILE__ ) . '/html/' ; //the paths to your website url -$BASE_WEBPATH = 'http://localhost:40917'; -$IMAGELOC_WEBPATH = 'http://localhost:40917/img'; +$BASE_WEBPATH = $_SERVER['REQUEST_URI'].; +$IMAGELOC_WEBPATH = $_SERVER['REQUEST_URI'].'/img'; $WEBPATH = $BASE_WEBPATH . '/index.php'; $INGAME_WEBPATH = $BASE_WEBPATH . '/index.php'; $CONFIG_PATH = dirname( __FILE__ ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index 40b4e6535..aec5d1825 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -13,8 +13,14 @@ //load required pages and turn error reporting on/off error_reporting(E_ALL); ini_set('display_errors', 'on'); -require( '../config.php' ); -require( '../../ams_lib/libinclude.php' ); +require_once( '../../ams_lib/libinclude.php' ); +if (!@include '../config.php') { + //if config doesnt exist run setup + require( 'install/libsetup.php' ); +} else { + //if config exists then include it + require( '../config.php' ); +} session_start(); //Decide what page to load diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index 0130f1a65..dbee8c7ba 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php @@ -6,8 +6,8 @@ */ //require the pages that are being needed. - require( '../../config.php' ); - require( '../../../ams_lib/libinclude.php' ); + require_once( '../../config.php' ); + require_once( '../../../ams_lib/libinclude.php' ); ini_set( "display_errors", true ); error_reporting( E_ALL ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl new file mode 100644 index 000000000..46d2996d5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl @@ -0,0 +1,43 @@ +{extends file="layout.tpl"} +{block name=content} + +
+
+ +
+
+ +
+
+
+ {$login_info} +
+
+
+
+ +
+
+ +
+ +
+
+ +

+ + +

+
+
+ + {if isset($login_error) and $login_error eq "TRUE"} +
+ + {$login_error_message} +
+ {/if} +
+
+{/block} +