Skip to content

Commit

Permalink
Force AutoUpdate Update
Browse files Browse the repository at this point in the history
  • Loading branch information
darknoon29 committed Apr 19, 2023
1 parent 4ad3731 commit b45a0b2
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 110 deletions.
31 changes: 21 additions & 10 deletions core/mod_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autoupdate
3.2.0
3.2.1
autoupdate,AutoUpdate,autoupdate,autoupdate,autoupdate.php,1,1
3.3.7
215 changes: 116 additions & 99 deletions view/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(), ">");
?>

<div align="center"><?php echo $lang['autoupdate_tableau_info']; ?></div>
<br />
<table width='60%'>
<tr>
<td class='c' colspan='100'><?php echo $lang['autoupdate_tableau_toolinstall']; ?></td>
</tr>
<tr>
<td class='c'><?php echo $lang['autoupdate_tableau_nametool']; ?></td>
<td class='c'><?php echo $lang['autoupdate_tableau_authtool']; ?></td>
<td class='c' width="50"><?php echo $lang['autoupdate_tableau_version']; ?></td>
<td class='c' width="50"><?php echo $lang['autoupdate_tableau_versionSVN']; ?></td>
<?php if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
echo '<td class=\'c\' width = "100">' . $lang['autoupdate_tableau_action'] . '</td>';
}
if (mod_get_option("MAJ_BETA") == 1) {
echo "<td class='c' width = '50'>";
echo $lang['autoupdate_tableau_versionBeta'] . "</td>";
}
?>
<td class='c' width="80"><?php echo $lang['autoupdate_tableau_bug']; ?></td>
</tr>
<tr>
<th>OGSpy</th>
<th>OGSteam</th>
<th>
<?php
echo $server_config["version"] . "</th>";
$cur_version = getRepositoryVersion('ogspy');
if (!is_array($cur_version) || $cur_version == '-1') {
echo "\t\t<th>" . $lang['autoupdate_tableau_norefered'] . "</th>\n";
$cur_version = 0;
} else {
echo "\t\t<th>" . $cur_version['release'] . "</th>\n";
}
echo "<th>";
if (version_compare($cur_version['release'], $server_config["version"], ">")) {
$ziplink = "<a href='index.php?action=autoupdate&sub=tool_upgrade&tool=ogspy&tag=release'>" . $lang['autoupdate_tableau_uptodate'] . "</a>";
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
} else {
echo "Aucune";
<table width='80%'>
<?php if (!$selfUpdateRequired) { ?>
<tr>
<td class='c' colspan='100'><?php echo $lang['autoupdate_tableau_toolinstall']; ?></td>
</tr>
<tr>
<td class='c'><?php echo $lang['autoupdate_tableau_nametool']; ?></td>
<td class='c'><?php echo $lang['autoupdate_tableau_authtool']; ?></td>
<td class='c' width="50"><?php echo $lang['autoupdate_tableau_version']; ?></td>
<td class='c' width="50"><?php echo $lang['autoupdate_tableau_versionSVN']; ?></td>
<?php if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
echo '<td class=\'c\' width = "100">' . $lang['autoupdate_tableau_action'] . '</td>';
}
echo "</th>";
if (mod_get_option("MAJ_BETA") == 1) {
echo "<td class='c' width = '50'>";
echo $lang['autoupdate_tableau_versionBeta'] . "</td>";
}
?>
<td class='c' width="80"><?php echo $lang['autoupdate_tableau_bug']; ?></td>
</tr>
<tr>
<th>OGSpy</th>
<th>OGSteam</th>
<th>
<?php
echo $server_config["version"] . "</th>";
$cur_version = getRepositoryVersion('ogspy');
if (!is_array($cur_version) || $cur_version == '-1') {
echo "\t\t<th>" . $lang['autoupdate_tableau_norefered'] . "</th>\n";
$cur_version = 0;
} else {
echo "\t\t<th>" . $cur_version['release'] . "</th>\n";
}
echo "<th>";
if (isset($cur_version['beta'])) {
$ziplink = "<a href='index.php?action=autoupdate&sub=tool_upgrade&tool=ogspy&tag=beta'>" . $cur_version['beta'] . "</a>";
if (version_compare($cur_version['release'], $server_config["version"], ">")) {
$ziplink = "<a href='index.php?action=autoupdate&sub=tool_upgrade&tool=ogspy&tag=release'>" . $lang['autoupdate_tableau_uptodate'] . "</a>";
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
} else {
$ziplink = "-";
echo "Aucune";
}
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
echo "</th>";
}
echo "<th>";
$trackerlink = "<a href='https://github.com/OGSteam/ogspy/issues' target='_blank' rel='noopener'>" . $lang['autoupdate_tableau_buglink'] . "</a>";
echo "<span style=\"color: lime; \">" . $trackerlink . "</span>";
echo "</th>";
?>
</tr>
<tr>
<td class='c' colspan='100'></td>
</tr>
if (mod_get_option("MAJ_BETA") == 1) {
echo "<th>";
if (isset($cur_version['beta'])) {
$ziplink = "<a href='index.php?action=autoupdate&sub=tool_upgrade&tool=ogspy&tag=beta'>" . $cur_version['beta'] . "</a>";
} else {
$ziplink = "-";
}
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
echo "</th>";
}
echo "<th>";
$trackerlink = "<a href='https://github.com/OGSteam/ogspy/issues' target='_blank' rel='noopener'>" . $lang['autoupdate_tableau_buglink'] . "</a>";
echo "<span style=\"color: lime; \">" . $trackerlink . "</span>";
echo "</th>";
?>
</tr>
<tr>
<td class='c' colspan='100'></td>
</tr>
<?php } //Fin if (!$selfUpdateRequired)
?>
<tr>
<td class='c' colspan='100'><?php echo $lang['autoupdate_tableau_modinstall']; ?></td>
</tr>
Expand All @@ -108,62 +112,74 @@
</tr>
<?php

