diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/README.md b/README.md index e07aa42..a2f2c41 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RconMC Module 1.3.0 +# RconMC Module 1.3.1 ## Upload Upload "custom" and the "modules" folder to your NamelessMC Root directory (public_html, html, htdocs) @@ -6,7 +6,7 @@ Upload "custom" and the "modules" folder to your NamelessMC Root directory (publ - Open your NamelessMC dashboard => Modules => Click on "Install" - Open the newly added sidebar entry RconMC and edit it to your liking -Get your support here https://resourcemc.net/discord +Get your support here https://pterodactyl-resources.com/discord ## Contribution ### Pull Requests diff --git a/custom/panel_templates/Default/RconMC/edit_rcon_.tpl b/custom/panel_templates/Default/RconMC/edit_rcon_.tpl index c3c22df..add22bb 100644 --- a/custom/panel_templates/Default/RconMC/edit_rcon_.tpl +++ b/custom/panel_templates/Default/RconMC/edit_rcon_.tpl @@ -1,102 +1,86 @@ {include file='header.tpl'} - - -
- - - {include file='sidebar.tpl'} - - -
- - -
- - - {include file='navbar.tpl'} - - -
- - -
- - -
-
-

{$TITLE}

-
-
-
- - -
-
-
-
-
{$EDIT_SERVER} {$EDIT_NAME}
-
- {$BACK} -
-
- - {if isset($ERRORS) && count($ERRORS)} -
- -
{$ERRORS_TITLE}
-
    - {foreach from=$ERRORS item=error} -
  • {$error}
  • - {/foreach} -
-
- {/if} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- -
-
-
- -
- - {include file='footer.tpl'} - - -
-
- - - {include file='scripts.tpl'} - + +
+ + {include file='sidebar.tpl'} + +
+ +
+ + {include file='navbar.tpl'} + +
+ +
+
+
+

{$TITLE}

+
+
+
+ +
+
+
+
+
{$EDIT_SERVER} {$EDIT_NAME}
+
+ {$BACK} +
+
+ {if isset($ERRORS) && count($ERRORS)} +
+ +
{$ERRORS_TITLE}
+
    + {foreach from=$ERRORS item=error} +
  • {$error}
  • + {/foreach} +
+
+ {/if} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+ {include file='footer.tpl'} +
+
+ + {include file='scripts.tpl'} \ No newline at end of file diff --git a/custom/panel_templates/Default/RconMC/index.tpl b/custom/panel_templates/Default/RconMC/index.tpl index 0d0f665..9443631 100644 --- a/custom/panel_templates/Default/RconMC/index.tpl +++ b/custom/panel_templates/Default/RconMC/index.tpl @@ -1,186 +1,160 @@ {include file='header.tpl'} - - -
- - - {include file='sidebar.tpl'} - - -
- - -
- - - {include file='navbar.tpl'} - - -
- - -
- - -
-
-

{$TITLE}

-
-
-
- -
- {if isset($SUCCESS)} -
- -
{$SUCCESS_TITLE}
- {$SUCCESS} -
- {/if} - - {if isset($ERRORS) && count($ERRORS)} -
- -
{$ERRORS_TITLE}
-
    - {foreach from=$ERRORS item=error} -
  • {$error}
  • - {/foreach} -
-
- {/if} - {if $USER_PERMISSION != 1} -
- -
- {/if} -
- {if count($SERVER_LIST)} -
- - - {foreach from=$SERVER_LIST item=server} - - - {if $USER_PERMISSION != 1} - - {/if} - - {/foreach} - -
- {$server.server_name} - -
- - -
-
-
- {else} - {$NO_SERVER} - {/if} -
-
- - - - - - - - - - - -
- - {include file='footer.tpl'} - - -
-
- - - {include file='scripts.tpl'} - - - - - + +
+ + {include file='sidebar.tpl'} + +
+ +
+ + {include file='navbar.tpl'} + +
+ +
+
+
+

{$TITLE}

+
+
+
+
+ {if isset($SUCCESS)} +
+ +
{$SUCCESS_TITLE}
+ {$SUCCESS} +
+ {/if} + {if isset($ERRORS) && count($ERRORS)} +
+ +
{$ERRORS_TITLE}
+
    + {foreach from=$ERRORS item=error} +
  • {$error}
  • + {/foreach} +
