Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v5.0.0
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
Expand Down
12 changes: 11 additions & 1 deletion autoupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<?= $lang['autoupdate_autoupdate_down'] ?>
</a>
</div>
<?php if ($user_data["user_admin"] == 1) { ?>
<?php if ($user_data["admin"] == 1) { ?>
<div class="nav-page-menu-item">
<a class="nav-page-menu-link" href='index.php?action=autoupdate&sub=admin'>
<?= $lang['autoupdate_autoupdate_admin'] ?>
Expand Down Expand Up @@ -99,3 +99,13 @@
include('view/admin.php');
break;
}
?>
<div style="text-align: center">
AutoUpdate<br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?><br>
<a href="https://github.com/ogsteam/mod-autoupdate" target="_blank" rel="noopener"><img src="./mod/autoupdate/img/GitHub-Mark-Light-32px.png" alt="Github"/></a>
</div>


<?php
require_once("views/page_tail.php");
61 changes: 49 additions & 12 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
die("Hacking attempt");
}

//require_once("mod/autoupdate/mod_list.php");

/*On récupère la liste des mods installés*/

/**
* @return mixed
* Returns an array of installed mods with their name, root, and version.
* Each entry in the array is an associative array with keys 'name', 'root', and 'version'.
* @return array
*/
function get_installed_mod_list()
{
Expand All @@ -36,8 +34,9 @@ function get_installed_mod_list()
}
return $installed_mods;
}

