From 1c4f256f40dcde881f78ae00f1cdb5175b42e336 Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Fri, 1 Mar 2024 18:40:18 -0300 Subject: [PATCH] fixes. --- .github/workflows/prettier-php.yml | 3 - .prettierignore | 1 - workflow_test/check_name.js | 56 ----- workflow_test/common.php | 135 ------------ workflow_test/index.php | 341 ----------------------------- workflow_test/style.css | 116 ---------- 6 files changed, 652 deletions(-) delete mode 100644 workflow_test/check_name.js delete mode 100644 workflow_test/common.php delete mode 100644 workflow_test/index.php delete mode 100644 workflow_test/style.css diff --git a/.github/workflows/prettier-php.yml b/.github/workflows/prettier-php.yml index ef5f44c08b..d183ec0e2f 100644 --- a/.github/workflows/prettier-php.yml +++ b/.github/workflows/prettier-php.yml @@ -45,9 +45,6 @@ jobs: - name: Run prettier code format run: npx prettier --write **/*.{php,js} --plugin=@prettier/plugin-php --ignore-unknown && npx stylelint **/*.css --fix -# - name: Run stylelint css format -# run: npx stylelint **/*.css --fix - - name: Run add and commit if: ${{ github.ref != 'refs/heads/main' }} uses: EndBug/add-and-commit@v9 diff --git a/.prettierignore b/.prettierignore index 22ad55d2c0..e522c8c5c4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ # Ignore system libs - plugins/ system/libs/PagSeguroLibrary system/libs/phpmailer diff --git a/workflow_test/check_name.js b/workflow_test/check_name.js deleted file mode 100644 index c0e0fd189f..0000000000 --- a/workflow_test/check_name.js +++ /dev/null @@ -1,56 +0,0 @@ -$(function() { - $('#character_name').blur(function() { - checkName(); - }); -}); - -var eventId = 0; -var lastSend = 0; - -function checkName() -{ - if(eventId != 0) - { - clearInterval(eventId) - eventId = 0; - } - - if(document.getElementById("character_name").value=="") - { - $('#character_error').html('Please enter new character name.'); - var $characterIndicator = $('#character_indicator'); - $characterIndicator.attr('src', 'images/global/general/nok.gif'); - $characterIndicator.show(); - return; - } - - //anti flood - var date = new Date; - var timeNow = parseInt(date.getTime()); - - if(lastSend != 0) - { - if(timeNow - lastSend < 1100) - { - eventId = setInterval('checkName()', 1100) - return; - } - } - - var name = document.getElementById("character_name").value; - $.getJSON("tools/validate.php", { name: name, uid: Math.random() }, - function(data) { - var $characterIndicator = $('#character_indicator'); - if(data.hasOwnProperty('success')) { - $('#character_error').html ('' + data.success + ''); - $characterIndicator.attr('src', 'images/global/general/ok.gif'); - } - else if(data.hasOwnProperty('error')) { - $('#character_error').html('' + data.error + ''); - $characterIndicator.attr('src', 'images/global/general/nok.gif'); - } - - $characterIndicator.show(); - lastSend = timeNow; - }); -} \ No newline at end of file diff --git a/workflow_test/common.php b/workflow_test/common.php deleted file mode 100644 index e99e07ce78..0000000000 --- a/workflow_test/common.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @author OpenTibiaBR - * @copyright 2023 MyAAC - * @link https://github.com/opentibiabr/myaac - */ -if (version_compare(phpversion(), '7.4', '<')) die('PHP version 7.4 or higher is required.'); - -define('MYAAC', true); -define('MYAAC_VERSION', '0.8.16'); -define('DATABASE_VERSION', 34); -define('TABLE_PREFIX', 'myaac_'); -define('START_TIME', microtime(true)); -define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); -define('IS_CLI', in_array(php_sapi_name(), ['cli', 'phpdb'])); - - -// account flags -define('FLAG_ADMIN', 1); -define('FLAG_SUPER_ADMIN', 2); -define('FLAG_CONTENT_PAGES', 4); -define('FLAG_CONTENT_MAILER', 8); -define('FLAG_CONTENT_NEWS', 16); -define('FLAG_CONTENT_FORUM', 32); -define('FLAG_CONTENT_COMMANDS', 64); -define('FLAG_CONTENT_SPELLS', 128); -define('FLAG_CONTENT_MONSTERS', 256); -define('FLAG_CONTENT_GALLERY', 512); -define('FLAG_CONTENT_VIDEOS', 1024); -define('FLAG_CONTENT_FAQ', 2048); -define('FLAG_CONTENT_MENUS', 4096); -define('FLAG_CONTENT_PLAYERS', 8192); - -// news -define('NEWS', 1); -define('TICKER', 2); -define('ARTICLE', 3); - -// directories -define('BASE', __DIR__ . '/'); -define('ADMIN', BASE . 'admin/'); -define('SYSTEM', BASE . 'system/'); -define('CACHE', SYSTEM . 'cache/'); -define('LOCALE', SYSTEM . 'locale/'); -define('LIBS', SYSTEM . 'libs/'); -define('LOGS', SYSTEM . 'logs/'); -define('PAGES', SYSTEM . 'pages/'); -define('PLUGINS', BASE . 'plugins/'); -define('TEMPLATES', BASE . 'templates/'); -define('TOOLS', BASE . 'tools/'); - -// menu categories -define('MENU_CATEGORY_NEWS', 1); -define('MENU_CATEGORY_ACCOUNT', 2); -define('MENU_CATEGORY_COMMUNITY', 3); -define('MENU_CATEGORY_FORUM', 4); -define('MENU_CATEGORY_LIBRARY', 5); -define('MENU_CATEGORY_SHOP', 6); -define('MENU_CATEGORY_CHARBAAZAR', 7); - -// otserv versions -define('OTSERV', 1); -define('OTSERV_06', 2); -define('OTSERV_FIRST', OTSERV); -define('OTSERV_LAST', OTSERV_06); -define('TFS_02', 3); -define('TFS_03', 4); -define('TFS_FIRST', TFS_02); -define('TFS_LAST', TFS_03); - -if (!IS_CLI) { - session_save_path(SYSTEM . 'php_sessions'); - session_set_cookie_params([ - "httponly" => true - ]); - session_start(); -} - -// basedir -$basedir = ''; -$tmp = explode('/', $_SERVER['SCRIPT_NAME']); -$size = count($tmp) - 1; -for ($i = 1; $i < $size; $i++) - $basedir .= '/' . $tmp[$i]; - -$basedir = str_replace(array('/admin', '/install', '/tools'), '', $basedir); -define('BASE_DIR', $basedir); - -if (file_exists(BASE . 'config.local.php') && !defined('MYAAC_INSTALL')) { - require BASE . 'config.local.php'; -} - -if (!IS_CLI) { - if (isset($_SERVER['HTTP_HOST'][0])) { - $baseHost = $_SERVER['HTTP_HOST']; - } else { - if (isset($_SERVER['SERVER_NAME'][0])) { - $baseHost = $_SERVER['SERVER_NAME']; - } else { - $baseHost = $_SERVER['SERVER_ADDR']; - } - } - - define('SERVER_URL', 'http' . (isset($_SERVER['HTTPS'][0]) && strtolower($_SERVER['HTTPS']) === 'on' ? 's' : '') . '://' . $baseHost); - define('BASE_URL', SERVER_URL . BASE_DIR . '/'); - define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/'); - - //define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']); - - if (@$config['env'] === 'dev') { - require SYSTEM . 'exception.php'; - } -} -require SYSTEM . 'autoload.php'; diff --git a/workflow_test/index.php b/workflow_test/index.php deleted file mode 100644 index ff88b33c54..0000000000 --- a/workflow_test/index.php +++ /dev/null @@ -1,341 +0,0 @@ - - * @author OpenTibiaBR - * @copyright 2023 MyAAC - * @link https://github.com/opentibiabr/myaac - */ - -require_once 'common.php'; -require_once SYSTEM . 'functions.php'; - -$uri = $_SERVER['REQUEST_URI']; - -$tmp = BASE_DIR; -if (!empty($tmp)) - $uri = str_replace(BASE_DIR . '/', '', $uri); -else - $uri = str_replace_first('/', '', $uri); - -$uri = str_replace(array('index.php/', '?'), '', $uri); -define('URI', $uri); - -if (preg_match("/^[A-Za-z0-9-_%'+]+\.png$/i", $uri)) { - $tmp = explode('.', $uri); - $_REQUEST['name'] = urldecode($tmp[0]); - - chdir(TOOLS . 'signature'); - include TOOLS . 'signature/index.php'; - exit(); -} - -if (preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz|ttf|woff|ico)$/i", $_SERVER['REQUEST_URI'])) { - http_response_code(404); - exit; -} - -if (file_exists(BASE . 'config.local.php')) { - require_once BASE . 'config.local.php'; -} - -ini_set('log_errors', 1); -if (config('env') === 'dev') { - ini_set('display_errors', 1); - ini_set('display_startup_errors', 1); - error_reporting(E_ALL); -} else { - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); -} - -if ((!isset($config['installed']) || !$config['installed']) && file_exists(BASE . 'install')) { - header('Location: ' . BASE_URL . 'install/'); - throw new RuntimeException('Setup detected that install/ directory exists. Please visit this url to start MyAAC Installation.
Delete install/ directory if you already installed MyAAC.
Remember to REFRESH this page when you\'re done!'); -} - -$found = false; -if (empty($uri) || isset($_REQUEST['template'])) { - $_REQUEST['p'] = 'news'; - $found = true; -} else { - $tmp = strtolower($uri); - if (!preg_match('/[^A-z0-9\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $tmp . '.php')) { - $_REQUEST['p'] = $uri; - $found = true; - } else { - $rules = array( - '/^account\/manage\/?$/' => array('subtopic' => 'accountmanagement'), - '/^account\/create\/?$/' => array('subtopic' => 'createaccount'), - '/^account\/lost\/?$/' => array('subtopic' => 'lostaccount'), - '/^account\/logout\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'logout'), - '/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_password'), - '/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register'), - '/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register_new'), - '/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_email'), - '/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_info'), - '/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'create_character'), - '/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_name'), - '/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_sex'), - '/^account\/character\/main\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_main'), - '/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'delete_character'), - '/^account\/character\/comment\/[A-Za-z0-9-_%+\']+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment', 'name' => '$3'), - '/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment'), - '/^account\/confirm_email\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'confirm_email', 'v' => '$2'), - '/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'), - '/^changelog\/[0-9]+\/?$/' => array('subtopic' => 'changelog', 'page' => '$1'), - '/^commands\/add\/?$/' => array('subtopic' => 'commands', 'action' => 'add'), - '/^commands\/edit\/?$/' => array('subtopic' => 'commands', 'action' => 'edit'), - '/^faq\/add\/?$/' => array('subtopic' => 'faq', 'action' => 'add'), - '/^faq\/edit\/?$/' => array('subtopic' => 'faq', 'action' => 'edit'), - '/^forum\/add_board\/?$/' => array('subtopic' => 'forum', 'action' => 'add_board'),# - '/^forum\/edit_board\/?$/' => array('subtopic' => 'forum', 'action' => 'edit_board'), - '/^forum\/board\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2'), - '/^forum\/board\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2', 'page' => '$3'), - '/^forum\/thread\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2'), - '/^forum\/thread\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2', 'page' => '$3'), - '/^gallery\/add\/?$/' => array('subtopic' => 'gallery', 'action' => 'add'), - '/^gallery\/edit\/?$/' => array('subtopic' => 'gallery', 'action' => 'edit'), - '/^gallery\/[0-9]+\/?$/' => array('subtopic' => 'gallery', 'image' => '$1'), - '/^gifts\/history\/?$/' => array('subtopic' => 'gifts', 'action' => 'show_history'), - '/^guilds\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'guilds', 'action' => 'show', 'guild' => '$1'), - '/^highscores\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+\/[0-9]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'vocation' => '$2', 'page' => '$3'), - '/^highscores\/[A-Za-z0-9-_]+\/[0-9]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'page' => '$2'), - '/^highscores\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'vocation' => '$2'), - '/^highscores\/[A-Za-z0-9-_\']+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1'), - '/^news\/add\/?$/' => array('subtopic' => 'news', 'action' => 'add'), - '/^news\/edit\/?$/' => array('subtopic' => 'news', 'action' => 'edit'), - '/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'), - '/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'), - '/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'), - '/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'), - '/^houses\/view\/?$/' => array('subtopic' => 'houses', 'page' => 'view') - ); - - foreach ($rules as $rule => $redirect) { - if (preg_match($rule, $uri)) { - $tmp = explode('/', $uri); - /* @var $redirect array */ - foreach ($redirect as $key => $value) { - - if (strpos($value, '$') !== false) { - $value = str_replace('$' . $value[1], $tmp[$value[1]], $value); - } - - $_REQUEST[$key] = $value; - $_GET[$key] = $value; - } - - $found = true; - break; - } - } - } -} - -// define page visited, so it can be used within events system -$page = $_REQUEST['subtopic'] ?? ($_REQUEST['p'] ?? ''); -if (empty($page) || !preg_match('/^[A-z0-9\-]+$/', $page)) { - $tmp = URI; - if (!empty($tmp)) { - $page = $tmp; - } else { - if (!$found) - $page = '404'; - else - $page = 'news'; - } -} - -$page = strtolower($page); -define('PAGE', $page); - -$template_place_holders = array(); - -require_once SYSTEM . 'init.php'; - -// verify myaac tables exists in database -if (!$db->hasTable('myaac_account_actions')) { - throw new RuntimeException('Seems that the table myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting this url.'); -} - -// event system -require_once SYSTEM . 'hooks.php'; -$hooks = new Hooks(); -$hooks->load(); -require_once SYSTEM . 'template.php'; -require_once SYSTEM . 'login.php'; -require_once SYSTEM . 'status.php'; - -$twig->addGlobal('config', $config); -$twig->addGlobal('status', $status); - -require SYSTEM . 'migrate.php'; - -$hooks->trigger(HOOK_STARTUP); - -if ($config['views_counter']) - require_once SYSTEM . 'counter.php'; - -if ($config['visitors_counter']) { - require_once SYSTEM . 'libs/visitors.php'; - $visitors = new Visitors($config['visitors_counter_ttl']); -} - -// page content loading -if (!isset($content[0])) - $content = ''; -$load_it = true; - -// check if site has been closed -$site_closed = false; -if (fetchDatabaseConfig('site_closed', $site_closed)) { - $site_closed = ($site_closed == 1); - if ($site_closed) { - if (!admin()) { - $title = getDatabaseConfig('site_closed_title'); - $content .= '

