Issues (2366)

Branch: master

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

Eccube/Controller/Admin/Order/OrderController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Controller\Admin\Order;
26
27
use Eccube\Application;
28
use Eccube\Common\Constant;
29
use Eccube\Controller\AbstractController;
30
use Eccube\Entity\Master\CsvType;
31
use Eccube\Event\EccubeEvents;
32
use Eccube\Event\EventArgs;
33
use Symfony\Component\HttpFoundation\Request;
34
use Symfony\Component\HttpFoundation\StreamedResponse;
35
36
class OrderController extends AbstractController
37
{
38
39
    public function index(Application $app, Request $request, $page_no = null)
40
    {
41
        $session = $request->getSession();
42
43
        $builder = $app['form.factory']
44
            ->createBuilder('admin_search_order');
45
46
        $event = new EventArgs(
47
            array(
48
                'builder' => $builder,
49
            ),
50
            $request
51
        );
52
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_INITIALIZE, $event);
53
54
        $searchForm = $builder->getForm();
55
56
        $pagination = array();
57
58
        $disps = $app['eccube.repository.master.disp']->findAll();
59
        $pageMaxis = $app['eccube.repository.master.page_max']->findAll();
60
61
        // 表示件数は順番で取得する、1.SESSION 2.設定ファイル
62
        $page_count = $session->get('eccube.admin.order.search.page_count', $app['config']['default_page_count']);
63
64
        $page_count_param = $request->get('page_count');
65
        // 表示件数はURLパラメターから取得する
66 View Code Duplication
        if($page_count_param && is_numeric($page_count_param)){
67
            foreach($pageMaxis as $pageMax){
68
                if($page_count_param == $pageMax->getName()){
69
                    $page_count = $pageMax->getName();
70
                    // 表示件数入力値正し場合はSESSIONに保存する
71
                    $session->set('eccube.admin.order.search.page_count', $page_count);
72
                    break;
73
                }
74
            }
75
        }
76
77
        $active = false;
78
79
        if ('POST' === $request->getMethod()) {
80
            $searchForm->handleRequest($request);
81 View Code Duplication
            if ($searchForm->isValid()) {
82
                $searchData = $searchForm->getData();
83
84
                // paginator
85
                $qb = $app['eccube.repository.order']->getQueryBuilderBySearchDataForAdmin($searchData);
86
87
                $event = new EventArgs(
88
                    array(
89
                        'form' => $searchForm,
90
                        'qb' => $qb,
91
                    ),
92
                    $request
93
                );
94
                $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event);
95
96
                $page_no = 1;
97
                $pagination = $app['paginator']()->paginate(
98
                    $qb,
99
                    $page_no,
100
                    $page_count
101
                );
102
103
                // sessionに検索条件を保持.
104
                $viewData = \Eccube\Util\FormUtil::getViewData($searchForm);
105
                $session->set('eccube.admin.order.search', $viewData);
106
                $session->set('eccube.admin.order.search.page_no', $page_no);
107
            }
108
        } else {
109
            if (is_null($page_no) && $request->get('resume') != Constant::ENABLED) {
110
                // sessionを削除
111
                $session->remove('eccube.admin.order.search');
112
                $session->remove('eccube.admin.order.search.page_no');
113
                $session->remove('eccube.admin.order.search.page_count');
114
            } else {
115
                // pagingなどの処理
116
                if (is_null($page_no)) {
117
                    $page_no = intval($session->get('eccube.admin.order.search.page_no'));
118
                } else {
119
                    $session->set('eccube.admin.order.search.page_no', $page_no);
120
                }
121
                $viewData = $session->get('eccube.admin.order.search');
122
                if (!is_null($viewData)) {
123
                    // sessionに保持されている検索条件を復元.
124
                    $searchData = \Eccube\Util\FormUtil::submitAndGetData($searchForm, $viewData);
125
                }
126 View Code Duplication
                if (!is_null($searchData)) {
127
                    // 表示件数
128
                    $pcount = $request->get('page_count');
129
130
                    $page_count = empty($pcount) ? $page_count : $pcount;
131
132
                    $qb = $app['eccube.repository.order']->getQueryBuilderBySearchDataForAdmin($searchData);
133
134
                    $event = new EventArgs(
135
                        array(
136
                            'form' => $searchForm,
137
                            'qb' => $qb,
138
                        ),
139
                        $request
140
                    );
141
                    $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event);
142
143
                    $pagination = $app['paginator']()->paginate(
144
                        $qb,
145
                        $page_no,
146
                        $page_count
147
                    );
148
                        }
149
                    }
