Issues (608)

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/PersistentCartHandler.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace XoopsModules\Oledrion;
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
 * oledrion
17
 *
18
 * @copyright   {@link https://xoops.org/ XOOPS Project}
19
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
20
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
21
 */
22
23
use XoopsModules\Oledrion;
24
25
/**
26
 * Panier persistant
27
 *
28
 * Lorque l'option correspondante dans le module est activée, tout produit rajouté dans le panier est
29
 * enregistré en base de données (à condition que l'utilisateur soit connecté).
30
 * Si l'utilisateur quitte le site et revient plus tard, cela permet de recharger son panier.
31
 */
32
33
/**
34
 * Class PersistentCartHandler
35
 */
36
class PersistentCartHandler extends OledrionPersistableObjectHandler
37
{
38
    /**
39
     * PersistentCartHandler constructor.
40
     * @param \XoopsDatabase|null $db
41
     */
42
    public function __construct(\XoopsDatabase $db = null)
43
    {
44
        //                          Table                     Classe                        Id
45
        parent::__construct($db, 'oledrion_persistent_cart', PersistentCart::class, 'persistent_id');
0 ignored issues
show
It seems like $db can also be of type null; however, parameter $db of XoopsModules\Oledrion\Ol...tHandler::__construct() does only seem to accept XoopsDatabase, 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

45
        parent::__construct(/** @scrutinizer ignore-type */ $db, 'oledrion_persistent_cart', PersistentCart::class, 'persistent_id');
Loading history...
46
    }
47
48
    /**
49
     * Supprime un produit des paniers enregistrés
50
     *
51
     * @param  mixed $persistent_product_id L'ID du produit à supprimer ou un tableau d'identifiants à supprimer
52
     * @return bool
53
     */
54
    public function deleteProductForAllCarts($persistent_product_id)
55
    {
56
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
57
            return true;
58
        }
59
        if (is_array($persistent_product_id)) {
60
            $criteria = new \Criteria('persistent_product_id', '(' . implode(',', $persistent_product_id) . ')', 'IN');
61
        } else {
62
            $criteria = new \Criteria('persistent_product_id', $persistent_product_id, '=');
63
        }
64
65
        return $this->deleteAll($criteria);
66
    }
67
68
    /**
69
     * Purge des produits d'un utilisateur
70
     *
71
     * @param int $persistent_uid L'identifiant de l'utilisateur
72
     * @return bool Le résultat de la suppression
73
     */
74
    public function deleteAllUserProducts($persistent_uid = 0)
75
    {
76
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
77
            return true;
78
        }
79
        $persistent_uid = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
80
81
        $criteria = new \Criteria('persistent_uid', $persistent_uid, '=');
82
83
        return $this->deleteAll($criteria);
84
    }
85
86
    /**
87
     * Supprime UN produit d'un utilisateur
88
     *
89
     * @param int $persistent_product_id L'identifiant du produit
90
     * @param int $persistent_uid        L'identifiant de l'utilisateur
91
     * @return bool Le résultat de la suppression
92
     */
93
    public function deleteUserProduct($persistent_product_id, $persistent_uid = 0)
94
    {
95
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
96
            return true;
97
        }
98
        $persistent_uid = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
99
        $criteria       = new \CriteriaCompo();
100
        $criteria->add(new \Criteria('persistent_uid', $persistent_uid, '='));
101
        $criteria->add(new \Criteria('persistent_product_id', $persistent_product_id, '='));
102
103
        return $this->deleteAll($criteria);
104
    }
105
106
    /**
107
     * Ajoute un produit au panier d'un utilisateur
108
     *
109
     * @param int $persistent_product_id L'ID du produit
110
     * @param int $persistent_qty        La quantité de produits
111
     * @param int $persistent_uid        L'ID de l'utilisateur
112
     * @return bool Le résultat de l'ajout du produit
113
     */
114
    public function addUserProduct($persistent_product_id, $persistent_qty, $persistent_uid = 0)
115
    {
116
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
117
            return true;
118
        }
119
        $persistent_uid  = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
120
        $persistent_cart = $this->create(true);
121
        $persistent_cart->setVar('persistent_product_id', $persistent_product_id);
122
        $persistent_cart->setVar('persistent_uid', $persistent_uid);
123
        $persistent_cart->setVar('persistent_date', time());
124
        $persistent_cart->setVar('persistent_qty', $persistent_qty);
125
126
        return $this->insert($persistent_cart, true);
127
    }
128
129
    /**
130
     * Mise à jour de la quantité de produit d'un utilisateur
131
     *
132
     * @param int $persistent_product_id L'identifiant du produit
133
     * @param int $persistent_qty        La quantité de produit
134
     * @param int $persistent_uid        L'ID de l'utilisateur
135
     * @return bool Le résultat de la mise à jour
136
     */
137
    public function updateUserProductQuantity($persistent_product_id, $persistent_qty, $persistent_uid = 0)
138
    {
139
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
140
            return true;
141
        }
142
        $persistent_uid = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
143
        $criteria       = new \CriteriaCompo();
144
        $criteria->add(new \Criteria('persistent_uid', $persistent_uid, '='));
145
        $criteria->add(new \Criteria('persistent_product_id', $persistent_product_id, '='));
146
147
        return $this->updateAll('persistent_qty', $persistent_qty, $criteria, true);
148
    }
149
150
    /**
151
     * Indique s'il existe un panier pour un utilisateur
152
     *
153
     * @param int $persistent_uid L'id de l'utilisateur
154
     * @return bool
155
     */
156
    public function isCartExists($persistent_uid = 0)
157
    {
158
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
159
            return false;
160
        }
161
        $persistent_uid = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
162
        $criteria       = new \Criteria('persistent_uid', $persistent_uid, '=');
163
164
        return (bool)$this->getCount($criteria);
165
    }
166
167
    /**
168
     * Retourne les produits d'un utilisateur
169
     *
170
     * @param int $persistent_uid L'ID de l'utilisateur
171
     * @return array|bool   Tableaux d'objets de type PersistentCart
172
     */
173
    public function getUserProducts($persistent_uid = 0)
174
    {
175
        if (0 == Oledrion\Utility::getModuleOption('persistent_cart')) {
176
            return false;
177
        }
178
        $persistent_uid = 0 == $persistent_uid ? Oledrion\Utility::getCurrentUserID() : $persistent_uid;
179
        $criteria       = new \Criteria('persistent_uid', $persistent_uid, '=');
180
181
        return $this->getObjects($criteria);
182
    }
183
}
184