renamed servers & vote sai modules
This commit is contained in:
parent
4e47ced6d5
commit
fd4c2dc1a3
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_servers/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_vote/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_downloads/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_server_handling/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_servers/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_server_tbc/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_server_classic/autoload.inc';
|
||||
require_once dirname(__FILE__).'/saimod_mojotrollz_teamspeak/autoload.inc';
|
||||
|
||||
@ -1,169 +0,0 @@
|
||||
function init_saimod_mojotrollz_server(){
|
||||
{
|
||||
load_visualisation_mojotrollz_server('vis_tbc_player', 'stats_tbc_player', '#filter_vis_tbc_player', 'Players on WoW-TBC', 400,250);
|
||||
load_visualisation_mojotrollz_server('vis_classic_player', 'stats_classic_player', '#filter_vis_classic_player', 'Players on WoW-Classic', 400,250);
|
||||
|
||||
load_visualisation_mojotrollz_server('vis_tbc_server', 'stats_tbc_server', '#filter_vis_tbc_server', 'WoW-TBC Server Status', 400,250);
|
||||
load_visualisation_mojotrollz_server('vis_classic_server', 'stats_classic_server', '#filter_vis_classic_server', 'WoW-Classic Server Status', 400,250);
|
||||
|
||||
$('#filter_vis_tbc_player').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_tbc_player', 'stats_tbc_player', '#filter_vis_tbc_player', 'Players on WoW-TBC', 400,250);
|
||||
})
|
||||
$('#filter_vis_tbc_server').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_tbc_server', 'stats_tbc_server', '#filter_vis_tbc_server', 'WoW-TBC Server Status', 400,250);
|
||||
})
|
||||
|
||||
$('#filter_vis_classic_player').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_classic_player', 'stats_classic_player', '#filter_vis_classic_player', 'Players on WoW-Classic', 400,250);
|
||||
})
|
||||
$('#filter_vis_classic_server').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_classic_server', 'stats_classic_server', '#filter_vis_classic_server', 'WoW-Classic Server Status', 400,250);
|
||||
})
|
||||
}
|
||||
{
|
||||
$('#btn_update').click(function(){
|
||||
growl_start('Updating Server Repository... please wait')
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
|
||||
action: 'update'},
|
||||
success : function(data) {
|
||||
$('#output_log').append(data);
|
||||
growl_end_success("Server Repository updated successfully!");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('#btn_changes').click(function(){
|
||||
growl_start("Calculating Diferences on the Server");
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
|
||||
action: 'changes'},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
$('#table_changes').html('');
|
||||
growl_end_success("Calculated diferences");
|
||||
data.result.revert.forEach(function(entry){
|
||||
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="revert_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-warning btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> Revert</button></td></tr>');
|
||||
});
|
||||
data.result.remove.forEach(function(entry){
|
||||
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="remove_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-danger btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Remove </button></td></tr>');
|
||||
});
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while calculating Diferences: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$('#btn_clear').click(function(){
|
||||
$('#output_log').html('');
|
||||
$('#table_changes').html('');
|
||||
});
|
||||
}
|
||||
|
||||
function revert_file(path,submodule){
|
||||
growl_start("Reverting path "+path);
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
|
||||
action: 'revert',
|
||||
path: path,
|
||||
submodule: submodule},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
growl_end_success("Reverted path "+path);
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while reverting: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function remove_file(path,submodule){
|
||||
growl_start("Removing file "+path);
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_server_handling',
|
||||
action: 'remove',
|
||||
path: path,
|
||||
submodule: submodule},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
growl_end_success("Removed file "+path);
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while removing file: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function growl_start(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'info', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 7000, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function growl_end_success(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'success', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 4500, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function growl_end_error(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'danger', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 4500, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function load_visualisation_mojotrollz_server(div, stats, filter, name, width, height){
|
||||
$.getJSON('./sai.php?sai_mod=.SAI.saimod_mojotrollz_server_handling&action='+stats+'&filter='+$(filter).val(),function(json){
|
||||
if(!json || json.status != true || !json.result){
|
||||
return;}
|
||||
json = json.result;
|
||||
var data = new google.visualization.DataTable();
|
||||
first = true;
|
||||
$.each(json[0], function(key, value){
|
||||
if(first){
|
||||
data.addColumn('datetime',key);
|
||||
first = false;
|
||||
} else {
|
||||
data.addColumn('number',key);
|
||||
}
|
||||
});
|
||||
$.each(json, function(key, value){first = true; data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [(v == null || parseFloat(v) <= 0) ? parseFloat(0) : parseFloat(v)];}}));});
|
||||
|
||||
var options = {title: name, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{left:40,top:40}, vAxis:{logScale: false}, interpolateNulls: false, width: width, height: height};
|
||||
new google.visualization.LineChart(document.getElementById(div)).draw(data, options);
|
||||
});
|
||||
}
|
||||
@ -1,162 +0,0 @@
|
||||
<?php
|
||||
namespace SAI;
|
||||
class saimod_mojotrollz_server_handling extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling(){
|
||||
$vars = array();
|
||||
$vars['classic_realm_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_realm_status();
|
||||
$vars['classic_world_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_world_status();
|
||||
$vars['classic_world_test_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_world_test_status();
|
||||
$vars['classic_players_online'] = self::online_classic();
|
||||
$vars['classic_test_players_online'] = self::online_classic_test();
|
||||
$vars['tbc_realm_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_status();
|
||||
$vars['tbc_world_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_status();
|
||||
$vars['tbc_world_test_status'] = self::sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_status();
|
||||
$vars['tbc_players_online'] = self::online_tbc();
|
||||
$vars['tbc_test_players_online'] = self::online_tbc_test();
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/main.tpl', $vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Server" href="#!mojotrollz_server"><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> WoW Servers</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array(new \PSAI('saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js'));}
|
||||
//public static function css(){}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_stats_tbc_player($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_TBC_PLAYER::QA(array($filter)));}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_stats_tbc_server($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_TBC_SERVER::QA(array($filter)));}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_stats_classic_player($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_CLASSIC_PLAYER::QA(array($filter)));}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_stats_classic_server($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_CLASSIC_SERVER::QA(array($filter)));}
|
||||
|
||||
public static function online_classic(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_zero_chars())['count'];}
|
||||
public static function online_tbc(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_one_chars())['count'];}
|
||||
public static function online_classic_test(){
|
||||
return 0;}//\SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_zero_chars_test())['count'];}
|
||||
public static function online_tbc_test(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_one_chars_test())['count'];}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_update(){
|
||||
\LIB\lib_git::php();
|
||||
$log = '';
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo');
|
||||
$log .= $repo->run('fetch --all');
|
||||
$log .= $repo->pull('origin','master');
|
||||
$log .= $repo->run('submodule update --init --recursive');
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
//$log .= chmod('/home/mojotrollz/mojo/'.'classic/server/bin/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
//$log .= chmod('/home/mojotrollz/mojo/'.'classic/server/bin_test/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/world_test',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/server/bin/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/server/bin_test/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
} catch (\Exception $e){
|
||||
$log .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return $log;
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_changes(){
|
||||
\LIB\lib_git::php();
|
||||
$result = array('log' => '', 'revert' => array(), 'remove' => array());
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo');
|
||||
|
||||
//Find Changes
|
||||
$log = $repo->run('diff --name-only');
|
||||
$sub_reverts = explode("\n", $log);
|
||||
foreach($sub_reverts as $sub){
|
||||
$result['revert'][] = array($sub,'');
|
||||
}
|
||||
\array_pop($result['revert']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
$log = $repo->run('submodule foreach --recursive git diff --name-only');
|
||||
$sub_reverts = explode("\n", $log);
|
||||
$last_path = '';
|
||||
foreach($sub_reverts as $sub){
|
||||
if(substr($sub,0,8) == 'Entering'){
|
||||
$last_path = explode('\'',substr($sub,10))[0].'/';
|
||||
} else {
|
||||
$result['revert'][] = array($sub,$last_path);
|
||||
}
|
||||
}
|
||||
\array_pop($result['revert']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
//Find Untracked Files
|
||||
$log = $repo->run('ls-files --others --exclude-standard');
|
||||
$sub_removes = explode("\n", $log);
|
||||
foreach($sub_removes as $sub){
|
||||
$result['remove'][] = array($sub,'');
|
||||
}
|
||||
\array_pop($result['remove']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
$log = $repo->run('submodule foreach --recursive git ls-files --others --exclude-standard');
|
||||
$sub_removes = explode("\n", $log);
|
||||
$last_path = '';
|
||||
foreach($sub_removes as $sub){
|
||||
if(substr($sub,0,8) == 'Entering'){
|
||||
$last_path = explode('\'',substr($sub,10))[0].'/';
|
||||
} else {
|
||||
$result['remove'][] = array($sub,$last_path);
|
||||
}
|
||||
}
|
||||
\array_pop($result['remove']);
|
||||
$result['log'] .= $log;
|
||||
} catch (\Exception $e){
|
||||
$result['log'] .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||
}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_remove($path,$submodule = ''){
|
||||
if(!\unlink('/home/mojotrollz/mojo/'.$submodule.$path)){
|
||||
throw new \SYSTEM\LOG\ERROR('Could not remove File: /home/mojotrollz/mojo/'.$submodule.$path);}
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_revert($path,$submodule = ''){
|
||||
\LIB\lib_git::php();
|
||||
$result = array('log' => '', 'revert' => array(), 'remove' => array(), 'submodules' => array(), 'revert_submodules' => array());
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo/'.$submodule);
|
||||
//Find Changes
|
||||
$log = $repo->run('checkout '.$path);
|
||||
$result['log'] .= $log;
|
||||
} catch (\Exception $e){
|
||||
$result['log'] .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||
}
|
||||
|
||||
private static function shell_run($ver,$prog,$cmd){
|
||||
return \str_replace("\n","\r\n",shell_exec('/home/mojotrollz/mojo/run '.$ver.' '.$prog.' '.$cmd.' 2>&1'));}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_realm_status(){
|
||||
return self::shell_run('classic', 'realm','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_world_status(){
|
||||
return self::shell_run('classic', 'world','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_classic_world_test_status(){
|
||||
return self::shell_run('classic', 'world_test','status');}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_realm_status(){
|
||||
return self::shell_run('tbc', 'realm','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_status(){
|
||||
return self::shell_run('tbc', 'world','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_server_handling_action_run_tbc_world_test_status(){
|
||||
return self::shell_run('tbc', 'world_test','status');}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5100, 42, 0, 0, '_SAI_saimod_mojotrollz_server_handling', 'action', NULL);
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5110, 42, 2, 5100, 'revert', 'path', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5111, 42, 3, 5100, 'revert', 'submodule', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5115, 42, 2, 5100, 'remove', 'path', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5116, 42, 3, 5100, 'remove', 'submodule', 'STRING');
|
||||
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5120, 42, 3, 5100, NULL, 'filter', 'INT');
|
||||
@ -1 +0,0 @@
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (510, 42, 'mojotrollz_server', 'mojotrollz_server', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_mojotrollz_server_handling', 'init_saimod_mojotrollz_server', '\\SAI\\saimod_mojotrollz_server_handling');
|
||||
@ -1,76 +1,169 @@
|
||||
function init_saimod_mojotrollz_servers() {
|
||||
register_server_edit();
|
||||
register_server_visible();
|
||||
register_server_del();
|
||||
register_server_save();
|
||||
};
|
||||
|
||||
function register_server_edit(){
|
||||
$('.btn_server_edit').click(function(){
|
||||
$('#input_id').val($(this).attr('_id'));
|
||||
$('#input_name').val($(this).attr('_name'));
|
||||
$('#input_url').val($(this).attr('_url'));
|
||||
$('#input_version').val($(this).attr('_version'));
|
||||
$('#input_description').val($(this).attr('_description'));
|
||||
$("#btn_server_save").focus();
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_visible(){
|
||||
$('.btn_server_visible').click(function(){
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_servers&action=visible'+
|
||||
'&id='+$(this).attr('_id')+
|
||||
'&visible='+$('#select_visible_'+$(this).attr('_i')).val(),
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_del(){
|
||||
$('.btn_server_del').click(function(){
|
||||
if (confirm("Delete Server Permanently?") === true) {
|
||||
function init_saimod_mojotrollz_servers(){
|
||||
{
|
||||
load_visualisation_mojotrollz_server('vis_tbc_player', 'stats_tbc_player', '#filter_vis_tbc_player', 'Players on WoW-TBC', 400,250);
|
||||
load_visualisation_mojotrollz_server('vis_classic_player', 'stats_classic_player', '#filter_vis_classic_player', 'Players on WoW-Classic', 400,250);
|
||||
|
||||
load_visualisation_mojotrollz_server('vis_tbc_server', 'stats_tbc_server', '#filter_vis_tbc_server', 'WoW-TBC Server Status', 400,250);
|
||||
load_visualisation_mojotrollz_server('vis_classic_server', 'stats_classic_server', '#filter_vis_classic_server', 'WoW-Classic Server Status', 400,250);
|
||||
|
||||
$('#filter_vis_tbc_player').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_tbc_player', 'stats_tbc_player', '#filter_vis_tbc_player', 'Players on WoW-TBC', 400,250);
|
||||
})
|
||||
$('#filter_vis_tbc_server').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_tbc_server', 'stats_tbc_server', '#filter_vis_tbc_server', 'WoW-TBC Server Status', 400,250);
|
||||
})
|
||||
|
||||
$('#filter_vis_classic_player').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_classic_player', 'stats_classic_player', '#filter_vis_classic_player', 'Players on WoW-Classic', 400,250);
|
||||
})
|
||||
$('#filter_vis_classic_server').on('change',function(){
|
||||
load_visualisation_mojotrollz_server('vis_classic_server', 'stats_classic_server', '#filter_vis_classic_server', 'WoW-Classic Server Status', 400,250);
|
||||
})
|
||||
}
|
||||
{
|
||||
$('#btn_update').click(function(){
|
||||
growl_start('Updating Server Repository... please wait')
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_servers&action=del'+
|
||||
'&id='+$(this).attr('_id'),
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_servers',
|
||||
action: 'update'},
|
||||
success : function(data) {
|
||||
$('#output_log').append(data);
|
||||
growl_end_success("Server Repository updated successfully!");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('#btn_changes').click(function(){
|
||||
growl_start("Calculating Diferences on the Server");
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_servers',
|
||||
action: 'changes'},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
$('#table_changes').html('');
|
||||
growl_end_success("Calculated diferences");
|
||||
data.result.revert.forEach(function(entry){
|
||||
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="revert_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-warning btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> Revert</button></td></tr>');
|
||||
});
|
||||
data.result.remove.forEach(function(entry){
|
||||
$('#table_changes').append('<tr><td>'+entry[0]+'</td><td>'+entry[1]+'</td><td><button onclick="remove_file(\''+entry[0]+'\',\''+entry[1]+'\')" class="btn-danger btn btn-sm" style="margin-right: 15px; height: 32px; font-size: 13px;"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Remove </button></td></tr>');
|
||||
});
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while calculating Diferences: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#btn_clear').click(function(){
|
||||
$('#output_log').html('');
|
||||
$('#table_changes').html('');
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_save(){
|
||||
$('#btn_server_save').click(function() {
|
||||
var id = $('#input_id').val();
|
||||
var name = $('#input_name').val();
|
||||
var url = $('#input_url').val();
|
||||
var version = $('#input_version').val();
|
||||
var description = $('#input_description').val();
|
||||
$.ajax({url: './sai.php',
|
||||
data: { sai_mod: '.SAI.saimod_mojotrollz_servers',
|
||||
action: 'save',
|
||||
id: id,
|
||||
name: name,
|
||||
url: url,
|
||||
version: version,
|
||||
description: description},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
function revert_file(path,submodule){
|
||||
growl_start("Reverting path "+path);
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_servers',
|
||||
action: 'revert',
|
||||
path: path,
|
||||
submodule: submodule},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
growl_end_success("Reverted path "+path);
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while reverting: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function remove_file(path,submodule){
|
||||
growl_start("Removing file "+path);
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php',
|
||||
data : { sai_mod: '.SAI.saimod_mojotrollz_servers',
|
||||
action: 'remove',
|
||||
path: path,
|
||||
submodule: submodule},
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
growl_end_success("Removed file "+path);
|
||||
} else {
|
||||
growl_end_error("An Error Occurred while removing file: "+data.result.message);
|
||||
}
|
||||
$('#output_log').append(data.result.log);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function growl_start(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'info', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 7000, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function growl_end_success(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'success', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 4500, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function growl_end_error(message){
|
||||
$.bootstrapGrowl(message, {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'danger', // (null, 'info', 'danger', 'success')
|
||||
offset: {from: 'top', amount: 50}, // 'top', or 'bottom'
|
||||
align: 'right', // ('left', 'right', or 'center')
|
||||
width: 250, // (integer, or 'auto')
|
||||
delay: 4500, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
|
||||
allow_dismiss: true, // If true then will display a cross to close the popup.
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
}
|
||||
|
||||
function load_visualisation_mojotrollz_server(div, stats, filter, name, width, height){
|
||||
$.getJSON('./sai.php?sai_mod=.SAI.saimod_mojotrollz_servers&action='+stats+'&filter='+$(filter).val(),function(json){
|
||||
if(!json || json.status != true || !json.result){
|
||||
return;}
|
||||
json = json.result;
|
||||
var data = new google.visualization.DataTable();
|
||||
first = true;
|
||||
$.each(json[0], function(key, value){
|
||||
if(first){
|
||||
data.addColumn('datetime',key);
|
||||
first = false;
|
||||
} else {
|
||||
data.addColumn('number',key);
|
||||
}
|
||||
});
|
||||
$.each(json, function(key, value){first = true; data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [(v == null || parseFloat(v) <= 0) ? parseFloat(0) : parseFloat(v)];}}));});
|
||||
|
||||
var options = {title: name, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{left:40,top:40}, vAxis:{logScale: false}, interpolateNulls: false, width: width, height: height};
|
||||
new google.visualization.LineChart(document.getElementById(div)).draw(data, options);
|
||||
});
|
||||
}
|
||||
@ -1,38 +1,162 @@
|
||||
<?php
|
||||
namespace SAI;
|
||||
|
||||
class saimod_mojotrollz_servers extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers(){
|
||||
$vars = array();
|
||||
$vars['content'] = '';
|
||||
$vars['last_visit'] = \SYSTEM\time::time_ago_string(\SYSTEM\CRON\cron::last('\SYSTEM\CRON\cron_log2sqlite'));
|
||||
$res = \SQL\MOJOTROLLZ_SERVER_LIST_ALL::QQ();
|
||||
$i = 0;
|
||||
while($r = $res->next()){
|
||||
$r['selected_0'] = $r['selected_1'] = '';
|
||||
$r['selected_'.$r['visible']] = 'selected';
|
||||
$r['i'] = $i++;
|
||||
$vars['content'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_servers/tpl/list_entry.tpl'))->SERVERPATH(), $r);}
|
||||
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_TIME),\SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_BASIC));
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_servers/tpl/saimod_mojotrollz_servers.tpl'))->SERVERPATH(),$vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Vote Servers" href="#!mojotrollz_servers"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span> Vote Servers</a></li>';}
|
||||
$vars['classic_realm_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_realm_status();
|
||||
$vars['classic_world_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_world_status();
|
||||
$vars['classic_world_test_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_world_test_status();
|
||||
$vars['classic_players_online'] = self::online_classic();
|
||||
$vars['classic_test_players_online'] = self::online_classic_test();
|
||||
$vars['tbc_realm_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_realm_status();
|
||||
$vars['tbc_world_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_world_status();
|
||||
$vars['tbc_world_test_status'] = self::sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_world_test_status();
|
||||
$vars['tbc_players_online'] = self::online_tbc();
|
||||
$vars['tbc_test_players_online'] = self::online_tbc_test();
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/main.tpl', $vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Server" href="#!mojotrollz_servers"><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> WoW Servers</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array(new \PSAI('saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js'));}
|
||||
//public static function css(){}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_visible($id,$visible){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_VISIBLE::QI(array($visible, $id));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_stats_tbc_player($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_TBC_PLAYER::QA(array($filter)));}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_stats_tbc_server($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_TBC_SERVER::QA(array($filter)));}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_stats_classic_player($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_CLASSIC_PLAYER::QA(array($filter)));}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_stats_classic_server($filter = 600){
|
||||
return \SYSTEM\LOG\JsonResult::toString(\SQL\STATS_CLASSIC_SERVER::QA(array($filter)));}
|
||||
|
||||
public static function online_classic(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_zero_chars())['count'];}
|
||||
public static function online_tbc(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_one_chars())['count'];}
|
||||
public static function online_classic_test(){
|
||||
return 0;}//\SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_zero_chars_test())['count'];}
|
||||
public static function online_tbc_test(){
|
||||
return \SQL\ONLINE_PLAYERS::Q1(new \SQL\mangos_one_chars_test())['count'];}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_update(){
|
||||
\LIB\lib_git::php();
|
||||
$log = '';
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo');
|
||||
$log .= $repo->run('fetch --all');
|
||||
$log .= $repo->pull('origin','master');
|
||||
$log .= $repo->run('submodule update --init --recursive');
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'classic/db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
//$log .= chmod('/home/mojotrollz/mojo/'.'classic/server/bin/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
//$log .= chmod('/home/mojotrollz/mojo/'.'classic/server/bin_test/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/world_test',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/server/bin/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
$log .= chmod('/home/mojotrollz/mojo/'.'tbc/server/bin_test/bin/run-mangosd',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n";
|
||||
} catch (\Exception $e){
|
||||
$log .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return $log;
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_save($id,$name,$url,$version,$description){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_SAVE::QI(array($id,$name,$url,$version,$description));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_changes(){
|
||||
\LIB\lib_git::php();
|
||||
$result = array('log' => '', 'revert' => array(), 'remove' => array());
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo');
|
||||
|
||||
//Find Changes
|
||||
$log = $repo->run('diff --name-only');
|
||||
$sub_reverts = explode("\n", $log);
|
||||
foreach($sub_reverts as $sub){
|
||||
$result['revert'][] = array($sub,'');
|
||||
}
|
||||
\array_pop($result['revert']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
$log = $repo->run('submodule foreach --recursive git diff --name-only');
|
||||
$sub_reverts = explode("\n", $log);
|
||||
$last_path = '';
|
||||
foreach($sub_reverts as $sub){
|
||||
if(substr($sub,0,8) == 'Entering'){
|
||||
$last_path = explode('\'',substr($sub,10))[0].'/';
|
||||
} else {
|
||||
$result['revert'][] = array($sub,$last_path);
|
||||
}
|
||||
}
|
||||
\array_pop($result['revert']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
//Find Untracked Files
|
||||
$log = $repo->run('ls-files --others --exclude-standard');
|
||||
$sub_removes = explode("\n", $log);
|
||||
foreach($sub_removes as $sub){
|
||||
$result['remove'][] = array($sub,'');
|
||||
}
|
||||
\array_pop($result['remove']);
|
||||
$result['log'] .= $log;
|
||||
|
||||
$log = $repo->run('submodule foreach --recursive git ls-files --others --exclude-standard');
|
||||
$sub_removes = explode("\n", $log);
|
||||
$last_path = '';
|
||||
foreach($sub_removes as $sub){
|
||||
if(substr($sub,0,8) == 'Entering'){
|
||||
$last_path = explode('\'',substr($sub,10))[0].'/';
|
||||
} else {
|
||||
$result['remove'][] = array($sub,$last_path);
|
||||
}
|
||||
}
|
||||
\array_pop($result['remove']);
|
||||
$result['log'] .= $log;
|
||||
} catch (\Exception $e){
|
||||
$result['log'] .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||
}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_remove($path,$submodule = ''){
|
||||
if(!\unlink('/home/mojotrollz/mojo/'.$submodule.$path)){
|
||||
throw new \SYSTEM\LOG\ERROR('Could not remove File: /home/mojotrollz/mojo/'.$submodule.$path);}
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_revert($path,$submodule = ''){
|
||||
\LIB\lib_git::php();
|
||||
$result = array('log' => '', 'revert' => array(), 'remove' => array(), 'submodules' => array(), 'revert_submodules' => array());
|
||||
try {
|
||||
$repo = \GIT\Git::open('/home/mojotrollz/mojo/'.$submodule);
|
||||
//Find Changes
|
||||
$log = $repo->run('checkout '.$path);
|
||||
$result['log'] .= $log;
|
||||
} catch (\Exception $e){
|
||||
$result['log'] .= 'Error: '.$e->getMessage();
|
||||
}
|
||||
return \SYSTEM\LOG\JsonResult::toString($result);
|
||||
}
|
||||
|
||||
private static function shell_run($ver,$prog,$cmd){
|
||||
return \str_replace("\n","\r\n",shell_exec('/home/mojotrollz/mojo/run '.$ver.' '.$prog.' '.$cmd.' 2>&1'));}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_del($id){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_DEL::QI(array($id));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
/*public static function css(){
|
||||
return array((new \SYSTEM\PSAI('modules/saistart_sys_sai/css/saistart_sys_sai.css'));}*/
|
||||
public static function js(){
|
||||
return array(new \PSAI('saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js'));}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_realm_status(){
|
||||
return self::shell_run('classic', 'realm','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_world_status(){
|
||||
return self::shell_run('classic', 'world','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_classic_world_test_status(){
|
||||
return self::shell_run('classic', 'world_test','status');}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_realm_status(){
|
||||
return self::shell_run('tbc', 'realm','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_world_status(){
|
||||
return self::shell_run('tbc', 'world','status');}
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_run_tbc_world_test_status(){
|
||||
return self::shell_run('tbc', 'world_test','status');}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'SQL');
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq/','SQL');
|
||||
\SYSTEM\SQL\setup::register('SQL\\DATA_SAIMOD_MOJOTROLLZ_SERVERS');
|
||||
\SYSTEM\SQL\setup::register('SQL\\DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING');
|
||||
@ -1,9 +1,7 @@
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5011, 42, 2, 5000, 'visible', 'visible', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5010, 42, 2, 5000, 'visible', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5008, 42, 2, 5000, 'del', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5005, 42, 2, 5000, 'save', 'description', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5004, 42, 2, 5000, 'save', 'version', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5003, 42, 2, 5000, 'save', 'url', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5002, 42, 2, 5000, 'save', 'name', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5001, 42, 2, 5000, 'save', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5000, 42, 0, 0, '_SAI_saimod_mojotrollz_servers', 'action', NULL);
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5100, 42, 0, 0, '_SAI_saimod_mojotrollz_servers', 'action', NULL);
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5110, 42, 2, 5100, 'revert', 'path', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5111, 42, 3, 5100, 'revert', 'submodule', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5115, 42, 2, 5100, 'remove', 'path', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5116, 42, 3, 5100, 'remove', 'submodule', 'STRING');
|
||||
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5120, 42, 3, 5100, NULL, 'filter', 'INT');
|
||||
@ -1 +1 @@
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (500, 42, 'mojotrollz_servers', 'mojotrollz_servers', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_mojotrollz_servers', 'init_saimod_mojotrollz_servers', '\\SAI\\saimod_mojotrollz_servers');
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (510, 42, 'mojotrollz_servers', 'mojotrollz_servers', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_mojotrollz_servers', 'init_saimod_mojotrollz_servers', '\\SAI\\saimod_mojotrollz_servers');
|
||||
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/sql/autoload.inc';
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'SAI');
|
||||
\SYSTEM\SAI\sai::register('\SAI\saimod_mojotrollz_server_handling');
|
||||
\SYSTEM\SAI\sai::register('\SAI\saimod_mojotrollz_vote');
|
||||
@ -0,0 +1,76 @@
|
||||
function init_saimod_mojotrollz_vote() {
|
||||
register_server_edit();
|
||||
register_server_visible();
|
||||
register_server_del();
|
||||
register_server_save();
|
||||
};
|
||||
|
||||
function register_server_edit(){
|
||||
$('.btn_server_edit').click(function(){
|
||||
$('#input_id').val($(this).attr('_id'));
|
||||
$('#input_name').val($(this).attr('_name'));
|
||||
$('#input_url').val($(this).attr('_url'));
|
||||
$('#input_version').val($(this).attr('_version'));
|
||||
$('#input_description').val($(this).attr('_description'));
|
||||
$("#btn_server_save").focus();
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_visible(){
|
||||
$('.btn_server_visible').click(function(){
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_vote&action=visible'+
|
||||
'&id='+$(this).attr('_id')+
|
||||
'&visible='+$('#select_visible_'+$(this).attr('_i')).val(),
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_del(){
|
||||
$('.btn_server_del').click(function(){
|
||||
if (confirm("Delete Server Permanently?") === true) {
|
||||
$.ajax({ type :'GET',
|
||||
url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_vote&action=del'+
|
||||
'&id='+$(this).attr('_id'),
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function register_server_save(){
|
||||
$('#btn_server_save').click(function() {
|
||||
var id = $('#input_id').val();
|
||||
var name = $('#input_name').val();
|
||||
var url = $('#input_url').val();
|
||||
var version = $('#input_version').val();
|
||||
var description = $('#input_description').val();
|
||||
$.ajax({url: './sai.php',
|
||||
data: { sai_mod: '.SAI.saimod_mojotrollz_vote',
|
||||
action: 'save',
|
||||
id: id,
|
||||
name: name,
|
||||
url: url,
|
||||
version: version,
|
||||
description: description},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
if(data.status){
|
||||
system.reload();
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace SAI;
|
||||
|
||||
class saimod_mojotrollz_vote extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_vote(){
|
||||
$vars = array();
|
||||
$vars['content'] = '';
|
||||
$vars['last_visit'] = \SYSTEM\time::time_ago_string(\SYSTEM\CRON\cron::last('\SYSTEM\CRON\cron_log2sqlite'));
|
||||
$res = \SQL\MOJOTROLLZ_SERVER_LIST_ALL::QQ();
|
||||
$i = 0;
|
||||
while($r = $res->next()){
|
||||
$r['selected_0'] = $r['selected_1'] = '';
|
||||
$r['selected_'.$r['visible']] = 'selected';
|
||||
$r['i'] = $i++;
|
||||
$vars['content'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_vote/tpl/list_entry.tpl'))->SERVERPATH(), $r);}
|
||||
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_TIME),\SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_BASIC));
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_vote/tpl/saimod_mojotrollz_vote.tpl'))->SERVERPATH(),$vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Vote Servers" href="#!mojotrollz_vote"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span> Vote Servers</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_vote_action_visible($id,$visible){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_VISIBLE::QI(array($visible, $id));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_vote_action_save($id,$name,$url,$version,$description){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_SAVE::QI(array($id,$name,$url,$version,$description));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_vote_action_del($id){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_DEL::QI(array($id));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
/*public static function css(){
|
||||
return array((new \SYSTEM\PSAI('modules/saistart_sys_sai/css/saistart_sys_sai.css'));}*/
|
||||
public static function js(){
|
||||
return array(new \PSAI('saimod_mojotrollz_vote/js/saimod_mojotrollz_vote.js'));}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'SQL');
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq/','SQL');
|
||||
\SYSTEM\SQL\setup::register('SQL\\DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING');
|
||||
\SYSTEM\SQL\setup::register('SQL\\DATA_SAIMOD_MOJOTROLLZ_SERVERS');
|
||||
@ -0,0 +1,9 @@
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5011, 42, 2, 5000, 'visible', 'visible', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5010, 42, 2, 5000, 'visible', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5008, 42, 2, 5000, 'del', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5005, 42, 2, 5000, 'save', 'description', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5004, 42, 2, 5000, 'save', 'version', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5003, 42, 2, 5000, 'save', 'url', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5002, 42, 2, 5000, 'save', 'name', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5001, 42, 2, 5000, 'save', 'id', 'INT');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5000, 42, 0, 0, '_SAI_saimod_mojotrollz_vote', 'action', NULL);
|
||||
@ -0,0 +1 @@
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (500, 42, 'mojotrollz_vote', 'mojotrollz_vote', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_mojotrollz_vote', 'init_saimod_mojotrollz_vote', '\\SAI\\saimod_mojotrollz_vote');
|
||||
@ -1,4 +1,4 @@
|
||||
<h4>Mojotrollz Servers</h4>
|
||||
<h4>Mojotrollz Vote Servers</h4>
|
||||
<hr>
|
||||
Cron Last Visit: ${last_visit}<br/>
|
||||
<a href="./sai.php?call=cron" target="_blank">Start Cron</a>
|
||||
Loading…
x
Reference in New Issue
Block a user