Skip to content

Commit

Permalink
Merge pull request #417 from OGSteam/bugfix/sonarcloud
Browse files Browse the repository at this point in the history
Corrections Sonar
  • Loading branch information
darknoon29 committed Aug 15, 2024
2 parents 454ad46 + 302dd31 commit 656dafd
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:latest

LABEL VERSION ="0.3"
LABEL VERSION="0.3"
LABEL DESCRIPTION="APACHE PHP OGSPY"
LABEL MAINTENER="darknoon@darkcity.fr"

Expand Down Expand Up @@ -45,7 +45,7 @@ RUN chmod 755 /app/.docker/*.sh
WORKDIR /app/.docker/
RUN /app/.docker/configure.sh

# Add volumes for MySQL
# Add volumes for MySQL
VOLUME ["/etc/mysql", "/var/lib/mysql", "/app" ]

EXPOSE 80 3306
Expand Down
6 changes: 1 addition & 5 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@

//Language File
if (!isset($ui_lang)) { // Checks the ui_lang value from parameters file
if (isset($pub_lang)) {
$ui_lang = $pub_lang; //This value is used during installation
} else {
$ui_lang = "fr";
}
$ui_lang = $pub_lang ?? "fr";
//If no language is available in id.php file we take fr by default
}
require_once "lang/lang_main.php";
Expand Down
8 changes: 4 additions & 4 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ function init_mod_cache()
$filename = 'cache/cache_mod.php';

if (file_exists($filename)) {
include $filename;
require_once $filename;
// regeneration si besoin
if ((filemtime($filename) + $server_config['mod_cache']) < time()) {
generate_mod_cache();
}
} else {
generate_mod_cache();
if (file_exists($filename)) {
include $filename; // on reinjecte le fichier s'il existe'
require_once $filename;
}
}
}
Expand All @@ -501,15 +501,15 @@ function init_serverconfig()
$filename = 'cache/cache_config.php';

if (file_exists($filename)) {
include $filename;
require_once $filename;
// regeneration si besoin
if ((filemtime($filename) + $server_config['config_cache']) < time()) {
generate_config_cache();
}
} else {
generate_config_cache();
if (file_exists($filename)) {
include $filename; // on reinjecte le fichier s'il existe'
require_once $filename;
}
}
}
Expand Down
45 changes: 11 additions & 34 deletions includes/sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@


/**
* Stating an user Session
* Starting a user Session
* @param $user_ip
*/
function session_begin($user_ip)
function session_begin($user_ip): void
{
global $cookie_id, $server_config, $pub_toolbar_type;
$Sessions_Model = new Sessions_Model();
Expand All @@ -48,7 +48,7 @@ function session_begin($user_ip)
/**
* Gets the current session and creates it if the session for the current user does not exists
*/
function session()
function session(): void
{
global $user_ip, $cookie_id, $server_config;
global $_COOKIE;
Expand Down Expand Up @@ -94,7 +94,7 @@ function session()
* @param int $user_id The current user
* @param int $lastvisit Lastvisit timestamp
*/
function session_set_user_id($user_id, $lastvisit = 0)
function session_set_user_id($user_id, $lastvisit = 0): void
{
global $user_ip, $cookie_id, $server_config;
$Sessions_Model = new Sessions_Model();
Expand All @@ -110,48 +110,27 @@ function session_set_user_id($user_id, $lastvisit = 0)

/**
* Set the user_data array according to the user parameters in the database
* @param int $cookie_id The cookie id of the user
* @todo Y a comme un probleme dans cette fonction... ne semble pas prendre de parametres alors que la fonction precedente lui en donne un...
* @param string $cookie_id The cookie id of the user
*
*/
function session_set_user_data($cookie_id)
function session_set_user_data(string $cookie_id)
{
global $user_ip, $user_data, $user_auth, $user_token;

$user_data = (new Sessions_Model())->select_user_data_session($cookie_id, $user_ip);

if ($user_data == false) {
if (!$user_data) {
unset($user_data);
unset($user_auth);
unset($user_token);
}
}

/**
* Get the user token (list) for the current user
* @return mixed
*
*function session_set_user_tokens_data()
*{
* global $db, $user_data, $user_token;
*
* $request_tokens = "SELECT `name`,`token`,`expiration_date` FROM " . TABLE_USER_TOKEN . " WHERE `user_id` = " . $user_data["user_id"];
* $result_tokens = $db->sql_query($request_tokens);
*
* if ($db->sql_numrows($result_tokens) > 0) {
*
* $user_token = $db->sql_fetch_assoc($result_tokens);
* }
* else
* {
* $user_auth = user_get_auth($user_data["user_id"]);
* }
*}*/

/**
* Closing an user session
* Closing a user session
* @param boolean $user_id ID user session
*/
function session_close($user_id = false)
function session_close(bool $user_id = false): void
{
global $user_ip, $cookie_id, $server_config;

Expand Down Expand Up @@ -198,9 +177,7 @@ function session_whois_online()
$members[] = array("user" => $username, "time_start" => $online["session_start"], "time_lastactivity" => $time_lastactivity, "ip" => $session_ip, "ogs" => $online["session_ogs"]);
}
}
$online = array_merge($members, $guests);

return $online;
return array_merge($members, $guests);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$php_start = microtime(true);

/**
* Tout les includes se font à partir de là
* Tous les includes se font à partir de là
*/
require_once "common.php";

Expand Down
37 changes: 15 additions & 22 deletions skin/OGSpy_skin/formateredesign.css
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ body {
header {
/* Non visible */
display: none;
/* si affichage visible
/* si affichage visible
a ajouter dans la grille principale
*/
grid-area: header;
Expand Down Expand Up @@ -957,7 +957,7 @@ footer#barre {
height: 30px;
background: linear-gradient(rgba(0, 0, 0,0.0), rgba(0, 0, 0, 0.8));
display: flex;


}

Expand Down Expand Up @@ -1112,13 +1112,6 @@ table.og-table thead tr td.og-legend {
text-align: center;
}








/*fin TABLE */


Expand Down Expand Up @@ -1208,7 +1201,7 @@ table.og-table thead tr td.og-legend {
border-radius: 4px;
padding: 2px 4px;
cursor: pointer;
margin: 2px 0px;
margin: 2px 0;

}

Expand Down Expand Up @@ -1425,15 +1418,15 @@ h2.page_about_h2 {
margin-right: 10%;
justify-content: center;


}
.card {
.card {
background-color: rgba(0,0,0,0.4);
flex: 0 0 200px;
margin: 10px 20px;
border: 2px solid #ccc;
padding: 5px;
}
}
.card img {
width: 100%;

Expand Down Expand Up @@ -1561,7 +1554,7 @@ table.og-table-galaxy tbody .tr-ishided .tdcontent a {

/* todo ogame-status-x */
/* Different status dans BDD*/
/*
/*
a
I
vI
Expand Down Expand Up @@ -1589,7 +1582,7 @@ io
color: var(--color-navpagemenu-link);
}
.ogspy-mod-footer {
position: fixed;
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
Expand Down Expand Up @@ -1642,22 +1635,22 @@ io
/*pied de page */
footer#barre .notviewlittle{
display: none;

}


/* fin pied de page */


/* page about */
.cards {
margin-left: 10px;
margin-right: 10px;
}
.card {
.card {
flex: 0 0 300px;
margin: 10px 10px;
}
}

/* fin page about */

Expand Down Expand Up @@ -1759,4 +1752,4 @@ footer#barre .notviewlittle{



}
}
4 changes: 2 additions & 2 deletions views/galaxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
//si autorisé server_show_positionhided doit etre a 1 !!!!!!!!!!!
//todo info a communiquer avec release
if ($tInfosGroups["server_show_positionhided"] == 1) {
if (($server_config["portee_missil"] != "0" && $server_config["portee_missil"] != "")) {
if ($server_config["portee_missil"] != "0" && $server_config["portee_missil"] != "") {
$missil = galaxy_portee_missiles($galaxy, $system);
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@
<?php $string_delfavorites = "alert('" . $lang['GALAXY_NO_FAVORITES_MESSAGE'] . "')"; ?>
<?php endif; ?>

<input class="og-button og-button-success" type="button" value="<?=($lang['GALAXY_ADD_FAVORITES'] ?>" onclick="<?= $string_addfavorites ?>">
<input class="og-button og-button-success" type="button" value="<?= $lang['GALAXY_ADD_FAVORITES'] ?>" onclick="<?= $string_addfavorites ?>">
<input class="og-button og-button-danger" type="button" value="<?= $lang['GALAXY_REMOVE_FAVORITES'] ?>" onclick="<?= $string_delfavorites ?>">
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions views/page_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

use Ogsteam\Ogspy\Helper\ToolTip_Helper;
?>
<!DOCTYPE html>
<!doctype html>
<html lang="<?= $lang['HEAD_LANGUAGE']; ?>">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8">
<title><?php echo $server_config["servername"] . " - OGSpy " . $server_config["version"]; ?></title>
<link rel="stylesheet" type="text/css" href="./skin/OGSpy_skin/formateredesign.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
Expand Down

0 comments on commit 656dafd

Please sign in to comment.