From bc17186d644ff54bcde43e900405d3ec080fcc6f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 17 Dec 2015 17:05:28 +0100 Subject: [PATCH] saimod serverhandling, fixed setup for mods --- mojotrollz/sai/autoload.inc | 3 +- .../autoload.inc | 4 + .../js/saimod_mojotrollz_server_handling.js | 124 +++++++++++++ .../saimod_mojotrollz_server_handling.php | 106 +++++++++++ ...DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php | 9 + .../sql/autoload.inc | 3 + .../sql/mysql/system_api.sql | 1 + .../sql/mysql/system_page.sql | 1 + .../tpl/main.tpl | 167 ++++++++++++++++++ .../saimod_mojotrollz_servers/autoload.inc | 1 + .../saimod_mojotrollz_servers.php | 2 +- .../sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php | 9 + .../sql/autoload.inc | 4 + .../sql/mysql/system_api.sql | 9 + .../sql/mysql/system_page.sql | 1 + mojotrollz/sql/mysql/system_api.sql | 14 +- mojotrollz/sql/mysql/system_page.sql | 3 - 17 files changed, 443 insertions(+), 18 deletions(-) create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/autoload.inc create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/sql/autoload.inc create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_api.sql create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/sql/mysql/system_page.sql create mode 100644 mojotrollz/sai/saimod_mojotrollz_server_handling/tpl/main.tpl create mode 100644 mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php create mode 100644 mojotrollz/sai/saimod_mojotrollz_servers/sql/autoload.inc create mode 100644 mojotrollz/sai/saimod_mojotrollz_servers/sql/mysql/system_api.sql create mode 100644 mojotrollz/sai/saimod_mojotrollz_servers/sql/mysql/system_page.sql diff --git a/mojotrollz/sai/autoload.inc b/mojotrollz/sai/autoload.inc index b8f1dda..a3fb1fb 100644 --- a/mojotrollz/sai/autoload.inc +++ b/mojotrollz/sai/autoload.inc @@ -1,2 +1,3 @@ '+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: 'saimod_webcraft_powertool', + 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: 'saimod_webcraft_powertool', + 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. + }); +} 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 new file mode 100644 index 0000000..08b83ee --- /dev/null +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/saimod_mojotrollz_server_handling.php @@ -0,0 +1,106 @@ +  Mojotrollz Server';} + 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( + \SYSTEM\WEBPATH(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_update(){ + \LIB\lib_git::php(); + $log = ''; + try { + $repo = \GIT\Git::open('/home/mojotrolls/mojo'); + $log .= $repo->run('fetch --all'); + $log .= $repo->pull('origin','master'); + $log .= $repo->run('submodule update --init --recursive'); + $log .= chmod('/home/mojotrolls/mojo/'.'compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'classic/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'classic/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'classic/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'classic/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'classic/db',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/compile',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/run',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/world',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/world_test',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/realm',0755) ? "rights apply: yes\r\n" : "rights apply: no\r\n"; + $log .= chmod('/home/mojotrolls/mojo/'.'tbc/db',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/mojotrolls/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); + } + + /* programms: run, db, update, compile + * run classic/tbc world/realm/world_test start/stop/status + * db classic/tbc realm live + * db classic/tbc chars/world live/test + * compile classic/tbc live/test + * update + * dif + */ +} \ 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_server_handling/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php new file mode 100644 index 0000000..7530770 --- /dev/null +++ b/mojotrollz/sai/saimod_mojotrollz_server_handling/sql/DATA_SAIMOD_MOJOTROLLZ_SERVER_HANDLING.php @@ -0,0 +1,9 @@ + +

Mojotrollz Server

+
+ + +
+ +
+
+
+

Classic

+
+ Status: +
+
+
+

compile

+
+ + + + + + + + + +
livecompile
testcompile
+
+
+
+

db

+
+ + + + + + + + + + + + + + + + +
worlddeploy livedeploy test
realmdeploy live
charsdeploy livedeploy test
+
+
+
+

run

+
+ + + + + + + + + + + + + + + + + + + +
worldstartstopstatus
realmstartstopstatus
world_teststartstopstatus
+
+
+
+
+
+

TBC

+
+ Status: +
+
+
+

compile

+
+ + + + + + + + + +
livecompile
testcompile
+
+
+
+

db

+
+ + + + + + + + + + + + + + + + +
worlddeploy livedeploy test
realmdeploy live
charsdeploy livedeploy test
+
+
+
+

run

+
+ + + + + + + + + + + + + + + + + + + +
worldstartstopstatus
realmstartstopstatus
world_teststartstopstatus
+
+
+
+
+
+

Output

+
+ + + + + + + + + + +
${table_path}${table_submodule}${table_action}
+ + +
+
\ No newline at end of file diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/autoload.inc b/mojotrollz/sai/saimod_mojotrollz_servers/autoload.inc index 6409c48..1453147 100644 --- a/mojotrollz/sai/saimod_mojotrollz_servers/autoload.inc +++ b/mojotrollz/sai/saimod_mojotrollz_servers/autoload.inc @@ -1,4 +1,5 @@   Servers';} + 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);} diff --git a/mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php b/mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php new file mode 100644 index 0000000..5b76660 --- /dev/null +++ b/mojotrollz/sai/saimod_mojotrollz_servers/sql/DATA_SAIMOD_MOJOTROLLZ_SERVERS.php @@ -0,0 +1,9 @@ +