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.

Admin/Setting/Shop/DeliveryController.php (4 issues)

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\Setting\Shop;
26
27
use Eccube\Application;
28
use Eccube\Common\Constant;
29
use Eccube\Controller\AbstractController;
30
use Eccube\Event\EccubeEvents;
31
use Eccube\Event\EventArgs;
32
use Symfony\Component\HttpFoundation\Request;
33
34
class DeliveryController extends AbstractController
0 ignored issues
show
Missing class doc comment
Loading history...
35
{
36
    private $main_title;
37
    private $sub_title;
38
39
    public $form;
40
41
    public function __construct()
0 ignored issues
show
Missing function doc comment
Loading history...
42
    {
43
    }
44
45 View Code Duplication
    public function index(Application $app, Request $request)
46
    {
47
        $Deliveries = $app['eccube.repository.delivery']
48
            ->findBy(
49
                array('del_flg' => 0),
50
                array('rank' => 'DESC')
51
            );
52
53
        $event = new EventArgs(
54
            array(
55
                'Deliveries' => $Deliveries,
56
            ),
57
            $request
58
        );
59
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_DELIVERY_INDEX_COMPLETE, $event);
60
61
        return $app->render('Setting/Shop/delivery.twig', array(
62
            'Deliveries' => $Deliveries,
63
        ));
64
    }
65
66
    public function edit(Application $app, Request $request, $id = 0)
67
    {
68
        /* @var $Delivery \Eccube\Entity\Delivery */
69
        $Delivery = $app['eccube.repository.delivery']
70
            ->findOrCreate($id);
71
72
        // FormType: DeliveryFeeの生成
73
        $Prefs = $app['eccube.repository.master.pref']
74
            ->findAll();
75
76
        foreach ($Prefs as $Pref) {
77
            $DeliveryFee = $app['eccube.repository.delivery_fee']
78
                ->findOrCreate(array(
79
                    'Delivery' => $Delivery,
80
                    'Pref' => $Pref,
81
                ));
82
            if (!$DeliveryFee->getFee()) {
83
                $Delivery->addDeliveryFee($DeliveryFee);
84
            }
85
        }
86
87
        $DeliveryFees = $Delivery->getDeliveryFees();
88
        $DeliveryFeesIndex = array();
89
        foreach ($DeliveryFees as $DeliveryFee) {
90
            $Delivery->removeDeliveryFee($DeliveryFee);
91
            $DeliveryFeesIndex[$DeliveryFee->getPref()->getId()] = $DeliveryFee;
92
        }
93
        ksort($DeliveryFeesIndex);
94
        foreach ($DeliveryFeesIndex as $timeId => $DeliveryFee) {
95
            $Delivery->addDeliveryFee($DeliveryFee);
96
        }
97
98
        // FormType: DeliveryTimeの生成
99
        $DeliveryTimes = $Delivery->getDeliveryTimes();
100
        $loop = 16 - count($DeliveryTimes);
101
        for ($i = 1; $i <= $loop; $i++) {
102
            $DeliveryTime = new \Eccube\Entity\DeliveryTime();
103
            $DeliveryTime->setDelivery($Delivery);
104
            $Delivery->addDeliveryTime($DeliveryTime);
105
        }
106
107
        $builder = $app['form.factory']
108
            ->createBuilder('delivery', $Delivery);
109
110
        $event = new EventArgs(
111
            array(
112
                'builder' => $builder,
113
                'Delivery' => $Delivery,
114
                'Prefs' => $Prefs,
115
                'DeliveryFees' => $DeliveryFees,
116
            ),
117
            $request
118
        );
119
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_DELIVERY_EDIT_INITIALIZE, $event);
120
121
        $form = $builder->getForm();
122
123
        // 支払方法をセット
124
        $Payments = array();
125
        foreach ($Delivery->getPaymentOptions() as $PaymentOption) {
126
            $Payments[] = $PaymentOption->getPayment();
127
        }
128
129
        $form['delivery_times']->setData($Delivery->getDeliveryTimes());
130
        $form['payments']->setData($Payments);
131
132
        // 登録ボタン押下
