diff --git a/.github/workflows/phplint.yml b/.github/workflows/phplint.yml new file mode 100644 index 00000000..a9c0d700 --- /dev/null +++ b/.github/workflows/phplint.yml @@ -0,0 +1,13 @@ +name: PHP Linting +on: + pull_request: + branches: [master, develop] + push: + branches: [master] + +jobs: + phplint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: michaelw90/PHP-Lint@master diff --git a/CREDITS b/CREDITS index f727b661..404de30c 100644 --- a/CREDITS +++ b/CREDITS @@ -1,3 +1,3 @@ * Gesior.pl (2007 - 2008) -* Slawkens (2009 - 2021) +* Slawkens (2009 - 2022) * Contributors listed in CONTRIBUTORS.txt diff --git a/README.md b/README.md index 4cfe40ce..6fabc570 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MyAAC +# [MyAAC](https://my-aac.org) [](https://travis-ci.org/github/slawkens/myaac) [](https://opensource.org/licenses/gpl-license) @@ -11,7 +11,7 @@ MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. Official website: https://my-aac.org -### REQUIREMENTS +### Requirements - PHP 5.6 or later - MySQL database @@ -20,7 +20,7 @@ Official website: https://my-aac.org - ZIP PHP Extension - (optional) mod_rewrite to use friendly_urls -### INSTALLATION AND CONFIGURATION +### Installation Just decompress and untar the source (which you should have done by now, if you're reading this), into your webserver's document root. @@ -40,15 +40,40 @@ Official website: https://my-aac.org Visit http://your_domain/install (http://localhost/install) and follow instructions in the browser. -### KNOWN PROBLEMS +### Configuration - - none - +Check *config.php* to get more informations. +Use *config.local.php* for your local configuration changes. -### OTHER NOTES +### Branches + +This repository follows the Git Flow Workflow. +Cheatsheet: [Git-Flow-Cheetsheet](https://danielkummer.github.io/git-flow-cheatsheet) + +That means, we use: +* master branch, for current stable release +* develop branch, for development version (next release) +* feature branches, for features etc. + +### Known Problems + +- Some compatibility issues with some exotical distibutions. + +### Contributing + +Contributions are more than welcome. + +Pull requests should be made to the *develop* branch as that is the working branch, master is for release code. + +Bug fixes to current release should be done to master branch. + +Look: [Contributing](https://github.com/otsoft/myaac/wiki/Contributing) in our wiki. + +### Other Notes If you have a great idea or want contribute to the project - visit our website at https://www.my-aac.org -### LICENSING +### License - This program and all associated files are released under the GNU Public - License, see LICENSE for details. +This program and all associated files are released under the GNU Public License. +See [LICENSE](https://github.com/slawkens/myaac/blob/master/LICENSE) for details. diff --git a/VERSION b/VERSION deleted file mode 100644 index 16d5c109..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.9.0-dev \ No newline at end of file diff --git a/common.php b/common.php index f0927d6b..df529a4a 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ if (version_compare(phpversion(), '7.1', '<')) die('PHP version 7.1 or higher is const MYAAC = true; const MYAAC_VERSION = '0.9.0-dev'; -const DATABASE_VERSION = 32; +const DATABASE_VERSION = 33; const TABLE_PREFIX = 'myaac_'; define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/config.php b/config.php index 73fbc2af..50f42d66 100644 --- a/config.php +++ b/config.php @@ -135,7 +135,7 @@ $config = array( 'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook) 'smtp_debug' => false, // set true to debug (you will see more info in error.log) - // reCAPTCHA (prevent spam bots) + // Google reCAPTCHA (prevent spam bots) 'recaptcha_enabled' => false, // enable recaptcha verification code 'recaptcha_type' => 'v3', // 'v2-checkbox', 'v2-invisible', 'v3' 'recaptcha_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha @@ -168,6 +168,8 @@ $config = array( 4 => 'Knight Sample' ), + 'use_character_sample_skills' => false, + // it must show limited number of players after using search in character page 'characters_search_limit' => 15, diff --git a/index.php b/index.php index 3ce40bb5..cb273f17 100644 --- a/index.php +++ b/index.php @@ -314,8 +314,10 @@ 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'; + if($config['backward_support']) { + require SYSTEM . 'compat/pages.php'; + require SYSTEM . 'compat/classes.php'; + } $ignore = false; diff --git a/install/includes/schema.sql b/install/includes/schema.sql index fb097bb0..8a12dd40 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -1,4 +1,4 @@ -SET @myaac_database_version = 32; +SET @myaac_database_version = 33; CREATE TABLE `myaac_account_actions` ( @@ -327,7 +327,7 @@ CREATE TABLE `myaac_spells` CREATE TABLE `myaac_visitors` ( - `ip` VARCHAR(16) NOT NULL, + `ip` VARCHAR(45) NOT NULL, `lastvisit` INT(11) NOT NULL DEFAULT 0, `page` VARCHAR(2048) NOT NULL, UNIQUE (`ip`) diff --git a/nginx-sample.conf b/nginx-sample.conf index f826d21d..f659c531 100644 --- a/nginx-sample.conf +++ b/nginx-sample.conf @@ -11,7 +11,7 @@ server { location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_read_timeout 240; - fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } location ~ /\.ht { @@ -22,4 +22,4 @@ server { deny all; return 404; } -} +} \ No newline at end of file diff --git a/release.sh b/release.sh index 6bf99385..e720a3a9 100644 --- a/release.sh +++ b/release.sh @@ -13,7 +13,7 @@ fi if [ $1 = "prepare" ]; then # define release version - version=`cat VERSION` + version=`php system/get_version_for_release.php` echo "Preparing to release version $version of the MyAAC Project!" @@ -24,7 +24,7 @@ if [ $1 = "prepare" ]; then # get myaac from git archive git archive --format zip --output tmp/myaac.zip master - cd tmp/ + cd tmp/ || exit dir="myaac-$version" if [ -d "$dir" ] ; then @@ -41,9 +41,9 @@ fi if [ $1 = "pack" ]; then # define release version - version=`cat VERSION` + version=`php system/get_version_for_release.php` - cd tmp + cd tmp || exit # tar.gz echo "Creating .tar.gz package.." diff --git a/system/clients.conf.php b/system/clients.conf.php index 4daaec15..b3ec18d5 100644 --- a/system/clients.conf.php +++ b/system/clients.conf.php @@ -76,11 +76,13 @@ $config['clients'] = [ 1096, 1097, 1098, + 1100, 1102, 1140, 1150, 1180, + 1200, 1202, 1215, @@ -89,4 +91,12 @@ $config['clients'] = [ 1240, 1251, 1260, + 1270, + 1280, + 1285, + 1286, + 1290, + 1291, + + 1300, ]; diff --git a/system/compat.php b/system/compat/base.php similarity index 100% rename from system/compat.php rename to system/compat/base.php diff --git a/system/compat/classes.php b/system/compat/classes.php new file mode 100644 index 00000000..051fbdf2 --- /dev/null +++ b/system/compat/classes.php @@ -0,0 +1,15 @@ + + * @copyright 2022 MyAAC + * @link https://my-aac.org + */ +defined('MYAAC') or die('Direct access not allowed!'); + +class Player extends OTS_Player {} +class Guild extends OTS_Guild {} +class GuildRank extends OTS_GuildRank {} +class House extends OTS_House {} diff --git a/system/compat_pages.php b/system/compat/pages.php similarity index 100% rename from system/compat_pages.php rename to system/compat/pages.php diff --git a/system/functions.php b/system/functions.php index fbed8384..644a716a 100644 --- a/system/functions.php +++ b/system/functions.php @@ -1037,7 +1037,7 @@ function getTopPlayers($limit = 5) { $deleted = 'deletion'; $is_tfs10 = $db->hasTable('players_online'); - $players = $db->query('SELECT `id`, `name`, `level`, `experience`, `looktype`' . ($db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `lookhead`, `lookbody`, `looklegs`, `lookfeet`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . config('highscores_groups_hidden') . ' AND `id` NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll(); + $players = $db->query('SELECT `id`, `name`, `level`, `vocation`, `experience`, `looktype`' . ($db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `lookhead`, `lookbody`, `looklegs`, `lookfeet`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . config('highscores_groups_hidden') . ' AND `id` NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll(); if($is_tfs10) { foreach($players as &$player) { @@ -1486,7 +1486,7 @@ function getAccountLoginByLabel() // validator functions require_once LIBS . 'validator.php'; -require_once SYSTEM . 'compat.php'; +require_once SYSTEM . 'compat/base.php'; // custom functions require SYSTEM . 'functions_custom.php'; diff --git a/system/get_version_for_release.php b/system/get_version_for_release.php new file mode 100644 index 00000000..fa378dbb --- /dev/null +++ b/system/get_version_for_release.php @@ -0,0 +1,4 @@ +setManaSpent($char_to_copy->getManaSpent()); $player->setSoul($char_to_copy->getSoul()); - for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) - $player->setSkill($skill, 10); + for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) { + $value = 10; + if (config('use_character_sample_skills')) { + $value = $char_to_copy->getSkill($skill); + } + + $player->setSkill($skill, $value); + } $player->setLookBody($char_to_copy->getLookBody()); $player->setLookFeet($char_to_copy->getLookFeet()); @@ -234,16 +240,22 @@ class CreateCharacter if($db->hasTable('player_skills')) { for($i=0; $i<7; $i++) { + $value = 10; + if (config('use_character_sample_skills')) { + $value = $char_to_copy->getSkill($i); + } $skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i); if($skillExists->rowCount() <= 0) { - $db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', 10, 0)'); + $db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', ' . $value . ', 0)'); } } } $loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId().""); - foreach($loaded_items_to_copy as $save_item) - $db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', '".$save_item['attributes']."');"); + foreach($loaded_items_to_copy as $save_item) { + $blob = $db->quote($save_item['attributes']); + $db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', $blob);"); + } global $twig; $twig->display('success.html.twig', array( diff --git a/system/libs/pot/OTS_Player.php b/system/libs/pot/OTS_Player.php index a32bed8a..b5f48dc6 100644 --- a/system/libs/pot/OTS_Player.php +++ b/system/libs/pot/OTS_Player.php @@ -2489,7 +2489,7 @@ class OTS_Player extends OTS_Row_DAO $value = $this->db->query('SELECT ' . $this->db->fieldName('value') . ' FROM ' . $this->db->tableName('player_storage') . ' WHERE ' . $this->db->fieldName('key') . ' = ' . (int) $key . ' AND ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetch(); - if($value !== false) + if($value === false) { return null; } diff --git a/system/locale/pt_br/install.php b/system/locale/pt_br/install.php index 029fd322..e47faede 100644 --- a/system/locale/pt_br/install.php +++ b/system/locale/pt_br/install.php @@ -19,7 +19,7 @@ $locale['not_loaded'] = 'Não carregado'; $locale['loading_spinner'] = 'Por favor aguarde, instalando...'; $locale['importing_spinner'] = 'Por favor, aguarde, importando dados...'; -$locale['please_fill_all'] = 'or favor, preencha todas as entradas!'; +$locale['please_fill_all'] = 'Por favor, preencha todas as entradas!'; $locale['already_installed'] = 'MyAAC já foi instalado. Por favor, apague o diretório install/ . Se você quiser reinstalar o MyAAC - exclua o arquivo config.local.php do diretório principal e atualize a página.'; // welcome diff --git a/system/migrations/33.php b/system/migrations/33.php new file mode 100644 index 00000000..12fe4c2c --- /dev/null +++ b/system/migrations/33.php @@ -0,0 +1,6 @@ +exec('ALTER TABLE `' . TABLE_PREFIX . "visitors` MODIFY `ip` VARCHAR(45) NOT NULL;"); diff --git a/system/pages/account/register.php b/system/pages/account/register.php index bfb69ee1..a10eb76f 100644 --- a/system/pages/account/register.php +++ b/system/pages/account/register.php @@ -22,6 +22,7 @@ if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1") $account_logged->setCustomField("key", $new_rec_key); $account_logged->logAction('Generated recovery key.'); + $message = ''; if($config['mail_enabled'] && $config['send_mail_when_generate_reckey']) { @@ -54,5 +55,3 @@ if($show_form) { //show form $twig->display('account.generate_recovery_key.html.twig'); } - -?> \ No newline at end of file diff --git a/system/pages/account/register_new.php b/system/pages/account/register_new.php index dfe9749f..93a14745 100644 --- a/system/pages/account/register_new.php +++ b/system/pages/account/register_new.php @@ -40,7 +40,7 @@ else $message = 'An error occorred while sending email ( '.$account_logged->getEMail().' ) with recovery key! Recovery key not changed. Try again later. For Admin: More info can be found in system/logs/mailer-error.log
'; + $message = 'An error occurred while sending email ( '.$account_logged->getEMail().' ) with recovery key! Recovery key not changed. Try again later. For Admin: More info can be found in system/logs/mailer-error.log
'; $twig->display('success.html.twig', array( 'title' => 'Account Registered', diff --git a/system/pages/accountmanagement.php b/system/pages/accountmanagement.php index 53c65c0c..6364d1ff 100644 --- a/system/pages/accountmanagement.php +++ b/system/pages/accountmanagement.php @@ -59,8 +59,7 @@ $errors = array(); return; } - if($action == '') - { + if($action == '') { $freePremium = isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium']) || $account_logged->getPremDays() == OTS_Account::GRATIS_PREMIUM_DAYS; $dayOrDays = $account_logged->getPremDays() == 1 ? 'day' : 'days'; /** @@ -72,10 +71,9 @@ $errors = array(); $account_status = '' . ($freePremium ? 'Gratis Premium Account' : 'Premium Account, ' . $account_logged->getPremDays() . ' '.$dayOrDays.' left') . ''; $recovery_key = $account_logged->getCustomField('key'); - if(empty($recovery_key)) + if(empty($recovery_key)) { $account_registered = 'No'; - else - { + } else { if($config['generate_new_reckey'] && $config['mail_enabled']) $account_registered = 'Yes ( Buy new Recovery Key )'; else diff --git a/system/pages/characters.php b/system/pages/characters.php index 5fa44c7f..84c5fd63 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -47,7 +47,7 @@ if(isset($_REQUEST['name'])) if(empty($name)) { $tmp_link = getPlayerLink($name); - echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.An error occorred while sending email! Try again later or contact with admin. For Admin: More info can be found in system/logs/mailer-error.log
'; + echo 'An error occurred while sending email! Try again later or contact with admin. For Admin: More info can be found in system/logs/mailer-error.log
'; } } else @@ -330,7 +330,7 @@ elseif($action == 'step3') } else { - echo 'An error occorred while sending email! You will not receive e-mail with this informations. For Admin: More info can be found in system/logs/mailer-error.log
'; + echo 'An error occurred while sending email! You will not receive e-mail with this informations. For Admin: More info can be found in system/logs/mailer-error.log
'; } } else @@ -513,7 +513,7 @@ elseif($action == 'setnewpassword') } else { - echo 'New password work! An error occorred while sending email! You will not receive e-mail with new password. For Admin: More info can be found in system/logs/mailer-error.log';
+ echo '
New password work! An error occurred while sending email! You will not receive e-mail with new password. For Admin: More info can be found in system/logs/mailer-error.log'; } echo '