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.
Labels
Severity
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
/**
21
 * Script pour tout ce qui est relatif Ă  Ajax et JSON
22
 *
23
 * @since 2.3.2009.03.17
24
 */
25
26
use XoopsModules\Oledrion;
27
use XoopsModules\Oledrion\Constants;
28
29
require_once __DIR__ . '/header.php';
30
error_reporting(0);
31
@$xoopsLogger->activated = false;
32
$db         = \XoopsDatabaseFactory::getDatabaseConnection();
33
$vatHandler = new Oledrion\VatHandler($db);
34
35
$op = \Xmf\Request::getString('op', '', 'POST');
36
if ('' === $op) {
37
    $op = \Xmf\Request::getString('op', '', 'GET');
38
}
39
$return  = '';
40
$uid     = Oledrion\Utility::getCurrentUserID();
41
$isAdmin = Oledrion\Utility::isAdmin();
42
43
switch ($op) {
44
    // ****************************************************************************************************************
45
    case 'updatePrice': // Mise à jour du prix du produit en fonction des attributs sélectionnés
46
47
        // ****************************************************************************************************************
48
        $product_id = \Xmf\Request::getInt('product_id', 0, 'POST');
49
        $product    = null;
50
        if ($product_id > 0 && \Xmf\Request::hasVar('formcontent', 'POST')) {
51
            $data = $data = $attributesIds = $attributes = $templateProduct = [];
52
            //            $handlers = HandlerManager::getInstance();
53
            /** @var \XoopsModules\Oledrion\Products $product */
54
            $product = $productsHandler->get($product_id);
55
            if (!is_object($product)) {
56
                return _OLEDRION_NA;
57
            }
58
            if (!$product->isProductVisible()) {
59
                return _OLEDRION_NA;
60
            }
61
            $vat_id = $product->getVar('product_vat_id');
62
63
            if (0 !== (int)$product->getVar('product_discount_price', '')) {
64
                $productPrice = (float)$product->getVar('product_discount_price', 'e');
65
            } else {
66
                $productPrice = (float)$product->getVar('product_price', 'e');
67
            }
68
69
            parse_str(urldecode($_POST['formcontent']), $data);
70
            /*
71
                        require_once __DIR__ . '/FirePHPCore/FirePHP.class.php';
72
                        $firephp = FirePHP::getInstance(true);
73
                        $firephp->log($data, 'Iterators');
74
            */
75
            // On récupère les ID des attributs valorisés
76
            foreach ($data as $key => $value) {
77
                $attributesIds[] = Oledrion\Utility::getId($key);
78
            }
79
            if (0 === count($attributesIds)) {
80
                return _OLEDRION_NA;
81
            }
82
            // Puis les attributs
83
            $attributes = $attributesHandler->getItemsFromIds($attributesIds);
84
            if (0 === count($attributes)) {
85
                return _OLEDRION_NA;
86
            }
87
88
            // Et on recalcule le prix
89
            foreach ($attributes as $attribute) {
90
                $attributeNameInForm = xoops_trim($attribute->getVar('attribute_name') . '_' . $attribute->getVar('attribute_id'));
91
                if (isset($data[$attributeNameInForm])) {
92
                    $attributeValues = $data[$attributeNameInForm];
93
                    if (is_array($attributeValues)) {
94
                        foreach ($attributeValues as $attributeValue) {
95
                            $optionName   = Oledrion\Utility::getName($attributeValue);
96
                            $optionPrice  = $attribute->getOptionPriceFromValue($optionName);
97
                            $productPrice += $optionPrice;
98
                        }
99
                    } else {
100
                        $optionPrice  = $attribute->getOptionPriceFromValue(Oledrion\Utility::getName($attributeValues));
101
                        $productPrice += $optionPrice;
102
                    }
103
                }
104
            }
105
            // Mise en template
106
            require_once XOOPS_ROOT_PATH . '/class/template.php';
107
            $template        = new \XoopsTpl();
108
            $vat             = null;
109
            $vat             = $vatHandler->get($vat_id);
110
            $productPriceTTC = Oledrion\Utility::getAmountWithVat($productPrice, $vat_id);
111
112
            $oledrionCurrency = Oledrion\Currency::getInstance();
113
114
            $templateProduct                                          = $product->toArray();
115
            $templateProduct['product_final_price_ht_formated_long']  = $oledrionCurrency->amountForDisplay($productPrice, 'l');
116
            $templateProduct['product_final_price_ttc_formated_long'] = $oledrionCurrency->amountForDisplay($productPriceTTC, 'l');
117
            if (is_object($vat)) {
118
                $templateProduct['product_vat_rate'] = $vat->toArray();
119
            }
120
            $templateProduct['product_vat_amount_formated_long'] = $oledrionCurrency->amountForDisplay($productPriceTTC - $productPrice, 'l');
121
            $template->assign('product', $templateProduct);
122
            $return = $template->fetch('db:oledrion_product_price.tpl');
123
        }
124
125
        break;
126
    // ajax search
127
    case 'search': // ajax search
128
129
        $key = $_GET['part'];
130
        if (isset($key) && '' !== $key) {
131
            // Set captul
132
            $i = 1;
133
            // Query 1
134
            $query  = 'SELECT `product_id` AS `id` , `product_cid` AS `cid`, `product_title` AS `title`, `product_thumb_url` AS `image`, `product_price` AS `price` FROM `'
135
                      . $xoopsDB->prefix('oledrion_products')
136
                      . "` WHERE (`product_online` = 1) AND (`product_title` LIKE '%"
137
                      . $key
138
                      . "%' OR `product_title` LIKE '%"
139
                      . ucfirst($key)
140
                      . "%') LIMIT 0, 10";
141
            $result = $xoopsDB->query($query);
142
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
143
                $items[$i]['title'] = $row['title'];
144
                $items[$i]['type']  = 'product';
145
                $items[$i]['link']  = XOOPS_URL . '/modules/oledrion/product.php?product_id=' . $row['id'];
146
                $items[$i]['image'] = OLEDRION_PICTURES_URL . '/' . $row['image'];
147
                //$items[$i]['price'] = Oledrion\Utility::getTTC($row['price']);
148
                $category               = $categoryHandler->get($row['cid']);
149
                $items[$i]['cat_cid']   = $category->getVar('cat_cid');
150
                $items[$i]['cat_title'] = $category->getVar('cat_title');
151
                ++$i;
152
            }
153
            // Query 2
154
            $query  = 'SELECT `cat_cid` AS `id` , `cat_title` AS `title`, `cat_imgurl` AS `image`  FROM `' . $xoopsDB->prefix('oledrion_cat') . "` WHERE (`cat_title` LIKE '%" . $key . "%') OR (`cat_title` LIKE '%" . ucfirst($key) . "%') LIMIT 0, 5";
155
            $result = $xoopsDB->query($query);
156
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
157
                $items[$i]['title'] = $row['title'];
158
                $items[$i]['type']  = 'cat';
159
                $items[$i]['link']  = XOOPS_URL . '/modules/oledrion/category.php?cat_cid=' . $row['id'];
160
                $items[$i]['image'] = OLEDRION_PICTURES_URL . '/' . $row['image'];
161
                $items[$i]['price'] = '';
162
                ++$i;
163
            }
