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 | * 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\Form\Type\Admin; |
||
26 | |||
27 | use Symfony\Component\Form\AbstractType; |
||
28 | use Symfony\Component\Form\FormBuilderInterface; |
||
29 | use Symfony\Component\Form\FormError; |
||
30 | use Symfony\Component\Form\FormEvents; |
||
31 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
32 | use Symfony\Component\Validator\Constraints as Assert; |
||
33 | |||
34 | class BlockType extends AbstractType |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
35 | { |
||
36 | public $app; |
||
37 | |||
38 | 286 | public function __construct(\Silex\Application $app) |
|
39 | { |
||
40 | 286 | $this->app = $app; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | public function buildForm(FormBuilderInterface $builder, array $options) |
|
47 | { |
||
48 | 1 | $app = $this->app; |
|
49 | |||
50 | $builder |
||
51 | ->add('name', 'text', array( |
||
0 ignored issues
–
show
|
|||
52 | 1 | 'label' => 'ブロック名', |
|
53 | 1 | 'required' => true, |
|
54 | 'constraints' => array( |
||
0 ignored issues
–
show
|
|||
55 | new Assert\NotBlank(), |
||
56 | new Assert\Length(array( |
||
57 | 1 | 'max' => $app['config']['stext_len'], |
|
58 | )) |
||
59 | 1 | ) |
|
60 | )) |
||
61 | ->add('file_name', 'text', array( |
||
62 | 1 | 'label' => 'ファイル名', |
|
63 | 1 | 'required' => true, |
|
64 | 'constraints' => array( |
||
65 | new Assert\NotBlank(), |
||
66 | new Assert\Length(array( |
||
67 | 1 | 'max' => $app['config']['stext_len'], |
|
68 | )), |
||
69 | new Assert\Regex(array( |
||
70 | 'pattern' => '/^[0-9a-zA-Z\/_]+$/', |
||
71 | )), |
||
72 | 1 | ) |
|
73 | )) |
||
74 | ->add('block_html', 'textarea', array( |
||
75 | 'label' => 'ブロックデータ', |
||
76 | 'mapped' => false, |
||
77 | 'required' => false, |
||
78 | 'constraints' => array() |
||
79 | )) |
||
80 | ->add('DeviceType', 'entity', array( |
||
81 | 'class' => 'Eccube\Entity\Master\DeviceType', |
||
82 | 'property' => 'id', |
||
83 | )) |
||
84 | 1 | ->add('id', 'hidden') |
|
85 | View Code Duplication | ->addEventListener(FormEvents::POST_SUBMIT, function($event) use ($app) { |
|
86 | $form = $event->getForm(); |
||
87 | $file_name = $form['file_name']->getData(); |
||
88 | $DeviceType = $form['DeviceType']->getData(); |
||
89 | $block_id = $form['id']->getData(); |
||
90 | |||
91 | $qb = $app['orm.em']->createQueryBuilder(); |
||
92 | $qb->select('b') |
||
93 | ->from('Eccube\\Entity\\Block', 'b') |
||
94 | ->where('b.file_name = :file_name') |
||
95 | ->setParameter('file_name', $file_name) |
||
96 | ->andWhere('b.DeviceType = :DeviceType') |
||
97 | ->setParameter('DeviceType', $DeviceType); |
||
98 | if (isset($block_id)) { |
||
99 | $qb |
||
100 | ->andWhere('b.id <> :block_id') |
||
101 | ->setParameter('block_id', $block_id); |
||
102 | } |
||
103 | |||
104 | $Block = $qb |
||
105 | ->getQuery() |
||
106 | ->getResult(); |
||
107 | if (count($Block) > 0) { |
||
108 | $form['file_name']->addError(new FormError('※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。')); |
||
109 | } |
||
110 | }); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
||
117 | { |
||
118 | $resolver->setDefaults(array( |
||
119 | 'data_class' => 'Eccube\Entity\Block', |
||
120 | )); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | public function getName() |
||
127 | 285 | { |
|
128 | return 'block'; |
||
129 | 285 | } |
|
130 | } |
||
131 |