diff --git a/mojotrollz/sai/autoload.inc b/mojotrollz/sai/autoload.inc index 19f8480..f23e67a 100644 --- a/mojotrollz/sai/autoload.inc +++ b/mojotrollz/sai/autoload.inc @@ -1,7 +1,7 @@ '+entry[0]+''+entry[1]+''); - }); - data.result.remove.forEach(function(entry){ - $('#table_changes').append(''+entry[0]+''+entry[1]+''); - }); - } 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); - }); -} \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php b/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php deleted file mode 100644 index a73306b..0000000 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php +++ /dev/null @@ -1,162 +0,0 @@ -  WoW Servers';} - 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');} -} \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql b/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql deleted file mode 100644 index bc50352..0000000 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql +++ /dev/null @@ -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'); \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_page.sql b/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_page.sql deleted file mode 100644 index 7a76c97..0000000 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_page.sql +++ /dev/null @@ -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'); \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js b/mojotrollz/sai/saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js index da2e75a..c8e67d2 100644 --- a/mojotrollz/sai/saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js +++ b/mojotrollz/sai/saimod_mojotrollz_servers/js/saimod_mojotrollz_servers.js @@ -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(''+entry[0]+''+entry[1]+''); + }); + data.result.remove.forEach(function(entry){ + $('#table_changes').append(''+entry[0]+''+entry[1]+''); + }); + } 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); }); } \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/saimod_mojotrollz_servers.php b/mojotrollz/sai/saimod_mojotrollz_servers/saimod_mojotrollz_servers.php index 165225e..4b1b9b1 100644 --- a/mojotrollz/sai/saimod_mojotrollz_servers/saimod_mojotrollz_servers.php +++ b/mojotrollz/sai/saimod_mojotrollz_servers/saimod_mojotrollz_servers.php @@ -1,38 +1,162 @@ 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 '
  •   Vote Servers
  • ';} + $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 '
  •   WoW Servers
  • ';} 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');} } \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php b/mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php similarity index 100% rename from mojotrollz/sai/saimod_mojotrollz_server_handling/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php rename to mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/sql/autoload.inc b/mojotrollz/sai/saimod_mojotrollz_servers/sql/autoload.inc index 6bccacb..e81a064 100644 --- a/mojotrollz/sai/saimod_mojotrollz_servers/sql/autoload.inc +++ b/mojotrollz/sai/saimod_mojotrollz_servers/sql/autoload.inc @@ -1,4 +1,4 @@ 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 '
  •   Vote Servers
  • ';} + 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'));} +} \ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php b/mojotrollz/sai/saimod_mojotrollz_vote/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php similarity index 100% rename from mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php rename to mojotrollz/sai/saimod_mojotrollz_vote/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php diff --git a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/autoload.inc b/mojotrollz/sai/saimod_mojotrollz_vote/sql/autoload.inc similarity index 63% rename from mojotrollz/sai/saimod_mojotrollz_server_handling/sql/autoload.inc rename to mojotrollz/sai/saimod_mojotrollz_vote/sql/autoload.inc index e81a064..6bccacb 100644 --- a/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/autoload.inc +++ b/mojotrollz/sai/saimod_mojotrollz_vote/sql/autoload.inc @@ -1,4 +1,4 @@ Mojotrollz Servers +

    Mojotrollz Vote Servers


    Cron Last Visit: ${last_visit}
    Start Cron