/**
*Récupère la version du mod
*
*/
function versionmod()
{
Expand All @@ -54,7 +53,7 @@ function versionmod()
*/
function upgrade_ogspy_mod($mod)
{
global $db, $lang;
global $db, $lang, $log;
// On vérifie si le mod est déjà installé
$check = "SELECT title FROM " . TABLE_MOD . " WHERE root='" . $mod . "'";
$query_check = $db->sql_query($check);
Expand All @@ -65,9 +64,19 @@ function upgrade_ogspy_mod($mod)
if (file_exists("mod/" . $mod . "/update.php")) {
require_once("mod/" . $mod . "/update.php");
generate_mod_cache();
log_("mod_update", $mod);
$log->info("Module update completed successfully", [
'module' => $mod,
'action' => 'mod_update',
'update_file' => "mod/" . $mod . "/update.php"
]);
$maj = $lang['autoupdate_tableau_uptodateok'] . "<br>\n<br>\n";
} else {
$log->warning("Module update file missing", [
'module' => $mod,
'action' => 'mod_update_failed',
'missing_file' => "mod/" . $mod . "/update.php",
'message' => "Update file update.php not found for module {$mod}"
]);
$maj = $lang['autoupdate_tableau_uptodateoff'] . "<br>\n<br>\n";
}
return $maj;
Expand All @@ -76,9 +85,19 @@ function upgrade_ogspy_mod($mod)
if (file_exists("mod/" . $mod . "/install.php")) {
require_once("mod/" . $mod . "/install.php");
generate_all_cache();
log_("mod_install", $mod);
$log->info("Module installation completed successfully", [
'module' => $mod,
'action' => 'mod_install',
'install_file' => "mod/" . $mod . "/install.php"
]);
$maj = $lang['autoupdate_tableau_installok'] . "<br><br>";
} else {
$log->warning("Module installation file missing", [
'module' => $mod,
'action' => 'mod_install_failed',
'missing_file' => "mod/" . $mod . "/install.php",
'message' => "Install file install.php not found for module {$mod}"
]);
$maj = $lang['autoupdate_tableau_installoff'] . "<br><br>";
}
return $maj;
Expand Down Expand Up @@ -171,13 +190,19 @@ function tableau($tableau, string $type = "maj")
*/
function check_ogspy_version_bcopy($mod_folder)
{
global $server_config;
global $server_config, $log;
// verification sur le fichier .txt
$filename = 'mod/autoupdate/tmp/' . $mod_folder . '/version.txt';

// On récupère les données du fichier version.txt

if (!file_exists($filename)) {
$log->error("Module version.txt file missing", [
'module' => $mod_folder,
'expected_file' => $filename,
'action' => 'check_ogspy_version_bcopy',
'message' => "Version file version.txt not found in temporary directory for module {$mod_folder}"
]);
return false;
}
$file = file($filename);
Expand All @@ -187,11 +212,23 @@ function check_ogspy_version_bcopy($mod_folder)
if (isset($file[3])) {
$mod_required_ogspy = trim($file[3]);
if (version_compare($mod_required_ogspy, $server_config["version"]) > 0) {
log_("mod_erreur_txt_version", $mod_folder);
$log->error("Insufficient OGSpy version for module", [
'module' => $mod_folder,
'required_version' => $mod_required_ogspy,
'current_version' => $server_config["version"],
'action' => 'check_ogspy_version_bcopy',
'message' => "Module {$mod_folder} requires OGSpy version {$mod_required_ogspy} minimum, but current version is {$server_config['version']}"
]);
return false;
}
} else {
log_("mod_erreur_txt_warning", $mod_folder);
$log->warning("Invalid or incomplete module version.txt file", [
'module' => $mod_folder,
'file' => $filename,
'issue' => 'missing_line_3_version',
'action' => 'check_ogspy_version_bcopy',
'message' => "Version.txt file for module {$mod_folder} does not contain required OGSpy minimum version on line 3"
]);
return false;
}
return true;
Expand Down
14 changes: 7 additions & 7 deletions core/mod_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function getRepositoryDetails($repoName)
*/
function getRepositoryVersion($Reponame)
{
global $lang;
global $lang, $log;

$version = array('release' => '' , 'beta' => '');

Expand Down Expand Up @@ -140,11 +140,11 @@ function getRepositoryVersion($Reponame)
}
return $version; // Récupération du Tag de version
} else {
log_('mod', $lang['autoupdate_tableau_error4'] . ' ' . $Reponame);
$log->error($lang['autoupdate_tableau_error4'] . ' ' . $Reponame);
return "-1";
}
} else {
log_('mod', $lang['autoupdate_tableau_error1'] . $Reponame);
$log->error($lang['autoupdate_tableau_error1'] . $Reponame);
mod_del_option('LAST_MOD_UPDATE-' . $Reponame);
return "-1";
}
Expand All @@ -158,7 +158,7 @@ function getRepositoryVersion($Reponame)
function github_Request($request)
{

global $lang;
global $lang, $log;
$userdefinedtoken = '';
$tokensource = '';

Expand All @@ -175,12 +175,12 @@ function github_Request($request)
}

if (strlen($userdefinedtoken) !== 40) {
log_('mod', $lang['autoupdate_tableau_errortoken'] . ' ' . $request);
$log->error($lang['autoupdate_tableau_errortoken'] . ' ' . $request);
$userdefinedtoken = '';
$tokensource = 'none';
}

//log_('debug', "Autoupdate Token source $tokensource");
//$log->debug("Autoupdate Token source $tokensource");

$opts = [
'http' => [
Expand All @@ -204,7 +204,7 @@ function github_Request($request)
$data = @file_get_contents($request, false, $context);

if ($data === false) {
log_('mod', "[ERROR_github_Request] Unable to get: " . $request);
$log->error("[ERROR_github_Request] Unable to get: " . $request);
mod_set_option('GITHUBTOKEN', 'UnauthorizedToken', 'autoupdate');
echo ('Error Data, Please Retry with a new Token (See Settings)');
exit();
Expand Down
4 changes: 2 additions & 2 deletions core/mod_upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$pub_confirmed = "no";
}

if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {

$modroot = filter_var($pub_mod);

Expand Down Expand Up @@ -109,7 +109,7 @@
}
?>
<div style="text-align: center">
AutoUpdate <?= $lang['autoupdate_version'] . ' ' . versionmod(); ?><br>
AutoUpdate<br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?>
</div>
<?php
Expand Down
7 changes: 3 additions & 4 deletions core/tool_upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/
$zip = new ZipArchive;

require_once("views/page_header.php");
require("views/page_header.php");

if (!isset($pub_confirmed)) {
$pub_confirmed = "no";
}

if ($user_data['user_admin'] == 1) {
if ($user_data['admin'] == 1) {

$toolroot = filter_var($pub_tool);
$tool_tag = filter_var($pub_tag);
Expand Down Expand Up @@ -142,10 +142,9 @@
}
?>
<div style="text-align: center">
AutoUpdate <?= $lang['autoupdate_version'] . ' ' . versionmod(); ?><br>
AutoUpdate<br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?>
</div>
<?php
require_once("views/page_tail.php");
?>

1 change: 0 additions & 1 deletion tmp/.htaccess

This file was deleted.

4 changes: 2 additions & 2 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autoupdate
3.2.3
3.2.4
autoupdate,AutoUpdate,autoupdate,autoupdate,autoupdate.php,1,1
3.3.7
4.0.0-dev
8 changes: 0 additions & 8 deletions view/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,4 @@
</table>
</form>

<div style="text-align: center">
AutoUpdate <?= $lang['autoupdate_version'] . ' ' . versionmod(); ?><br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?><br>
<a href="https://github.com/ogsteam/mod-autoupdate" target="_blank" rel="noopener"><img src="./mod/autoupdate/img/GitHub-Mark-Light-32px.png" alt="Github"/></a>
</div>


<?php
require_once("views/page_tail.php");
12 changes: 2 additions & 10 deletions view/down.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
require_once("views/page_header.php");

if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {

// Récupérer la liste des modules installés
$sql = "SELECT title,root,version from " . TABLE_MOD;
Expand Down Expand Up @@ -47,7 +47,7 @@
<tr>
<th><?php echo $lang['autoupdate_tableau_namemod']; ?></th>
<th><?php echo $lang['autoupdate_tableau_descmod']; ?></th>
<?php if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
<?php if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {
echo '<th>' . $lang['autoupdate_tableau_action'] . '</th>';
}
?>
Expand Down Expand Up @@ -99,11 +99,3 @@
die($lang['autoupdate_MaJ_rights']);
}
?>
<br>
<div style="text-align: center">
AutoUpdate <?= $lang['autoupdate_version'] . ' ' . versionmod(); ?><br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?>
</div>
<?php
require_once("views/page_tail.php");
?>
16 changes: 4 additions & 12 deletions view/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<th><?php echo $lang['autoupdate_tableau_authtool']; ?></th>
<th><?php echo $lang['autoupdate_tableau_version']; ?></th>
<th><?php echo $lang['autoupdate_tableau_versionSVN']; ?></th>
<?php if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
<?php if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {
echo '<th>' . $lang['autoupdate_tableau_action'] . '</th>';
}
if (mod_get_option("MAJ_BETA") == 1) {
Expand Down Expand Up @@ -103,7 +103,7 @@
<th><?php echo $lang['autoupdate_tableau_authormod']; ?></th>
<th><?php echo $lang['autoupdate_tableau_version']; ?></th>
<th><?php echo $lang['autoupdate_tableau_versionSVN']; ?></th>
<?php if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
<?php if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {
echo '<th>' . $lang['autoupdate_tableau_action'] . '</th>';
}
?>
Expand Down Expand Up @@ -140,7 +140,7 @@
echo "\t\t<td>" . $cur_version['release'] . "</td>\n";
}

if ($user_data['user_admin'] == 1 || $user_data['user_coadmin'] == 1) {
if ($user_data['admin'] == 1 || $user_data['coadmin'] == 1) {
echo "\t\t<td>";
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>";
Expand Down Expand Up @@ -180,7 +180,7 @@
</table>
<?php

if ($user_data["user_admin"] == 1 || $user_data['user_coadmin'] == 1) {
if ($user_data["admin"] == 1 || $user_data['coadmin'] == 1) {
// Proposer le lien vers le panneau d'administration des modules

?>
Expand All @@ -204,11 +204,3 @@
}
?>
</table>
<br>
<div style="text-align: center">
AutoUpdate <?= $lang['autoupdate_version'] . ' ' . versionmod(); ?><br>
<?= $lang['autoupdate_createdby'] . ' Jibus ' . $lang['autoupdate_and'] . ' Bartheleway' ?>
</div>
<?php
require_once("views/page_tail.php");
?>
Loading