164
            // Set array
165
            $results = [];
166
            // search colors
167
            foreach ($items as $item) {
168
                // if it starts with 'part' add to results
169
                //if ( strpos($item['title'], $key) === 0 || strpos($item['title'], ucfirst($key)) === 0 ) {
170
                if ('product' === $item['type']) {
171
                    $results[] = '<div class="searchbox">
172
                         <div class="searchboxright"><a href="' . $item['link'] . '"><img src="' . $item['image'] . '" alt=""></a></div>
173
                         <div class="searchboxleft">
174
                             <div class="searchboxitem"><a href="' . $item['link'] . '">' . $item['title'] . '</a></div>
175
                             <div class="searchboxcat"><a href="' . XOOPS_URL . '/modules/oledrion/category.php?cat_cid=' . $item['cat_cid'] . '">' . $item['cat_title'] . '</a></div>
176
                         </div>
177
                         <div class="clear"></div>
178
                     </div>';
179
                } else {
180
                    $results[] = '<div class="searchbox">
181
                         <div class="searchboxright"><a href="' . $item['link'] . '"><img src="' . $item['image'] . '" alt=""></a></div>
182
                         <div class="searchboxleft">
183
                             <div class="searchboxitem"><a href="' . $item['link'] . '">' . $item['title'] . '</a></div>
184
                         </div>
185
                         <div class="clear"></div>
186
                     </div>';
187
                }
188
                //}
189
            }
