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

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
 * Gestion des votes sur les produits
27
 */
28
29
/**
30
 * Class VotedataHandler
31
 */
32
class VotedataHandler extends OledrionPersistableObjectHandler
33
{
34
    /**
35
     * VotedataHandler constructor.
36
     * @param \XoopsDatabase|null $db
37
     */
38
    public function __construct(\XoopsDatabase $db = null)
39
    {
40
        if (null === $db) {
41
            $db = \XoopsDatabaseFactory::getDatabaseConnection();
42
        }
43
        //                                Table                   Classe                             Id
44
        parent::__construct($db, 'oledrion_votedata', Votedata::class, 'vote_ratingid');
45
    }
46
47
    /**
48
     * Renvoie le nombre total de votes pour un produit ainsi que la sommes des votes
49
     *
50
     * @param int $product_id Identifiant du produit
51
     * @param int $totalVotes Variable passée par référence et devant contenir le nombre total de votes du produit
52
     * @param int $sumRating  Variable passée par référence et devant contenir le cumul des votes
53
     * @return int Rien
54
     */
55
    public function getCountRecordSumRating($product_id, &$totalVotes, &$sumRating)
56
    {
57
        $sql    = 'SELECT count( * ) AS cpt, sum( vote_rating ) AS sum_rating FROM ' . $this->table . ' WHERE vote_product_id = ' . (int)$product_id;
58
        $result = $this->db->query($sql);
59
        if (!$result) {
60
            return 0;
61
        }
62
63
        $myrow      = $this->db->fetchArray($result);
64
        $totalVotes = $myrow['cpt'];
65
        $sumRating  = $myrow['sum_rating'];
66
    }
67
68
    /**
69
     * Returns the (x) last votes
70
     *
71
     * @param int $start Starting position
72
     * @param int $limit count of items to return
73
     * @return array   Array of votedata objects
74
     */
75
    public function getLastVotes($start = 0, $limit = 0)
76
    {
77
        $tbl_datas = [];
0 ignored issues
show
The assignment to $tbl_datas is dead and can be removed.
Loading history...
78
        $criteria  = new \Criteria('vote_ratingid', 0, '<>');
79
        $criteria->setLimit($limit);
80
        $criteria->setStart($start);
81
        $criteria->setSort('vote_ratingtimestamp');
82
        $criteria->setOrder('DESC');
83
        $tbl_datas = $this->getObjects($criteria, true);
84
85
        return $tbl_datas;
86
    }
87
88
    /**
89
     * Suppression des votes d'un produit
90
     *
91
     * @param int $vote_product_id L'identifiant du produit
92
     * @return bool résultat de la suppression
93
     */
94
    public function deleteProductRatings($vote_product_id)
95
    {
96
        $criteria = new \Criteria('vote_product_id', $vote_product_id, '=');
97
98
        return $this->deleteAll($criteria);
99
    }
100
101
    /**
102
     * Indique si un utilisateur a déjà voté pour un produit
103
     *
104
     * @param int $vote_uid        L'identifiant de l'utilisateur
105
     * @param int $vote_product_id Le numéro du produit
106
     * @return bool True s'il a déjà voté sinon False
107
     */
108
    public function hasUserAlreadyVoted($vote_uid, $vote_product_id)
109
    {
110
        if (0 == $vote_uid) {
111
            $vote_uid = Oledrion\Utility::getCurrentUserID();
112
        }
113
        $criteria = new \CriteriaCompo();
114
        $criteria->add(new \Criteria('vote_product_id', $vote_product_id, '='));
115
        $criteria->add(new \Criteria('vote_uid', $vote_uid, '='));
116
        $count = $this->getCount($criteria);
117
118
        return $count > 0;
119
    }
120
121
    /**
122
     * Indique si un utilisateur anonyme a déjà voté (d'après son adresse IP)
123
     *
124
     * @param  string $ip              L'adresse IP
125
     * @param int     $vote_product_id Ld'identifiant du produit
126
     * @return bool
127
     */
128
    public function hasAnonymousAlreadyVoted($ip = '', $vote_product_id = 0)
129
    {
130
        if ('' === $ip) {
131
            $ip = Oledrion\Utility::IP();
132
        }
133
        $anonwaitdays = 1;
134
        $yesterday    = (time() - (86400 * $anonwaitdays));
135
        $criteria     = new \CriteriaCompo();
136
        $criteria->add(new \Criteria('vote_product_id', $vote_product_id, '='));
137
        $criteria->add(new \Criteria('vote_uid', 0, '='));
138
        $criteria->add(new \Criteria('vote_ratinghostname', $ip, '='));
139
        $criteria->add(new \Criteria('vote_ratingtimestamp', $yesterday, '>'));
140
        $count = $this->getCount($criteria);
141
142
        return $count > 0;
143
    }
144
145
    /**
146
     * Crée un vote pour un produit
147
     *
148
     * @param int $vote_product_id L'identifiant du produit
149
     * @param int $vote_uid        L'identifiant de l'utilisateur
150
     * @param int $vote_rating     Le vote
151
     * @return bool résultat de la création du vote
152
     */
153
    public function createRating($vote_product_id, $vote_uid, $vote_rating)
154
    {
155
        $product = $this->create(true);
156
        $product->setVar('vote_product_id', $vote_product_id);
157
        $product->setVar('vote_uid', $vote_uid);
158
        $product->setVar('vote_rating', $vote_rating);
159
        $product->setVar('vote_ratinghostname', Oledrion\Utility::IP());
160
        $product->setVar('vote_ratingtimestamp', time());
161
162
        return $this->insert($product);
163
    }
164
}
165