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 | * $Id: promotion.php,v 1.42 2007/02/04 15:01:40 malanciault Exp $ |
||
4 | * Module:martin |
||
5 | * Licence: GNU |
||
6 | */ |
||
7 | |||
8 | if (!defined("XOOPS_ROOT_PATH")) { |
||
9 | die("XOOPS root path not defined"); |
||
10 | } |
||
11 | |||
12 | include_once XOOPS_ROOT_PATH . '/modules/martin/include/common.php'; |
||
13 | |||
14 | /** |
||
15 | * Class MartinHotelPromotion |
||
16 | */ |
||
17 | class MartinHotelPromotion extends XoopsObject |
||
18 | { |
||
19 | public function MartinHotelPromotion() |
||
20 | { |
||
21 | $this->initVar("promotion_id", XOBJ_DTYPE_INT, null, false); |
||
22 | $this->initVar("hotel_id", XOBJ_DTYPE_INT, null, false); |
||
23 | $this->initVar("hotel_name", XOBJ_DTYPE_TXTBOX, null, true, 255); |
||
24 | $this->initVar("promotion_start_date", XOBJ_DTYPE_INT, null, false); |
||
25 | $this->initVar("promotion_end_date", XOBJ_DTYPE_INT, null, false); |
||
26 | $this->initVar("promotion_description", XOBJ_DTYPE_TXTAREA, null, false); |
||
27 | $this->initVar("promotion_add_time", XOBJ_DTYPE_INT, null, false); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return mixed |
||
32 | */ |
||
33 | public function promotion_id() |
||
34 | { |
||
35 | return $this->getVar("promotion_id"); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function hotel_id() |
||
42 | { |
||
43 | return $this->getVar("hotel_id"); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function hotel_name() |
||
50 | { |
||
51 | return $this->getVar("hotel_name"); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function promotion_start_date() |
||
58 | { |
||
59 | return $this->getVar("promotion_start_date"); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return mixed |
||
64 | */ |
||
65 | public function promotion_end_date() |
||
66 | { |
||
67 | return $this->getVar("promotion_end_date"); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param string $format |
||
72 | * @return mixed |
||
73 | */ |
||
74 | public function promotion_description($format = 'edit') |
||
75 | { |
||
76 | return $this->getVar("promotion_description", $format); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function promotion_add_time() |
||
83 | { |
||
84 | return $this->getVar("promotion_add_time"); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @method: MartinHotelPromotionHandler |
||
90 | * @license http://www.blags.org/ |
||
91 | * @created :2010年05月21日 20时40分 |
||
92 | * @copyright 1997-2010 The Martin promotion |
||
93 | * @author Martin <[email protected]> |
||
94 | * */ |
||
95 | class MartinHotelPromotionHandler extends XoopsObjectHandler |
||
96 | { |
||
97 | /** |
||
98 | * create a new hotel city |
||
99 | * @param bool $isNew flag the new objects as "new"? |
||
100 | * @return object promotion |
||
101 | */ |
||
102 | public function &create($isNew = true) |
||
103 | { |
||
104 | $promotion = new MartinHotelPromotion(); |
||
105 | if ($isNew) { |
||
106 | $promotion->setNew(); |
||
107 | } |
||
108 | |||
109 | return $promotion; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * retrieve a hotel city |
||
114 | * |
||
115 | * @param int $id promotionid of the hotel promotion |
||
116 | * @return mixed reference to the {@link promotion} object, FALSE if failed |
||
117 | */ |
||
118 | View Code Duplication | public function &get($id) |
|
119 | { |
||
120 | if ((int)($id) <= 0) { |
||
121 | return false; |
||
122 | } |
||
123 | |||
124 | $criteria = new CriteriaCompo(new Criteria('promotion_id', $id)); |
||
125 | $criteria->setLimit(1); |
||
126 | $obj_array = $this->getObjects($criteria); |
||
127 | if (count($obj_array) != 1) { |
||
128 | $obj =& $this->create(); |
||
129 | |||
130 | return $obj; |
||
131 | } |
||
132 | |||
133 | return $obj_array[0]; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @得到列表 |
||
138 | * @method: |
||
139 | * @license http://www.blags.org/ |
||
140 | * @created :2010年05月23日 14时59分 |
||
141 | * @copyright 1997-2010 The Martin promotion |
||
142 | * @author Martin <[email protected]> |
||
143 | * @param int $limit |
||
144 | * @param int $start |
||
145 | * @param string $sort |
||
146 | * @param string $order |
||
147 | * @param bool $id_as_key |
||
148 | * @return array |
||
149 | */ |
||
150 | View Code Duplication | public function &getPromotions($limit = 0, $start = 0, $sort = 'promotion_add_time', $order = 'DESC', $id_as_key = true) |
|
151 | { |
||
152 | $criteria = new CriteriaCompo(); |
||
153 | |||
154 | $criteria->setSort($sort); |
||
155 | $criteria->setOrder($order); |
||
156 | |||
157 | $criteria->setStart($start); |
||
158 | $criteria->setLimit($limit); |
||
159 | |||
160 | return $this->getObjects($criteria, $id_as_key); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * insert a new promotion in the database |
||
165 | * |
||
166 | * @param object $promotion reference to the {@link hotel promotion} object |
||
167 | * @param bool $force |
||
168 | * @return bool FALSE if failed, TRUE if already present and unchanged or successful |
||
169 | */ |
||
170 | public function insert(&$promotion, $force = false) |
||
171 | { |
||
172 | if (strtolower(get_class($promotion)) !== 'martinhotelpromotion') { |
||
173 | return false; |
||
174 | } |
||
175 | |||
176 | if (!$promotion->cleanVars()) { |
||
177 | return false; |
||
178 | } |
||
179 | |||
180 | foreach ($promotion->cleanVars as $k => $v) { |
||
181 | ${$k} = $v; |
||
182 | } |
||
183 | |||
184 | if ($promotion->isNew()) { |
||
185 | $sql = sprintf("INSERT INTO %s ( |
||
186 | promotion_id, |
||
187 | promotion_description, |
||
188 | hotel_id, |
||
189 | promotion_start_date, |
||
190 | promotion_end_date, |
||
191 | promotion_add_time |
||
192 | ) VALUES ( |
||
193 | NULL, |
||
194 | %s,%u,%u,%u,%u |
||
195 | )", $this->db->prefix('martin_hotel_promotions'), $this->db->quoteString($promotion_description), $hotel_id, $promotion_start_date, $promotion_end_date, $promotion_add_time); |
||
196 | } else { |
||
197 | $sql = sprintf("UPDATE %s SET |
||
198 | promotion_description = %s, |
||
199 | hotel_id = %u, |
||
200 | promotion_start_date = %u, |
||
201 | promotion_end_date = %u |
||
202 | WHERE promotion_id = %u", $this->db->prefix('martin_hotel_promotions'), $this->db->quoteString($promotion_description), $hotel_id, $promotion_start_date, $promotion_end_date, $promotion_id); |
||
203 | } |
||
204 | //echo $sql;exit; |
||
205 | if (false != $force) { |
||
206 | $result = $this->db->queryF($sql); |
||
0 ignored issues
–
show
|
|||
207 | } else { |
||
208 | $result = $this->db->query($sql); |
||
0 ignored issues
–
show
$result is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
209 | } |
||
210 | |||
211 | return $promotion_id > 0 ? $promotion_id : $this->db->getInsertId(); |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * @删除一个城市 |
||
216 | * @method:delete(promotion_id) |
||
217 | * @license http://www.blags.org/ |
||
218 | * @created :2010年05月21日 20时40分 |
||
219 | * @copyright 1997-2010 The Martin promotion |
||
220 | * @author Martin <[email protected]> |
||
221 | * @param object $promotion |
||
222 | * @param bool $force |
||
223 | * @return bool|void |
||
224 | */ |
||
225 | View Code Duplication | public function delete(&$promotion, $force = false) |
|
226 | { |
||
227 | if (strtolower(get_class($promotion)) !== 'martinhotelpromotion') { |
||
228 | return false; |
||
229 | } |
||
230 | |||
231 | $sql = "DELETE FROM " . $this->db->prefix("martin_hotel_promotions") . " WHERE promotion_id = " . $promotion->promotion_id(); |
||
232 | |||
233 | if (false != $force) { |
||
234 | $result = $this->db->queryF($sql); |
||
235 | } else { |
||
236 | $result = $this->db->query($sql); |
||
237 | } |
||
238 | |||
239 | if (!$result) { |
||
240 | return false; |
||
241 | } |
||
242 | |||
243 | return true; |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * delete hotel cities matching a set of conditions |
||
248 | * |
||
249 | * @param object $criteria {@link CriteriaElement} |
||
250 | * @return bool FALSE if deletion failed |
||
251 | */ |
||
252 | View Code Duplication | public function deleteAll($criteria = null) |
|
253 | { |
||
254 | $sql = 'DELETE FROM ' . $this->db->prefix('martin_hotel_promotions'); |
||
255 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
||
256 | $sql .= ' ' . $criteria->renderWhere(); |
||
257 | } |
||
258 | if (!$result = $this->db->query($sql)) { |
||
259 | return false; |
||
260 | } |
||
261 | |||
262 | return true; |
||
263 | } |
||
264 | |||
265 | /** |
||
266 | * count hotel cities matching a condition |
||
267 | * |
||
268 | * @param object $criteria {@link CriteriaElement} to match |
||
269 | * @return int count of categories |
||
270 | */ |
||
271 | View Code Duplication | public function getCount($criteria = null) |
|
272 | { |
||
273 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('martin_hotel_promotions'); |
||
274 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
||
275 | $sql .= ' ' . $criteria->renderWhere(); |
||
276 | } |
||
277 | $result = $this->db->query($sql); |
||
278 | if (!$result) { |
||
279 | return 0; |
||
280 | } |
||
281 | list($count) = $this->db->fetchRow($result); |
||
282 | |||
283 | return $count; |
||
284 | } |
||
285 | |||
286 | /** |
||
287 | * @得到城市 |
||
288 | * @license http://www.blags.org/ |
||
289 | * @created :2010年05月21日 20时40分 |
||
290 | * @copyright 1997-2010 The Martin promotion |
||
291 | * @author Martin <[email protected]> |
||
292 | * @param null $criteria |
||
293 | * @param bool $id_as_key |
||
294 | * @return array |
||
295 | */ |
||
296 | public function &getObjects($criteria = null, $id_as_key = false) |
||
297 | { |
||
298 | $ret = array(); |
||
299 | $limit = $start = 0; |
||
300 | $sql = 'SELECT p.*,h.hotel_name FROM ' . $this->db->prefix('martin_hotel_promotions') . ' p '; |
||
301 | $sql .= ' left join ' . $this->db->prefix('martin_hotel') . ' h on ( h.hotel_id = p.hotel_id ) '; |
||
302 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
||
303 | $sql .= ' ' . $criteria->renderWhere(); |
||
304 | if ($criteria->getSort() != '') { |
||
305 | $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
||
306 | } |
||
307 | $limit = $criteria->getLimit(); |
||
308 | $start = $criteria->getStart(); |
||
309 | } |
||
310 | $sql .= " order by p.promotion_id DESC "; |
||
311 | //echo "<br />" . $sql . "<br />"; |
||
312 | $result = $this->db->query($sql, $limit, $start); |
||
313 | |||
314 | if (!$result) { |
||
315 | return $ret; |
||
316 | } |
||
317 | |||
318 | $theObjects = array(); |
||
319 | |||
320 | while ($myrow = $this->db->fetchArray($result)) { |
||
321 | $promotion = new MartinHotelPromotion(); |
||
322 | $promotion->assignVars($myrow); |
||
323 | $theObjects[$myrow['promotion_id']] =& $promotion; |
||
324 | //var_dump($promotion); |
||
325 | unset($promotion); |
||
326 | } |
||
327 | //var_dump($theObjects); |
||
328 | |||
329 | foreach ($theObjects as $theObject) { |
||
330 | if (!$id_as_key) { |
||
331 | $ret[] =& $theObject; |
||
332 | } else { |
||
333 | $ret[$theObject->promotion_id()] =& $theObject; |
||
334 | } |
||
335 | unset($theObject); |
||
336 | } |
||
337 | |||
338 | return $ret; |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * @get hotel promotion |
||
343 | * @license http://www.blags.org/ |
||
344 | * @created :2010年06月14日 20时47分 |
||
345 | * @copyright 1997-2010 The Martin Group |
||
346 | * @author Martin <[email protected]> |
||
347 | * @param $hotel_id |
||
348 | * @return string |
||
349 | */ |
||
350 | public function getHotelPromotion($hotel_id) |
||
351 | { |
||
352 | global $xoopsDB; |
||
353 | if (!$hotel_id > 0) { |
||
354 | return ''; |
||
355 | } |
||
356 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('martin_hotel_promotions') . ' WHERE |
||
357 | ' . time() . ' BETWEEN promotion_start_date AND promotion_end_date AND hotel_id = ' . $hotel_id . ' limit 1 '; |
||
358 | |||
359 | return $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
360 | } |
||
361 | } |
||
362 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.