' . getDatabaseConfig('site_closed_message') . '


'; - $load_it = false; - } - - if (!$logged) { - ob_start(); - require SYSTEM . 'pages/accountmanagement.php'; - $content .= ob_get_contents(); - ob_end_clean(); - $load_it = false; - } - } -} -define('SITE_CLOSED', $site_closed); - -// backward support for gesior -if ($config['backward_support']) { - define('INITIALIZED', true); - $SQL = $db; - $layout_header = template_header(); - $layout_name = $template_path; - $news_content = ''; - $tickers_content = ''; - $subtopic = PAGE; - $main_content = ''; - - $config['access_admin_panel'] = 2; - $group_id_of_acc_logged = 0; - if ($logged && $account_logged) - $group_id_of_acc_logged = $account_logged->getGroupId(); - - $config['site'] = &$config; - $config['server'] = &$config['lua']; - $config['site']['shop_system'] = $config['gifts_system']; - $config['site']['gallery_page'] = true; - - if (!isset($config['vdarkborder'])) - $config['vdarkborder'] = '#505050'; - if (!isset($config['darkborder'])) - $config['darkborder'] = '#D4C0A1'; - if (!isset($config['lightborder'])) - $config['lightborder'] = '#F1E0C6'; - - $config['site']['download_page'] = true; - $config['site']['serverinfo_page'] = true; - $config['site']['screenshot_page'] = true; - - if ($config['forum'] != '') - $config['forum_link'] = (strtolower($config['forum']) === 'site' ? getLink('forum') : $config['forum']); - - foreach ($status as $key => $value) - $config['status']['serverStatus_' . $key] = $value; -} - -if ($load_it) { - if (SITE_CLOSED && admin()) - $content .= '

