This commit is contained in:
botanic 2014-09-07 22:27:32 -07:00
commit 4ff51bf600
15 changed files with 100 additions and 86 deletions

View file

@ -54,14 +54,6 @@ public:
// Release the service
void release ();
void addTestClient(const std::string & clientId);
void removeTestClient(const std::string & clientId);
void listTestClient() const;
void runTestClientLuaScript(const std::string & clientId, const std::string & cmd);
static R2::CDynamicScenarioService & instance() { return (CDynamicScenarioService&)*IService::getInstance(); }

View file

@ -648,7 +648,7 @@ namespace RSMGR
userAccessPriv.clear();
CSString query;
query << "SELECT AccessPrivilege FROM permission";
query << " WHERE UId = " << userId << " AND DomainId = " << DomainId;
query << " WHERE UId = " << userId << " AND DomainId = (SELECT domain_id FROM domain WHERE domain_name = '" << DomainName << "')";
if (!_NelDb.query(query))
{

View file

@ -23,6 +23,8 @@ class Helpers {
global $AMS_TRANS;
global $INGAME_LAYOUT;
global $AMS_CACHEDIR;
global $AMS_PLUGINS;
// define('SMARTY_SPL_AUTOLOAD',1);
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
spl_autoload_register( '__autoload' );
@ -37,8 +39,12 @@ class Helpers {
$smarty -> caching = false;
$smarty -> cache_lifetime = 300;
$smarty->addPluginsDir($AMS_PLUGINS);
if (function_exists('apc_cache_info')) {
// production
$smarty->caching = true;
$smarty->setCachingType("apc");
$smarty->compile_check = false;
}

View file

@ -164,10 +164,10 @@ userlist_info = "welcome to the userlist"
[login]
login_info = "Please login with your user name (or email) and password."
login_error_message = "Create a new account"
login_register_message ="<strong>Register</strong>"
login_here = "I forgot my password"
login_forgot_password_message = ""
login_error_message = "Login or password were invalid"
login_register_message ="Create a new account"
login_here = ""
login_forgot_password_message = "I forgot my password"
[logout]
logout_message = "You've been logged out successfully."

View file

@ -137,7 +137,7 @@ $NEL_SETUP_PASSWORD = '%nelSetupPassword%';
$NEL_DOMAIN_NAME = '%nelDomainName%';
// Currently configured setup version
$NEL_SETUP_VERSION_CONFIGURED = %nelSetupVersion%;
$NEL_SETUP_VERSION_CONFIGURED = (int)'%nelSetupVersion%';
// Get installed version
require_once('setup/version.php');

View file

@ -1,28 +1,3 @@
-- phpMyAdmin SQL Dump
-- version 4.2.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 04, 2014 at 09:28 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
INSERT INTO `plugins` (`FileName`, `Name`, `Type`, `Owner`, `Permission`, `Status`, `Weight`, `Info`) VALUES
('Domain_Management', 'Domain_Management', 'Manual', '', 'admin', 1, 0, '{"PluginName":"Domain Management","Description":"Plug-in for Domain Management.","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Domain_Management\\/templates\\/index.tpl","Type":"Manual","":null}');
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Dumping data for table `plugins`
--
INSERT INTO `plugins` (`Id`, `FileName`, `Name`, `Type`, `Owner`, `Permission`, `Status`, `Weight`, `Info`) VALUES
(3, 'Domain_Management', 'Domain_Management', 'Manual', '', 'admin', 1, 0, '{"PluginName":"Domain Management","Description":"Plug-in for Domain Management.","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Domain_Management\\/templates\\/index.tpl","Type":"Manual","":null}');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -0,0 +1,3 @@
ALTER TABLE `plugins` ADD UNIQUE(`Name`);
UPDATE `plugins` SET `Info` = '{"PluginName":"Achievements","Description":"Returns the achievements of a user with respect to the character","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Achievements\\/templates\\/index.tpl","Type":"Manual","":null}' WHERE `Name` = 'Achievements';

View file

@ -20,11 +20,18 @@ try {
if (!file_exists('../role_support')) {
header("Cache-Control: max-age=1");
header('Location: ../setup', true, 303);
header('Location: ../setup?reason=no_role_support&from=ams', true, 303);
throw new SystemExit();
}
require( '../config.php' );
if ($NEL_SETUP_VERSION_CONFIGURED < $NEL_SETUP_VERSION) {
header("Cache-Control: max-age=1");
header('Location: ../setup?reason=upgrade&from=ams', true, 303);
throw new SystemExit();
}
require_once( $AMS_LIB . '/libinclude.php' );
session_start();

View file

@ -43,7 +43,7 @@
</div>
{/if}
<div class="alert alert-info">
{$login_register_message} <a href="?page=register">{$login_here}</a>.<br/> {$login_forgot_password_message} <a href="?page=forgot_password">{$login_here}</a>
<a href="?page=register">{$login_register_message}</a>.<br><a href="?page=forgot_password">{$login_forgot_password_message}</a>
</div>
</div><!--/span-->
</div>

View file

@ -223,7 +223,7 @@
$RingWebHost = $domainInfo['web_host'];
$RingWebHostPHP = $domainInfo['web_host_php'];
$LSaddr = split(":", $domainInfo['login_address']);
$LSaddr = explode(":", $domainInfo['login_address']);
// ask for a session cookie to the login service
$login = new LoginCb;

View file

@ -53,10 +53,10 @@ class JoinShardCb extends CRingSessionManagerWeb
global $getShardListCallback;
$onlineShardsBySessionId = array();
$resultArray = split(';', $resultStr);
$resultArray = explode(';', $resultStr);
foreach ($resultArray as $shardInfo)
{
$shardAttr = split(',', $shardInfo);
$shardAttr = explode(',', $shardInfo);
if (isset($shardAttr[1]))
$onlineShardsBySessionId[$shardAttr[0]] = $shardAttr[1];
}
@ -120,7 +120,7 @@ function joinShardFromIdPost( $destSessionId )
function joinShardFromId( $userId, $domainId, $destSessionId )
{
$domainInfo = getDomainInfo($domainId);
$addr = split(":", $domainInfo["session_manager_address"]);
$addr = explode(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
@ -148,7 +148,7 @@ function joinShardFromId( $userId, $domainId, $destSessionId )
function getShardList($userId, $domainId)
{
$domainInfo = getDomainInfo($domainId);
$addr = split(":", $domainInfo["session_manager_address"]);
$addr = explode(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
@ -223,7 +223,7 @@ function displayAllShards(&$onlineShardsBySessionId)
function joinMainland($userId, $domainId)
{
$domainInfo = getDomainInfo($domainId);
$addr = split(":", $domainInfo["session_manager_address"]);
$addr = explode(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];

View file

@ -1,12 +1,26 @@
<?php
// Service
$db_nel = 3;
$db_nel_tool = 1;
// Support
$db_nel_ams = 1;
$db_nel_ams_lib = 4;
// Domain
$db_ring_domain = 1;
function set_db_version($continue_r, $name, $version) {
$continue = $continue_r;
if (file_put_contents("db_version_" . $name, (string)$version)) {
} else {
printalert("danger", "Failed to set database version");
$continue = false;
if ($continue) {
if (file_put_contents("db_version_" . $name, (string)$version)) {
} else {
printalert("danger", "Failed to set database version");
$continue = false;
}
}
return $continue;
@ -53,26 +67,24 @@ function upgrade_service_databases($continue_r) {
$con = null;
$con = connect_database($continue, "shard");
$continue = ($con != null);
if ($continue && get_db_version("shard") < 1) {
$continue = update_database_structure($continue, $con, "nel_00001.sql");
$continue = set_db_version($continue, "shard", 1);
}
if ($continue && get_db_version("shard") < 2) {
$continue = update_database_structure($continue, $con, "nel_00002.sql");
$continue = set_db_version($continue, "shard", 2);
}
if ($continue && get_db_version("shard") < 3) {
$continue = update_database_structure($continue, $con, "nel_00003.sql");
$continue = set_db_version($continue, "shard", 3);
global $db_nel;
for ($i = 1; $i <= $db_nel; $i++) {
if ($continue && get_db_version("shard") < $i) {
$continue = update_database_structure($continue, $con, "nel_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "shard", $i);
}
}
disconnect_database($con, "shard");
$con = null;
$con = connect_database($continue, "tool");
$continue = ($con != null);
if ($continue && get_db_version("tool") < 1) {
$continue = update_database_structure($continue, $con, "nel_tool_00001.sql");
$continue = set_db_version($continue, "tool", 1);
global $db_nel_tool;
for ($i = 1; $i <= $db_nel_tool; $i++) {
if ($continue && get_db_version("tool") < $i) {
$continue = update_database_structure($continue, $con, "nel_tool_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "tool", $i);
}
}
disconnect_database($con, "tool");
@ -85,22 +97,24 @@ function upgrade_support_databases($continue_r) {
$con = null;
$con = connect_database($continue, "web");
$continue = ($con != null);
if ($continue && get_db_version("web") < 1) {
$continue = update_database_structure($continue, $con, "nel_ams_00001.sql");
$continue = set_db_version($continue, "web", 1);
global $db_nel_ams;
for ($i = 1; $i <= $db_nel_ams; $i++) {
if ($continue && get_db_version("web") < $i) {
$continue = update_database_structure($continue, $con, "nel_ams_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "web", $i);
}
}
disconnect_database($con, "web");
$con = null;
$con = connect_database($continue, "lib");
$continue = ($con != null);
if ($continue && get_db_version("lib") < 1) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql");
$continue = set_db_version($continue, "lib", 1);
}
if ($continue && get_db_version("lib") < 2) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql");
$continue = set_db_version($continue, "lib", 2);
global $db_nel_ams_lib;
for ($i = 1; $i <= $db_nel_ams_lib; $i++) {
if ($continue && get_db_version("lib") < $i) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "lib", $i);
}
}
disconnect_database($con, "lib");
@ -113,9 +127,12 @@ function upgrade_domain_databases($continue_r) {
$con = null;
$con = connect_database($continue, "ring");
$continue = ($con != null);
if ($continue && get_db_version("ring") < 1) {
$continue = update_database_structure($continue, $con, "ring_domain_00001.sql");
$continue = set_db_version($continue, "ring", 1);
global $db_ring_domain;
for ($i = 1; $i <= $db_ring_domain; $i++) {
if ($continue && get_db_version("ring") < $i) {
$continue = update_database_structure($continue, $con, "ring_domain_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "ring", $i);
}
}
disconnect_database($con, "ring");

View file

@ -83,8 +83,9 @@ function create_use_database($continue_r, $con, $database) {
}
function update_database_structure($continue_r, $con, $file) {
$continue = $continue_r;
global $PRIVATE_PHP_PATH;
if ($continue) {
$sql = file_get_contents($_POST["privatePhpDirectory"] . "/setup/sql/" . $file);
$sql = file_get_contents($PRIVATE_PHP_PATH . "/setup/sql/" . $file);
if (!$sql) {
printalert("danger", "Cannot read <em>" . $file . "</em>");
$continue = false;

View file

@ -361,7 +361,7 @@ include('header.php');
<div class="col-sm-offset-3 col-sm-8">
<div class="checkbox">
<label>
<input id="roleDomain" name="roleDomain" type="checkbox" onclick="checkDomain();" disabled> Domain <small>(Ring Database, ...) <em>TODO</em></small>
<input id="roleDomain" name="roleDomain" type="checkbox" onclick="checkDomain();" checked> Domain <small>(Ring Database, ...)</small>
</label>
</div>
</div>
@ -497,6 +497,19 @@ include('header.php');
<h2 class="panel-title">Domain <small>(Multiple domains require separate installations, as they may run different versions)</small></h2>
</div>
<div class="panel-body">
<div class="panel panel-danger">
<div class="panel-heading"><span class="glyphicon glyphicon-info-sign"></span> Database Only</div>
<div class="panel-body">
<p>The setup script is intended only for installation and upgrade of the domain specific database.</p>
<p>This will only configure the database for a single domain. It will not register the domain in the domain configuration.</p>
<p>The domain must be manually configured in the databases according to the procedure for configuring your server park with patchman, as it depends on several values defined within the patchman configuration.</p>
<!-- NOTE: For future implementation, it would be practical to configure the nel database directly from the patchman configuration script, as this has all the required values ready. -->
<!-- IMPORTANT: This setup must NEVER be modified to configure the domains, it is not it's responsibility. -->
<p>It is required to use separate virtual hosts for multiple domains, in order to allow domain-specific script to run at different versions.</p>
<p>It is recommended, when planning to use multiple domains, to use a separate virtual host for each web service role.</p>
<p>There can be multiple instances of the domain role, there can only be one support and one service role setup.</p>
</div>
</div>
<div class="form-group">
<label for="nelDomainName" class="col-sm-3 control-label">Name</label>
<div class="col-sm-6">

View file

@ -1,6 +1,6 @@
<?php
// Increment whenever a web upgrade is required.
$NEL_SETUP_VERSION = 2;
$NEL_SETUP_VERSION = 5;
/* end of file */