190
            $return = json_encode($results);
191
        }
192
193
        break;
194
    // Product output as json
195
    case 'product':
196
197
        $start = \Xmf\Request::getInt('start', 0, 'GET');
198
        $limit = \Xmf\Request::getInt('limit', 0, 'GET');
199
        if (isset($start) && '' !== $start) {
200
            $ret      = [];
201
            $criteria = new \CriteriaCompo();
202
            $criteria->add(new \Criteria('product_id', $start, '>='));
203
            $criteria->add(new \Criteria('product_online', 1));
204
            $criteria->setSort('product_id');
205
            $criteria->setOrder('ASC');
206
            $criteria->setLimit($limit);
207
            $obj = $productsHandler->getObjects($criteria, false);
208
            if ($obj) {
209
                foreach ($obj as $root) {
210
                    $tab                         = [];
211
                    $tab                         = $root->toArray();
212
                    $json['product_id']          = $tab['product_id'];
213
                    $json['product_cid']         = $tab['product_cid'];
214
                    $json['product_title']       = preg_replace('/,/', ';', $tab['product_title']);
215
                    $json['product_description'] = preg_replace('/,/', ';', $tab['product_description']);
216
                    $json['product_image_url']   = $tab['product_image_url'];
217
                    $json['product_thumb_url']   = $tab['product_thumb_url'];
218
                    $json['product_property1']   = $tab['product_property1'];
219
                    $json['product_property2']   = $tab['product_property2'];
220
                    $json['product_property3']   = $tab['product_property3'];
221
                    $json['product_property4']   = $tab['product_property4'];
222
                    $json['product_submitted']   = $tab['product_submitted'];
223
                    unset($tab);
224
                    $ret[] = $json;
225
                }
226
            }
227
            $return = json_encode($ret);
228
        }
229
230
        break;
231
    // Product output as json
232
    case 'category':
233
234
        $start = \Xmf\Request::getInt('start', 0, 'GET');
235
        if (isset($start) && '' !== $start) {
236
            $ret      = [];
237
            $criteria = new \CriteriaCompo();
238
            $criteria->add(new \Criteria('cat_cid', $start, '>='));
239
            $criteria->setSort('cat_cid');
240
            $criteria->setOrder('DESC');
241
            $obj = $categoryHandler->getObjects($criteria, false);
242
            if ($obj) {
243
                foreach ($obj as $root) {
244
                    $tab                = [];
245
                    $tab                = $root->toArray();
246
                    $json['cat_cid']    = $tab['cat_cid'];
247
                    $json['cat_pid']    = $tab['cat_pid'];
248
                    $json['cat_title']  = preg_replace('/,/', ';', $tab['cat_title']);
249
                    $json['cat_imgurl'] = $tab['cat_imgurl'];
250
                    unset($tab);
251
                    $ret[] = $json;
252
                }
253
            }
254
            $return = json_encode($ret);
255
        }
256
257
        break;
258
    // Product output as json
259
    case 'price':
260
261
        $product_id = \Xmf\Request::getInt('product_id', 0, 'GET');
262
        $product    = $productsHandler->get($product_id);
