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\Install; |
||
26 | |||
27 | use Symfony\Component\Form\AbstractType; |
||
28 | use Symfony\Component\Form\Extension\Core\Type; |
||
29 | use Symfony\Component\Form\FormBuilderInterface; |
||
30 | use Symfony\Component\Form\FormError; |
||
31 | use Symfony\Component\Form\FormEvents; |
||
32 | use Symfony\Component\Validator\Constraints as Assert; |
||
33 | use Symfony\Component\Validator\Context\ExecutionContext; |
||
34 | |||
35 | class Step4Type extends AbstractType |
||
36 | { |
||
37 | public $app; |
||
38 | |||
39 | 36 | public function __construct(\Silex\Application $app) |
|
40 | { |
||
41 | 36 | $this->app = $app; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 1 | public function buildForm(FormBuilderInterface $builder, array $options) |
|
48 | { |
||
49 | |||
50 | 1 | $database = array(); |
|
51 | 1 | if (extension_loaded('pdo_pgsql')) { |
|
52 | 1 | $database['pdo_pgsql'] = 'PostgreSQL'; |
|
53 | } |
||
54 | 1 | if (extension_loaded('pdo_mysql')) { |
|
55 | 1 | $database['pdo_mysql'] = 'MySQL'; |
|
56 | } |
||
57 | 1 | if (extension_loaded('pdo_sqlite')) { |
|
58 | 1 | $database['pdo_sqlite'] = 'SQLite(開発者用)'; |
|
59 | } |
||
60 | |||
61 | $builder |
||
62 | 1 | ->add('database', 'choice', array( |
|
63 | 1 | 'label' => 'データベースの種類', |
|
64 | 1 | 'choices' => $database, |
|
65 | 'expanded' => false, |
||
66 | 'multiple' => false, |
||
67 | 'constraints' => array( |
||
68 | 1 | new Assert\NotBlank(), |
|
69 | ), |
||
70 | )) |
||
71 | 1 | ->add('database_host', 'text', array( |
|
72 | 1 | 'label' => 'データベースのホスト名', |
|
73 | 'required' => false, |
||
74 | )) |
||
75 | 1 | ->add('database_port', 'text', array( |
|
76 | 1 | 'label' => 'ポート番号', |
|
77 | 'required' => false, |
||
78 | )) |
||
79 | 1 | ->add('database_name', 'text', array( |
|
80 | 1 | 'label' => 'データベース名', |
|
81 | 'constraints' => array( |
||
82 | 1 | new Assert\Callback(array($this, 'validate')), |
|
83 | ), |
||
84 | )) |
||
85 | 1 | ->add('database_user', 'text', array( |
|
86 | 1 | 'label' => 'ユーザ名', |
|
87 | 'constraints' => array( |
||
88 | 1 | new Assert\Callback(array($this, 'validate')), |
|
89 | ), |
||
90 | )) |
||
91 | 1 | ->add('database_password', 'password', array( |
|
92 | 1 | 'label' => 'パスワード', |
|
93 | 'required' => false, |
||
94 | )) |
||
95 | 1 | ->addEventListener(FormEvents::POST_SUBMIT, function ($event) { |
|
96 | $form = $event->getForm(); |
||
97 | $data = $form->getData(); |
||
98 | try { |
||
99 | $config = new \Doctrine\DBAL\Configuration(); |
||
100 | if ($data['database'] == 'pdo_sqlite') { |
||
101 | $connectionParams = array( |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
102 | 'driver' => $data['database'], |
||
103 | 'path' => __DIR__.'/../../../../../app/config/eccube/eccube.db' |
||
104 | ); |
||
105 | |||
0 ignored issues
–
show
|
|||
106 | } else { |
||
107 | $connectionParams = array( |
||
108 | 'dbname' => $data['database_name'], |
||
109 | 'user' => $data['database_user'], |
||
110 | 'password' => $data['database_password'], |
||
111 | 'host' => $data['database_host'], |
||
112 | 'driver' => $data['database'], |
||
113 | 'port' => $data['database_port'], |
||
114 | ); |
||
115 | } |
||
116 | // todo MySQL, PostgreSQLのバージョンチェックも欲しい.DBALで接続すればエラーになる? |
||
117 | $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); |
||
118 | $conn->connect(); |
||
119 | } catch (\Exception $e) { |
||
120 | $form['database']->addError(new FormError('データベースに接続できませんでした。' . $e->getMessage())); |
||
121 | } |
||
122 | 1 | }); |
|
123 | } |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | 37 | public function getName() |
|
129 | { |
||
130 | 37 | return 'install_step4'; |
|
131 | } |
||
132 | |||
133 | public function validate($data, ExecutionContext $context, $param = null) |
||
0 ignored issues
–
show
|
|||
134 | { |
||
135 | $parameters = $this->app['request']->get('install_step4'); |
||
136 | if ($parameters['database'] != 'pdo_sqlite'){ |
||
137 | $context->validateValue($data, array( |
||
0 ignored issues
–
show
|
|||
138 | new Assert\NotBlank() |
||
139 | )); |
||
140 | } |
||
141 | } |
||
142 | } |
||
143 |