//
for ($i = 0; $i < count($installed_mods); $i++) {
if (substr($installed_mods[$i]['name'], 0, 5) != "Group") {
$repo_details = getRepositoryDetails($installed_mods[$i]['root']);
echo "\t<tr>\n";
echo "\t\t<th>" . $installed_mods[$i]['name'] . "</th>\n";
if (isset($repo_details['owner'])) {
echo "\t\t<th>" . $repo_details['owner'] . "</th>\n";
} else {
echo "\t\t<th>Non OGSteam</th>\n";
}

echo "\t\t<th>" . $installed_mods[$i]['version'] . "</th>\n";
if (!$selfUpdateRequired) {
foreach ($installed_mods as $installedMod) {
if (substr($installedMod['name'], 0, 5) != "Group") {
$repo_details = getRepositoryDetails($installedMod['root']);
echo "\t<tr>\n";
echo "\t\t<th>" . $installedMod['name'] . "</th>\n";
if (isset($repo_details['owner'])) {
echo "\t\t<th>" . $repo_details['owner'] . "</th>\n";
} else {
echo "\t\t<th>Non OGSteam</th>\n";
}

$cur_modroot = $installed_mods[$i]['root'];
$cur_version = getRepositoryVersion($cur_modroot);
echo "\t\t<th>" . $installedMod['version'] . "</th>\n";

if (!is_array($cur_version) || $cur_version == '-1') {
echo "\t\t<th>" . $lang['autoupdate_tableau_norefered'] . "</th>\n";
$cur_version = 0;
} else {
echo "\t\t<th>" . $cur_version['release'] . "</th>\n";
}
$cur_modroot = $installedMod['root'];
$cur_version = getRepositoryVersion($cur_modroot);

if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
echo "\t\t<th>";
if (!is_writeable("./mod/" . $installed_mods[$i]['root'] . "/")) {
echo "<a title='Pas de droit en écriture sur:./mod/" . $installed_mods[$i]['root'] . "'><span style=\"color: red; \">(RO)</span></a>";
if (!is_array($cur_version) || $cur_version == '-1') {
echo "\t\t<th>" . $lang['autoupdate_tableau_norefered'] . "</th>\n";
$cur_version = 0;
} else {
if (version_compare($cur_version['release'], $installed_mods[$i]['version'], ">")) {
$ziplink = "<a href='index.php?action=autoupdate&sub=mod_upgrade&mod=" . $cur_modroot . "&tag=release'>" . $lang['autoupdate_tableau_uptodate'] . "</a>";
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
} else {
echo "Aucune";
}
echo "\t\t<th>" . $cur_version['release'] . "</th>\n";
}
echo "</th>\n";
if (mod_get_option("MAJ_BETA") == 1) {

if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
echo "\t\t<th>";
if (isset($cur_version['beta'])) {
$ziplink = "<a href='index.php?action=autoupdate&sub=mod_upgrade&mod=" . $cur_modroot . "&tag=beta'>" . $cur_version['beta'] . "</a>";
if (!is_writeable("./mod/" . $installedMod['root'] . "/")) {
echo "<a title='Pas de droit en écriture sur:./mod/" . $installedMod['root'] . "'><span style=\"color: red; \">(RO)</span></a>";
} else {
$ziplink = "-";
if (version_compare($cur_version['release'], $installedMod['version'], ">")) {
$ziplink = "<a href='index.php?action=autoupdate&sub=mod_upgrade&mod=" . $cur_modroot . "&tag=release'>" . $lang['autoupdate_tableau_uptodate'] . "</a>";
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
} else {
echo "Aucune";
}
}
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
echo "</th>\n";
}
if (mod_get_option("MAJ_BETA") == 1) {
echo "\t\t<th>";
if (isset($cur_version['beta'])) {
$ziplink = "<a href='index.php?action=autoupdate&sub=mod_upgrade&mod=" . $cur_modroot . "&tag=beta'>" . $cur_version['beta'] . "</a>";
} else {
$ziplink = "-";
}
echo "<span style=\"color: lime; \">" . $ziplink . "</span>";
echo "</th>\n";
}

echo "\t\t<th>";
if (isset($repo_details['owner'])) {
$trackerlink = "<a href='https://github.com/" . $repo_details['owner'] . "/mod-" . $cur_modroot . "/issues' target='_blank'>" . $lang['autoupdate_tableau_buglink'] . "</a>";
echo "<span style=\"color: lime; \">" . $trackerlink . "</span>";
echo "\t\t<th>";
if (isset($repo_details['owner'])) {
$trackerlink = "<a href='https://github.com/" . $repo_details['owner'] . "/mod-" . $cur_modroot . "/issues' target='_blank'>" . $lang['autoupdate_tableau_buglink'] . "</a>";
echo "<span style=\"color: lime; \">" . $trackerlink . "</span>";
}
echo "</th>\n";
}
echo "</th>\n";
}
echo "\t</tr>\n";
}
} else {
echo "\t<tr>\n";
echo "\t\t<th>Autoupdate</th>\n";
echo "\t\t<th>OGSteam</th>\n";
echo "\t\t<th>" . versionmod() . "</th>\n";
echo "\t\t<th>" . $mylastVersion . "</th>\n";
$ziplink = "<a href='index.php?action=autoupdate&sub=mod_upgrade&mod=autoupdate&tag=release'>" . $lang['autoupdate_tableau_uptodate'] . "</a>";
echo "\t\t<th><span style=\"color: lime; \">" . $ziplink . "</span></th>\n";
echo "\t\t<th><span style=\"color: lime; \"> - </span></th>\n";
echo "\t\t<th><span style=\"color: lime; \"> - </span></th>\n";
echo "\t</tr>\n";
}

Expand All @@ -176,7 +192,8 @@
<td class="c" colspan="100"><?php echo $lang['autoupdate_tableau_link']; ?></td>
</tr>
<tr>
<th colspan="100"><a href="index.php?action=administration&subaction=mod"><?php echo $lang['autoupdate_tableau_pageadmin']; ?></a>
<th colspan="100">
<a href="index.php?action=administration&subaction=mod"><?= $lang['autoupdate_tableau_pageadmin'] ?></a>
</th>
</tr>
<tr>
Expand Down

0 comments on commit b45a0b2

Please sign in to comment.