263
        if (is_object($product)) {
264
            if ($product->getVar('product_online') && $product->getVar('product_stock') > 0) {
265
                $product_price = $product->getVar('product_price');
266
                if ($attributesHandler->getProductAttributesCount($product->getVar('product_id')) > 0) {
267
                    $criteria = new \CriteriaCompo();
268
                    $criteria->add(new \Criteria('attribute_product_id', $product->getVar('product_id')));
269
                    $attribute = $attributesHandler->getObjects($criteria, false);
270
                    foreach ($attribute as $root) {
271
                        $product_price = $root->getVar('attribute_default_value');
272
                    }
273
                }
274
                $ret = [
275
                    'product_id'    => $product->getVar('product_id'),
276
                    'product_price' => $product_price,
277
                ];
278
            } else {
279
                $ret = [
280
                    'product_id'    => $product->getVar('product_id'),
281
                    'product_price' => 0,
282
                ];
283
            }
284
        } else {
285
            $ret = [
286
                'product_id'    => 0,
287
                'product_price' => 0,
288
            ];
289
        }
290
        $return = json_encode($ret);
291
292
        break;
293
    // Ajax rate
294
    case 'rate':
295
296
        if (\Xmf\Request::hasVar('product_id', 'POST')) {
297
            $product_id = \Xmf\Request::getInt('product_id', 0, 'POST');
298
            $product    = null;
299
            $product    = $productsHandler->get($product_id);
300
            if (is_object($product) && $product->getVar('product_online') && !Oledrion\Utility::getModuleOption('show_unpublished') && Oledrion\Utility::getModuleOption('nostock_display') && $product->getVar('product_submitted') < time() && $product->getVar('product_stock')) {
301
                $GLOBALS['current_category'] = -1;
302
                $ratinguser                  = Oledrion\Utility::getCurrentUserID();
303
                $canRate                     = true;
304
                if (0 !== $ratinguser) {
305
                    if ($votedataHandler->hasUserAlreadyVoted($ratinguser, $product->getVar('product_id'))) {
306
                        $canRate = false;
307
                    }
308
                } else {
309
                    if ($votedataHandler->hasAnonymousAlreadyVoted('', $product->getVar('product_id'))) {
310
                        $canRate = false;
311
                    }
312
                }
313
                if ($canRate) {
314
                    /* if ($_POST['rating'] == '--') {
315
                                            Oledrion\Utility::redirect(_OLEDRION_NORATING, OLEDRION_URL . 'product.php?product_id=' . $product->getVar('product_id'), 4);
316
                                        } */
317
                    $rating = \Xmf\Request::getInt('rating', 0, 'POST');
318
                    /* if ($rating < 1 || $rating > 10) {
319
                        exit(_ERRORS);
320
                    } */
321
                    if (1 === $rating || -1 === $rating) {
322
                        $result = $votedataHandler->createRating($product->getVar('product_id'), $ratinguser, $rating);
323
324
                        $totalVotes = 0;
325
                        $sumRating  = 0;
326
                        $ret        = 0;
327
                        $ret        = $votedataHandler->getCountRecordSumRating($product->getVar('product_id'), $totalVotes, $sumRating);
328
329
                        //$finalrating = $sumRating / $totalVotes;
330
                        //$finalrating = number_format($finalrating, 4);
331
332
                        $productsHandler->updateRating($product_id, $sumRating, $totalVotes);
333
                        //$ratemessage = _OLEDRION_VOTEAPPRE . '<br>' . sprintf(_OLEDRION_THANKYOU, $xoopsConfig['sitename']);
334
                        //Oledrion\Utility::redirect($ratemessage, OLEDRION_URL . 'product.php?product_id=' . $product->getVar('product_id'), 2);
335
                    } else {
336
                        $return = false;
337
                    }
338
                } else {
339
                    $return = false;
340
                }
341
            }
342
        }
343
344
        break;
345
    case 'order':
346
347
        $ret            = [];
348
        $ret['status']  = 0;
349
        $ret['message'] = 'error';
