This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PlaygroundGame\Mapper; |
||
4 | |||
5 | use PlaygroundGame\Mapper\AbstractMapper; |
||
6 | |||
7 | class Entry extends AbstractMapper |
||
8 | { |
||
9 | public function countByGame(\PlaygroundGame\Entity\Game $game) |
||
10 | { |
||
11 | $query = $this->em->createQuery('SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e WHERE e.game = :game'); |
||
12 | $query->setParameter('game', $game); |
||
13 | return $query->getSingleScalarResult(); |
||
14 | } |
||
15 | |||
16 | public function draw($game, $userClass, $total) |
||
0 ignored issues
–
show
|
|||
17 | { |
||
18 | $sql =' |
||
19 | SELECT |
||
20 | u.user_id uid, |
||
21 | u.username, |
||
22 | u.firstname, |
||
23 | u.lastname, |
||
24 | u.email, |
||
25 | u.optin_partner, |
||
26 | e.created_at ecreated_at, |
||
27 | e.updated_at eupdated_at, |
||
28 | e.* |
||
29 | FROM game_entry as e |
||
30 | INNER JOIN user AS u ON e.user_id = u.user_id |
||
31 | WHERE e.game_id = :game_id AND e.drawable = 1 |
||
32 | GROUP BY u.user_id |
||
33 | ORDER BY RAND() |
||
34 | LIMIT :total |
||
35 | '; |
||
36 | |||
37 | $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->em); |
||
38 | $rsm->addRootEntityFromClassMetadata( |
||
39 | '\PlaygroundGame\Entity\Entry', |
||
40 | 'e', |
||
41 | array('id' => 'id', 'created_at' => 'ecreated_at', 'updated_at' => 'eupdated_at') |
||
42 | ); |
||
43 | $query = $this->em->createNativeQuery($sql, $rsm); |
||
44 | $query->setParameter('game_id', $game->getId()); |
||
45 | $query->setParameter('total', $total); |
||
46 | |||
47 | return $query->getResult(); |
||
48 | } |
||
49 | |||
50 | public function queryByGame(\PlaygroundGame\Entity\Game $game) |
||
51 | { |
||
52 | $query = $this->em->createQuery('SELECT e FROM PlaygroundGame\Entity\Entry e WHERE e.game = :game'); |
||
53 | $query->setParameter('game', $game); |
||
54 | return $query; |
||
55 | } |
||
56 | |||
57 | public function findByGameId($game) |
||
58 | { |
||
59 | return $this->getEntityRepository()->findBy(array('game' => $game)); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get all the entries of the player except those offered as bonus |
||
64 | * |
||
65 | * @param unknown_type $game |
||
66 | * @param unknown_type $user |
||
67 | */ |
||
68 | View Code Duplication | public function findLastEntriesByUser($game, $user, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
69 | { |
||
70 | $query = $this->em->createQuery( |
||
71 | 'SELECT e.id FROM PlaygroundGame\Entity\Entry e |
||
72 | WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
73 | ); |
||
74 | $query->setParameter('user', $user); |
||
75 | $query->setParameter('game', $game); |
||
76 | $query->setParameter('date', $dateLimit); |
||
77 | |||
78 | $total = $query->getResult(); |
||
79 | |||
80 | return $total; |
||
81 | } |
||
82 | |||
83 | View Code Duplication | public function findLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
84 | { |
||
85 | $query = $this->em->createQuery( |
||
86 | 'SELECT e.id FROM PlaygroundGame\Entity\Entry e |
||
87 | WHERE e.anonymousIdentifier = :anonymousIdentifier AND e.game = :game |
||
88 | AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
89 | ); |
||
90 | $query->setParameter('anonymousIdentifier', $anonymousIdentifier); |
||
91 | $query->setParameter('game', $game); |
||
92 | $query->setParameter('date', $dateLimit); |
||
93 | |||
94 | $total = $query->getResult(); |
||
95 | |||
96 | return $total; |
||
97 | } |
||
98 | |||
99 | View Code Duplication | public function findLastEntriesByIp($game, $ip, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
100 | { |
||
101 | $query = $this->em->createQuery( |
||
102 | 'SELECT e.id FROM PlaygroundGame\Entity\Entry e |
||
103 | WHERE e.ip = :ip AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
104 | ); |
||
105 | $query->setParameter('ip', $ip); |
||
106 | $query->setParameter('game', $game); |
||
107 | $query->setParameter('date', $dateLimit); |
||
108 | |||
109 | $total = $query->getResult(); |
||
110 | |||
111 | return $total; |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Get all the entries of the player except those offered as bonus |
||
116 | * |
||
117 | * @param unknown_type $game |
||
118 | * @param unknown_type $user |
||
119 | */ |
||
120 | View Code Duplication | public function countLastEntriesByUser($game, $user, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
121 | { |
||
122 | $query = $this->em->createQuery( |
||
123 | 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e |
||
124 | WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
125 | ); |
||
126 | $query->setParameter('user', $user); |
||
127 | $query->setParameter('game', $game); |
||
128 | $query->setParameter('date', $dateLimit); |
||
129 | |||
130 | $total = $query->getSingleScalarResult(); |
||
131 | |||
132 | return $total; |
||
133 | } |
||
134 | |||
135 | View Code Duplication | public function countLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
136 | { |
||
137 | $query = $this->em->createQuery( |
||
138 | 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e |
||
139 | WHERE e.anonymousIdentifier = :anonymousIdentifier AND e.game = :game |
||
140 | AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
141 | ); |
||
142 | $query->setParameter('anonymousIdentifier', $anonymousIdentifier); |
||
143 | $query->setParameter('game', $game); |
||
144 | $query->setParameter('date', $dateLimit); |
||
145 | |||
146 | $total = $query->getSingleScalarResult(); |
||
147 | |||
148 | return $total; |
||
149 | } |
||
150 | |||
151 | View Code Duplication | public function countLastEntriesByIp($game, $ip, $dateLimit) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
152 | { |
||
153 | $query = $this->em->createQuery( |
||
154 | 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e |
||
155 | WHERE e.ip = :ip AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date' |
||
156 | ); |
||
157 | $query->setParameter('ip', $ip); |
||
158 | $query->setParameter('game', $game); |
||
159 | $query->setParameter('date', $dateLimit); |
||
160 | |||
161 | $total = $query->getSingleScalarResult(); |
||
162 | |||
163 | return $total; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * get users with only one participation able to |
||
168 | * replay the game in the timeframe (I except offered entries marked as bonus) |
||
169 | * |
||
170 | * @param unknown_type $game |
||
171 | */ |
||
172 | public function findPlayersWithOneEntryBy($game, $dateLimit) |
||
173 | { |
||
174 | $query = $this->em->createQuery( |
||
175 | 'SELECT e, u FROM PlaygroundGame\Entity\Entry e |
||
176 | JOIN e.user u |
||
177 | WHERE e.game = :game |
||
178 | AND (e.bonus = 0 OR e.bonus IS NULL) |
||
179 | GROUP BY e.user |
||
180 | HAVING COUNT(e.id) = 1 |
||
181 | AND e.created_at <= :date ' |
||
182 | ); |
||
183 | $query->setParameter('game', $game); |
||
184 | $query->setParameter('date', $dateLimit); |
||
185 | |||
186 | $result = $query->getResult(); |
||
187 | |||
188 | return $result; |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Compte les nombre de participations bonus |
||
193 | * @param unknown_type $game |
||
194 | * @param unknown_type $user |
||
195 | */ |
||
196 | public function checkBonusEntry($game, $user) |
||
197 | { |
||
198 | $query = $this->em->createQuery( |
||
199 | 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e |
||
200 | WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL)' |
||
201 | ); |
||
202 | $query->setParameter('user', $user); |
||
203 | $query->setParameter('game', $game); |
||
204 | $nbEntries = $query->getSingleScalarResult(); |
||
205 | |||
206 | $query = $this->em->createQuery( |
||
207 | 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e |
||
208 | WHERE e.user = :user AND e.game = :game AND e.bonus = 1' |
||
209 | ); |
||
210 | $query->setParameter('user', $user); |
||
211 | $query->setParameter('game', $game); |
||
212 | $nbBonusEntries = $query->getSingleScalarResult(); |
||
213 | |||
214 | if (($nbEntries - $nbBonusEntries) <= 0) { |
||
215 | return false; |
||
216 | } |
||
217 | |||
218 | return true; |
||
219 | } |
||
220 | |||
221 | public function getEntityRepository() |
||
222 | { |
||
223 | if (null === $this->er) { |
||
224 | $this->er = $this->em->getRepository('PlaygroundGame\Entity\Entry'); |
||
225 | } |
||
226 | |||
227 | return $this->er; |
||
228 | } |
||
229 | } |
||
230 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.