From b45a0b2d593e4fc25b85c5c6fc3c7ef30bf706ad Mon Sep 17 00:00:00 2001
From: Anthony <13015521+darknoon29@users.noreply.github.com>
Date: Wed, 19 Apr 2023 22:32:41 +0200
Subject: [PATCH] Force AutoUpdate Update
---
core/mod_list.php | 31 ++++---
version.txt | 2 +-
view/overview.php | 215 +++++++++++++++++++++++++---------------------
3 files changed, 138 insertions(+), 110 deletions(-)
diff --git a/core/mod_list.php b/core/mod_list.php
index 64870e0..36710f4 100644
--- a/core/mod_list.php
+++ b/core/mod_list.php
@@ -14,14 +14,21 @@ function getRepositorylist()
{
$mod_list = array();
+ $repoListFilename = './mod/autoupdate/tmp/repo_list.json';
if (time() > (mod_get_option('LAST_REPO_LIST') + mod_get_option('CYCLEMAJ') * 3600)) {
$mod_data = github_Request("https://github.com/gitapi/orgs/ogsteam/repos?per_page=100");
- file_put_contents('./mod/autoupdate/tmp/repo_list.json', $mod_data);
+ file_put_contents($repoListFilename, $mod_data);
mod_set_option('LAST_REPO_LIST', time());
}
- $mod_file = file_get_contents('./mod/autoupdate/tmp/repo_list.json');
+
+ if (is_readable($repoListFilename)) {
+ $mod_file = file_get_contents($repoListFilename);
+ }else {
+ mod_set_option('LAST_REPO_LIST', 0);
+ return false;
+ }
$data = json_decode($mod_file, true);
//print_r($data);
@@ -68,16 +75,18 @@ function getRepositoryDetails($repoName)
$liste_mods = getRepositorylist();
//print_r($liste_mods);
- foreach ($liste_mods as $mod) {
+ if (is_array($liste_mods)) {
+ foreach ($liste_mods as $mod) {
- if ($mod['nom'] == $repoName) {
+ if ($mod['nom'] == $repoName) {
- return array(
- 'nom' => $mod["nom"],
- 'description' => $mod["description"],
- 'resource_uri' => $mod["resource_uri"],
- 'owner' => $mod["owner"]
- );
+ return array(
+ 'nom' => $mod["nom"],
+ 'description' => $mod["description"],
+ 'resource_uri' => $mod["resource_uri"],
+ 'owner' => $mod["owner"]
+ );
+ }
}
}
return false;
@@ -219,6 +228,8 @@ function github_RequestToken()
]
];
+ $context = stream_context_create($opts);
+
$data = file_get_contents('https://darkcity.fr/statistiques/collector/repolistkey', false, $context);
return $data;
}
diff --git a/version.txt b/version.txt
index d54b956..7aeff84 100755
--- a/version.txt
+++ b/version.txt
@@ -1,4 +1,4 @@
autoupdate
-3.2.0
+3.2.1
autoupdate,AutoUpdate,autoupdate,autoupdate,autoupdate.php,1,1
3.3.7
diff --git a/view/overview.php b/view/overview.php
index 0e03565..c827d44 100644
--- a/view/overview.php
+++ b/view/overview.php
@@ -24,70 +24,74 @@
//TODO Améliorer ce contrôle
$installed_mods = get_installed_mod_list();
-
-
+$mylastVersion = getRepositoryVersion('autoupdate')['release'];
+$selfUpdateRequired = version_compare($mylastVersion, versionmod(), ">");
?>
+
-
-
- |
-
-
- |
- |
- |
- |
- ' . $lang['autoupdate_tableau_action'] . '';
- }
- if (mod_get_option("MAJ_BETA") == 1) {
- echo "";
- echo $lang['autoupdate_tableau_versionBeta'] . " | ";
- }
- ?>
- |
-
-
- OGSpy |
- OGSteam |
-
- ";
- $cur_version = getRepositoryVersion('ogspy');
- if (!is_array($cur_version) || $cur_version == '-1') {
- echo "\t\t | " . $lang['autoupdate_tableau_norefered'] . " | \n";
- $cur_version = 0;
- } else {
- echo "\t\t" . $cur_version['release'] . " | \n";
- }
- echo "";
- if (version_compare($cur_version['release'], $server_config["version"], ">")) {
- $ziplink = "" . $lang['autoupdate_tableau_uptodate'] . "";
- echo "" . $ziplink . "";
- } else {
- echo "Aucune";
+
+
+
+ |
+
+
+ |
+ |
+ |
+ |
+ ' . $lang['autoupdate_tableau_action'] . '';
}
- echo "";
if (mod_get_option("MAJ_BETA") == 1) {
+ echo "";
+ echo $lang['autoupdate_tableau_versionBeta'] . " | ";
+ }
+ ?>
+ |
+
+
+ OGSpy |
+ OGSteam |
+
+ ";
+ $cur_version = getRepositoryVersion('ogspy');
+ if (!is_array($cur_version) || $cur_version == '-1') {
+ echo "\t\t | " . $lang['autoupdate_tableau_norefered'] . " | \n";
+ $cur_version = 0;
+ } else {
+ echo "\t\t" . $cur_version['release'] . " | \n";
+ }
echo "";
- if (isset($cur_version['beta'])) {
- $ziplink = "" . $cur_version['beta'] . "";
+ if (version_compare($cur_version['release'], $server_config["version"], ">")) {
+ $ziplink = "" . $lang['autoupdate_tableau_uptodate'] . "";
+ echo "" . $ziplink . "";
} else {
- $ziplink = "-";
+ echo "Aucune";
}
- echo "" . $ziplink . "";
echo " | ";
- }
- echo "";
- $trackerlink = "" . $lang['autoupdate_tableau_buglink'] . "";
- echo "" . $trackerlink . "";
- echo " | ";
- ?>
-
-
- |
-
+ if (mod_get_option("MAJ_BETA") == 1) {
+ echo "";
+ if (isset($cur_version['beta'])) {
+ $ziplink = "" . $cur_version['beta'] . "";
+ } else {
+ $ziplink = "-";
+ }
+ echo "" . $ziplink . "";
+ echo " | ";
+ }
+ echo "";
+ $trackerlink = "" . $lang['autoupdate_tableau_buglink'] . "";
+ echo "" . $trackerlink . "";
+ echo " | ";
+ ?>
+
+
+ |
+
+
|
@@ -108,62 +112,74 @@
\n";
- echo "\t\t" . $installed_mods[$i]['name'] . " | \n";
- if (isset($repo_details['owner'])) {
- echo "\t\t" . $repo_details['owner'] . " | \n";
- } else {
- echo "\t\tNon OGSteam | \n";
- }
-
- echo "\t\t" . $installed_mods[$i]['version'] . " | \n";
+ if (!$selfUpdateRequired) {
+ foreach ($installed_mods as $installedMod) {
+ if (substr($installedMod['name'], 0, 5) != "Group") {
+ $repo_details = getRepositoryDetails($installedMod['root']);
+ echo "\t\n";
+ echo "\t\t" . $installedMod['name'] . " | \n";
+ if (isset($repo_details['owner'])) {
+ echo "\t\t" . $repo_details['owner'] . " | \n";
+ } else {
+ echo "\t\tNon OGSteam | \n";
+ }
- $cur_modroot = $installed_mods[$i]['root'];
- $cur_version = getRepositoryVersion($cur_modroot);
+ echo "\t\t" . $installedMod['version'] . " | \n";
- if (!is_array($cur_version) || $cur_version == '-1') {
- echo "\t\t" . $lang['autoupdate_tableau_norefered'] . " | \n";
- $cur_version = 0;
- } else {
- echo "\t\t" . $cur_version['release'] . " | \n";
- }
+ $cur_modroot = $installedMod['root'];
+ $cur_version = getRepositoryVersion($cur_modroot);
- if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
- echo "\t\t";
- if (!is_writeable("./mod/" . $installed_mods[$i]['root'] . "/")) {
- echo "(RO)";
+ if (!is_array($cur_version) || $cur_version == '-1') {
+ echo "\t\t | " . $lang['autoupdate_tableau_norefered'] . " | \n";
+ $cur_version = 0;
} else {
- if (version_compare($cur_version['release'], $installed_mods[$i]['version'], ">")) {
- $ziplink = "" . $lang['autoupdate_tableau_uptodate'] . "";
- echo "" . $ziplink . "";
- } else {
- echo "Aucune";
- }
+ echo "\t\t" . $cur_version['release'] . " | \n";
}
- echo "\n";
- if (mod_get_option("MAJ_BETA") == 1) {
+
+ if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
echo "\t\t";
- if (isset($cur_version['beta'])) {
- $ziplink = "" . $cur_version['beta'] . "";
+ if (!is_writeable("./mod/" . $installedMod['root'] . "/")) {
+ echo "(RO)";
} else {
- $ziplink = "-";
+ if (version_compare($cur_version['release'], $installedMod['version'], ">")) {
+ $ziplink = "" . $lang['autoupdate_tableau_uptodate'] . "";
+ echo "" . $ziplink . "";
+ } else {
+ echo "Aucune";
+ }
}
- echo "" . $ziplink . "";
echo " | \n";
- }
+ if (mod_get_option("MAJ_BETA") == 1) {
+ echo "\t\t";
+ if (isset($cur_version['beta'])) {
+ $ziplink = "" . $cur_version['beta'] . "";
+ } else {
+ $ziplink = "-";
+ }
+ echo "" . $ziplink . "";
+ echo " | \n";
+ }
- echo "\t\t";
- if (isset($repo_details['owner'])) {
- $trackerlink = "" . $lang['autoupdate_tableau_buglink'] . "";
- echo "" . $trackerlink . "";
+ echo "\t\t | ";
+ if (isset($repo_details['owner'])) {
+ $trackerlink = "" . $lang['autoupdate_tableau_buglink'] . "";
+ echo "" . $trackerlink . "";
+ }
+ echo " | \n";
}
- echo "\n";
}
+ echo "\t \n";
}
+ } else {
+ echo "\t\n";
+ echo "\t\tAutoupdate | \n";
+ echo "\t\tOGSteam | \n";
+ echo "\t\t" . versionmod() . " | \n";
+ echo "\t\t" . $mylastVersion . " | \n";
+ $ziplink = "" . $lang['autoupdate_tableau_uptodate'] . "";
+ echo "\t\t" . $ziplink . " | \n";
+ echo "\t\t - | \n";
+ echo "\t\t - | \n";
echo "\t \n";
}
@@ -176,7 +192,8 @@
|
-
+ |
+ = $lang['autoupdate_tableau_pageadmin'] ?>
|
|