150
                        }
151
152
        return $app->render('Order/index.twig', array(
153
            'searchForm' => $searchForm->createView(),
154
            'pagination' => $pagination,
155
            'disps' => $disps,
156
            'pageMaxis' => $pageMaxis,
157
            'page_no' => $page_no,
158
            'page_count' => $page_count,
159
            'active' => $active,
160
        ));
161
162
    }
163
164
    public function delete(Application $app, Request $request, $id)
165
    {
166
        $this->isTokenValid($app);
167
        $session = $request->getSession();
168
        $page_no = intval($session->get('eccube.admin.order.search.page_no'));
169
        $page_no = $page_no ? $page_no : Constant::ENABLED;
170
171
        $Order = $app['orm.em']->getRepository('Eccube\Entity\Order')
172
            ->find($id);
173
174
        if (!$Order) {
175
            $app->deleteMessage();
176
            return $app->redirect($app->url('admin_order_page', array('page_no' => $page_no)).'?resume='.Constant::ENABLED);
0 ignored issues
show
Missing blank line before return statement
Loading history...
177
        }
178
179
        log_info('受注削除開始', array($Order->getId()));
180
181
        $Order->setDelFlg(Constant::ENABLED);
182
183
        $app['orm.em']->persist($Order);
184
        $app['orm.em']->flush();
185
186
        $Customer = $Order->getCustomer();
187
        if ($Customer) {
188
            // 会員の場合、購入回数、購入金額などを更新
189
            $app['eccube.repository.customer']->updateBuyData($app, $Customer, $Order->getOrderStatus()->getId());
190
        }
191
192
        $event = new EventArgs(
193
            array(
194
                'Order' => $Order,
195
                'Customer' => $Customer,
196
            ),
197
            $request
198
        );
199
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_DELETE_COMPLETE, $event);
200
201
        $app->addSuccess('admin.order.delete.complete', 'admin');
202
203
        log_info('受注削除完了', array($Order->getId()));
204
205
        return $app->redirect($app->url('admin_order_page', array('page_no' => $page_no)).'?resume='.Constant::ENABLED);
206
    }
207
208
209
    /**
210
     * 受注CSVの出力.
211
     *
212
     * @param Application $app
213
     * @param Request $request
214
     * @return StreamedResponse
215
     */
216
    public function exportOrder(Application $app, Request $request)
217
    {
218
219
        // タイムアウトを無効にする.
220
        set_time_limit(0);
221
222
        // sql loggerを無効にする.
223
        $em = $app['orm.em'];
224
        $em->getConfiguration()->setSQLLogger(null);
225
226
        $response = new StreamedResponse();
227
        $response->setCallback(function () use ($app, $request) {
228
229
            // CSV種別を元に初期化.
230
            $app['eccube.service.csv.export']->initCsvType(CsvType::CSV_TYPE_ORDER);
231
232
            // ヘッダ行の出力.
233
            $app['eccube.service.csv.export']->exportHeader();
234
235
            // 受注データ検索用のクエリビルダを取得.
236
            $qb = $app['eccube.service.csv.export']
237
                ->getOrderQueryBuilder($request);
238
239
            // データ行の出力.
240
            $app['eccube.service.csv.export']->setExportQueryBuilder($qb);
241 View Code Duplication
            $app['eccube.service.csv.export']->exportData(function ($entity, $csvService) use ($app, $request) {
242
243
                $Csvs = $csvService->getCsvs();
244
245
                $Order = $entity;
246
                $OrderDetails = $Order->getOrderDetails();
247
248
                foreach ($OrderDetails as $OrderDetail) {
249
                    $ExportCsvRow = new \Eccube\Entity\ExportCsvRow();
250
251
                    // CSV出力項目と合致するデータを取得.
252
                    foreach ($Csvs as $Csv) {
253
                        // 受注データを検索.
254
                        $ExportCsvRow->setData($csvService->getData($Csv, $Order));
255
                        if ($ExportCsvRow->isDataNull()) {
256
                            // 受注データにない場合は, 受注明細を検索.
257
                            $ExportCsvRow->setData($csvService->getData($Csv, $OrderDetail));
258
                        }
259
260
                        $event = new EventArgs(
261
                            array(
262
                                'csvService' => $csvService,
263
                                'Csv' => $Csv,
264
                                'OrderDetail' => $OrderDetail,
265
                                'ExportCsvRow' => $ExportCsvRow,
266
                            ),
267
                            $request
268
                        );
269
                        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_CSV_EXPORT_ORDER, $event);
270
271
                        $ExportCsvRow->pushData();
272
                    }
273
274
                    //$row[] = number_format(memory_get_usage(true));
275
                    // 出力.
276
                    $csvService->fputcsv($ExportCsvRow->getRow());
277
                }
278
            });
279
        });
