From 94c6252d92c183d611bf47d096ecac4b70094909 Mon Sep 17 00:00:00 2001 From: PadowYT2 Date: Fri, 12 May 2023 17:44:35 +0300 Subject: [PATCH] 1.3.2 --- .gitattributes | 2 - README.md | 4 +- .../Default/Iframe/edit_iframe.tpl | 224 +++++----- .../panel_templates/Default/Iframe/iframe.tpl | 319 +++++++-------- .../Default/Iframe/setting.tpl | 381 ++++++++---------- .../templates/DefaultRevamp/Iframe/index.tpl | 110 ++--- modules/Iframe/init.php | 12 +- modules/Iframe/module.php | 35 +- modules/Iframe/pages/index.php | 4 +- modules/Iframe/pages/panel/iframe.php | 43 +- modules/Iframe/pages/panel/setting.php | 41 +- 11 files changed, 484 insertions(+), 691 deletions(-) delete mode 100644 .gitattributes 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 d12a9d1..0a59af7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Iframe Module 1.3.1 +# Iframe Module 1.3.2 ## 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 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/Iframe/edit_iframe.tpl b/custom/panel_templates/Default/Iframe/edit_iframe.tpl index 6876b91..ac2a86d 100644 --- a/custom/panel_templates/Default/Iframe/edit_iframe.tpl +++ b/custom/panel_templates/Default/Iframe/edit_iframe.tpl @@ -1,130 +1,102 @@ {include file='header.tpl'} - - -
- - - {include file='sidebar.tpl'} - - -
- - -
- - - {include file='navbar.tpl'} - - -
- - -
- - -
-
-

{$TITLE}

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

{$TITLE}

