Create shard admin user in setup

This commit is contained in:
kaetemi 2014-09-06 00:35:28 +02:00
parent 2a6edf5c0f
commit f46cb42bed
4 changed files with 55 additions and 25 deletions

View file

@ -595,14 +595,7 @@ CREATE TABLE IF NOT EXISTS `neltool_users` (
UNIQUE KEY `user_login` (`user_name`), UNIQUE KEY `user_login` (`user_name`),
KEY `user_group_id` (`user_group_id`), KEY `user_group_id` (`user_group_id`),
KEY `user_active` (`user_active`) KEY `user_active` (`user_active`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `neltool_users`
--
INSERT INTO `neltool_users` (`user_id`, `user_name`, `user_password`, `user_group_id`, `user_created`, `user_active`, `user_logged_last`, `user_logged_count`, `user_menu_style`) VALUES
(1, 'guest', '084e0343a0486ff05530df6c705c8bb4', 1, 1405357395, 1, 0, 0, 0);
-- -------------------------------------------------------- -- --------------------------------------------------------

View file

@ -1,30 +1,32 @@
<?php <?php
require_once('../config.php');
define('NELTOOL_LOADED', true); define('NELTOOL_LOADED', true);
// database information for nel tool // database information for nel tool
define('NELTOOL_DBHOST','localhost'); define('NELTOOL_DBHOST', $cfg['db']['tool']['host']);
define('NELTOOL_DBUSER','shard'); define('NELTOOL_DBUSER', $cfg['db']['tool']['user']);
define('NELTOOL_DBPASS',''); define('NELTOOL_DBPASS', $cfg['db']['tool']['pass']);
define('NELTOOL_DBNAME','nel_tool'); define('NELTOOL_DBNAME', $cfg['db']['tool']['name']);
// site paths definitions // site paths definitions
define('NELTOOL_SITEBASE',$_SERVER['PHP_SELF']); define('NELTOOL_SITEBASE', $_SERVER['PHP_SELF']);
define('NELTOOL_SYSTEMBASE',dirname( dirname(__FILE__) ) . '/admin/'); define('NELTOOL_SYSTEMBASE', dirname( dirname(__FILE__) ) . '/admin/');
define('NELTOOL_LOGBASE', NELTOOL_SYSTEMBASE .'/logs/'); define('NELTOOL_LOGBASE', NELTOOL_SYSTEMBASE .'/logs/');
define('NELTOOL_IMGBASE', NELTOOL_SYSTEMBASE .'/imgs/'); define('NELTOOL_IMGBASE', NELTOOL_SYSTEMBASE .'/imgs/');
define('NELTOOL_RRDTOOL', '/usr/bin/rrdtool'); define('NELTOOL_RRDTOOL', '/usr/bin/rrdtool');
define('NELTOOL_RRDSYSBASE', NELTOOL_SYSTEMBASE . 'graphs_output/'); define('NELTOOL_RRDSYSBASE', NELTOOL_SYSTEMBASE . 'graphs_output/');
define('NELTOOL_RRDWEBBASE', NELTOOL_SITEBASE . 'graphs_output/'); define('NELTOOL_RRDWEBBASE', NELTOOL_SITEBASE . 'graphs_output/');
define('NELTOOL_SITETITLE', 'Ryzom Admin'); define('NELTOOL_SITETITLE', 'Ryzom Core Admin');
define('NELTOOL_SESSIONID', 'sid'); define('NELTOOL_SESSIONID', 'sid');
define('NELTOOL_DEBUG', true); define('NELTOOL_DEBUG', true);
// SQL table names // SQL table names
define('NELDB_PREFIX', 'neltool_'); define('NELDB_PREFIX', 'neltool_');
// for later use // for later use
// the config table will gather some of the settings // the config table will gather some of the settings
@ -60,9 +62,9 @@
define('NELDB_RESTART_SEQUENCE_TABLE', NELDB_PREFIX .'restart_sequences'); define('NELDB_RESTART_SEQUENCE_TABLE', NELDB_PREFIX .'restart_sequences');
define('VIEW_DELAY', 0); define('VIEW_DELAY', 0);
define('HARDWARE_REFRESH', 600); define('HARDWARE_REFRESH', 600);
define('LOCK_TIMEOUT', 1800); define('LOCK_TIMEOUT', 1800);
define('BG_IMG', 'imgs/bg_live.png'); define('BG_IMG', 'imgs/bg_live.png');
$nel_user_group_levels = array(array( 'level_id' => 0, $nel_user_group_levels = array(array( 'level_id' => 0,
'level_name' => 'Normal'), 'level_name' => 'Normal'),
@ -70,6 +72,6 @@
'level_name' => 'Administrator'), 'level_name' => 'Administrator'),
); );
$restart_notification_emails = array('vl@ryzom.com'); $restart_notification_emails = array('support@ryzomcore.org');
?> ?>

View file

@ -112,6 +112,8 @@ function update_database_structure($continue_r, $con, $file) {
<?php <?php
$continue = true;
// Change to root directory // Change to root directory
if (!chdir("../")) { if (!chdir("../")) {
printalert("danger", "Cannot change to public PHP root directory"); printalert("danger", "Cannot change to public PHP root directory");

View file

@ -24,7 +24,6 @@ include('header.php');
</div> </div>
<?php <?php
$continue = true;
$roleService = isset($_POST["roleService"]) && $_POST["roleService"] == "on"; $roleService = isset($_POST["roleService"]) && $_POST["roleService"] == "on";
$roleSupport = isset($_POST["roleSupport"]) && $_POST["roleSupport"] == "on"; $roleSupport = isset($_POST["roleSupport"]) && $_POST["roleSupport"] == "on";
@ -173,7 +172,41 @@ include('header.php');
} }
if ($roleService) { if ($roleService) {
// TODO: Create the default admin user // Create the default shard admin user
if (!chdir("admin/")) {
printalert("danger", "Cannot change to admin tools directory");
$continue = false;
}
if ($continue) {
try {
require_once('common.php');
} catch (Exception $e) {
printalert("danger", "Failed to include NeL <em>admin/common.php</em>");
$continue = false;
}
}
if ($continue) {
try {
require_once('functions_tool_administration.php');
} catch (Exception $e) {
printalert("danger", "Failed to include NeL <em>admin/functions_tool_administration.php</em>");
$continue = false;
}
}
if ($continue) {
$adminGroup = 1;
$result = tool_admin_users_add($_POST["toolsAdminUsername"], $_POST["toolsAdminPassword"], (string)$adminGroup, (string)1);
if ($result == "") {
printalert("success", "Added shard admin to NeL tools database");
} else {
printalert("danger", "Failed to add shard admin to NeL tools database<br>" . htmlentities($result));
$continue = false;
}
}
if (!chdir("../")) {
printalert("danger", "Cannot change to public PHP root directory");
$continue = false;
}
} }
if ($roleSupport) { if ($roleSupport) {