350
        if (\Xmf\Request::hasVar('product_id', 'POST') && is_numeric($_POST['product_id'])) {
351
            // Set from post
352
            $product_id    = \Xmf\Request::getString('product_id', '', 'POST');
353
            $cmd_lastname  = \Xmf\Request::getString('cmd_lastname', '', 'POST');
354
            $cmd_firstname = \Xmf\Request::getString('cmd_firstname', '', 'POST');
355
            $cmd_adress    = \Xmf\Request::getString('cmd_adress', '', 'POST');
356
            $cmd_zip       = \Xmf\Request::getString('cmd_zip', '', 'POST');
357
            $cmd_town      = \Xmf\Request::getString('cmd_town', '', 'POST');
358
            $cmd_country   = \Xmf\Request::getString('cmd_country', '', 'POST');
359
            $cmd_telephone = \Xmf\Request::getString('cmd_telephone', '', 'POST');
360
            $cmd_mobile    = \Xmf\Request::getString('cmd_mobile', '', 'POST');
361
            $cmd_email     = \Xmf\Request::getString('cmd_email', '', 'POST');
362
            //$cmd_total = isset($_POST['cmd_total']) ? $_POST['cmd_total'] : '';
363
            //$cmd_shipping = isset($_POST['cmd_shipping']) ? $_POST['cmd_shipping'] : '';
364
            $cmd_packing_price = \Xmf\Request::getString('cmd_packing_price', '', 'POST');
365
            $cmd_bill          = \Xmf\Request::getString('cmd_bill', '', 'POST');
366
            $cmd_text          = \Xmf\Request::getString('cmd_text', '', 'POST');
367
            $cmd_comment       = \Xmf\Request::getString('cmd_comment', '', 'POST');
368
            $cmd_vat_number    = \Xmf\Request::getString('cmd_vat_number', '', 'POST');
369
            $cmd_packing       = \Xmf\Request::getString('cmd_packing', '', 'POST');
370
            $cmd_packing_id    = \Xmf\Request::getString('cmd_packing_id', '', 'POST');
371
            $cmd_location      = \Xmf\Request::getString('cmd_location', '', 'POST');
372
            $cmd_location_id   = \Xmf\Request::getString('cmd_location_id', '', 'POST');
373
            $cmd_delivery      = \Xmf\Request::getString('cmd_delivery', '', 'POST');
374
            $cmd_delivery_id   = \Xmf\Request::getString('cmd_delivery_id', '', 'POST');
375
            $cmd_payment       = \Xmf\Request::getString('cmd_payment', '', 'POST');
376
            $cmd_payment_id    = \Xmf\Request::getString('cmd_payment_id', '', 'POST');
377
            $cmd_track         = \Xmf\Request::getString('cmd_track', '', 'POST');
378
            $cmd_gift          = \Xmf\Request::getString('cmd_gift', '', 'POST');
379
            $attributes        = \Xmf\Request::getString('attributes', '', 'POST');
380
            // Get product
381
            $product       = $productsHandler->get($product_id);
382
            $product_price = $product->getVar('product_price');
383
            if ($attributesHandler->getProductAttributesCount($product->getVar('product_id')) > 0) {
384
                $criteria = new \CriteriaCompo();
385
                $criteria->add(new \Criteria('attribute_product_id', $product->getVar('product_id')));
386
                $attribute = $attributesHandler->getObjects($criteria, false);
387
                foreach ($attribute as $root) {
388
                    $product_price = $root->getVar('attribute_default_value');
389
                }
390
            }
391
            if ($product->getVar('product_online') && $product->getVar('product_stock') > 0) {
392
                // Set parameter
393
                $password       = md5(xoops_makepass());
394
                $passwordCancel = md5(xoops_makepass());
395
                $uid            = Oledrion\Utility::getCurrentUserID();
396
                $cmd_total      = $product_price;
397
                $cmd_shipping   = 0;
398
                // Save command
399
                $commande = $commandsHandler->create(true);
400
                $commande->setVar('cmd_uid', $uid);
401
                $commande->setVar('cmd_date', date('Y-m-d'));
402
                $commande->setVar('cmd_create', time());
403
                $commande->setVar('cmd_state', Constants::OLEDRION_STATE_NOINFORMATION);
404
                $commande->setVar('cmd_ip', Oledrion\Utility::IP());
405
                $commande->setVar('cmd_lastname', $cmd_lastname);
406
                $commande->setVar('cmd_firstname', $cmd_firstname);
407
                $commande->setVar('cmd_adress', $cmd_adress);
408
                $commande->setVar('cmd_zip', $cmd_zip);
409
                $commande->setVar('cmd_town', $cmd_town);
410
                $commande->setVar('cmd_country', $cmd_country);
411
                $commande->setVar('cmd_telephone', $cmd_telephone);
412
                $commande->setVar('cmd_mobile', $cmd_mobile);
413
                $commande->setVar('cmd_email', $cmd_email);
414
                $commande->setVar('cmd_articles_count', 1);
415
                $commande->setVar('cmd_total', Oledrion\Utility::formatFloatForDB($cmd_total));
416
                $commande->setVar('cmd_shipping', Oledrion\Utility::formatFloatForDB($cmd_shipping));
417
                $commande->setVar('cmd_packing_price', $cmd_packing_price);
418
                $commande->setVar('cmd_bill', $cmd_bill);
419
                $commande->setVar('cmd_password', $password);
420
                $commande->setVar('cmd_text', $cmd_text);
421
                $commande->setVar('cmd_cancel', $passwordCancel);
422
                $commande->setVar('cmd_comment', $cmd_comment);
423
                $commande->setVar('cmd_vat_number', $cmd_vat_number);
424
                $commande->setVar('cmd_packing', $cmd_packing);
425
                $commande->setVar('cmd_packing_id', $cmd_packing_id);
426
                $commande->setVar('cmd_location', $cmd_location);
427
                $commande->setVar('cmd_location_id', $cmd_location_id);
428
                $commande->setVar('cmd_delivery', $cmd_delivery);
429
                $commande->setVar('cmd_delivery_id', $cmd_delivery_id);
430
                $commande->setVar('cmd_payment', $cmd_payment);
431
                $commande->setVar('cmd_payment_id', $cmd_payment_id);
432
                $commande->setVar('cmd_status', 2);
433
                $commande->setVar('cmd_track', $cmd_track);
434
                $commande->setVar('cmd_gift', $cmd_gift);
435
                $res1 = $commandsHandler->insert($commande, true);
436
                // Save caddy
437
                $caddy = $caddyHandler->create(true);
438
                $caddy->setVar('caddy_product_id', $product_id);
439
                $caddy->setVar('caddy_qte', $product->getVar('product_qty'));
440
                $caddy->setVar('caddy_price', Oledrion\Utility::formatFloatForDB($cmd_total));
441
                $caddy->setVar('caddy_cmd_id', $commande->getVar('cmd_id'));
442
                $caddy->setVar('caddy_shipping', Oledrion\Utility::formatFloatForDB($cmd_shipping));
443
                $caddy->setVar('caddy_pass', md5(xoops_makepass()));
444
                $res2 = $caddyHandler->insert($caddy, true);
445
                // Attributs
446
                /* if ($res2 && is_array($attributes) && count($attributes) > 0) {
447
                    foreach ($attributes as $attributeId => $attributeInformation) {
448
                        $caddyAttribute = $handlers->h_oledrion_caddy_attributes->create(true);
449
                        $caddyAttribute->setVar('ca_cmd_id', $commande->getVar('cmd_id'));
450
                        $caddyAttribute->setVar('ca_caddy_id', $caddy->getVar('caddy_id'));
451
                        $caddyAttribute->setVar('ca_attribute_id', $attributeId);
452
                        $selectedOptions = $attributeInformation['attribute_options'];
453
                        $msgCommande .= '- ' . $attributeInformation['attribute_title'] . "\n";
454
                        foreach ($selectedOptions as $selectedOption) {
455
                            $caddyAttribute ->addOption($selectedOption['option_name'], $selectedOption['option_value'], $selectedOption['option_price']);
456
                            $msgCommande .= '    ' . $selectedOption['option_name'] . ' : ' . $selectedOption['option_ttc_formated'] . "\n";
457
                        }
458
                        $handlers->h_oledrion_caddy_attributes->insert($caddyAttribute, true);
459
                    }
460
                } */
461
                if (!$res1) {
462
                    $ret['status']  = 0;
463
                    $ret['message'] = _OLEDRION_ERROR10;
464
                } else {
465
                    $ret['status']  = 1;
466
                    $ret['message'] = 'ok';
467
                    // Send mail
468
                    /* $msgCommande = '';
469
                    $msgCommande .= str_pad($product_id, 5, ' ') . ' ';
470
                    $msgCommande .= str_pad('', 10, ' ', STR_PAD_LEFT) . ' ';
471
                    $msgCommande .= str_pad($product->getVar('product_title'), 19, ' ', STR_PAD_LEFT) . ' ';
472
                    $msgCommande .= str_pad($product->getVar('product_qty'), 8, ' ', STR_PAD_LEFT) . ' ';
473
                    $msgCommande .= str_pad($oledrionCurrency->amountForDisplay($product_price), 15, ' ', STR_PAD_LEFT) . ' ';+
474
                    $msgCommande .= "\n";
475
                    $msgCommande .= "\n\n" . _OLEDRION_TOTAL . " " . $oledrionCurrency->mountForDisplay($cmd_total) . "\n";
476
                    $msg = array();
477
                    $msg['COMMANDE'] = $msgCommande;
478
                    $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id');
479
                    $msg['NOM'] = $commande->getVar('cmd_lastname');
480
                    $msg['PRENOM'] = $commande->getVar('cmd_firstname');
481
                    $msg['ADRESSE'] = $commande->getVar('cmd_adress', 'n');
482
                    $msg['CP'] = $commande->getVar('cmd_zip');
483
                    $msg['VILLE'] = $commande->getVar('cmd_town');
484
                    $msg['PAYS'] = $countries[$commande->getVar('cmd_country')];
485
                    $msg['TELEPHONE'] = $commande->getVar('cmd_telephone');
486
                    $msg['EMAIL'] = $commande->getVar('cmd_email');
487
                    $msg['URL_BILL'] = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password');
488
                    $msg['IP'] = Oledrion\Utility::IP();
489
                    if ($commande->getVar('cmd_bill') == 1) {
490
                        $msg['FACTURE'] = _YES;
491
                    } else {
492
                        $msg['FACTURE'] = _NO;
493
                    }
494
                    // Send mail to client
495
                    Oledrion\Utility::sendEmailFromTpl('command_client.tpl', $commande -> getVar('cmd_email'), sprintf(_OLEDRION_THANKYOU_CMD, $xoopsConfig['sitename']), $msg);
496
                    // Send mail to admin
497
                    Oledrion\Utility::sendEmailFromTpl('command_shop.tpl', Oledrion\Utility::getEmailsFromGroup(Oledrion\Utility::getModuleOption('grp_sold')), _OLEDRION_NEW_COMMAND, $msg);
498
                    */
499
                    // Send SMS
500
                    if (Oledrion\Utility::getModuleOption('sms_checkout')) {
501
                        $information['to']   = ltrim($commande->getVar('cmd_mobile'), 0);
502
                        $information['text'] = Oledrion\Utility::getModuleOption('sms_checkout_text');
503
                        $sms                 = \XoopsModules\Oledrion\Sms::sendSms($information);
504
                    }
505
                }
506
            } else {
507
                $ret['status']  = 0;
508
                $ret['message'] = _OLEDRION_ERROR10;
509
            }
510
        }
511
        $return = json_encode($ret);
512
513
        break;
514
}
515
echo $return;
0 ignored issues
show
Are you sure $return of type false|string can be used in echo? ( Ignorable by Annotation )

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

515
echo /** @scrutinizer ignore-type */ $return;
Loading history...
516