280
281
        $now = new \DateTime();
282
        $filename = 'order_' . $now->format('YmdHis') . '.csv';
283
        $response->headers->set('Content-Type', 'application/octet-stream');
284
        $response->headers->set('Content-Disposition', 'attachment; filename=' . $filename);
285
        $response->send();
286
287
        log_info('受注CSV出力ファイル名', array($filename));
288
289
        return $response;
290
    }
291
292
    /**
293
     * 配送CSVの出力.
294
     *
295
     * @param Application $app
296
     * @param Request $request
297
     * @return StreamedResponse
298
     */
299
    public function exportShipping(Application $app, Request $request)
300
    {
301
        // タイムアウトを無効にする.
302
        set_time_limit(0);
303
304
        // sql loggerを無効にする.
305
        $em = $app['orm.em'];
306
        $em->getConfiguration()->setSQLLogger(null);
307
308
        $response = new StreamedResponse();
309
        $response->setCallback(function () use ($app, $request) {
310
311
            // CSV種別を元に初期化.
312
            $app['eccube.service.csv.export']->initCsvType(CsvType::CSV_TYPE_SHIPPING);
313
314
            // ヘッダ行の出力.
315
            $app['eccube.service.csv.export']->exportHeader();
316
317
            // 受注データ検索用のクエリビルダを取得.
318
            $qb = $app['eccube.service.csv.export']
319
                ->getOrderQueryBuilder($request);
320
321
            // データ行の出力.
322
            $app['eccube.service.csv.export']->setExportQueryBuilder($qb);
323
            $app['eccube.service.csv.export']->exportData(function ($entity, $csvService) use ($app, $request) {
324
325
                $Csvs = $csvService->getCsvs();
326
327
                /** @var $Order \Eccube\Entity\Order */
328
                $Order = $entity;
329
                /** @var $Shippings \Eccube\Entity\Shipping[] */
330
                $Shippings = $Order->getShippings();
331
332
                foreach ($Shippings as $Shipping) {
333
                    /** @var $ShipmentItems \Eccube\Entity\ShipmentItem */
334
                    $ShipmentItems = $Shipping->getShipmentItems();
335
                    foreach ($ShipmentItems as $ShipmentItem) {
336
                        $ExportCsvRow = new \Eccube\Entity\ExportCsvRow();
337
338
                        // CSV出力項目と合致するデータを取得.
339
                        foreach ($Csvs as $Csv) {
340
                            // 受注データを検索.
341
                            $ExportCsvRow->setData($csvService->getData($Csv, $Order));
342
                            if ($ExportCsvRow->isDataNull()) {
343
                                // 配送情報を検索.
344
                                $ExportCsvRow->setData($csvService->getData($Csv, $Shipping));
345
                            }
346
                            if ($ExportCsvRow->isDataNull()) {
347
                                // 配送商品を検索.
348
                                $ExportCsvRow->setData($csvService->getData($Csv, $ShipmentItem));
349
                            }
350
351
                            $event = new EventArgs(
352
                                array(
353
                                    'csvService' => $csvService,
354
                                    'Csv' => $Csv,
355
                                    'ShipmentItem' => $ShipmentItem,
356
                                    'ExportCsvRow' => $ExportCsvRow,
357
                                ),
358
                                $request
359
                            );
360
                            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_CSV_EXPORT_SHIPPING, $event);
361
362
                            $ExportCsvRow->pushData();
363
                        }
364
                        //$row[] = number_format(memory_get_usage(true));
365
                        // 出力.
366
                        $csvService->fputcsv($ExportCsvRow->getRow());
367
                    }
368
                }
369
            });
370
        });
371
372
        $now = new \DateTime();
373
        $filename = 'shipping_' . $now->format('YmdHis') . '.csv';
374
        $response->headers->set('Content-Type', 'application/octet-stream');
375
        $response->headers->set('Content-Disposition', 'attachment; filename=' . $filename);
376
        $response->send();
377
378
        log_info('配送CSV出力ファイル名', array($filename));
379
380
        return $response;
381
    }
382
}
383