Issues (292)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/Currency.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Adslight;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * @copyright   {@link https://xoops.org/ XOOPS Project}
17
 * @license     {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later}
18
 * @author      Hervé Thouzard (https://www.herve-thouzard.com/)
19
 */
20
21
/**
22
 * Gestion de la Currency
23
 */
24
class Currency
25
{
26
    protected $decimalsCount = 0;
27
    protected $thousandsSep;
28
    protected $decimalSep;
29
    protected $moneyFull;
30
    protected $moneyShort;
31
    protected $currencyPosition;
32
33
    /**
34
     * Currency constructor.
35
     */
36
    public function __construct()
37
    {
38
        $moduleDirName          = \basename(__DIR__);
39
        $helper                 = Helper::getHelper($moduleDirName); // Get the module's preferences
40
        $this->decimalsCount    = $helper->getConfig('decimals_count');
41
        $this->thousandsSep     = $helper->getConfig('thousands_sep');
42
        $this->decimalSep       = $helper->getConfig('decimal_sep');
43
        $this->moneyFull        = $helper->getConfig('money_full');
44
        $this->moneyShort       = $helper->getConfig('money_short');
45
        $this->currencyPosition = $helper->getConfig('currency_position');
46
        $this->thousandsSep     = \str_replace('[space]', ' ', $this->thousandsSep);
47
        $this->decimalSep       = \str_replace('[space]', ' ', $this->decimalSep);
48
    }
49
50
    /**
51
     * Access the only instance of this class
52
     *
53
     * @static
54
     * @staticvar   object
55
     */
56
    public static function getInstance(): object
57
    {
58
        static $instance;
59
        if (null === $instance) {
60
            $instance = new static();
61
        }
62
63
        return $instance;
64
    }
65
66
    /**
67
     * Returns an amount according to the currency's preferences (defined in the module's options)
68
     *
69
     * @param float|int $amount The amount to work on
70
     * @return string    The amount formated according to the currency
71
     */
72
    public function amountInCurrency($amount = 0): string
73
    {
74
        return \number_format($amount, $this->decimalsCount, $this->decimalSep, $this->thousandsSep);
0 ignored issues
show
It seems like $this->decimalsCount can also be of type null; however, parameter $decimals of number_format() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

74
        return \number_format($amount, /** @scrutinizer ignore-type */ $this->decimalsCount, $this->decimalSep, $this->thousandsSep);
Loading history...
75
    }
76
77
    /**
78
     * Format an amount for display according to module's preferences
79
     *
80
     * @param float  $originalAmount The amount to format
81
     * @param string $format         Format to use, 's' for Short and 'l' for Long
82
     * @return string The amount formated
83
     */
84
    public function amountForDisplay($originalAmount, $format = 's'): string
85
    {
86
        $amount = $this->amountInCurrency($originalAmount);
87
88
        $currencyLeft = $currencyRight = $currencyLeftShort = $currencyRightShort = '';
89
        if (1 === $this->currencyPosition) { // To the right
90
            $currencyRight      = '' . $this->moneyFull; // Long version
91
            $currencyRightShort = '' . $this->moneyShort; // Short version
92
        } else { // To the left
93
            $currencyLeft      = $this->moneyFull . ''; // Long version
94
            $currencyLeftShort = $this->moneyShort . ''; // Short version
95
        }
96
        if ('s' !== $format) {
97
            return $currencyLeft . $amount . $currencyRight;
98
        }
99
100
        return $currencyLeftShort . $amount . $currencyRightShort;
101
    }
102
}
103