Site is under maintenance (closed mode). Only privileged users can see it.

'; - - if ($config['backward_support']) { - require SYSTEM . 'compat/pages.php'; - require SYSTEM . 'compat/classes.php'; - } - - $ignore = false; - - $logged_access = 1; - if ($logged && $account_logged && $account_logged->isLoaded()) { - $logged_access = $account_logged->getAccess(); - } - - $success = false; - $tmp_content = getCustomPage($page, $success); - if ($success) { - $content .= $tmp_content; - if (hasFlag(FLAG_CONTENT_PAGES) || superAdmin()) { - $pageInfo = getCustomPageInfo($page); - $content = $twig->render('admin.pages.links.html.twig', array( - 'page' => array('id' => $pageInfo !== null ? $pageInfo['id'] : 0, 'hidden' => $pageInfo !== null ? $pageInfo['hidden'] : '0') - )) . $content; - } - } else { - $file = TEMPLATES . "$template_name/pages/$page.php"; - if (!@file_exists($file) || preg_match('/[^A-z0-9_\-]/', $page)) { - $file = SYSTEM . "pages/$page.php"; - if (!@file_exists($file) || preg_match('/[^A-z0-9_\-]/', $page)) { - $page = '404'; - $file = SYSTEM . 'pages/404.php'; - } - } - } - - ob_start(); - if ($hooks->trigger(HOOK_BEFORE_PAGE)) { - if (!$ignore) - require $file; - } - - if ($config['backward_support'] && isset($main_content[0])) - $content .= $main_content; - - $content .= ob_get_contents(); - ob_end_clean(); - $hooks->trigger(HOOK_AFTER_PAGE); -} - -if ($config['backward_support']) { - $main_content = $content; - if (!isset($title)) - $title = ucfirst($page); - - $topic = $title; -} - -$title_full = (isset($title) ? $title . $config['title_separator'] : '') . $config['lua']['serverName']; -require $template_path . '/' . $template_index; - -echo base64_decode('PCEtLSBQb3dlcmVkIGJ5IE9wZW5UaWJpYUJSIE15QUFDIDo6IGh0dHBzOi8vZ2l0aHViLmNvbS9vcGVudGliaWFici9teWFhYyAtLT4=') . PHP_EOL; -if (superAdmin()) { - echo ''; - echo PHP_EOL . ''; - if (function_exists('memory_get_peak_usage')) { - echo PHP_EOL . ''; - } -} - -$hooks->trigger(HOOK_FINISH); diff --git a/workflow_test/style.css b/workflow_test/style.css deleted file mode 100644 index ae39a872ac..0000000000 --- a/workflow_test/style.css +++ /dev/null @@ -1,116 +0,0 @@ -.slidecontainer { - width: 100%; -} - -.slider { - -webkit-appearance: none; - width: 100%; - - outline: none; - opacity: 0.7; - -webkit-transition: .2s; - transition: opacity .2s; -} - -.slider:hover { - opacity: 1; -} - -.slider::-webkit-slider-thumb { - -webkit-appearance: none; - appearance: none; - width: 15px; - height: 25px; - background: #3c8dbc; - cursor: pointer; -} - -.slider::-moz-range-thumb { - width: 25px; - height: 25px; - background: #3c8dbc; - cursor: pointer; -} - -td.details-control { - text-align: center; - color: forestgreen; - cursor: pointer; -} - -tr.shown td.details-control { - text-align: center; - color: red; -} - - - - - - - - - - - - - - - - - - - - - - -.table{ - --bs-table-striped-color: #B8C7D0; -} -a { - text-decoration: none; -} -.skin-blue .main-header .navbar{ - padding-bottom: 0px; - padding-top: 0px; -} -tr { - color: #B8C7D0; -} -.nav-tabs .nav-link{ - color: #fff; - border-bottom: 1px solid #fff; - background: #202634; - border-radius: 5px 5px 0px 0px; -} -ul.nav.nav-tabs.nav-justified.control-sidebar-tabs{ - background: #202634; - padding: 20px; -} - - - - - - - - - - - - - - - - - - - - - - - - - - -