+
+
+
+ +
+
+
+
+
{$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/Iframe/iframe.tpl b/custom/panel_templates/Default/Iframe/iframe.tpl index b08df69..33300cd 100644 --- a/custom/panel_templates/Default/Iframe/iframe.tpl +++ b/custom/panel_templates/Default/Iframe/iframe.tpl @@ -1,181 +1,150 @@ {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 count($PAGES_LIST)} -

{$PAGES}

-
- - - {foreach from=$PAGES_LIST item=page} - - - - - {/foreach} - -
- {$page.name} - -
- - - -
-
-
- {else} -

{$NO_PAGES}

- {/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 count($PAGES_LIST)} +

{$PAGES}

+
+ + + {foreach from=$PAGES_LIST item=page} + + + + + {/foreach} + +
+ {$page.name} + +
+ + + +
+
+
+ {else} +

{$NO_PAGES}

+ {/if} +
+
+ + + +
+ {include file='footer.tpl'} +
+
+ + {include file='scripts.tpl'} + \ No newline at end of file diff --git a/custom/panel_templates/Default/Iframe/setting.tpl b/custom/panel_templates/Default/Iframe/setting.tpl index 4ecd4fe..918835f 100644 --- a/custom/panel_templates/Default/Iframe/setting.tpl +++ b/custom/panel_templates/Default/Iframe/setting.tpl @@ -1,220 +1,169 @@ {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} - - -
- -
- {$BACK} -
-
- -
- - {if count($IFRAME_LIST)} -

{$IFRAME}

-
- - - {foreach from=$IFRAME_LIST item=iframe} - - - - - {/foreach} - -
- {$iframe.name} - -
- - -
-
-
- {else} -

{$NO_IFRAME}

- {/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} +
+ +
+ {$BACK} +
+
+
+ {if count($IFRAME_LIST)} +

{$IFRAME}

+
+ + + {foreach from=$IFRAME_LIST item=iframe} + + + + + {/foreach} + +
+ {$iframe.name} + +
+ + +
+
+
+ {else} +

{$NO_IFRAME}

+ {/if} +
+
+ + + +
+ {include file='footer.tpl'} +
+
+ + {include file='scripts.tpl'} + \ No newline at end of file diff --git a/custom/templates/DefaultRevamp/Iframe/index.tpl b/custom/templates/DefaultRevamp/Iframe/index.tpl index ee58281..e9087ff 100644 --- a/custom/templates/DefaultRevamp/Iframe/index.tpl +++ b/custom/templates/DefaultRevamp/Iframe/index.tpl @@ -1,77 +1,55 @@ {include file='header.tpl'} {include file='navbar.tpl'} -
-
- - {if count($WIDGETS_LEFT)} -
- {foreach from=$WIDGETS_LEFT item=widget} - {$widget} - {/foreach} -
- {/if} - -
- - {if isset($SUCCESS)} -
- -
- {$SUCCESS} -
-
- {/if} - - {if isset($ERRORS)} -
- -
- {foreach from=$ERRORS item=error} - {$error}
- {/foreach} -
-
- {/if} - - - - - {foreach from=$IFRAME_LIST item=iframe} - - - {$iframe.description} - - - -
+ {if count($WIDGETS_LEFT)} +
+ {foreach from=$WIDGETS_LEFT item=widget} + {$widget} + {/foreach} +
+ {/if} +
+ {if isset($SUCCESS)} +
+ +
+ {$SUCCESS} +
+
+ {/if} + {if isset($ERRORS)} +
+ +
+ {foreach from=$ERRORS item=error} + {$error}
+ {/foreach} +
+
+ {/if} + {foreach from=$IFRAME_LIST item=iframe} + {$iframe.description} +
- -
- - - {$iframe.footer_description} - - {/foreach} - - - -
- {if count($WIDGETS_RIGHT)} -
- {foreach from=$WIDGETS_RIGHT item=widget} - {$widget} - {/foreach} -
- {/if} -
+ +
+ {$iframe.footer_description} + {/foreach} +
+ {if count($WIDGETS_RIGHT)} +
+ {foreach from=$WIDGETS_RIGHT item=widget} + {$widget} + {/foreach} +
+ {/if} +
- - {include file='footer.tpl'} \ No newline at end of file diff --git a/modules/Iframe/init.php b/modules/Iframe/init.php index 8740f68..7ab1861 100755 --- a/modules/Iframe/init.php +++ b/modules/Iframe/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 * * Iframe By VertisanPRO */ -$INFO_MODULE = [ - 'name' => 'Iframe', - 'author' => 'VertisanPRO', - 'module_ver' => '1.3.1', - 'nml_ver' => '2.0.0-pr13', -]; - $IframeLanguage = new Language(ROOT_PATH . '/modules/' . $INFO_MODULE['name'] . '/language', LANGUAGE); - $GLOBALS['IframeLanguage'] = $IframeLanguage; require_once(ROOT_PATH . '/modules/' . $INFO_MODULE['name'] . '/module.php'); -$module = new Iframe($language, $pages, $INFO_MODULE); +$module = new Iframe($language, $pages); \ No newline at end of file diff --git a/modules/Iframe/module.php b/modules/Iframe/module.php index b7b5a31..937942f 100755 --- a/modules/Iframe/module.php +++ b/modules/Iframe/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 Iframe extends Module private $_language, $IframeLanguage; - public function __construct($language, $pages, $INFO_MODULE) + public function __construct($language, $pages) { $this->_language = $language; $this->IframeLanguage = $GLOBALS['IframeLanguage']; - $name = $INFO_MODULE['name']; - $author = $INFO_MODULE['author']; - $module_version = $INFO_MODULE['module_ver']; - $nameless_version = $INFO_MODULE['nml_ver']; + $name = 'Iframe'; + $author = 'VertisanPRO'; + $module_version = '1.3.2'; + $nameless_version = '2.1.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); $pages->add('Iframe', '/panel/iframe', 'pages/panel/iframe.php'); @@ -51,7 +51,6 @@ public function onUninstall() public function onEnable() { - try { DB::getInstance()->createTable("iframe_pages", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`id`)"); DB::getInstance()->createTable("iframe_data", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `src` varchar(5000) NOT NULL, `iframe_size` varchar(255) NOT NULL, `page_id` int(11) NOT NULL, `description` text NULL, `footer_description` text NULL, PRIMARY KEY (`id`)"); @@ -68,10 +67,12 @@ public function onEnable() } } - public function onDisable() {} - - public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template) { + public function onDisable() + { + } + public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template) + { PermissionHandler::registerPermissions('Iframe', [ 'admincp.iframe' => $this->IframeLanguage->get('general', 'group_permission') ]); @@ -80,20 +81,16 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem $order = 44; if (defined('BACK_END')) { - - $title = $this->IframeLanguage->get('general', 'title'); - - + $title = $this->IframeLanguage->get('general', 'title'); if ($user->hasPermission('admincp.iframe')) { - $navs[2]->add('iframe_divider', mb_strtoupper($title, 'UTF-8'), 'divider', 'top', null, $order); - $navs[2]->add('iframe_items', $title, URL::build('/panel/iframe'), 'top', null, $order + 0.1, $icon); } } } - public function getDebugInfo(): array { - return[]; + public function getDebugInfo(): array + { + return []; } -} +} \ No newline at end of file diff --git a/modules/Iframe/pages/index.php b/modules/Iframe/pages/index.php index 80f2d44..d249b58 100755 --- a/modules/Iframe/pages/index.php +++ b/modules/Iframe/pages/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 * @@ -12,7 +12,6 @@ const PAGE = 'Iframe'; $GLOBALS['IframeLanguage'] = $IframeLanguage; - $page_title = $IframeLanguage->get('general', 'title'); require_once(ROOT_PATH . '/core/templates/frontend_init.php'); @@ -39,7 +38,6 @@ 'footer_description' => Output::getDecoded($iframe->footer_description) ]; } - $smarty->assign([ 'IFRAME_LIST' => $iframe_list ]); diff --git a/modules/Iframe/pages/panel/iframe.php b/modules/Iframe/pages/panel/iframe.php index f9cb1a5..a3cc5f6 100755 --- a/modules/Iframe/pages/panel/iframe.php +++ b/modules/Iframe/pages/panel/iframe.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 * @@ -34,7 +34,6 @@ require_once(ROOT_PATH . '/core/templates/backend_init.php'); - $iframes_pages = DB::getInstance()->get('iframe_pages', ['id', '<>', 0])->results(); $pages_list = []; if (count($iframes_pages)) { @@ -48,11 +47,8 @@ 'url' => $page->url ]; } -}; - -$smarty->assign([ - 'PAGES_LIST' => $pages_list -]); +} +; $smarty->assign([ 'SUBMIT' => $language->get('general', 'submit'), @@ -67,20 +63,17 @@ 'URL' => $language->get('admin', 'page_path'), 'PAGES' => $language->get('admin', 'pages'), 'ADD_PAGE' => $language->get('admin', 'new_page'), - 'NO_PAGES' => $language->get('admin', 'no_custom_pages') + 'NO_PAGES' => $language->get('admin', 'no_custom_pages'), + 'PAGES_LIST' => $pages_list ]); - $template_file = 'Iframe/iframe.tpl'; - if (!isset($_GET['action'])) { - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'url' => [ 'required' => true, @@ -93,18 +86,13 @@ 'max' => 32 ] ]); - - // validation matches '/' if (preg_match('/^\//', Input::get('url'))) { - if ($validation->passed()) { try { - DB::getInstance()->insert('iframe_pages', [ 'name' => Input::get('name'), 'url' => Input::get('url') ]); - Session::flash('staff', $language->get('admin', 'page_created_successfully')); Redirect::to(URL::build('/panel/iframe')); } catch (Exception $e) { @@ -125,23 +113,18 @@ } } else { switch ($_GET['action']) { - case 'delete': if (isset($_GET['id']) && is_numeric($_GET['id'])) { try { - DB::getInstance()->delete('iframe_pages', ['id', '=', $_GET['id']]); } catch (Exception $e) { die($e->getMessage()); } - Session::flash('staff', $language->get('admin', 'page_deleted_successfully')); Redirect::to(URL::build('/panel/iframe')); } break; - case 'edit': - if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { Redirect::to(URL::build('/panel/iframe')); } @@ -149,14 +132,11 @@ if (!count($edit_page)) { Redirect::to(URL::build('/panel/iframe')); } - $edit_page = $edit_page[0]; - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'url' => [ 'required' => true, @@ -169,19 +149,13 @@ 'max' => 32 ] ]); - - // validation matches '/' if (preg_match('/^\//', Input::get('url'))) { - if ($validation->passed()) { try { - DB::getInstance()->update('iframe_pages', $edit_page->id, [ 'name' => Input::get('name'), 'url' => Input::get('url') ]); - - Session::flash('staff', $language->get('admin', 'page_updated_successfully')); Redirect::to(URL::build('/panel/iframe')); } catch (Exception $e) { @@ -200,17 +174,12 @@ // Error } } - $smarty->assign([ 'EDIT_NAME' => Output::getClean($edit_page->name), 'EDIT_URL' => Output::getClean($edit_page->url) ]); - - $template_file = 'Iframe/edit_page.tpl'; - break; - default: Redirect::to(URL::build('/panel/iframe')); } @@ -241,4 +210,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/Iframe/pages/panel/setting.php b/modules/Iframe/pages/panel/setting.php index eeb8779..5fd450a 100755 --- a/modules/Iframe/pages/panel/setting.php +++ b/modules/Iframe/pages/panel/setting.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,11 +14,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.iframe')) { @@ -50,11 +48,8 @@ 'page_id' => $iframe->page_id, ]; } -}; - -$smarty->assign([ - 'IFRAME_LIST' => $iframes_list -]); +} +; $smarty->assign([ 'SUBMIT' => $language->get('general', 'submit'), @@ -72,19 +67,16 @@ 'NO_IFRAME' => $IframeLanguage->get('general', 'no_iframe'), 'IFRAME_SIZE' => $IframeLanguage->get('general', 'iframe_size'), 'DESCRIPTION' => $language->get('admin', 'page_content'), - 'FOOTER_DESCRIPTION' => $IframeLanguage->get('general', 'footer_description') + 'FOOTER_DESCRIPTION' => $IframeLanguage->get('general', 'footer_description'), + 'IFRAME_LIST' => $iframes_list ]); - $template_file = 'Iframe/setting.tpl'; - if (isset($_POST['add'])) { - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'src' => [ 'required' => true, @@ -96,13 +88,10 @@ 'max' => 32 ] ]); - $content = Output::getClean(Input::get('content')); $footer_content = Output::getClean(Input::get('footer_content')); - if ($validation->passed()) { try { - DB::getInstance()->insert('iframe_data', [ 'name' => Input::get('name'), 'src' => Input::get('src'), @@ -111,7 +100,6 @@ 'description' => $content, 'footer_description' => $footer_content ]); - Session::flash('staff', $language->get('admin', 'page_created_successfully')); Redirect::to(URL::build('/panel/iframe/setting', 'action=edit&id=' . $_GET['id'])); } catch (Exception $e) { @@ -129,39 +117,31 @@ } } else { switch ($_GET['action']) { - case 'delete': if (isset($_GET['name']) && is_numeric($_GET['name'])) { try { - $page_id = DB::getInstance()->get('iframe_data', ['id', '=', $_GET['name']])->results(); $page_id = $page_id['0']; $page_id = $page_id->page_id; - DB::getInstance()->delete('iframe_data', ['id', '=', $_GET['name']]); } catch (Exception $e) { die($e->getMessage()); } - Session::flash('staff', $language->get('admin', 'page_deleted_successfully')); Redirect::to(URL::build('/panel/iframe/setting', 'action=edit&id=' . $page_id)); } break; - case 'frame_edit': - if (!isset($_GET['name']) || !is_numeric($_GET['name'])) { Redirect::to(URL::build('/panel/iframe')); } $edit_iframe = DB::getInstance()->get('iframe_data', ['id', '=', $_GET['name']])->results(); $edit_iframe = $edit_iframe[0]; $page_id = $edit_iframe->page_id; - if (Input::exists()) { $errors = []; try { if (Token::check(Input::get('token'))) { - $validation = Validate::check($_POST, [ 'src' => [ 'required' => true, @@ -173,13 +153,10 @@ 'max' => 32 ] ]); - $content = Output::getClean(Input::get('content')); $footer_content = Output::getClean(Input::get('footer_content')); - if ($validation->passed()) { try { - DB::getInstance()->update('iframe_data', $edit_iframe->id, [ 'name' => Input::get('name'), 'src' => Input::get('src'), @@ -187,8 +164,6 @@ 'description' => $content, 'footer_description' => $footer_content ]); - - Session::flash('staff', $language->get('admin', 'page_updated_successfully')); Redirect::to(URL::build('/panel/iframe/setting', 'action=edit&id=' . $page_id)); } catch (Exception $e) { @@ -204,7 +179,6 @@ // Error } } - $smarty->assign([ 'EDIT_NAME' => Output::getClean($edit_iframe->name), 'EDIT_SRC' => Output::getClean($edit_iframe->src), @@ -213,10 +187,7 @@ 'FOOTER_CONTENT' => $edit_iframe->footer_description, 'BACK_LINK' => URL::build('/panel/iframe/setting', 'action=edit&id=' . $page_id) ]); - - $template_file = 'Iframe/edit_iframe.tpl'; - break; } } @@ -252,4 +223,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