From 995787a07c45e38528c445896f7b18cf9407a5c5 Mon Sep 17 00:00:00 2001 From: Copilot App <223556219+Copilot@users.noreply.github.com> Date: Tue, 4 Aug 2026 23:24:22 +0200 Subject: [PATCH 1/2] Upgrade dependencies Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- composer.lock | 75 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/composer.lock b/composer.lock index 794f193f..6bd67bf8 100644 --- a/composer.lock +++ b/composer.lock @@ -471,20 +471,19 @@ }, { "name": "nikic/php-parser", - "version": "v5.7.0", + "version": "v5.8.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" + "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", - "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/044a6a392ff8ad0d61f14370a5fbbd0a0107152f", + "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f", "shasum": "" }, "require": { - "ext-ctype": "*", "ext-json": "*", "ext-tokenizer": "*", "php": ">=7.4" @@ -523,9 +522,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.8.0" }, - "time": "2025-12-06T11:56:16+00:00" + "time": "2026-07-04T14:30:18+00:00" }, { "name": "phar-io/manifest", @@ -647,16 +646,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "14.2.2", + "version": "14.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "10d7da3628a99289cdf4c662dd7f0d73f1baec83" + "reference": "82f6e49ff224e2cde923d74425e583a883910783" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/10d7da3628a99289cdf4c662dd7f0d73f1baec83", - "reference": "10d7da3628a99289cdf4c662dd7f0d73f1baec83", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/82f6e49ff224e2cde923d74425e583a883910783", + "reference": "82f6e49ff224e2cde923d74425e583a883910783", "shasum": "" }, "require": { @@ -664,7 +663,7 @@ "ext-libxml": "*", "ext-mbstring": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^5.7.0", + "nikic/php-parser": "^5.8.0", "php": ">=8.4", "phpunit/php-text-template": "^6.0", "sebastian/complexity": "^6.0", @@ -675,7 +674,7 @@ "theseer/tokenizer": "^2.0.1" }, "require-dev": { - "phpunit/phpunit": "^13.2.0" + "phpunit/phpunit": "^13.2.2" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -713,7 +712,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.2.2" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.2.3" }, "funding": [ { @@ -733,7 +732,7 @@ "type": "tidelift" } ], - "time": "2026-06-08T11:50:38+00:00" + "time": "2026-07-06T15:04:02+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1030,30 +1029,30 @@ }, { "name": "phpunit/phpunit", - "version": "13.2.1", + "version": "13.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "60da0ff1e10a0f72ee18a24117ec3b613a346bba" + "reference": "8f5180f4627fc1978be2f61d8d9979dbe37e0c10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/60da0ff1e10a0f72ee18a24117ec3b613a346bba", - "reference": "60da0ff1e10a0f72ee18a24117ec3b613a346bba", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8f5180f4627fc1978be2f61d8d9979dbe37e0c10", + "reference": "8f5180f4627fc1978be2f61d8d9979dbe37e0c10", "shasum": "" }, "require": { "ext-dom": "*", + "ext-filter": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", - "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.13.4", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.4.1", - "phpunit/php-code-coverage": "^14.2.2", + "phpunit/php-code-coverage": "^14.2.3", "phpunit/php-file-iterator": "^7.0.0", "phpunit/php-invoker": "^7.0.0", "phpunit/php-text-template": "^6.0.0", @@ -1110,7 +1109,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/13.2.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/13.2.4" }, "funding": [ { @@ -1118,7 +1117,7 @@ "type": "other" } ], - "time": "2026-06-15T13:14:22+00:00" + "time": "2026-07-08T08:36:51+00:00" }, { "name": "sebastian/cli-parser", @@ -1508,16 +1507,16 @@ }, { "name": "sebastian/exporter", - "version": "8.1.0", + "version": "8.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "c0d29a945f8cf82f300a05e69874508e307ca4c6" + "reference": "cfaa77c750dcad6f44c9bac8f62ac486e1c82c26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c0d29a945f8cf82f300a05e69874508e307ca4c6", - "reference": "c0d29a945f8cf82f300a05e69874508e307ca4c6", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/cfaa77c750dcad6f44c9bac8f62ac486e1c82c26", + "reference": "cfaa77c750dcad6f44c9bac8f62ac486e1c82c26", "shasum": "" }, "require": { @@ -1526,7 +1525,7 @@ "sebastian/recursion-context": "^8.0" }, "require-dev": { - "phpunit/phpunit": "^13.1.10" + "phpunit/phpunit": "^13.2.4" }, "type": "library", "extra": { @@ -1574,7 +1573,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/8.1.0" + "source": "https://github.com/sebastianbergmann/exporter/tree/8.1.1" }, "funding": [ { @@ -1594,7 +1593,7 @@ "type": "tidelift" } ], - "time": "2026-05-21T11:50:56+00:00" + "time": "2026-07-13T11:35:11+00:00" }, { "name": "sebastian/file-filter", @@ -1810,24 +1809,24 @@ }, { "name": "sebastian/lines-of-code", - "version": "5.0.1", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "d2cff273a90c79b0eb590baa682d4b5c318bdbb7" + "reference": "d1b6f8fce682505dbd048977f1abedf1b8ad3ff8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d2cff273a90c79b0eb590baa682d4b5c318bdbb7", - "reference": "d2cff273a90c79b0eb590baa682d4b5c318bdbb7", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d1b6f8fce682505dbd048977f1abedf1b8ad3ff8", + "reference": "d1b6f8fce682505dbd048977f1abedf1b8ad3ff8", "shasum": "" }, "require": { - "nikic/php-parser": "^5.7.0", + "nikic/php-parser": "^5.8.0", "php": ">=8.4" }, "require-dev": { - "phpunit/phpunit": "^13.1.10" + "phpunit/phpunit": "^13.2.4" }, "type": "library", "extra": { @@ -1856,7 +1855,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/5.0.2" }, "funding": [ { @@ -1876,7 +1875,7 @@ "type": "tidelift" } ], - "time": "2026-05-19T16:23:37+00:00" + "time": "2026-07-09T08:42:34+00:00" }, { "name": "sebastian/object-enumerator", From df556a77c9e513d40cd196ec4587e206dbd47834 Mon Sep 17 00:00:00 2001 From: Copilot App <223556219+Copilot@users.noreply.github.com> Date: Tue, 4 Aug 2026 23:27:16 +0200 Subject: [PATCH 2/2] Capture remaining worktree changes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .devcontainer/devcontainer-lock.json | 9 + .github/workflows/tests.yml | 8 +- core/helper/ToolTip_Helper.php | 16 +- includes/cache.php | 2 +- includes/chart_js.php | 18 +- includes/config.php | 2 +- includes/functions.php | 119 ++++----- includes/galaxy.php | 58 ++--- includes/log.php | 2 +- includes/mail.php | 8 +- includes/mod.php | 8 +- includes/mysql.php | 76 +++--- includes/ogame.php | 98 +++---- includes/ogame_planet.php | 10 +- includes/ogame_requirements.php | 2 +- includes/ogame_structs.php | 10 +- includes/player.php | 54 ++-- includes/sessions.php | 4 +- includes/token.php | 2 +- includes/user.php | 70 ++--- includes/usergroups.php | 16 +- index.php | 6 +- install/AutoUpgradeManager.php | 22 +- install/ConfigGenerator.php | 26 +- install/MigrationManager.php | 2 +- install/TestManager.php | 84 +++--- install/config/database_config.php | 2 +- install/migrations/00000000000_initial.php | 4 +- .../migrations/20251227001_UpgradeTo403.php | 2 +- install/upgrade_cli.php | 24 +- model/Ally_Model.php | 12 +- model/AstroObject_Model.php | 39 +-- model/Combat_Report_Model.php | 22 +- model/Config_Model.php | 12 +- model/DBUtils_Model.php | 9 +- model/Group_Model.php | 2 +- model/Mod_Config_Model.php | 18 +- model/Mod_Model.php | 42 +-- model/Mod_User_Config_Model.php | 18 +- model/Player_Building_Model.php | 165 ++++++------ model/Player_Defense_Model.php | 16 +- model/Player_Model.php | 26 +- model/Player_Technology_Model.php | 34 +-- model/Rankings_Ally_Model.php | 10 +- model/Rankings_Model.php | 14 +- model/Rankings_Player_Model.php | 3 +- model/Sessions_Model.php | 16 +- model/Spy_Model.php | 19 +- model/Statistics_Model.php | 9 +- model/Tokens_Model.php | 24 +- model/User_Favorites_Model.php | 11 +- model/User_Model.php | 239 +++++++++++++----- stubs/intelephense_globals.php | 53 ++++ 53 files changed, 894 insertions(+), 683 deletions(-) create mode 100644 .devcontainer/devcontainer-lock.json create mode 100644 stubs/intelephense_globals.php diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 00000000..b6f196a7 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "version": "2.5.9", + "resolved": "ghcr.io/devcontainers/features/common-utils@sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a", + "integrity": "sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a" + } + } +} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4d8d69fd..a6162bbd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,8 +11,12 @@ permissions: jobs: test: - name: PHPUnit Tests + name: PHPUnit Tests (PHP ${{ matrix.php-version }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ['8.4', '8.5'] steps: - name: Checkout code @@ -21,7 +25,7 @@ jobs: - name: Setup PHP with Xdebug uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: ${{ matrix.php-version }} coverage: xdebug extensions: curl, mysqli, json, mbstring, openssl, zlib, zip diff --git a/core/helper/ToolTip_Helper.php b/core/helper/ToolTip_Helper.php index 9eaa706d..6a3fe601 100644 --- a/core/helper/ToolTip_Helper.php +++ b/core/helper/ToolTip_Helper.php @@ -32,7 +32,7 @@ public function __construct() } /** - * Retourne la cle courante si elle existe + * Returns la cle courante si elle existe * * @return string */ @@ -42,7 +42,7 @@ public function getCurentKey() } /** - * Ajoute une cle/ valeur pour la création d'un tooltip + * Adds a key/value pair for tooltip creation. */ public function addTooltip($key, $value) { @@ -59,10 +59,10 @@ public function addTooltip($key, $value) } /** - * Retourne Le contenu a ajouter dans la class de l'element html permettant l'affichage du tooltip - * si la cle n'est pas précisé on retourne le courant + * Returns the content to add to the HTML element class for tooltip display. + * If no key is provided, the current key is used. * - * @param $tclass contient les differents tags à placer en plus du tooltip + * @param $tclass Contains additional tags to place alongside the tooltip class * @return string */ public function GetHTMLClassContent($tClass = array(), $key = null) @@ -85,8 +85,8 @@ public function GetHTMLClassContent($tClass = array(), $key = null) } /** - * Retourne Le contenu Html qui sera afficher au survol - * ce contenu nest pas directement visible dans la page html (hide()) + * Returns the HTML content displayed on hover. + * This content is hidden in the page HTML by default. * * @return string */ @@ -108,7 +108,7 @@ public function GetHTMLHideContent() } /** - * Retroune une cle compatible avec l'element js de tooltip + * Retroune une cle compatible avec l'element js of tooltip * * @return string */ diff --git a/includes/cache.php b/includes/cache.php index edb164bc..7a2de5d2 100644 --- a/includes/cache.php +++ b/includes/cache.php @@ -74,7 +74,7 @@ function generate_mod_cache() } /** - * Fonction generate_all_cache() + * Function generate_all_cache(). * Description: Generates the all cache file system */ function generate_all_cache() diff --git a/includes/chart_js.php b/includes/chart_js.php index 1f16f453..09e515fd 100644 --- a/includes/chart_js.php +++ b/includes/chart_js.php @@ -16,8 +16,8 @@ } /** - * Generates and returns a pie chart script based on specified data, legends, and title. - * Displays each slice as a percentage of the total. + * Generates and returns a pie chart script from data, labels, and title. + * Displays chaque part en pourcentage of the total. * * @param string $_data A serialized string representing the data values, separated by "_x_". Must match the specified format. * @param string $_legend A serialized string representing the legends for the data values, separated by "_x_". Must match the specified format. @@ -106,8 +106,8 @@ function create_pie($_data, $_legend, $_title, $conteneur, $theme = true) } /** - * Creates and returns a pie chart script based on the provided data, legends, and title. - * Displays each slice with its absolute numeric value. + * Generates and returns a pie chart script from the provided data. + * Displays chaque part avec sa value numérique absolue. * * @param mixed $_data A formatted string representing numerical data values, separated by "_x_". Must match the specified format. * @param mixed $_legend A formatted string representing labels for the data, separated by "_x_". Must match the specified format. @@ -195,7 +195,7 @@ function create_pie_numbers($_data, $_legend, $_title, $conteneur, $theme = true /** - * Generates and returns curves based on a specified range of dates and player data. + * Generates and returns curves based on a date range and player data. * * @param mixed $_player The primary player for whom the curves are being created. Must be specified. * @param mixed $conteneur The container that manages the context of the errors or results. @@ -283,7 +283,7 @@ function create_curves($_player, $conteneur, $_date_min, $_date_max, $_comp) /** * affiche_error() - * Generates a JavaScript snippet to display an error message within a specified HTML container. + * Generates un extrait JavaScript for afficher un message d'erreur dans un conteneur HTML. * * @param string $conteneur The ID of the HTML container where the error message will be displayed. * @param string $error The error message to be displayed. @@ -304,7 +304,7 @@ function affiche_error($conteneur, $error) /** * graph_colors() - * Returns the color palette used for Chart.js charts (dark theme compatible). + * Returns la palette of couleurs used for the graphiques Chart.js. * * @return array Array of color hex strings. */ @@ -318,7 +318,7 @@ function graph_colors(): array /** * graph_theme() - * Returns an empty string (theme is now applied inline via Chart.js options). + * Returns une string vide (le thème est maintenant appliqué inline via the options Chart.js). * Kept for backward compatibility. * * @return string Empty string. @@ -330,7 +330,7 @@ function graph_theme(): string /** * create_multi_curve() - * Generate the JavaScript code for rendering a multi-curve chart using Chart.js. + * Generates le code JavaScript of rendu d'un graphique multi-courbes avec Chart.js. * * @param string $titre The title of the chart. * @param string $sous_titre The subtitle of the chart. diff --git a/includes/config.php b/includes/config.php index 68a4f53d..1d99aa0b 100644 --- a/includes/config.php +++ b/includes/config.php @@ -2,7 +2,7 @@ global $table_prefix; /** - * Fichier de configuration communes + * Fichier of configuration communes * @package OGSpy * @subpackage Main * @author Kyser diff --git a/includes/functions.php b/includes/functions.php index 18b404be..2fcca0bf 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -44,9 +44,9 @@ function redirection($url) /** * Write a text or a table in a file - * @param string $file Filename + * @param string $filename Filename * @param string $mode File Opening Mode - * @param string|Array $content String or table to write + * @param string|array $content String or table to write * @return boolean false if failed */ function write_file($filename, $mode, $content) @@ -117,7 +117,7 @@ function write_file_gz($file, $mode, $content) /** * Remove a Folder with its content - * @param string $folder Chemin vers le dossier à supprimer + * @param string $folder Path vers le folder à delete */ function remove_dir_from_ogspy($folder) { @@ -949,7 +949,7 @@ function set_serverconfig() /** * Returns the Status of the Database used size. - * @return Array [Server], et [Total] + * @return Array [Server], and [Total] */ function db_size_info() { @@ -1593,10 +1593,10 @@ function generate_key() "m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0" = string de stockage par défaut */ /*##Base de donnée ##*/ -/* Lit les informations des objets Ogame dans la BDD et les transformes en un tableau - * @arg id_player id du joueur - * @arg id_planet id de la planète à rechercher - * @return tableau associatif des boosters ou NULL en cas d'échec +/* Reads OGame item information from the database and converts it into an array. + * @arg id_player player ID + * @arg id_planet planet ID to search for + * @return associative array of boosters or NULL on failure * array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date', 'extention_p', 'extention_m') * */ @@ -1607,17 +1607,17 @@ function booster_lire_bdd($id_player, $id_planet) $tBoosters = $userBuildingModel->get_all_booster_player($id_player); if (isset($tBoosters[$id_planet])) { - return booster_decode($tBoosters[$id_planet]); + return booster_decode($tBoosters[$id_planet]['boosters']); } return $result; } -/* Écrit les informations des objets Ogame dans la BDD sous forme d'une string de stockage. - * @arg id_player id du joueur - * @arg id_planet id de la planète à rechercher - * @tab_booster tableau infos des boosters (donnée par les fonctions booster_lire_bdd() ou booster_decode()) - * @return FALSE en cas d'échec +/* Writes OGame item information into the database as a storage string. + * @arg id_player player ID + * @arg id_planet planet ID to search for + * @tab_booster booster info array (provided by booster_lire_bdd() or booster_decode()) + * @return FALSE on failure */ /** * @param $id_player @@ -1632,7 +1632,7 @@ function booster_ecrire_bdd_tab($id_player, $id_planet, $tab_booster) return $userBuildingModel->update_booster($id_player, $id_planet, booster_encode($tab_booster)); } -/* Mets à jour les boosters de tous les users en fonction de la date de fin dans la BDD +/* Updates boosters for all users based on end date in the database. */ function booster_maj_bdd() { @@ -1662,9 +1662,9 @@ function booster_maj_bdd() /*#######Contrôles et modifications poussées #######*/ /** - * Contrôle la date de validité des boosters et reset si la date est dépassée - * @param $boosters tableau infos des boosters (donnée par les fonctions booster_lire_bdd() ou booster_decode()) - * @return tableau associatif des boosters mis à jour array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date', 'extention_p', 'extention_m') + * Checks booster expiration dates and resets values if expired. + * @param $boosters Booster info array (provided by booster_lire_bdd() or booster_decode()) + * @return Associative array of updated boosters: array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date', 'extention_p', 'extention_m') */ function booster_verify($boosters) { @@ -1681,9 +1681,9 @@ function booster_verify($boosters) } /** - * Contrôle la date de validité des boosters et reset si la date est dépassée - * @param $str string de stockage des boosters (donnée par les fonctions booster_encode() ou booster_encodev() ou directement from BDD) - * @return tableau associatif des boosters mis à jour + * Checks booster expiration dates and resets values if expired. + * @param $str booster storage string (from booster_encode(), booster_encodev(), or directly from DB) + * @return associative array of updated boosters * array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date', 'extention_p', 'extention_m') */ function booster_verify_str($str) @@ -1692,16 +1692,19 @@ function booster_verify_str($str) } /** - * donne des tableaux d'informations en relation avec les objets Ogame - * @type détermine les informations renvoyées - * [Default] donne un tableau avec les uuid des objets Ogame - * 'definition' donne un tableau avec le nom de l'objet (ex. 'Booster de métal en or') - * 'array' donne un tableau asso de tab uuid=>array('booster_x'|'extension_x', valeur) - * 'string' donne un tableau asso de string uuid=>'x:valeur:0'|'x:valeur' - * 'full' donne les tableaux simple : définition, uuid, string, array) - * 'separateur' donne le char qui sert de séparateur entre les objets Ogame - * 'default_str' donne la string de stockage par défaut : "m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0" - * @return array le tableau correspondant au type + * Returns metadata structures related to OGame booster items. + * + * Supported `$type` values: + * - `''` (default): UUID list array + * - `definition`: item labels array + * - `array`: UUID => [booster/extension, value] + * - `string`: UUID => encoded item string + * - `full`: [definition, uuid, string, array] + * - `separateur`: separator string used in encoded storage + * - `default_str`: default encoded storage string + * + * @param string $type Requested metadata format + * @return array|string */ function booster_objets_tab($type = '') { @@ -1798,6 +1801,8 @@ function booster_objets_tab($type = '') throw new Exception("Erreur interne : mauvais inventaire des boosters, remplissage (uid=$ni, n=" . count($objet_uuid) . ")"); } + $result = array(); + switch ($type) { case 'definition': return $objet_str; @@ -1825,8 +1830,8 @@ function booster_objets_tab($type = '') } /** - * Indique si un uuid est enregistré dans OGSpy (il existe) - * @uuid string uuid récupéré de la page Ogame + * Indicates whether a UUID is registered in OGSpy (it exists). + * @uuid string UUID retrieved from the OGame page */ function booster_is_uuid($uuid) { @@ -1834,13 +1839,13 @@ function booster_is_uuid($uuid) } /** - * Mets à jour le tableau infos des boosters. - * @boosters tableau infos des boosters (donnée par les fonctions booster_lire_bdd() ou booster_decode()) - * @uuid string uuid de l'objet Ogame récupéré de la page Ogame - * @date date de fin de l'objet Ogame. [defaut=0] - * return le tableau à jour (par uuid et date) - * si $boosters==NULL OU booster_uuid($b) sans uuid -> donne tableau avec valeurs par défaut (équivalent booster_decode()) - * NULL en cas d'erreur (uuid inconnu) + * Updates the booster info array. + * @boosters Booster info array (provided by booster_lire_bdd() or booster_decode()) + * @uuid string UUID of the OGame item retrieved from the OGame page + * @date OGame item end date. [default=0] + * return updated array (by UUID and date) + * if $boosters==NULL OR booster_uuid($b) without UUID -> returns array with default values (equivalent to booster_decode()) + * NULL on error (unknown UUID) */ function booster_uuid($boosters, $uuid = '', $date = 0) @@ -1867,9 +1872,9 @@ function booster_uuid($boosters, $uuid = '', $date = 0) } /** - * Transforme la date Ogame de format "*s *j *h" en nombre de seconde 6j 23h - * @str string contenant le temps - * @return int nombre de seconde correspondant à $str. 0 si problème + * Converts an OGame date from "*w *d *h" format into seconds. + * @str string containing the duration + * @return int number of seconds corresponding to $str, or 0 on error */ function booster_lire_date($str) { @@ -1887,11 +1892,11 @@ function booster_lire_date($str) /*#######Lecture et modifications poussées #######*/ /** - * Transforme en tableau les données des objets Ogame contenues dans une string de stockage. - * Si aucun argument n'ai donné alors elle renvoie les valeurs des objets par défaut. - * @param $str string de stockage des objets Ogame - * @param null $boosters - * @return array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_c_val', 'booster_c_date', 'extention_p', 'extention_m') + * Converts OGame item data from a storage string into an array. + * If no argument is provided, returns default item values. + * @param string|null $str Storage string of OGame items + * @param array|null $boosters Regex match buffer used internally + * @return array */ function booster_decode($str = null, $boosters = null) { @@ -1906,7 +1911,7 @@ function booster_decode($str = null, $boosters = null) $tab_ex = array('p', 'm'); if ($str) { - $s = booster_objets_tab('separateur'); + $s = (string) booster_objets_tab('separateur'); $str_split = explode($s, $str); foreach ($str_split as $objet) { $i = 0; @@ -1931,9 +1936,9 @@ function booster_decode($str = null, $boosters = null) } /** - * Transforme le tableau des informations des objets Ogame en une string de stockage. - * @b tableau associatif des infos array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date','extention_p', 'extention_m') - * @return objet sous format string de stockage ("m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0 si pas d'argument) + * Converts the OGame item information array into a storage string. + * @b associative array of info: array('booster_m_val', 'booster_m_date', 'booster_c_val', 'booster_c_date', 'booster_d_val', 'booster_d_date', 'booster_e_val', 'booster_e_date','extention_p', 'extention_m') + * @return item in storage string format ("m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0" if no argument) */ function booster_encode($b = null) { @@ -1953,9 +1958,9 @@ function booster_encode($b = null) } /** - * Transforme les valeurs des objets Ogame en une string de stockage. - * string de stockage par défaut = m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0 - * @return string sous format string de stockage ("m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0" si pas d'argument) + * Transforme the values des objets Ogame en une string of stockage. + * string of stockage par défaut = m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0 + * @return string sous format string of stockage ("m:0:0_c:0:0_d:0:0_e:0:0_p:0_m:0" si pas d'argument) */ function booster_encodev( $booster_m_val = 0, @@ -1984,7 +1989,7 @@ function booster_encodev( /********************************************************************************/ /** - * Retourne la liste des helpers presents + * Returns la liste des helpers presents * @return array */ function get_Helpers() @@ -2005,7 +2010,7 @@ function get_Helpers() } /** - * Arrondit les points à l'unité de mille. + * Rounds the points à l'unité of thousand. * @param mixed $point * @return int */ diff --git a/includes/galaxy.php b/includes/galaxy.php index 21259784..2160f410 100644 --- a/includes/galaxy.php +++ b/includes/galaxy.php @@ -1,7 +1,7 @@ 10, etc.)). * @param array $user_techno List of technologies affecting fleet speed (e.g., array('RC', 'RI', 'PH')). Default is null. @@ -59,7 +59,7 @@ function ogame_fleet_slowest_speed($fleet, $user_techno = null, $class = 'none') } /** - * Calculates the distance and type of travel between two coordinates. + * Calcule la distance and le type of trajet entre deux coordonnées. * * @param mixed $a Starting coordinates. * @param mixed $b Target coordinates. @@ -124,17 +124,18 @@ function ogame_fleet_distance($a, $b, $user_techno = null, $class = 'none', $ser } /** - * @brief Calculates time and conso to send a fleet. + * Calculates travel time and fuel consumption for a fleet. * - * @param[in] string $coord_from,$coord_to Coordinates begin and end - * @param[in] array $fleet Array of fleet and their number (array('PT'=>10,etc.)) - * @param[in] int $speed_per Percentage of speed wanted - * @param[in] array $user_techno List of techno ('RC','RI','PH', le reste est ignoré) - * @param[in] string $class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) - * @param[in] array $server_config Info of universe ('num_of_galaxies','num_of_systems','donutGalaxy','donutSystem' only these are checked) default 9/499/1/1 - * @param[in] string $type Indicates specific mission ('statio'/'expe', 'fuite') - * @param[in] int $hour_mission Number of hour of the specific mission - * @return array('conso', 'time'), time in seconds (one trip only) + * @param string $coord_from Source coordinates. + * @param string $coord_to Destination coordinates. + * @param array $fleet Fleet composition (e.g. ['PT' => 10]). + * @param int $speed_per Requested speed percentage. + * @param array|null $user_techno User technologies affecting speed. + * @param string $class User class ('COL', 'GEN', 'EXP', 'none'). + * @param array|null $server_config Universe config subset. + * @param string $type Specific mission type ('statio', 'expe', 'fuite'). + * @param int $hour_mission Mission duration in hours for stationary/expedition cases. + * @return array{conso:int,time:int} One-way result in fuel units and seconds. */ function ogame_fleet_send($coord_from, $coord_to, $fleet, $speed_per = 100, $user_techno = null, $class = 'none', $server_config = null, $type = '', $hour_mission = 0) { @@ -209,11 +210,11 @@ function ogame_fleet_send($coord_from, $coord_to, $fleet, $speed_per = 100, $use ///////////////////// TEMPS fonctions : //////////////////////////////////////// /** - * @brief Calculates cumulate lab network. + * Calculates cumulative laboratory network level. * - * @param[in] array $user_empire From user_get_empire() - * @param[in] int $current_planet_id Current planet to run a research, if not best lab (theory). - * @return int Number of cumulate lab network + * @param array $user_empire From user_get_empire(). + * @param int $current_planet_id Current planet to run a research on, if not best lab (theory). + * @return int Number of cumulative lab levels. */ function ogame_labo_cumulate($user_empire, $current_planet_id = -1) { @@ -252,14 +253,14 @@ function ogame_labo_cumulate($user_empire, $current_planet_id = -1) } /** - * @brief Calculates construction time of a OGame element bat/vso/def/rech. + * Calculates construction time of an OGame element (BAT/VSO/DEF/RECH). * - * @param[in] string $name The name, like name in Database - * @param[in] int $level The level or number for def/vso - * @param[in] array $user_building Array of bat level ('CSp','UdR','UdN','Lab') - * @param[in] int $cumul_labo Number of cumulate lab network (only for rech) - * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) - * @return float Time in seconds + * @param string $name The element name as stored in database. + * @param int $level The level or number for DEF/VSO. + * @param array $user_building Building levels ('CSp', 'UdR', 'UdN', 'Lab'). + * @param int $cumul_labo Number of cumulative lab levels (RECH only). + * @param string $player_class User class ('COL', 'GEN', 'EXP', 'none'). + * @return float Time in seconds. */ function ogame_construction_time($name, $level, $user_building, $cumul_labo = 0, $player_class = 'none') { @@ -322,18 +323,19 @@ function ogame_construction_time($name, $level, $user_building, $cumul_labo = 0, ///////////////////// DIVERS fonctions : /////////////////////////////////////// /** - * @brief Return planet position from coordinates. - * @param[in] string $coordinates planet coordinates (galaxy:system:position) - * @return int planet position + * Returns the planet position from coordinates. + * + * @param string $coordinates Planet coordinates (galaxy:system:position). + * @return int Planet position. */ // Coordinate helpers moved to includes/ogame_structs.php /** - * @brief Calculates the planet storage capacity (taille hangar). + * Calculates the planet storage capacity. * - * @param[in] int $level Storage building level - * @return float capacity + * @param int $level Storage building level. + * @return float Capacity. */ function ogame_depot_capacity($level) { @@ -347,7 +349,7 @@ function ogame_depot_capacity($level) } /** - * Returns the maximum numbers of planet slots available according to the Astrophysic level + * Returns le nombre maximal d'emplacements of planets selon le niveau d'Astrophysique. * @param int $level Astrophysic Level * @return int the maximum number of planets */ @@ -359,11 +361,11 @@ function astro_max_planete($level) /** - * @brief Calculates phalanx range. + * Calculates phalanx range. * - * @param[in] int $level Level of the phalanx - * @param[in] array $user_class User class ($user_data['user_class']=array('user_class'=>'COL'/GEN/EXP/none)) - * @return float Range in system + * @param int $level Level of the phalanx. + * @param string $player_class User class ('COL', 'GEN', 'EXP', 'none'). + * @return float Range in systems. */ function ogame_phalanx_range($level, $player_class = 'none') { @@ -378,10 +380,10 @@ function ogame_phalanx_range($level, $player_class = 'none') } /** - * @brief Calculates MIP range. + * Calculates MIP range. * - * @param[in] int $impulsion Techno impulsion (RI) - * @return int Range in system + * @param int $impulsion Impulse drive technology level (RI). + * @return int Range in systems. */ function ogame_missile_range($impulsion = 1) { @@ -389,11 +391,11 @@ function ogame_missile_range($impulsion = 1) } /** - * @brief Calculates MIP speed. + * Calculates MIP travel time. * - * @param[in] int $nb_system Number of sub-system from current planet - * @param[in] int $speed_uni Universe speed - * @return int Speed in seconds + * @param int $nb_system Number of systems from current planet. + * @param int $speed_uni Universe speed. + * @return int Travel time in seconds. */ function ogame_missile_speed($nb_system, $speed_uni = 1) { @@ -401,10 +403,10 @@ function ogame_missile_speed($nb_system, $speed_uni = 1) } /** - * @brief Calculates additional case given by terraformer. + * Calculates additional slots given by terraformer. * - * @param[in] int $level The terra level - * @return int Number of additional case + * @param int $level Terraformer level. + * @return int Number of additional slots. */ function ogame_terra_case($level) { diff --git a/includes/ogame_planet.php b/includes/ogame_planet.php index 91e1951d..97cdd978 100644 --- a/includes/ogame_planet.php +++ b/includes/ogame_planet.php @@ -21,14 +21,14 @@ * @param[in] array $user_data User info (array('user_class'=>'COL'/...,'off_commandant','off_amiral','off_ingenieur','off_geologue', or 'off_full') * @param[in] array $server_config Ogame universe info ('speed_uni') * @return array('prod_reel,'prod_theorique','ratio','conso_E','prod_E', //Production totale - * 'prod_CES','prod_CEF','prod_SAT','prod_FOR', //production énergie de chaque unité - * 'prod_M','prod_C','prod_D','prod_base', //production ressources de chaque mine + * 'prod_CES','prod_CEF','prod_SAT','prod_FOR', //production énergie of chaque unité + * 'prod_M','prod_C','prod_D','prod_base', //production ressources of chaque mine * 'prod_booster','prod_off','prod_Plasma','prod_classe', //production des bonus - * 'M','C','D','NRJ','AM', =>héritage du type ressource pour les valeurs retournées. + * 'M','C','D','NRJ','AM', =>héritage of the type ressource for the values retournées. * 'nb_FOR_maxed', - * ) à part conso_E/prod_E (float) les autres sont array('M','C','D','NRJ','AM') + * ) à part conso_E/prod_E (float) the autres sont array('M','C','D','NRJ','AM') * - * @details remplace les fonctions ratio et bilan_production_ratio + * @details remplace the fonctions ratio and bilan_production_ratio */ function ogame_production_planet($user_building, $user_technology = null, $player_data = null, $server_config = null) { diff --git a/includes/ogame_requirements.php b/includes/ogame_requirements.php index a0b9071a..cf856eb4 100644 --- a/includes/ogame_requirements.php +++ b/includes/ogame_requirements.php @@ -9,7 +9,7 @@ /** * @brief Calculates technical data of Ogame requirement. * - * @param[in] string $nom The name, like name in Database + * @param[in] string $name The name, like name in Database * @return array('none','COL','GEN','EXP' : bool for class, 'CES',etc. : int for all bat/rech name in database) */ function ogame_elements_requirement($name = 'all') diff --git a/includes/ogame_structs.php b/includes/ogame_structs.php index aaf805ab..df1481d2 100644 --- a/includes/ogame_structs.php +++ b/includes/ogame_structs.php @@ -1,13 +1,13 @@ delete_user_aster($user_data["player_id"], intval($pub_planet_id)); //batiment - $userDefenseModel->delete_user_aster($user_data["player_id"], intval($pub_planet_id)); //defense + $userDefenseModel->delete_user_aster(intval($pub_planet_id)); //defense // si on supprime une planete; la lune doit suivre if (intval($pub_planet_id) < 199) { $moon_id = (intval($pub_planet_id) + 100); $userBuildingModel->delete_user_aster($user_data["player_id"], $moon_id); //batiment - $userDefenseModel->delete_user_aster($user_data["player_id"], $moon_id); //defense + $userDefenseModel->delete_user_aster($moon_id); //defense } //si plus de planete @@ -158,20 +158,14 @@ function user_del_building() (new Player_Technology_Model())->delete_user_technologies($user_data["player_id"]); } - if ($iNBPlanet != 0) { - // remise en ordre des planetes : - //uniquement s'il en reste - user_set_all_empire_resync_id(); - - } redirection("index.php?action=home&subaction=empire&view=" . $pub_view); } /** - * Récuperation du nombre de planete de l utilisateur. + * Retrieves the number of user planets. * - * @param $player_id - * @return int|the + * @param int $player_id + * @return int */ function getPlanetCountForPlayer($player_id) { @@ -179,8 +173,10 @@ function getPlanetCountForPlayer($player_id) } /** - * @param $user_id - * @return int Nb of moons + * Retrieves the number of user moons. + * + * @param int $player_id + * @return int Number of moons */ function find_nb_moon_user($player_id) { @@ -192,7 +188,7 @@ function find_nb_moon_user($player_id) * @param int $id_RC RC à reconstituer * @return string $template_RC reconstitué * - * TODO : fonctionne-t-elle ? Pleins de variables non utilisées. + * TODO : fonctionne-t-elle ? Pleins of variables non utilisées. */ function UNparseRC($id_RC) { diff --git a/includes/sessions.php b/includes/sessions.php index 3ac5df5f..40e4729b 100644 --- a/includes/sessions.php +++ b/includes/sessions.php @@ -1,7 +1,7 @@ lockFile)) { @@ -237,7 +237,7 @@ private function isUpgradeInProgress() { } /** - * Crée le fichier de verrouillage + * Creates le fichier of verrouillage */ private function createLock() { $lockDir = dirname($this->lockFile); @@ -253,7 +253,7 @@ private function createLock() { } /** - * Supprime le fichier de verrouillage + * Deletes le fichier of verrouillage */ private function releaseLock() { if (file_exists($this->lockFile)) { @@ -262,7 +262,7 @@ private function releaseLock() { } /** - * Nettoyage du cache + * Cleanup of the cache */ private function clearCache() { $cacheFiles = glob(dirname(__DIR__) . '/cache/*.php'); @@ -279,7 +279,7 @@ private function clearCache() { } /** - * Vérifie si les migrations peuvent être exécutées automatiquement + * Verifies si the migrations peuvent être exécutées automatiquement */ public function canAutoUpgrade() { global $server_config; @@ -296,7 +296,7 @@ public function canAutoUpgrade() { } /** - * Mode de secours : force la mise à jour même en cas de problème + * Mode of secours : force la update même en cas of problème */ public function forceUpgrade() { $this->releaseLock(); // Supprime les verrous existants @@ -310,7 +310,7 @@ public function forceUpgrade() { } /** - * Vérifie si une synchronisation de version est nécessaire + * Verifies si une synchronisation of version est nécessaire */ public function isVersionSyncNeeded() { try { diff --git a/install/ConfigGenerator.php b/install/ConfigGenerator.php index db223d35..0601f6b1 100644 --- a/install/ConfigGenerator.php +++ b/install/ConfigGenerator.php @@ -1,7 +1,7 @@ getTemplate(); @@ -52,7 +52,7 @@ public function generateIdFile($dbConfig) { } /** - * Insère ou met à jour une valeur dans la table de configuration + * Inserts or updates a value in the configuration table. */ public function setConfigValue($db, $table_prefix, $name, $value): void { @@ -63,8 +63,8 @@ public function setConfigValue($db, $table_prefix, $name, $value): void } /** - * Insère ou met à jour la version applicative en base de données - * Utilisé uniquement par les scripts d'installation/upgrade + * Inserts or updates the application version in the database. + * Used only by install/upgrade scripts. */ public function setApplicationVersion($db, $table_prefix, $version): void { @@ -72,7 +72,7 @@ public function setApplicationVersion($db, $table_prefix, $version): void } /** - * Valide la configuration de base de données + * Validates database configuration. */ private function validateDbConfig($config) { $required = ['host', 'user', 'password', 'database']; @@ -88,7 +88,7 @@ private function validateDbConfig($config) { } /** - * Teste la connexion à la base de données + * Tests the database connection. */ public function testDbConnection($config) { try { @@ -127,7 +127,7 @@ public function testDbConnection($config) { } /** - * Récupère le template du fichier id.php + * Retrieves the id.php template. */ private function getTemplate() { if (file_exists($this->templatePath)) { @@ -139,15 +139,15 @@ private function getTemplate() { } /** - * Template par défaut pour id.php + * Default template for id.php. */ private function getDefaultTemplate() { return <<<'PHP' configPath); diff --git a/install/MigrationManager.php b/install/MigrationManager.php index 70e01a99..41228a63 100644 --- a/install/MigrationManager.php +++ b/install/MigrationManager.php @@ -366,7 +366,7 @@ public function rollbackMigration($version) { } /** - * Vérifie si la version en base correspond à celle de version.php et synchronise si nécessaire + * Verifies si la version en base correspond à celle of version.php and synchronise si nécessaire */ private function checkAndSyncVersion($interactive = true): bool { try { diff --git a/install/TestManager.php b/install/TestManager.php index 4f4e4e12..a22deb1a 100644 --- a/install/TestManager.php +++ b/install/TestManager.php @@ -1,7 +1,7 @@ false, 'error' => null, 'details' => []]; @@ -224,7 +224,7 @@ public function testUpgrade() { } /** - * Crée une base de données de test vierge + * Creates an empty test database. */ private function createTestDatabase() { $this->originalDbName = $this->db->getDatabaseName(); @@ -236,7 +236,7 @@ private function createTestDatabase() { } /** - * Bascule vers la base de données de test + * Switches to the test database. */ private function switchToTestDatabase() { $this->db->sql_select_db($this->testDbName); @@ -244,7 +244,7 @@ private function switchToTestDatabase() { } /** - * Retourne à la base de données originale + * Switches back to the original database. */ private function switchToOriginalDatabase() { if ($this->originalDbName) { @@ -253,7 +253,7 @@ private function switchToOriginalDatabase() { } /** - * Récupère toutes les tables OGSpy existantes + * Retrieves all existing OGSpy tables. */ private function getOGSpyTables() { $tables = []; @@ -267,7 +267,7 @@ private function getOGSpyTables() { } /** - * Crée un état "ancien" pour tester les mises à niveau + * Creates an "older" state to test upgrades. */ private function createOlderVersionState() { global $table_prefix; @@ -312,11 +312,11 @@ private function createOlderVersionState() { } /** - * Vérifie l'intégrité de l'installation : - * - présence de toutes les tables définies dans ogspy_structure.sql - * - présence de toutes les colonnes définies dans ogspy_structure.sql - * - données de configuration - * - conformité des index avec ogspy_structure.sql + * Verifies installation integrity: + * - all tables defined in ogspy_structure.sql are present + * - all columns defined in ogspy_structure.sql are present + * - configuration data exists + * - indexes match ogspy_structure.sql */ public function verifyInstallIntegrity($tablePrefix = 'ogspy_') { $schemaFile = __DIR__ . '/schemas/ogspy_structure.sql'; @@ -356,8 +356,8 @@ public function verifyInstallIntegrity($tablePrefix = 'ogspy_') { } /** - * Compare les index attendus (issus de $expectedIndexes ou parsés depuis le schéma) - * avec ceux présents en base de données. + * Compares expected indexes (from $expectedIndexes or parsed from schema) + * with indexes present in the database. */ private function verifyIndexesAgainstSchema(string $tablePrefix = 'ogspy_', array $expectedIndexes = []): void { $schemaFile = __DIR__ . '/schemas/ogspy_structure.sql'; @@ -393,9 +393,9 @@ private function verifyIndexesAgainstSchema(string $tablePrefix = 'ogspy_', arra } /** - * Parse les définitions d'index de toutes les tables dans un fichier SQL de structure. - * Remplace $sourcePrefix par $targetPrefix dans les noms de tables. - * Retourne [ tableName => [ indexName => [col1, col2, ...] ] ] + * Parses index definitions for all tables in a schema SQL file. + * Replaces $sourcePrefix with $targetPrefix in table names. + * Returns [ tableName => [ indexName => [col1, col2, ...] ] ] */ private function parseIndexesFromSchema(string $file, string $sourcePrefix, string $targetPrefix): array { $indexes = []; @@ -431,8 +431,8 @@ private function parseIndexesFromSchema(string $file, string $sourcePrefix, stri } /** - * Découpe une liste de colonnes d'index SQL en tableau. - * Ex: "`col1`, `col2`(191)" → ["col1", "col2"] + * Splits a list of SQL index columns into an array. + * Example: "`col1`, `col2`(191)" -> ["col1", "col2"] */ private function parseIndexColumns(string $rawCols): array { $cols = []; @@ -446,8 +446,8 @@ private function parseIndexColumns(string $rawCols): array { } /** - * Récupère tous les index des tables avec $tablePrefix depuis information_schema. - * Retourne [ tableName => [ indexName => [col1, col2, ...] ] ] + * Retrieves all table indexes with $tablePrefix from information_schema. + * Returns [ tableName => [ indexName => [col1, col2, ...] ] ] */ private function getIndexesFromDb(string $tablePrefix): array { $result = $this->db->sql_query( @@ -467,9 +467,9 @@ private function getIndexesFromDb(string $tablePrefix): array { } /** - * Parse les colonnes de toutes les tables dans un fichier SQL de structure. - * Remplace $sourcePrefix par $targetPrefix dans les noms de tables. - * Retourne [ tableName => [col1, col2, ...] ] + * Parses columns of all tables in a schema SQL file. + * Replaces $sourcePrefix with $targetPrefix in table names. + * Returns [ tableName => [col1, col2, ...] ] */ private function parseColumnsFromSchema(string $file, string $sourcePrefix, string $targetPrefix): array { $columns = []; @@ -502,7 +502,7 @@ private function parseColumnsFromSchema(string $file, string $sourcePrefix, stri } /** - * Vérifie que toutes les colonnes définies dans le schéma existent en DB. + * Verifies that all columns defined in the schema exist in the DB. */ private function verifyColumnsAgainstSchema(string $tablePrefix, array $expectedColumns): void { $actual = $this->getColumnsFromDb($tablePrefix); @@ -525,8 +525,8 @@ private function verifyColumnsAgainstSchema(string $tablePrefix, array $expected } /** - * Récupère toutes les colonnes des tables avec $tablePrefix depuis information_schema. - * Retourne [ tableName => [col1, col2, ...] ] + * Retrieves all table columns with $tablePrefix from information_schema. + * Returns [ tableName => [col1, col2, ...] ] */ private function getColumnsFromDb(string $tablePrefix): array { $result = $this->db->sql_query( @@ -546,7 +546,7 @@ private function getColumnsFromDb(string $tablePrefix): array { } /** - * Récupère la version de la dernière migration disponible + * Retrieves the version of the latest available migration. */ private function getLatestMigrationVersion() { global $table_prefix; @@ -562,7 +562,7 @@ private function getLatestMigrationVersion() { } /** - * Crée dynamiquement les fichiers de migration de test + * Creates dynamiquement the files of migration of test */ private function createTestMigrations() { echo "🔧 Création des migrations de test...\n"; @@ -585,7 +585,7 @@ private function createTestMigrations() { } /** - * Supprime les fichiers de migration de test créés + * Deletes the files of migration of test created */ private function removeTestMigrations() { if (!empty($this->createdTestMigrations)) { @@ -603,13 +603,13 @@ private function removeTestMigrations() { } /** - * Génère le contenu de la première migration de test + * Generates le contenu of the première migration of test */ private function getTestMigration1Content() { return ' false, 'error' => null, 'performance_data' => []]; @@ -834,7 +834,7 @@ public function testMigrationPerformance() { } /** - * Récupère une valeur de la table de configuration + * Retrieves a value from the configuration table. */ private function getConfigValue($name) { global $table_prefix; @@ -848,7 +848,7 @@ private function getConfigValue($name) { /** - * Journalise l'état de la version applicative + * Logs application version state. */ private function logApplicationVersionState($stage) { $appVersion = $this->getConfigValue('version'); @@ -856,7 +856,7 @@ private function logApplicationVersionState($stage) { } /** - * Test avec différents préfixes de table + * Tests with different table prefixes. */ public function testTablePrefix() { $result = ['success' => false, 'error' => null, 'details' => []]; diff --git a/install/config/database_config.php b/install/config/database_config.php index 0fddef24..80b348be 100644 --- a/install/config/database_config.php +++ b/install/config/database_config.php @@ -1,7 +1,7 @@ db->sql_query($request); - list($nb_planet) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $nb_planet = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $nb_planet; } @@ -290,7 +291,8 @@ public function get_nb_empty_planets(int $galaxy, int $system_down, int $system_ $request .= " AND `system` BETWEEN " . $system_down . " AND " . ($system_up); $result = $this->db->sql_query($request); - list($nb_planet_used) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $nb_planet_used = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $totalPlanets - $nb_planet_used; } @@ -313,7 +315,8 @@ public function get_last_update(int $galaxy, int $system_down, int $system_up) $request .= " AND `system` BETWEEN " . $system_down . " AND " . ($system_up); $result = $this->db->sql_query($request); - list($last_update) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $last_update = (is_array($row) && isset($row[0])) ? $row[0] : null; return $last_update; } @@ -463,7 +466,7 @@ public function get_planetId_by_coordinates(int $galaxy, int $system, int $row) * values associated with a specific astronomical object ID from the user * building database table. * - * @param int $astroobject_id The ID of the astronomical object for which to retrieve the coordinates. + * @param int $astroObject_id The ID of the astronomical object for which to retrieve the coordinates. * @return array An array containing the galaxy, system, and row coordinates of the planet. */ public function getPlanetCoordsByObjectId(int $astroObject_id): array @@ -521,17 +524,17 @@ public function get_phalanx(int $galaxy): array } /** - * Récupère les systèmes solaires considérés comme obsolètes selon les critères spécifiés. - * Un système est considéré comme obsolète lorsque sa dernière mise à jour est antérieure - * à une date limite définie. - * - * @param int $galaxy Numéro de la galaxie à vérifier. Si 0, recherche dans toutes les galaxies. - * @param int $system_down Limite inférieure pour la plage des systèmes solaires à vérifier. - * @param int $system_up Limite supérieure pour la plage des systèmes solaires à vérifier. - * @param int $indice Index correspondant à la période d'obsolescence à utiliser dans le tableau $since. - * @param array $since Tableau contenant les différentes périodes d'obsolescence disponibles. - * @param bool $forMoon Si true, recherche les lunes obsolètes. Si false, recherche les planètes obsolètes. - * @return array Tableau associatif regroupant les systèmes obsolètes par période, avec leurs informations de galaxie, système, position et dernière mise à jour. + * Retrieves solar systems considered obsolete according to the specified criteria. + * A system is considered obsolete when its last update is older + * than a defined cutoff date. + * + * @param int $galaxy Galaxy number to check. If 0, searches across all galaxies. + * @param int $system_down Lower bound of the solar system range to check. + * @param int $system_up Upper bound of the solar system range to check. + * @param int $indice Index of the obsolescence period to use from the $since array. + * @param array $since Array containing available obsolescence periods. + * @param bool $forMoon If true, searches obsolete moons. If false, searches obsolete planets. + * @return array Associative array grouping obsolete systems by period, with galaxy, system, position, and last update. */ public function get_galaxy_obsolete(int $galaxy, int $system_down, int $system_up, int $indice, array $since, bool $forMoon = false) { @@ -557,7 +560,8 @@ public function get_galaxy_obsolete(int $galaxy, int $system_down, int $system_u while ($row = $this->db->sql_fetch_assoc($result)) { $request = "SELECT MIN(" . $field . ") FROM " . TABLE_USER_BUILDING . " WHERE `galaxy` = " . $row["galaxy"] . " AND `system` = " . $row["system"]; $result2 = $this->db->sql_query($request); - list($last_update) = $this->db->sql_fetch_row($result2); + $row_last_update = $this->db->sql_fetch_row($result2); + $last_update = (is_array($row_last_update) && isset($row_last_update[0])) ? $row_last_update[0] : null; $row["last_update"] = $last_update; $obsolete[$since[$indice]][] = $row; @@ -722,7 +726,8 @@ public function find(SearchCriteria_Helper $criteria, array $order_by = [], int $queryCount .= " WHERE " . $where; } $result = $this->db->sql_query($queryCount); - list($total_row) = $this->db->sql_fetch_row($result); + $row_count = $this->db->sql_fetch_row($result); + $total_row = (is_array($row_count) && isset($row_count[0])) ? (int)$row_count[0] : 0; $result = $this->db->sql_query($query); diff --git a/model/Combat_Report_Model.php b/model/Combat_Report_Model.php index 2087a838..4ce4ab4b 100644 --- a/model/Combat_Report_Model.php +++ b/model/Combat_Report_Model.php @@ -122,13 +122,13 @@ public function get_empire_combat_report_list(int $player_id, int $sort = 2, int } /** - * Retrieves the number of combat reports associated with a specific planet - * identified by its coordinates (galaxy, system, row). + * Retrieves the number of combat reports associated with a planet + * identified by its coordinates (galaxy, system, position). * - * @param int $galaxy The galaxy number of the planet. - * @param int $system The system number of the planet. - * @param int $row The row number of the planet. - * @return int The number of combat reports corresponding to the specified planet. + * @param int $galaxy Galaxy number of the planet. + * @param int $system System number of the planet. + * @param int $row Planet position. + * @return int Number of combat reports matching the planet. */ public function get_nb_combat_report_by_planet(int $galaxy, int $system, int $row) { @@ -147,12 +147,12 @@ public function get_nb_combat_report_by_planet(int $galaxy, int $system, int $ro } /** - * Retrieves a list of combat report (CR) IDs by planet coordinates. + * Retrieves the list of combat report (CR) identifiers by planet coordinates. * - * @param int $galaxy The galaxy number of the target coordinates. - * @param int $system The system number of the target coordinates. - * @param int $row The row number of the target planet within the galaxy and system. - * @return array An array of combat report IDs (id_rc) sorted by date in descending order. + * @param int $galaxy Galaxy number for target coordinates. + * @param int $system System number for target coordinates. + * @param int $row Position of the target planet in galaxy and system. + * @return array Array of combat report identifiers (id_rc), sorted by descending date. */ public function get_cr_id_list_by_planet(int $galaxy, int $system, int $row) { diff --git a/model/Config_Model.php b/model/Config_Model.php index b9e16f75..6f87dacd 100644 --- a/model/Config_Model.php +++ b/model/Config_Model.php @@ -19,7 +19,7 @@ class Config_Model extends Model_Abstract { //TODO: There is no method to create a new configuration if not exists /** - * Retourne tous les elements de la configuration + * Returns tous the elements of the configuration * @return array */ public function get_all() @@ -36,7 +36,7 @@ public function get_all() } /** - * Fonction de recherche de la configuration + * Configuration lookup function. * @param array|null $filter * @return array|bool */ @@ -59,7 +59,7 @@ public function get(?array $filter): bool|array } /** - * Fonction de recherche de la configuration + * Configuration lookup function. * @param array $filter * @return array */ @@ -90,7 +90,7 @@ public function find_by($filter = array()) } /** * Met à jour la config - * @param array $config tableau associatif représentant le mod + * @param array $config Associative array representing the mod */ public function update(array $config) { @@ -102,8 +102,8 @@ public function update(array $config) /** * Met à jour la config - * @$config_value valeur de la configuration - * @$config_name nom de la configuration + * @$config_value value of the configuration + * @$config_name name of the configuration * @param $configName * @param $configValue */ diff --git a/model/DBUtils_Model.php b/model/DBUtils_Model.php index eb9a00bd..0581ec9b 100644 --- a/model/DBUtils_Model.php +++ b/model/DBUtils_Model.php @@ -6,14 +6,14 @@ /** * Class DBUtils_Model - * Classe de maintenance base de donnée + * Database maintenance class. * @package Ogsteam\Ogspy\Model */ class DBUtils_Model extends Model_Abstract { /** - * Retourne la taille de la base ainsi que la taille total des tables ogspy + * Returns database size and total size of OGSpy tables. * @return array */ public function SizeInfo() @@ -35,13 +35,14 @@ public function SizeInfo() } /** - * Optimize l'espace utilisé par la base de donnée + * Optimizes disk space used by the database. */ public function Optimize() { $request = 'SHOW TABLES'; $res = $this->db->sql_query($request); - while (list($table) = $this->db->sql_fetch_row($res)) { + while (($row = $this->db->sql_fetch_row($res)) !== false && $row !== null) { + [$table] = $row; $request = 'OPTIMIZE TABLE ' . $table; $this->db->sql_query($request); } diff --git a/model/Group_Model.php b/model/Group_Model.php index f16804db..64fa6542 100644 --- a/model/Group_Model.php +++ b/model/Group_Model.php @@ -235,7 +235,7 @@ public function update_group( } /** - * suppression de l'utlisateur + * suppression of l'utlisateur * @param $group_id * @return bool */ diff --git a/model/Mod_Config_Model.php b/model/Mod_Config_Model.php index 5467e81a..f59f8a20 100644 --- a/model/Mod_Config_Model.php +++ b/model/Mod_Config_Model.php @@ -18,10 +18,10 @@ class Mod_Config_Model extends Model_Abstract { /** - * Retourne la configuration pour le module - * @param string $module Nom du module + * Returns la configuration for le module + * @param string $module Name of the module * @param string $config Configuration - * @return array Liste des valeurs correspondantes + * @return array Liste des values correspondantes */ public function get_mod_config($module, $config = null) { @@ -47,10 +47,10 @@ public function get_mod_config($module, $config = null) } /** - * Supprime la configuration souhaitée pour le module - * @param string $module Nom du module + * Deletes la configuration souhaitée for le module + * @param string $module Name of the module * @param string $config Configuration - * @return bool succès + * @return bool success */ public function delete_mod_config($module, $config = null) { @@ -70,11 +70,11 @@ public function delete_mod_config($module, $config = null) } /** - * Défini la valeur de la configuration fournie - * @param string $module Nom du module + * Defines la value of the configuration fournie + * @param string $module Name of the module * @param string $config Configuration * @param string $value Valeur - * @return bool succès + * @return bool success */ public function set_mod_config($module, $config, $value) { diff --git a/model/Mod_Model.php b/model/Mod_Model.php index 0fc911f0..4e0b0688 100644 --- a/model/Mod_Model.php +++ b/model/Mod_Model.php @@ -24,10 +24,10 @@ class Mod_Model extends Model_Abstract { /** - * Fonction de recherche d'un mod en fonction des filtres définis - * @param array $filter Tableau associatif ayant pour clé le champ à filtrer, et pour valeur la valeur souhaitée - * @param array $orderBy tableau associatif sur le champ et l'ordre - * @return array Liste de mods + * Searches for a mod using the defined filters. + * @param array $filter Tableau associatif ayant for clé le champ à filtrer, and for value la value souhaitée + * @param array $orderBy Associative array for field and sort order + * @return array Liste of mods */ public function find_by($filter = array(), $orderBy = array()) { @@ -89,10 +89,10 @@ public function find_by($filter = array(), $orderBy = array()) } /** - * Fonction de recherche d'un mod en fonction des filtres définis - * @param array $filter Tableau associatif ayant pour clé le champ à filtrer, et pour valeur la valeur souhaitée - * @param array $orderBy tableau associatif sur le champ et l'ordre - * @return array Liste de mods + * Searches for a mod using the defined filters. + * @param array $filter Tableau associatif ayant for clé le champ à filtrer, and for value la value souhaitée + * @param array $orderBy Associative array for field and sort order + * @return array Liste of mods */ public function find_one_by($filter = array(), $orderBy = array()) { @@ -131,20 +131,21 @@ public function add(array $mod) } /** - * Indique la valeur de la position la plus élevée + * Indique la value of the position la plus élevée * @return integer */ public function get_position_max() { $query = "SELECT MAX(`position`) from " . TABLE_MOD; $result = $this->db->sql_query($query); - list($position) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $position = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $position; } /** - * retourne l'id du mod + * Returns the mod ID. * @return integer */ public function get_mod_id_by_root($root) @@ -153,13 +154,14 @@ public function get_mod_id_by_root($root) $request = "SELECT `id` from " . TABLE_MOD . " WHERE `root` = '" . $root . "'"; $result = $this->db->sql_query($request); - list($id) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $id = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $id; } /** * Met à jour le mod - * @param array $mod tableau associatif représentant le mod + * @param array $mod Associative array representing the mod */ public function update(array $mod) { @@ -181,7 +183,7 @@ public function update(array $mod) /** - * Actualise la position du mod + * Actualise la position of the mod */ public function update_posisiton($mod_id, $position) { @@ -194,8 +196,8 @@ public function update_posisiton($mod_id, $position) /** - * Supprime le mod - * @param $mod_id id du mod + * Deletes le mod + * @param $mod_id id of the mod */ public function delete($mod_id) { @@ -207,8 +209,8 @@ public function delete($mod_id) /** - * Supprime le mod - * @param $mod_uninstall_title title du mod + * Deletes the mod. + * @param $mod_uninstall_title Mod title */ public function delete_by_title($mod_uninstall_title) { @@ -220,8 +222,8 @@ public function delete_by_title($mod_uninstall_title) /** - * Supprime table d un mod - * @param $table_name nom de la table + * Drops a custom mod table. + * @param $table_name Table name */ public function drop_custum_table($table_name) { diff --git a/model/Mod_User_Config_Model.php b/model/Mod_User_Config_Model.php index a7df80aa..bee32929 100644 --- a/model/Mod_User_Config_Model.php +++ b/model/Mod_User_Config_Model.php @@ -18,11 +18,11 @@ class Mod_User_Config_Model extends Model_Abstract { /** - * Retourne la configuration pour l'utilisateur du module - * @param string $module Nom du module + * Returns module configuration for the user. + * @param string $module Name of the module * @param int $userid Configuration * @param string $config Configuration - * @return array Liste des valeurs correspondantes + * @return array Liste des values correspondantes */ public function get_user_mod_config($module, $userid, $config = null) { @@ -48,10 +48,10 @@ public function get_user_mod_config($module, $userid, $config = null) } /** - * Supprime la configuration souhaitée pour l'utilsateur du module - * @param string $module Nom du module + * Deletes la configuration souhaitée for l'utilsateur of the module + * @param string $module Name of the module * @param string $config Configuration - * @return bool succès + * @return bool success */ public function delete_user_mod_config($module, $userid, $config = null) { @@ -71,12 +71,12 @@ public function delete_user_mod_config($module, $userid, $config = null) } /** - * Défini la valeur de la configuration fournie pour l'utilateur du module - * @param string $module Nom du module + * Defines la value of the configuration fournie for l'utilateur of the module + * @param string $module Name of the module * @param int $userid Configuration * @param string $config Configuration * @param string $value Valeur - * @return bool succès + * @return bool success */ public function set_user_mod_config($module, $userid, $config, $value) { diff --git a/model/Player_Building_Model.php b/model/Player_Building_Model.php index 5a489455..f3debaa4 100644 --- a/model/Player_Building_Model.php +++ b/model/Player_Building_Model.php @@ -17,36 +17,40 @@ class Player_Building_Model extends Model_Abstract { /** - * Retrieves the list of planets associated with a user, organized by coordinates. + * Retrieves the list of a user's planets, indexed by coordinates. * - * This method executes an SQL query to get the planet IDs and their coordinates - * associated with a given user. The results are organized in an associative array - * where the keys are the coordinates and the values are the planet IDs. + * This method runs an SQL query to get planet identifiers + * and their coordinates for a given user. * - * @param int $user_id The user identifier. - * @return array An associative array containing coordinates as keys and planet IDs as values. + * @param int $user_id User identifier. + * @return array Associative array: key = coordinates, value = planet identifier. */ public function get_planet_list($user_id) { $user_id = (int)$user_id; + $planet_position = []; $request = "SELECT `planet_id`, `coordinates`"; $request .= " FROM " . TABLE_USER_BUILDING; $request .= " WHERE `user_id` = " . $user_id; $request .= " ORDER BY `planet_id`"; $result = $this->db->sql_query($request); - while (list($planet_id, $coordinates) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + [$planet_id, $coordinates] = $row; $planet_position[$coordinates] = $planet_id; } return $planet_position; } /** - * @param $user_id - * @return mixed + * Retrieves the list of a player's moons, indexed by coordinates. + * + * @param int $player_id Player identifier. + * @return array Associative array: key = coordinates, value = moon identifier. */ public function get_moon_list($player_id) { + $moon_position = []; // les lunes $request = "SELECT `id`, `coordinates`"; $request .= " FROM " . TABLE_USER_BUILDING; @@ -54,19 +58,20 @@ public function get_moon_list($player_id) $request .= " AND `type` = 'moon'"; $request .= " ORDER BY `id`"; $result = $this->db->sql_query($request); - while (list($planet_id, $coordinates) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + [$planet_id, $coordinates] = $row; $moon_position[$coordinates] = $planet_id; } return $moon_position; } /** - * Récupère le nombre de planètes d'un joueur spécifique. + * Retrieves the number of planets for a specific player. * - * Cette méthode exécute une requête SQL pour compter le nombre de planètes - * associées à un joueur donné dans la table `TABLE_USER_BUILDING`. + * This method runs an SQL query to count planets + * associated with a given player in the `TABLE_USER_BUILDING` table. * - * @param int $player_id L'identifiant du joueur dont les planètes doivent être comptées. - * @return int Le nombre de planètes du joueur. + * @param int $player_id Player identifier whose planets must be counted. + * @return int Number of player planets. */ public function get_nb_planets(int $player_id) { @@ -75,17 +80,18 @@ public function get_nb_planets(int $player_id) $request .= " WHERE `player_id` = " . $player_id . " AND `type` = 'planet'"; $result = $this->db->sql_query($request); - list($count) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $count = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $count; } /** - * Récupère le nombre de lunes d'un joueur spécifique. + * Retrieves the number of moons for a specific player. * - * Cette méthode exécute une requête SQL pour compter le nombre de lunes - * associées à un joueur donné dans la table `TABLE_USER_BUILDING`. + * This method runs an SQL query to count moons + * associated with a given player in the `TABLE_USER_BUILDING` table. * - * @param int $player_id L'identifiant du joueur dont les lunes doivent être comptées. - * @return int Le nombre de lunes du joueur. + * @param int $player_id Player identifier whose moons must be counted. + * @return int Number of player moons. */ public function get_nb_moons(int $player_id) { @@ -94,24 +100,25 @@ public function get_nb_moons(int $player_id) $request .= " WHERE `player_id` = " . $player_id . " AND `type` = 'moon'"; $result = $this->db->sql_query($request); - list($count) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $count = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $count; } /** - * Récupère les boosters d'un joueur spécifique. + * Retrieves boosters for a specific player. * - * Cette méthode interroge la table `TABLE_USER_BUILDING` pour récupérer - * les informations sur les boosters associés à un joueur donné. + * This method queries `TABLE_USER_BUILDING` to retrieve + * booster information associated with a given player. * - * @param int $player_id L'identifiant du joueur dont les boosters doivent être récupérés. - * @return array Un tableau associatif contenant les boosters pour chaque planète du joueur. - * Chaque élément du tableau est une entrée associative avec les clés : - * - `user_id` : L'identifiant de l'utilisateur. - * - `planet_id` : L'identifiant de la planète. - * - `boosters` : Les boosters associés. + * @param int $player_id Player identifier whose boosters must be retrieved. + * @return array Associative array containing boosters for each player planet. + * Each item is an associative entry with keys: + * - `user_id` : User identifier. + * - `planet_id` : Planet identifier. + * - `boosters` : Associated boosters. */ public function get_all_booster_player(int $player_id) { @@ -119,23 +126,24 @@ public function get_all_booster_player(int $player_id) $result = $this->db->sql_query($request); $playerBoosters = array(); - while (list($player_id, $id, $boosters) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + [$player_id, $id, $boosters] = $row; $playerBoosters[$id] = array("user_id" => $player_id, "planet_id" => $id, "boosters" => $boosters); } return $playerBoosters; } /** - * Récupère les boosters de tous les utilisateurs. + * Retrieves boosters for all users. * - * Cette méthode interroge la table `TABLE_USER_BUILDING` pour récupérer - * les informations sur les boosters associés à chaque utilisateur et planète. + * This method queries `TABLE_USER_BUILDING` to retrieve + * booster information associated with each user and planet. * - * @return array Un tableau contenant les boosters pour chaque utilisateur et planète. - * Chaque élément du tableau est une entrée associative avec les clés : - * - `user_id` : L'identifiant de l'utilisateur. - * - `planet_id` : L'identifiant de la planète. - * - `boosters` : Les boosters associés. + * @return array Array containing boosters for each user and planet. + * Each item is an associative entry with keys: + * - `user_id` : User identifier. + * - `planet_id` : Planet identifier. + * - `boosters` : Associated boosters. */ public function get_all_booster() { @@ -143,17 +151,18 @@ public function get_all_booster() $result = $this->db->sql_query($request); $Boosters = array(); - while (list($user_id, $planet_id, $boosters) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + [$user_id, $planet_id, $boosters] = $row; $Boosters[] = array("user_id" => $user_id, "planet_id" => $planet_id, "boosters" => $boosters); } return $Boosters; } /* Écrit la string de stockage des objets Ogame dans la BDD. - * @arg id_player id du joueur - * @arg id_planet id de la planète à rechercher - * @str_booster string de stockage des boosters (donnée par les fonctions booster_encode() ou booster_encodev()) - * @return FALSE en cas d'échec + * @arg id_player id of the joueur + * @arg id_planet planet ID to search for + * @str_booster booster storage string (provided by booster_encode() or booster_encodev()) + * @return FALSE on failure */ /** * @param $id_player @@ -175,24 +184,24 @@ public function update_booster($user_id, $planet_id, $boosters) } /** - * Récupère la liste des bâtiments associés à un joueur spécifique. + * Retrieves the list of buildings associated with a specific player. * - * Cette méthode interroge la table `TABLE_USER_BUILDING` pour obtenir les informations - * sur tous les bâtiments d'un joueur donné, identifiés par son `player_id`. + * This method queries `TABLE_USER_BUILDING` to get information + * about all buildings for a given player, identified by `player_id`. * - * @param int $player_id L'identifiant unique du joueur dont les bâtiments doivent être récupérés. - * @return array Un tableau associatif contenant les bâtiments du joueur spécifié. - * Les clés principales du tableau correspondent aux identifiants uniques des bâtiments (`id`). - * Chaque entrée contient un tableau associatif décrivant les attributs du bâtiment, - * tels que : - * - `id` : L'identifiant du bâtiment. - * - `name` : Le nom du bâtiment. - * - `galaxy` : La galaxie dans laquelle le bâtiment se trouve. - * - `system` : Le système dans lequel le bâtiment se trouve. - * - `row` : La rangée dans laquelle le bâtiment se situe. - * - `fields`, `boosters`, `temperature_min`, `temperature_max`, et d'autres attributs - * spécifiques au bâtiment. - * Les détails de chaque élément correspondent aux colonnes listées dans `$tElemList`. + * @param int $player_id Unique player identifier whose buildings must be retrieved. + * @return array Associative array containing buildings for the specified player. + * Main keys correspond to unique building identifiers (`id`). + * Each entry contains an associative array describing building attributes, + * such as: + * - `id` : Building identifier. + * - `name` : Building name. + * - `galaxy` : Galaxy where the building is located. + * - `system` : System where the building is located. + * - `row` : Slot where the building is located. + * - `fields`, `boosters`, `temperature_min`, `temperature_max`, and other + * building-specific attributes. + * Each entry details correspond to columns listed in `$tElemList`. */ public function select_player_building_list($player_id) { @@ -217,19 +226,19 @@ public function select_player_building_list($player_id) } /** - * Récupère les bâtiments en fonction du niveau de silo spécifié. + * Retrieves buildings based on the specified silo level. * - * Cette méthode interroge la table `TABLE_USER_BUILDING` pour récupérer - * les informations sur les bâtiments qui ont un niveau de silo supérieur ou égal - * au niveau fourni en paramètre. + * This method queries `TABLE_USER_BUILDING` to retrieve + * building information where silo level is greater than or equal + * to the provided level. * - * @param int $silo_level Le niveau de silo minimum requis pour récupérer les bâtiments. - * @return array Un tableau contenant les informations des bâtiments correspondant au critère. - * Chaque élément du tableau est une entrée associative avec les clés : - * - `user_id` : L'identifiant de l'utilisateur. - * - `planet_id` : L'identifiant de la planète. - * - `coordinates` : Les coordonnées du bâtiment. - * - `Silo` : Le niveau du silo. + * @param int $silo_level Minimum silo level required to retrieve buildings. + * @return array Array containing building information matching the criterion. + * Each item is an associative entry with keys: + * - `user_id` : User identifier. + * - `planet_id` : Planet identifier. + * - `coordinates` : Building coordinates. + * - `Silo` : Silo level. */ public function get_building_by_silo(int $silo_level) { @@ -245,14 +254,14 @@ public function get_building_by_silo(int $silo_level) } /** - * Supprime un astéroïde associé à un utilisateur spécifique. + * Deletes an asteroid associated with a specific user. * - * Cette méthode supprime l'enregistrement d'un astéroïde spécifique - * pour un utilisateur particulier de la table `TABLE_USER_BUILDING`. + * This method deletes the record of a specific asteroid + * for a given user from the `TABLE_USER_BUILDING` table. * - * @param int $user_id L'identifiant de l'utilisateur auquel l'astéroïde est associé. - * @param int $aster_id L'identifiant de l'astéroïde à supprimer. - * @return void Cette méthode ne retourne aucune valeur. + * @param int $user_id User identifier associated with the asteroid. + * @param int $aster_id Asteroid identifier to delete. + * @return void This method does not return a value. */ public function delete_user_aster($user_id, $aster_id) { diff --git a/model/Player_Defense_Model.php b/model/Player_Defense_Model.php index bcfa6297..a3c9390d 100644 --- a/model/Player_Defense_Model.php +++ b/model/Player_Defense_Model.php @@ -15,10 +15,10 @@ class Player_Defense_Model extends Model_Abstract { /** - * Retrieves the defense data for a specific player. + * Retrieves defense data for a player. * - * @param int $playerId The unique identifier of the player. - * @return array An associative array containing the player's defense data. + * @param int $playerId Identifier unique of the joueur. + * @return array Tableau associatif contenant the defenses of the joueur. */ public function select_player_defense(int $playerId) { @@ -45,10 +45,10 @@ public function select_player_defense(int $playerId) } /** - * Retrieves the defense configuration for a specified planet. + * Retrieves defense configuration for a planet. * - * @param int $planet_id The unique identifier of the planet whose defense data is to be retrieved. - * @return array|null An associative array containing the defense information for the specified planet, or null if no data is found. + * @param int $planet_id Planet identifier. + * @return array|null Associative array of defenses, or null if no data. */ public function select_player_defense_planete(int $planet_id) { @@ -65,9 +65,9 @@ public function select_player_defense_planete(int $planet_id) /** - * Deletes a specified asteroid entry from the player defense table. + * Deletes une entrée of défense liée à un objet astronomique. * - * @param int $aster_id The unique identifier of the asteroid to be deleted. + * @param int $aster_id Identifier of l'objet à delete. * @return void */ public function delete_user_aster(int $aster_id) diff --git a/model/Player_Model.php b/model/Player_Model.php index d5376622..b9aa3e34 100644 --- a/model/Player_Model.php +++ b/model/Player_Model.php @@ -7,10 +7,10 @@ class Player_Model extends Model_Abstract { /** - * Récupère les données d'un joueur en jeu à partir de son identifiant. + * Retrieves in-game player data from its identifier. * - * @param int $player_id L'identifiant du joueur en jeu. - * @return array|bool Retourne un tableau contenant les informations du joueur, ou false si non trouvé. + * @param int $player_id In-game player identifier. + * @return array|bool Returns an array containing player information, or false if not found. */ public function get_player_data(int $player_id) { @@ -31,10 +31,10 @@ public function get_player_data(int $player_id) } /** - * Obtient le nom du joueur en jeu à partir de son identifiant. + * Retrieves the in-game player name from its identifier. * - * @param int $player_id L'identifiant du joueur en jeu. - * @return string|false Retourne le nom du joueur en jeu, ou false si non trouvé. + * @param int $player_id In-game player identifier. + * @return string|false Returns le name of the joueur en jeu, ou false si non trouvé. */ public function get_player_name(int $player_id) { @@ -52,10 +52,10 @@ public function get_player_name(int $player_id) } /** - * Retrieves the player ID based on the provided player name. + * Retrieves the player identifier from its name. * - * @param string $player_name The name of the player to retrieve the ID for. - * @return int|false Returns the player ID as an integer if found, or false if the player does not exist. + * @param string $player_name Name of the joueur. + * @return int|false Identifier of the joueur si trouvé, sinon false. */ public function getPlayerId(string $player_name) { @@ -76,7 +76,7 @@ public function getPlayerId(string $player_name) /** * A quoi sert donc cette fonction ? :p - * Reponse elle sert a mettre a jour le pseudo ingame afin d afficher les stats users dans son espace perso + * Reponse elle sert a mettre a jour le pseudo ingame afin d afficher the stats users dans son espace perso * * set_game_account_id ? * @@ -131,10 +131,10 @@ public function set_player_officer($user_id, $officer, $value) } /** - * Récupère l'ID du joueur en jeu associé à un utilisateur OGSpy. + * Retrieves the in-game player ID associated with an OGSpy user. * - * @param int $ogspy_user_id L'identifiant de l'utilisateur OGSpy. - * @return int|null Retourne l'ID du joueur en jeu, ou null si non trouvé ou non défini. + * @param int $ogspy_user_id OGSpy user identifier. + * @return int|null Returns l'ID of the joueur en jeu, ou null si non trouvé ou non défini. */ public function get_game_player_id_for_user($ogspy_user_id) { diff --git a/model/Player_Technology_Model.php b/model/Player_Technology_Model.php index 8c3af228..c9626080 100644 --- a/model/Player_Technology_Model.php +++ b/model/Player_Technology_Model.php @@ -1,10 +1,10 @@ db->sql_fetch_assoc($result); } /** - * Supprime les technologies d'un joueur spécifique. + * Deletes technologies for a specific player. * - * @param int $player_id L'identifiant unique du joueur. - * Correspond à la clé primaire dans la table des technologies des joueurs. - * @return void Cette méthode ne retourne aucune valeur. + * @param int $player_id Unique player identifier. + * Matches the primary key in the player technology table. + * @return void This method does not return a value. */ public function delete_user_technologies(int $player_id) { @@ -51,13 +51,13 @@ public function delete_user_technologies(int $player_id) } /** - * Met à jour le niveau de la technologie d'espionnage pour un joueur spécifique. + * Updates espionage technology level for a specific player. * - * @param int $player_id L'identifiant unique du joueur. - * Correspond à la clé primaire dans la table des technologies des joueurs. - * @param int $level Le nouveau niveau de la technologie d'espionnage. - * Doit être un entier positif représentant le niveau à définir. - * @return void Cette méthode ne retourne aucune valeur. + * @param int $player_id Unique player identifier. + * Matches the primary key in the player technology table. + * @param int $level New espionage technology level. + * Must be a positive integer representing the target level. + * @return void This method does not return a value. */ public function update_esp(int $player_id, int $level) { diff --git a/model/Rankings_Ally_Model.php b/model/Rankings_Ally_Model.php index a453b956..d7dddaa8 100644 --- a/model/Rankings_Ally_Model.php +++ b/model/Rankings_Ally_Model.php @@ -27,7 +27,7 @@ public function __construct() } /** - * @param $allyId Id de l'alliance + * @param $allyId Id of l'alliance * @return array */ @@ -63,7 +63,8 @@ public function get_all_ranktable_byally($allyId) //Remplissage du ranking content. Toutes les valeurs doivent être présentes dans l'array sous peine de soucis d'affichages $ranking_content = array(); $row = 0; - while (list($datadate, $ally_name, $member, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $this->db->sql_fetch_row($result)) { + while (($row_data = $this->db->sql_fetch_row($result)) !== false && $row_data !== null) { + list($datadate, $ally_name, $member, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $row_data; $ranking_content[$row]['datadate'] = $datadate; $ranking_content[$row]['postion'] = $general_rank; $ranking_content[$row]['ally_name'] = $ally_name; @@ -107,7 +108,7 @@ public function get_all_ranktable_byally($allyId) * @param int $higher_rank * @param int $lower_rank * @return array - * todo fonction ecrrite pour 3.4 modification page view necessaire pour usage ... + * todo fonction ecrrite for 3.4 modification page view necessaire for usage ... */ public function get_all_ranktable_bydate($datadate, $higher_rank = 1, $lower_rank = 100, $ref = "general") { @@ -146,7 +147,8 @@ public function get_all_ranktable_bydate($datadate, $higher_rank = 1, $lower_ran //Remplissage du ranking content. Toutes les valeurs doivent être présentes dans l'array sous peine de soucis d'affichages $ranking_content = array(); $row = 0; - while (list($position, $ally_name, $member, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $this->db->sql_fetch_row($result)) { + while (($row_data = $this->db->sql_fetch_row($result)) !== false && $row_data !== null) { + list($position, $ally_name, $member, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $row_data; $ranking_content[$row]['postion'] = $position; $ranking_content[$row]['ally_name'] = $ally_name; $ranking_content[$row]['member'] = $member; diff --git a/model/Rankings_Model.php b/model/Rankings_Model.php index aefae89f..f8d31e19 100644 --- a/model/Rankings_Model.php +++ b/model/Rankings_Model.php @@ -31,7 +31,7 @@ public function get_rank_table_ref() return $this->rank_table_ref; } /** - * Selection du max rank pour définir la taille des tableaux parmi tous les classements + * Selection of the max rank for définir la taille des tableaux parmi tous the classements * @return mixed */ public function select_max_rank_row() @@ -56,7 +56,8 @@ public function get_rank_latest_table_date($rank_table) $request = "SELECT MAX(`datadate`) FROM `" . $rank_table . "` LIMIT 0,1"; $result = $this->db->sql_query($request); - list($max) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $max = (is_array($row) && isset($row[0])) ? $row[0] : null; return $max; } /** @@ -100,6 +101,7 @@ public function get_ranktable($rank_table, $datadate, $bydate = false, $higher_r $request .= " WHERE `datadate` = '" . $datadate . "'" . " AND `rank` >= '" . $higher_rank . "' AND `rank` <= '" . $lower_rank . "'"; } $result = $this->db->sql_query($request); + $ranking_content = []; while ($row = $this->db->sql_fetch_assoc($result)) { $ranking_content[] = $row; } @@ -107,10 +109,10 @@ public function get_ranktable($rank_table, $datadate, $bydate = false, $higher_r } /** - * Remove old ranking - * @param datadate temps en seconde - * @param $table nom de la table impacté - * remove entry from database when datadate is out of time + * Removes old ranking entries. + * @param datadate Time in seconds + * @param $table Name of the impacted table + * Removes database entries when datadate is outdated */ public function remove_all_rank_older_than($datadate, $table = null) { diff --git a/model/Rankings_Player_Model.php b/model/Rankings_Player_Model.php index 00c4c2be..5538a937 100644 --- a/model/Rankings_Player_Model.php +++ b/model/Rankings_Player_Model.php @@ -72,7 +72,8 @@ public function get_all_ranktable_bydate($datadate, $higher_rank = 1, $lower_ran // Remplissage du ranking content. Toutes les valeurs doivent être présentes dans l'array sous peine de soucis d'affichages $ranking_content = array(); $row = 0; - while (list($position, $player_name, $ally_name, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $this->db->sql_fetch_row($result)) { + while (($row_data = $this->db->sql_fetch_row($result)) !== false && $row_data !== null) { + list($position, $player_name, $ally_name, $general_rank, $general_pts, $eco_rank, $eco_pts, $tech_rank, $tech_pts, $mil_rank, $mil_pts, $milb_rank, $milb_pts, $mill_rank, $mill_pts, $mild_rank, $mild_pts, $milh_rank, $milh_pts) = $row_data; $ranking_content[$row]['postion'] = $position; $ranking_content[$row]['player_name'] = $player_name; $ranking_content[$row]['ally_name'] = $ally_name; diff --git a/model/Sessions_Model.php b/model/Sessions_Model.php index 93e66186..e89d892b 100644 --- a/model/Sessions_Model.php +++ b/model/Sessions_Model.php @@ -19,7 +19,7 @@ class Sessions_Model extends Model_Abstract /** * @param $cookie_id * @param string $user_ip - * @return bool|mixed|\Ogsteam\Ogspy\mysqli_result + * @return bool */ public function is_valid_session_id($cookie_id, $user_ip = '') { @@ -41,7 +41,8 @@ public function get_xtense_session($user_id) $request = "SELECT `session_type` FROM " . TABLE_SESSIONS . " WHERE `user_id` = " . $user_id; $result = $this->db->sql_query($request); if ($this->db->sql_numrows($result) > 0) { - list($session_type) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $session_type = (is_array($row) && isset($row[0])) ? (int)$row[0] : -1; return $session_type; } return -1; @@ -127,7 +128,7 @@ public function insert_xtense_session($cookie_id, $cookie_expire, $user_ip) $this->db->sql_query($request, true, false); } /** - * Deletes all sessions + * Deletes toutes the sessions. */ public function drop_all() { @@ -163,7 +164,7 @@ public function close_user_session($user_id) $this->db->sql_query($request, true, false); } /** - * Removes all expired sessions from the table + * Deletes all expired sessions from the table. */ public function clean_expired_sessions() { @@ -216,14 +217,15 @@ public function who_is_online() return $retour; } /** - * Number of sessions - * @return int number of sessions + * Number of sessions actives. + * @return int Number of sessions */ public function count_online() { $request = "SELECT COUNT(`session_ip`) FROM " . TABLE_SESSIONS; $connectes_req = $this->db->sql_query($request); - list($connectes) = $this->db->sql_fetch_row($connectes_req); + $row = $this->db->sql_fetch_row($connectes_req); + $connectes = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $connectes; } } diff --git a/model/Spy_Model.php b/model/Spy_Model.php index 6bc0acf7..107591ef 100644 --- a/model/Spy_Model.php +++ b/model/Spy_Model.php @@ -9,7 +9,7 @@ class Spy_Model extends Model_Abstract { /** - * Retrieves a list of favorite spy reports for a specific user. + * Retrieves the list of favorite spy reports for a user. * * @param int $user_id The ID of the user whose favorite spy reports are to be retrieved. * @param int $sort Optional parameter to specify the sorting criterion. @@ -106,7 +106,8 @@ public function get_favoriteSpyList(int $user_id, int $sort = 5, int $sort2 = 0, $request .= " ORDER BY " . $ordered_by; $result = $this->db->sql_query($request); - while (list($spy_id, $galaxy, $system, $row, $datadate, $sender_name, $moon, $ally, $player, $status, $metal, $crystal, $deuterium) = $this->db->sql_fetch_row($result)) { + while (($row_data = $this->db->sql_fetch_row($result)) !== false && $row_data !== null) { + list($spy_id, $galaxy, $system, $row, $datadate, $sender_name, $moon, $ally, $player, $status, $metal, $crystal, $deuterium) = $row_data; $total_resources = ($metal >= 0 && $crystal >= 0 && $deuterium >= 0) ? ($metal + $crystal + $deuterium) @@ -126,7 +127,7 @@ public function get_favoriteSpyList(int $user_id, int $sort = 5, int $sort2 = 0, /** - * Retrieves detailed information about a specific spy report. + * Retrieves detailed information for a spy report. * * @param int $id_RE The unique identifier of the spy report to retrieve. * @return array An associative array containing detailed information about the spy report, @@ -145,7 +146,7 @@ public function get_spy_Id(int $id_RE) } /** - * Retrieves spy data for a specific astronomical object. + * Retrieves spy data for a given astronomical object. * * @param int $astro_object_id The ID of the astronomical object for which the spy data is to be retrieved. * @return array An array of associative arrays, where each entry contains detailed spy report information @@ -168,7 +169,7 @@ public function get_spy_data(int $astro_object_id) } /** - * Retrieves the number of active spy reports associated with a specific planet based on its galaxy, system, and row coordinates. + * Retrieves the number of active spy reports for a given planet. * * @param int $galaxy The galaxy number of the planet. * @param int $system The system number of the planet. @@ -192,7 +193,7 @@ public function get_nb_spy_by_planet(int $galaxy, int $system, int $row) } /** - * Retrieves a list of active spy reports for a specific astro object. + * Retrieves the list of active spy reports for an astronomical object. * * @param int $astroObjectId The ID of the astro object for which active spy reports are to be retrieved. * @return array An array of spy reports, where each report contains the spy ID, user name of the sender, @@ -218,7 +219,7 @@ public function get_spy_id_list_by_planet(int $astroObjectId) } /** - * Deletes a specific spy report based on its ID. + * Deletes a spy report by its identifier. * * @param int $spy_id The ID of the spy report to be deleted. * @return void @@ -234,7 +235,7 @@ public function delete_spy($spy_id) } /** - * Deletes a spy report from the database based on the given spy ID and sender ID. + * Deletes a spy report using its identifier and sender. * * @param int $spy_id The unique identifier of the spy report to be deleted. * @param int $user_id The ID of the sender associated with the spy report. @@ -251,7 +252,7 @@ public function delete_spy_by_senderId($spy_id, $user_id) /** - * Deletes expired spy reports from the database based on the provided time limit or inactive status. + * Deletes expired or inactive spy reports. * * @param int $limit_time The timestamp used to determine expiration. Spy reports with a date earlier than this value, or marked as inactive, will be deleted. * @return void diff --git a/model/Statistics_Model.php b/model/Statistics_Model.php index 6e3d78c6..aa0faa59 100644 --- a/model/Statistics_Model.php +++ b/model/Statistics_Model.php @@ -48,7 +48,8 @@ public function find() $stats = array(); - while (list($statistic_name, $statistic_value) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + list($statistic_name, $statistic_value) = $row; $stats[$statistic_name] = $statistic_value; } @@ -65,7 +66,11 @@ public function get_users_stat_sum() FROM ' . TABLE_USER; $result = $this->db->sql_query($query); - list($planet_imports, $spy_imports, $rank_imports, $search) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $planet_imports = (is_array($row) && isset($row[0])) ? $row[0] : 0; + $spy_imports = (is_array($row) && isset($row[1])) ? $row[1] : 0; + $rank_imports = (is_array($row) && isset($row[2])) ? $row[2] : 0; + $search = (is_array($row) && isset($row[3])) ? $row[3] : 0; $sum = array(); $sum["planet_imports"] = $planet_imports; diff --git a/model/Tokens_Model.php b/model/Tokens_Model.php index a8561397..49423391 100644 --- a/model/Tokens_Model.php +++ b/model/Tokens_Model.php @@ -1,8 +1,8 @@ delete_expired_tokens(); } /** - * This function will add or update a token into the database + * Adds or updates a token in the database. * @param $token_id * @param $token_user_id * @param $token_expire @@ -48,7 +48,7 @@ public function add_token($token_id, $token_user_id, $token_expire, $token_type) } /** - * THis function will retrieve the token id from the user + * Retrieves a user's token identifier. * @param $token_user_id * @return mixed */ @@ -60,7 +60,8 @@ public function get_token($token_user_id, $token_type) $request = "SELECT `token` FROM " . TABLE_USER_TOKEN . " WHERE `user_id`= '" . $token_user_id . "' AND `name` = '" . $token_type . "'"; $result = $this->db->sql_query($request); if ($this->db->sql_numrows($result) > 0) { - list($token_id) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $token_id = (is_array($row) && isset($row[0])) ? $row[0] : false; return $token_id; } else { return false; @@ -68,7 +69,7 @@ public function get_token($token_user_id, $token_type) } /** - * THis function will retrieve the token id from the user + * Retrieves all tokens for a user. * @param $token_user_id * @return mixed */ @@ -91,7 +92,7 @@ public function get_all_tokens($token_user_id) } /** - * THis function will retrieve the token id from the user + * Retrieves a user identifier from a token. * @param $token * @return boolean true False * @internal param $token_user_id @@ -104,7 +105,8 @@ public function get_userid_from_token($token, $token_type) $request = "SELECT `user_id` FROM " . TABLE_USER_TOKEN . " WHERE `token`= '" . $token . "' AND `name` = '" . $token_type . "'"; $result = $this->db->sql_query($request); if ($this->db->sql_numrows($result) > 0) { - list($token_user_id) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $token_user_id = (is_array($row) && isset($row[0])) ? (int)$row[0] : false; return $token_user_id; } else { return false; @@ -113,7 +115,7 @@ public function get_userid_from_token($token, $token_type) /** - * This function removes all tokens from the Table + * Deletes all tokens from the table. */ public function delete_all_tokens() { @@ -123,7 +125,7 @@ public function delete_all_tokens() /** - * This function removes all tokens by type from the Table + * Deletes all tokens of a given type. */ public function delete_all_tokens_by_type($token_type) { @@ -135,7 +137,7 @@ public function delete_all_tokens_by_type($token_type) /** - * This function clean all expired tokens + * Deletes all expired tokens. */ public function delete_expired_tokens() { diff --git a/model/User_Favorites_Model.php b/model/User_Favorites_Model.php index 59294047..7ec52799 100644 --- a/model/User_Favorites_Model.php +++ b/model/User_Favorites_Model.php @@ -18,9 +18,9 @@ class User_Favorites_Model extends Model_Abstract { /** - * Gets the favorite system list for the defined user - * @param $user_id - * @return array $favorite Liste des systèmes favoris + * Retrieves the list of the user's favorite systems. + * @param int $user_id + * @return array $favorite List of favorite systems */ public function select_user_favorites($user_id) { @@ -33,7 +33,8 @@ public function select_user_favorites($user_id) $request .= " ORDER BY `galaxy`, `system`"; $result = $this->db->sql_query($request); - while (list($galaxy, $system) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + list($galaxy, $system) = $row; $favorite[] = array("galaxy" => $galaxy, "system" => $system); } @@ -88,7 +89,7 @@ public function delete_user_favorites($user_id, $galaxy, $system) } /** - * Supprime les Favoris qui ne sont plus accessibles après redimensionnement de univers + * Deletes the Favoris qui ne sont plus accessibles après redimensionnement of univers * @param $nb_galaxies * @param $nb_system */ diff --git a/model/User_Model.php b/model/User_Model.php index 706d7581..179ae7c9 100644 --- a/model/User_Model.php +++ b/model/User_Model.php @@ -16,11 +16,13 @@ class User_Model extends Model_Abstract { - /* Fonctions concerning user account */ + /* User account related methods */ /** - * @param $login - * @param $password - * @return array|bool hash or not + * Fetch login data for a user by username. + * + * @param string $login + * @param string $password + * @return array|false */ public function select_user_login($login, $password) { @@ -39,7 +41,9 @@ public function select_user_login($login, $password) } /** - * @param $username + * Check whether a username already exists. + * + * @param string $username * @return bool */ public function select_is_user_name($username) @@ -56,7 +60,10 @@ public function select_is_user_name($username) } /** - * @param $username + * Check whether a username exists for another user ID. + * + * @param string $username + * @param int $user_id * @return bool */ public function select_is_other_user_name($username, $user_id) @@ -74,7 +81,9 @@ public function select_is_other_user_name($username, $user_id) } /** - * @return array + * Return the list of all usernames. + * + * @return array */ public function select_user_list() { @@ -82,14 +91,17 @@ public function select_user_list() $list_user_name = array(); $result = $this->db->sql_query($request); - while (list($user_name) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + list($user_name) = $row; $list_user_name[] = $user_name; } return $list_user_name; } /** - * @return array + * Return the list of all user IDs. + * + * @return array */ public function select_userid_list() { @@ -97,15 +109,18 @@ public function select_userid_list() $list_user_id = array(); $result = $this->db->sql_query($request); - while (list($user_id) = $this->db->sql_fetch_row($result)) { + while (($row = $this->db->sql_fetch_row($result)) !== false && $row !== null) { + list($user_id) = $row; $list_user_id[] = $user_id; } return $list_user_id; } /** - * @param $user_id - * @return mixed + * Get the last visit timestamp for a user. + * + * @param int $user_id + * @return int|string|null */ public function select_last_visit($user_id) { @@ -114,14 +129,17 @@ public function select_last_visit($user_id) $request = "SELECT `lastvisit` FROM " . TABLE_USER; $request .= " WHERE `id` = '" . $user_id . "'"; $result = $this->db->sql_query($request); - list($lastvisit) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $lastvisit = (is_array($row) && isset($row[0])) ? $row[0] : null; return $lastvisit; } /** - * @param $user_id - * @return mixed + * Fetch profile data for one user. + * + * @param int $user_id + * @return array>|false */ public function select_user_data($user_id) { @@ -148,7 +166,9 @@ public function select_user_data($user_id) } /** - * @return mixed + * Fetch profile data for all users. + * + * @return array>|false */ public function select_all_user_data() { @@ -172,7 +192,9 @@ public function select_all_user_data() } /** - * @return mixed + * Fetch statistics data for all users. + * + * @return array> */ public function select_all_user_stats_data() { @@ -187,7 +209,10 @@ public function select_all_user_stats_data() } /** - * @return mixed + * Fetch statistics data for one user. + * + * @param int $user_id + * @return array{planet_imports:int|string,search:int|string,spy_imports:int|string,rank_imports:int|string} */ public function select_user_stats_data($user_id) { @@ -201,18 +226,31 @@ public function select_user_stats_data($user_id) $request .= " WHERE `id`='" . $user_id . "'"; $result = $this->db->sql_query($request); - list($planet_imports, $search, $spy_imports, $rank_imports) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $planet_imports = (is_array($row) && isset($row[0])) ? $row[0] : 0; + $search = (is_array($row) && isset($row[1])) ? $row[1] : 0; + $spy_imports = (is_array($row) && isset($row[2])) ? $row[2] : 0; + $rank_imports = (is_array($row) && isset($row[3])) ? $row[3] : 0; return array("planet_imports" => $planet_imports, "search" => $search, "spy_imports" => $spy_imports, "rank_imports" => $rank_imports); } + /** + * Compute aggregated import and search counters across all users. + * + * @return array{planetimporttotal:int|string,spyimporttotal:int|string,rankimporttotal:int|string,searchtotal:int|string} + */ public function select_user_stats_sum() { $request = "SELECT SUM(planet_imports), SUM(spy_imports), SUM(rank_imports), SUM(search)"; $request .= "FROM " . TABLE_USER; $resultat = $this->db->sql_query($request); - list($planetimporttotal, $spyimporttotal, $rankimporttotal, $searchtotal) = $this->db->sql_fetch_row($resultat); + $row = $this->db->sql_fetch_row($resultat); + $planetimporttotal = (is_array($row) && isset($row[0])) ? $row[0] : 0; + $spyimporttotal = (is_array($row) && isset($row[1])) ? $row[1] : 0; + $rankimporttotal = (is_array($row) && isset($row[2])) ? $row[2] : 0; + $searchtotal = (is_array($row) && isset($row[3])) ? $row[3] : 0; return array( "planetimporttotal" => $planetimporttotal, @@ -223,8 +261,10 @@ public function select_user_stats_sum() } /** - * @param $user_id - * @return array + * Fetch effective rights for a user through group membership. + * + * @param int $user_id + * @return array */ public function select_user_rights($user_id) { @@ -264,7 +304,10 @@ public function select_user_rights($user_id) /** + * Update the last visit timestamp for a user. * + * @param int $user_id + * @return void */ public function update_lastvisit_time($user_id) { @@ -275,8 +318,11 @@ public function update_lastvisit_time($user_id) } /** - * @param $user_id - * @param $user_name + * Update a user's display name. + * + * @param int $user_id + * @param string $user_name + * @return void */ public function set_user_pseudo($user_id, $user_name) { @@ -288,8 +334,12 @@ public function set_user_pseudo($user_id, $user_name) } /** - * @param $user_id - * @param $user_password + * Update a user's password hash. + * + * @param int $user_id + * @param string $encrypted_password + * @param int $user_pwd_change + * @return void */ public function set_user_password($user_id, $encrypted_password, $user_pwd_change = 1) { @@ -304,8 +354,11 @@ public function set_user_password($user_id, $encrypted_password, $user_pwd_chang } /** - * @param $user_id - * @param $user_email + * Update a user's email and reset validation state. + * + * @param int $user_id + * @param string $user_email + * @return void */ public function set_user_email($user_id, $user_email) { @@ -320,8 +373,11 @@ public function set_user_email($user_id, $user_email) } /** - * @param $user_id - * @param $default_galaxy + * Update a user's default galaxy. + * + * @param int $user_id + * @param int $default_galaxy + * @return void */ public function set_user_default_galaxy($user_id, $default_galaxy) { @@ -334,8 +390,10 @@ public function set_user_default_galaxy($user_id, $default_galaxy) } /** - * Utilisé après un redimensionement de l'univers - * @param $int $nb_galaxy + * Reset default galaxy when universe size is reduced. + * + * @param int $nb_galaxy + * @return void */ public function set_default_galaxy_after_resize($nb_galaxy) { @@ -345,8 +403,11 @@ public function set_default_galaxy_after_resize($nb_galaxy) } /** - * @param $user_id - * @param $default_system + * Update a user's default system. + * + * @param int $user_id + * @param int $default_system + * @return void */ public function set_user_default_system($user_id, $default_system) { @@ -358,8 +419,10 @@ public function set_user_default_system($user_id, $default_system) } /** - * Utilisé après un redimensionement de l'univers - * @param $int $nb_systems + * Reset default system when universe size is reduced. + * + * @param int $nb_systems + * @return void */ public function set_default_system_after_resize($nb_systems) { @@ -370,8 +433,11 @@ public function set_default_system_after_resize($nb_systems) } /** - * @param $user_id - * @param $disable_ip_check + * Enable or disable IP checks for a user. + * + * @param int $user_id + * @param int $disable_ip_check + * @return void */ public function set_user_ip_check($user_id, $disable_ip_check) { @@ -385,8 +451,11 @@ public function set_user_ip_check($user_id, $disable_ip_check) /** - * @param $user_id - * @param $user_active boolean 1/0 + * Set user active status. + * + * @param int $user_id + * @param int $value + * @return void */ public function set_user_active($user_id, $value) { @@ -398,8 +467,11 @@ public function set_user_active($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Set user co-admin status. + * + * @param int $user_id + * @param int $value + * @return void */ public function set_user_coadmin($user_id, $value) { @@ -412,8 +484,11 @@ public function set_user_coadmin($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Set user management permission. + * + * @param int $user_id + * @param int $value + * @return void */ public function set_user_management_user($user_id, $value) { @@ -425,8 +500,11 @@ public function set_user_management_user($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Set user ranking management permission. + * + * @param int $user_id + * @param int $value + * @return void */ public function set_user_management_ranking($user_id, $value) { @@ -438,8 +516,11 @@ public function set_user_management_ranking($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Increment user planet import counter. + * + * @param int $user_id + * @param int $value + * @return void */ public function add_stat_planet_inserted($user_id, $value) { @@ -451,8 +532,11 @@ public function add_stat_planet_inserted($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Increment user spy import counter. + * + * @param int $user_id + * @param int $value + * @return void */ public function add_stat_spy_inserted($user_id, $value) { @@ -464,8 +548,11 @@ public function add_stat_spy_inserted($user_id, $value) } /** - * @param $user_id - * @param $value boolean 1/0 + * Increment user ranking import counter. + * + * @param int $user_id + * @param int $value + * @return void */ public function add_stat_rank_inserted($user_id, $value) { @@ -477,8 +564,11 @@ public function add_stat_rank_inserted($user_id, $value) } /** - * @param $user_id - * @param $value int + * Increment user search counter. + * + * @param int $user_id + * @param int $value + * @return void */ public function add_stat_search_made($user_id, $value) { @@ -490,6 +580,9 @@ public function add_stat_search_made($user_id, $value) } /** + * Reset search counters for all users. + * + * @return void */ public function all_raz_ratio_search() { @@ -498,7 +591,9 @@ public function all_raz_ratio_search() } /** - * @return \Ogsteam\Ogspy\the + * Count active users. + * + * @return int */ public function get_nb_active_users() { @@ -508,19 +603,22 @@ public function get_nb_active_users() } /** - * @return \Ogsteam\Ogspy\the + * @return int */ public function get_nb_users() { $result = $this->db->sql_query("SELECT COUNT(*) FROM " . TABLE_USER); - list($count) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $count = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $count; } /** - * @param $pseudo - * @param $password - * @return \Ogsteam\Ogspy\Returs + * Create a new user and assign the default group. + * + * @param string $pseudo + * @param string $password + * @return int */ public function add_new_user($pseudo, $password) { @@ -540,8 +638,10 @@ public function add_new_user($pseudo, $password) } /** - * @param $user_id - * @param $group_id + * Check whether a user belongs to a specific group. + * + * @param int $user_id + * @param int $group_id * @return bool */ public function is_user_in_group($user_id, $group_id) @@ -551,13 +651,17 @@ public function is_user_in_group($user_id, $group_id) $request = "SELECT COUNT(*) FROM " . TABLE_USER_GROUP . " WHERE `group_id` = " . $group_id . " AND `user_id` = " . $user_id; $result = $this->db->sql_query($request); - list($count) = $this->db->sql_fetch_row($result); + $row = $this->db->sql_fetch_row($result); + $count = (is_array($row) && isset($row[0])) ? (int)$row[0] : 0; return $count > 0; } /** - * @param $user_id - * @param $group_id + * Add a user to a group if not already linked. + * + * @param int $user_id + * @param int $group_id + * @return void */ public function add_user_to_group($user_id, $group_id) { @@ -572,7 +676,10 @@ public function add_user_to_group($user_id, $group_id) } /** - * @param $user_id + * Delete a user and linked records. + * + * @param int $user_id + * @return void */ public function delete_user($user_id) { diff --git a/stubs/intelephense_globals.php b/stubs/intelephense_globals.php new file mode 100644 index 00000000..7bf084b4 --- /dev/null +++ b/stubs/intelephense_globals.php @@ -0,0 +1,53 @@ +