+
+ {/if} + {if $USER_PERMISSION != 1} +
+ +
+ {/if} +
+ {if count($SERVER_LIST)} +
+ + + {foreach from=$SERVER_LIST item=server} + + + {if $USER_PERMISSION != 1} + + {/if} + + {/foreach} + +
+ {$server.server_name} + +
+ + +
+
+
+ {else} + {$NO_SERVER} + {/if} +
+
+ + + +
+ {include file='footer.tpl'} +
+
+ + {include file='scripts.tpl'} + \ No newline at end of file diff --git a/custom/panel_templates/Default/RconMC/rcon.tpl b/custom/panel_templates/Default/RconMC/rcon.tpl index 7f98be6..b4a283b 100644 --- a/custom/panel_templates/Default/RconMC/rcon.tpl +++ b/custom/panel_templates/Default/RconMC/rcon.tpl @@ -1,370 +1,301 @@ {include file='header.tpl'} - - -
- - - {include file='sidebar.tpl'} - - -
- - -
- - - {include file='navbar.tpl'} - - -
- - -
- - -
-
-

{$TITLE}

-
-
-
- - - -
- - -
- {$BACK} -
- - -
- {$SERVER_NAME}
- - - {if count($CMD_BTN)} - - {foreach from=$CMD_BTN item=item key=key} - - {/foreach} - - {/if} - - -
-
- - - -
- -
-
-
- - - - -
-
-
- - -
-
- -
- - {include file='footer.tpl'} - - - - -
- - -
- - - - - - - -
-
- - - {include file='scripts.tpl'} - - - + +
+ + {include file='sidebar.tpl'} + +
+ +
+ + {include file='navbar.tpl'} + +
+ +
+
+
+

{$TITLE}

