mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-25 02:00:54 +00:00
added installer for when database is missing
This commit is contained in:
parent
96691a1a9b
commit
cbed910d11
6 changed files with 85 additions and 18 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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__ );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{extends file="layout.tpl"}
|
||||
{block name=content}
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12 center login-header">
|
||||
<img src="img/mainlogo.png"/>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="well span5 center login-box">
|
||||
<div class="alert alert-info">
|
||||
{$login_info}
|
||||
</div>
|
||||
<form method="post" action="index.php{if isset($getstring)}{$getstring}{/if}" class="form-horizontal">
|
||||
<fieldset>
|
||||
<div data-rel="tooltip" class="input-prepend" data-original-title="Username">
|
||||
<span class="add-on"><i class="icon-user"></i></span><input type="text" value="" id="Username" name="Username" class="input-large span10" placeholder="Username">
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div data-rel="tooltip" class="input-prepend" data-original-title="Password">
|
||||
<span class="add-on"><i class="icon-lock"></i></span><input type="password" value="" id="Password" name="Password" class="input-large span10" placeholder="Password">
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<p class="center span5">
|
||||
<input type="hidden" name="function" value="do_install">
|
||||
<button class="btn btn-primary" type="submit">Run Install</button>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{if isset($login_error) and $login_error eq "TRUE"}
|
||||
<div class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>{$login_error_message}</strong>
|
||||
</div>
|
||||
{/if}
|
||||
</div><!--/span-->
|
||||
</div>
|
||||
{/block}
|
||||
|
Loading…
Reference in a new issue