133
        if ($app['request']->getMethod() === 'POST') {
134
            $form->handleRequest($app['request']);
135
136
            if ($form->isValid()) {
137
                $DeliveryData = $form->getData();
138
139
                // 配送時間の登録
140
                $DeliveryTimes = $form['delivery_times']->getData();
141
                foreach ($DeliveryTimes as $DeliveryTime) {
142
                    if (is_null($DeliveryTime->getDeliveryTime())) {
143
                        $Delivery->removeDeliveryTime($DeliveryTime);
144
                        $app['orm.em']->remove($DeliveryTime);
145
                    }
146
                }
147
148
                // お支払いの登録
149
                $PaymentOptions = $app['eccube.repository.payment_option']
150
                    ->findBy(array('delivery_id' => $id));
151
                // 消す
152
                foreach ($PaymentOptions as $PaymentOption) {
153
                    $DeliveryData->removePaymentOption($PaymentOption);
154
                    $app['orm.em']->remove($PaymentOption);
155
                }
156
                $app['orm.em']->persist($DeliveryData);
157
                $app['orm.em']->flush();
158
159
                // いれる
160
                $PaymentsData = $form->get('payments')->getData();
161
                foreach ($PaymentsData as $PaymentData) {
162
                    $PaymentOption = new \Eccube\Entity\PaymentOption();
163
                    $PaymentOption
164
                        ->setPaymentId($PaymentData->getId())
165
                        ->setPayment($PaymentData)
166
                        ->setDeliveryId($DeliveryData->getId())
167
                        ->setDelivery($DeliveryData);
168
                    $DeliveryData->addPaymentOption($PaymentOption);
169
                    $app['orm.em']->persist($DeliveryData);
170
                }
171
172
                $app['orm.em']->persist($DeliveryData);
173
174
                $app['orm.em']->flush();
175
176
                $event = new EventArgs(
177
                    array(
178
                        'form' => $form,
179
                        'Delivery' => $Delivery,
180
                        'Prefs' => $Prefs,
181
                        'DeliveryFees' => $DeliveryFees,
182
                    ),
183
                    $request
184
                );
185
                $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_DELIVERY_EDIT_COMPLETE, $event);
186
187
                $app->addSuccess('admin.register.complete', 'admin');
188
189
                return $app->redirect($app->url('admin_setting_shop_delivery'));
190
            }
191
        }
192
        return $app->render('Setting/Shop/delivery_edit.twig', array(
0 ignored issues
show
Missing blank line before return statement
Loading history...
193
            'form' => $form->createView(),
194
            'delivery_id' => $id,
195
        ));
196
    }
197
198
    public function delete(Application $app, Request $request, $id)
199
    {
200
        $this->isTokenValid($app);
201
202
        $repo = $app['eccube.repository.delivery'];
203
        $Delivery = $repo->find($id);
204
        if (!$Delivery) {
205
            $app->deleteMessage();
206
            return $app->redirect($app->url('admin_setting_shop_delivery'));
207
        }
208
209
        $Delivery
210
            ->setDelFlg(Constant::ENABLED)
211
            ->setRank(0);
212
213
        $app['orm.em']->persist($Delivery);
214
215
        $rank = 1;
216
        $Delivs = $repo
217
            ->findBy(
218
                array('del_flg' => Constant::DISABLED),
219
                array('rank' => 'ASC')
220
            );
221
        foreach ($Delivs as $Deliv) {
222
            if ($Deliv->getId() != $id) {
223
                $Deliv->setRank($rank);
224
                $rank++;
225
            }
226
        }
227
228
        $app['orm.em']->flush();
229
230
        $event = new EventArgs(
231
            array(
232
                'Delivs' => $Delivs,
233
                'Delivery' => $Delivery,
234
            ),
235
            $request
236
        );
237
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_DELIVERY_DELETE_COMPLETE, $event);
238
239
        $app->addSuccess('admin.delete.complete', 'admin');
240
241
        return $app->redirect($app->url('admin_setting_shop_delivery'));
242
    }
243
244 View Code Duplication
    public function moveRank(Application $app, Request $request)
0 ignored issues
show
Missing function doc comment
Loading history...
245
    {
246
        if ($request->isXmlHttpRequest()) {
247
            $ranks = $request->request->all();
248
            foreach ($ranks as $deliveryId => $rank) {
249
                $Delivery = $app['eccube.repository.delivery']
250
                    ->find($deliveryId);
251
                $Delivery->setRank($rank);
252
                $app['orm.em']->persist($Delivery);
253
            }
254
            $app['orm.em']->flush();
255
        }
256
257
        return true;
258
    }
259
}
260