+
+
+
+
+
+ {$BACK} +
+
+ {$SERVER_NAME}
+ {if count($CMD_BTN)} + {foreach from=$CMD_BTN item=item key=key} + + {/foreach} + {/if} +
+
+ + + +
+
+
+
+ + + +
+
+
+
+
+
+ {include file='footer.tpl'} +
+ + +
+ + +
+
+ + {include file='scripts.tpl'} + \ No newline at end of file diff --git a/modules/RconMC/classes/Rcon.php b/modules/RconMC/classes/Rcon.php index 604f60b..a3263d7 100755 --- a/modules/RconMC/classes/Rcon.php +++ b/modules/RconMC/classes/Rcon.php @@ -87,7 +87,7 @@ public function connect() public function disconnect() { if ($this->socket) { - fclose($this->socket); + fclose($this->socket); } } @@ -111,7 +111,7 @@ public function isConnected() public function sendCommand($command) { if (!$this->isConnected()) { - return false; + return false; } // send command packet @@ -164,23 +164,23 @@ private function authorize() private function writePacket($packetId, $packetType, $packetBody) { /* - Size 32-bit little-endian Signed Integer Varies, see below. - ID 32-bit little-endian Signed Integer Varies, see below. - Type 32-bit little-endian Signed Integer Varies, see below. - Body Null-terminated ASCII String Varies, see below. - Empty String Null-terminated ASCII String 0x00 - */ + Size 32-bit little-endian Signed Integer Varies, see below. + ID 32-bit little-endian Signed Integer Varies, see below. + Type 32-bit little-endian Signed Integer Varies, see below. + Body Null-terminated ASCII String Varies, see below. + Empty String Null-terminated ASCII String 0x00 + */ //create packet $packet = pack('VV', $packetId, $packetType); - $packet = $packet.$packetBody."\x00"; - $packet = $packet."\x00"; + $packet = $packet . $packetBody . "\x00"; + $packet = $packet . "\x00"; // get packet size. $packet_size = strlen($packet); // attach size to packet. - $packet = pack('V', $packet_size).$packet; + $packet = pack('V', $packet_size) . $packet; // write packet. fwrite($this->socket, $packet, strlen($packet)); @@ -209,4 +209,4 @@ private function readPacket() return $packet_pack; } -} +} \ No newline at end of file diff --git a/modules/RconMC/init.php b/modules/RconMC/init.php index 4d5738a..b205696 100755 --- a/modules/RconMC/init.php +++ b/modules/RconMC/init.php @@ -2,24 +2,16 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/tree/v2/ - * NamelessMC version 2.0.0-pr7 + * NamelessMC version 2.1.0 * * License: MIT * * RconMC By VertisanPRO */ -$INFO_MODULE = array( - 'name' => 'RconMC', - 'author' => 'VertisanPRO', - 'module_ver' => '1.3.0', - 'nml_ver' => '2.0.0-pr13', -); - $RconMCLanguage = new Language(ROOT_PATH . '/modules/' . $INFO_MODULE['name'] . '/language', LANGUAGE); - $GLOBALS['RconMCLanguage'] = $RconMCLanguage; require_once(ROOT_PATH . '/modules/' . $INFO_MODULE['name'] . '/module.php'); -$module = new RconMC_Module($language, $pages, $INFO_MODULE); +$module = new RconMC_Module($language, $pages); \ No newline at end of file diff --git a/modules/RconMC/module.php b/modules/RconMC/module.php index 60ba946..d376019 100755 --- a/modules/RconMC/module.php +++ b/modules/RconMC/module.php @@ -2,7 +2,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/tree/v2/ - * NamelessMC version 2.0.0-pr7 + * NamelessMC version 2.1.0 * * License: MIT * @@ -14,16 +14,16 @@ class RconMC_Module extends Module private $_language, $RconMCLanguage; - public function __construct($language, $pages, $INFO_MODULE) + public function __construct($language, $pages) { $this->_language = $language; $this->RconMCLanguage = $GLOBALS['RconMCLanguage']; - $name = $INFO_MODULE['name']; - $author = $INFO_MODULE['author']; - $module_version = $INFO_MODULE['module_ver']; - $nameless_version = $INFO_MODULE['nml_ver']; + $name = 'RconMC'; + $author = 'VertisanPRO'; + $module_version = '1.3.1'; + $nameless_version = '2.1.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); $pages->add('RconMC', '/panel/rconmc', 'pages/panel/index.php'); @@ -94,7 +94,7 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem - $rcon_mc_name = $this->RconMCLanguage->get('general', 'rcon_name'); + $rcon_mc_name = $this->RconMCLanguage->get('general', 'rcon_name'); if ($user->hasPermission('admincp.rconmc') or $user->hasPermission('admincp.rcon.veiw')) { $cache->setCache('panel_sidebar'); @@ -118,7 +118,8 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem } } - public function getDebugInfo(): array { - return[]; + public function getDebugInfo(): array + { + return []; } -} +} \ No newline at end of file diff --git a/modules/RconMC/pages/panel/index.php b/modules/RconMC/pages/panel/index.php index 73e7658..477f6cb 100755 --- a/modules/RconMC/pages/panel/index.php +++ b/modules/RconMC/pages/panel/index.php @@ -2,7 +2,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/tree/v2/ - * NamelessMC version 2.0.0-pr7 + * NamelessMC version 2.1.0 * * License: MIT * @@ -46,7 +46,6 @@ require_once(ROOT_PATH . '/core/templates/backend_init.php'); require_once(ROOT_PATH . '/modules/RconMC/classes/Rcon.php'); - $smarty->assign([ 'SUBMIT' => $language->get('general', 'submit'), 'YES' => $language->get('general', 'yes'), @@ -64,16 +63,12 @@ $template_file = 'RconMC/index.tpl'; - if ($user->hasPermission('admincp.rconmc')) { - if (!isset($_GET['action'])) { - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'server_name' => [ 'required' => true, @@ -96,17 +91,14 @@ 'max' => 10 ] ]); - if ($validation->passed()) { try { - DB::getInstance()->insert('rcon_mc', [ 'rcon_name' => htmlspecialchars(Input::get('server_name')), 'rcon_ip' => htmlspecialchars(Input::get('server_ip')), 'rcon_port' => htmlspecialchars(Input::get('server_port')), 'rcon_pass' => htmlspecialchars(Input::get('server_pass')), ]); - Session::flash('staff_rcon', $RconMCLanguage->get('general', 'new_server_successfully')); } catch (Exception $e) { $errors[] = $e->getMessage(); @@ -123,9 +115,7 @@ } } else { switch ($_GET['action']) { - case 'edit': - if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { Redirect::to(URL::build('/panel/rconmc')); } @@ -133,14 +123,11 @@ if (!count($edit_server)) { Redirect::to(URL::build('/panel/rconmc')); } - $edit_server = $edit_server[0]; - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'server_name' => [ 'required' => true, @@ -163,18 +150,14 @@ 'max' => 10 ] ]); - if ($validation->passed()) { try { - DB::getInstance()->update('rcon_mc', $edit_server->id, [ 'rcon_name' => htmlspecialchars(Input::get('server_name')), 'rcon_ip' => htmlspecialchars(Input::get('server_ip')), 'rcon_port' => htmlspecialchars(Input::get('server_port')), 'rcon_pass' => htmlspecialchars(Input::get('server_pass')), ]); - - Session::flash('staff_rcon', $RconMCLanguage->get('general', 'edit_server_successfully')); Redirect::to(URL::build('/panel/rconmc')); } catch (Exception $e) { @@ -190,7 +173,6 @@ // Error } } - $smarty->assign([ 'EDIT_SERVER' => $RconMCLanguage->get('general', 'server_edit_title'), 'BACK_LINK' => URL::build('/panel/rconmc'), @@ -199,26 +181,19 @@ 'EDIT_PORT' => Output::getClean($edit_server->rcon_port), 'EDIT_PASS' => Output::getClean($edit_server->rcon_pass) ]); - - $template_file = 'RconMC/edit_rcon_.tpl'; - break; - case 'delete': if (isset($_GET['id']) && is_numeric($_GET['id'])) { try { - DB::getInstance()->delete('rcon_mc', ['id', '=', $_GET['id']]); } catch (Exception $e) { die($e->getMessage()); } - Session::flash('staff_rcon', $RconMCLanguage->get('general', 'deleted_successfully')); Redirect::to(URL::build('/panel/rconmc')); } break; - default: Redirect::to(URL::build('/panel/rconmc')); } @@ -261,8 +236,6 @@ ]); } - - // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); @@ -288,4 +261,4 @@ require(ROOT_PATH . '/core/templates/panel_navbar.php'); -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file, $smarty); \ No newline at end of file diff --git a/modules/RconMC/pages/panel/rcon.php b/modules/RconMC/pages/panel/rcon.php index 8f9f16a..484f077 100755 --- a/modules/RconMC/pages/panel/rcon.php +++ b/modules/RconMC/pages/panel/rcon.php @@ -2,7 +2,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/tree/v2/ - * NamelessMC version 2.0.0-pr7 + * NamelessMC version 2.1.0 * * License: MIT * @@ -13,11 +13,9 @@ if ($user->isLoggedIn()) { if (!$user->canViewStaffCP()) { - Redirect::to(URL::build('/')); } if (!$user->isAdmLoggedIn()) { - Redirect::to(URL::build('/panel/auth')); } else { if (!$user->hasPermission('admincp.rconmc')) { @@ -27,7 +25,6 @@ } } } else { - Redirect::to(URL::build('/login')); } @@ -35,32 +32,21 @@ const PARENT_PAGE = 'rcon_mc_items'; const PANEL_PAGE = 'rcon_mc_items'; - require_once(ROOT_PATH . '/modules/RconMC/classes/Rcon.php'); require_once(ROOT_PATH . '/core/templates/backend_init.php'); - if (isset($_GET['id']) && is_numeric($_GET['id'])) { - if (!is_numeric($_GET['id'])) { Redirect::to(URL::build('/panel/rconmc')); } - if ($cache->isCached('rcon_cmd_btn')) { $cmd_btn = $cache->retrieve('rcon_cmd_btn'); } else { $cmd_btn = []; } - - - - // Add BTN if (isset($_POST['cmd_name'])) { - try { if (Token::check($_POST['token'])) { - - $cmd_btn[$_POST['cmd_name']] = $_POST['command']; $cache->store('rcon_cmd_btn', $cmd_btn); Redirect::to(URL::build('/panel/rconmc/server', 'action=rcon&id=' . $_GET['id'])); @@ -71,10 +57,7 @@ // Error } } - - // Remove BTN if (isset($_POST['btn_remove'])) { - try { if (Token::check($_POST['token'])) { unset($cmd_btn[$_POST['btn_remove']]); @@ -87,32 +70,21 @@ // Error } } - - - $query_server = DB::getInstance()->get('rcon_mc', ['id', '=', $_GET['id']])->results(); if (!count($query_server)) { Redirect::to(URL::build('/panel/rconmc')); } - $query_server = $query_server[0]; - $host = Output::getClean($query_server->rcon_ip); $port = Output::getClean($query_server->rcon_port); $password = Output::getClean($query_server->rcon_pass); $timeout = 3; - - - if (isset($_POST['cmd_mc'])) { try { if (Token::check($_POST['token'])) { - $response = []; $rcon = new Rcon($host, $port, $password, $timeout); - $command = $_POST['cmd_mc']; - if (empty($command)) { $response['status'] = 'error'; $response['error_label'] = $RconMCLanguage->get('general', 'error_commands_label'); @@ -123,8 +95,6 @@ $response['status'] = 'success'; $response['command'] = $_POST['cmd_mc']; $response['response'] = $rcon->get_response(); - - $response['success_status'] = $RconMCLanguage->get('general', 'success_send_command'); } else { $response['status'] = 'error'; @@ -166,15 +136,12 @@ 'TPS' => $RconMCLanguage->get('general', 'tps') ]); - $template_file = 'RconMC/rcon.tpl'; - // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); - if (isset($response)) $smarty->assign([ 'RESPONSE' => $response, @@ -182,4 +149,4 @@ require(ROOT_PATH . '/core/templates/panel_navbar.php'); -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file, $smarty); \ No newline at end of file