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\Controller\Admin\Content; |
||
26 | |||
27 | use Eccube\Application; |
||
28 | use Eccube\Controller\AbstractController; |
||
29 | use Eccube\Entity\Master\DeviceType; |
||
30 | use Eccube\Entity\PageLayout; |
||
31 | use Eccube\Event\EccubeEvents; |
||
32 | use Eccube\Event\EventArgs; |
||
33 | use Eccube\Util\Str; |
||
34 | use Symfony\Component\Filesystem\Filesystem; |
||
35 | use Symfony\Component\Finder\Finder; |
||
36 | 1 | use Symfony\Component\HttpFoundation\Request; |
|
37 | |||
38 | class PageController extends AbstractController |
||
39 | { |
||
40 | View Code Duplication | public function index(Application $app, Request $request) |
|
41 | { |
||
42 | $DeviceType = $app['eccube.repository.master.device_type'] |
||
43 | 1 | ->find(DeviceType::DEVICE_TYPE_PC); |
|
44 | |||
45 | $PageLayouts = $app['eccube.repository.page_layout']->getPageList($DeviceType); |
||
46 | 1 | ||
47 | $event = new EventArgs( |
||
48 | 1 | array( |
|
49 | 'DeviceType' => $DeviceType, |
||
50 | 'PageLayouts' => $PageLayouts, |
||
51 | ), |
||
52 | $request |
||
53 | ); |
||
54 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_INDEX_COMPLETE, $event); |
||
55 | |||
56 | 1 | return $app->render('Content/page.twig', array( |
|
57 | 'PageLayouts' => $PageLayouts, |
||
58 | )); |
||
59 | } |
||
60 | |||
61 | public function edit(Application $app, Request $request, $id = null) |
||
62 | 1 | { |
|
63 | $DeviceType = $app['eccube.repository.master.device_type'] |
||
64 | ->find(DeviceType::DEVICE_TYPE_PC); |
||
65 | 1 | ||
66 | 1 | $PageLayout = $app['eccube.repository.page_layout'] |
|
67 | ->findOrCreate($id, $DeviceType); |
||
68 | |||
69 | $editable = true; |
||
70 | |||
71 | $builder = $app['form.factory'] |
||
72 | ->createBuilder('main_edit', $PageLayout); |
||
73 | |||
74 | $event = new EventArgs( |
||
75 | array( |
||
76 | 'builder' => $builder, |
||
77 | 'DeviceType' => $DeviceType, |
||
78 | 'PageLayout' => $PageLayout, |
||
79 | ), |
||
80 | $request |
||
81 | ); |
||
82 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_EDIT_INITIALIZE, $event); |
||
83 | |||
84 | $form = $builder->getForm(); |
||
85 | |||
86 | // 更新時 |
||
87 | $fileName = null; |
||
88 | if ($id) { |
||
89 | // 編集不可ページはURL、ページ名、ファイル名を保持 |
||
90 | if ($PageLayout->getEditFlg() == PageLayout::EDIT_FLG_DEFAULT) { |
||
91 | $editable = false; |
||
92 | $PrevPageLayout = clone $PageLayout; |
||
93 | } |
||
94 | // テンプレートファイルの取得 |
||
95 | $file = $app['eccube.repository.page_layout'] |
||
96 | ->getReadTemplateFile($PageLayout->getFileName(), $editable); |
||
97 | |||
98 | $form->get('tpl_data')->setData($file['tpl_data']); |
||
99 | |||
100 | $fileName = $PageLayout->getFileName(); |
||
101 | } |
||
102 | |||
103 | $form->handleRequest($request); |
||
104 | |||
105 | if ($form->isSubmitted() && $form->isValid()) { |
||
106 | |||
107 | $PageLayout = $form->getData(); |
||
108 | |||
109 | 1 | if (!$editable) { |
|
110 | 1 | $PageLayout |
|
111 | 1 | ->setUrl($PrevPageLayout->getUrl()) |
|
112 | ->setFileName($PrevPageLayout->getFileName()) |
||
113 | ->setName($PageLayout->getName()); |
||
114 | } |
||
115 | 1 | // DB登録 |
|
116 | $app['orm.em']->persist($PageLayout); |
||
117 | 1 | $app['orm.em']->flush(); |
|
118 | |||
119 | // ファイル生成・更新 |
||
120 | $templatePath = $app['eccube.repository.page_layout']->getWriteTemplatePath($editable); |
||
121 | $filePath = $templatePath.'/'.$PageLayout->getFileName().'.twig'; |
||
122 | |||
123 | $fs = new Filesystem(); |
||
124 | $pageData = $form->get('tpl_data')->getData(); |
||
125 | $pageData = Str::convertLineFeed($pageData); |
||
126 | $fs->dumpFile($filePath, $pageData); |
||
127 | |||
128 | // 更新でファイル名を変更した場合、以前のファイルを削除 |
||
129 | View Code Duplication | if ($PageLayout->getFileName() != $fileName && !is_null($fileName)) { |
|
130 | 1 | $oldFilePath = $templatePath.'/'.$fileName.'.twig'; |
|
131 | if ($fs->exists($oldFilePath)) { |
||
132 | $fs->remove($oldFilePath); |
||
133 | } |
||
134 | } |
||
135 | |||
136 | $event = new EventArgs( |
||
137 | array( |
||
138 | 'form' => $form, |
||
139 | 'PageLayout' => $PageLayout, |
||
140 | 'templatePath' => $templatePath, |
||
141 | 'filePath' => $filePath, |
||
142 | ), |
||
143 | $request |
||
144 | ); |
||
145 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_EDIT_COMPLETE, $event); |
||
146 | |||
147 | $app->addSuccess('admin.register.complete', 'admin'); |
||
148 | |||
149 | // twig キャッシュの削除. |
||
150 | $finder = Finder::create()->in($app['config']['root_dir'].'/app/cache/twig'); |
||
151 | 1 | $fs->remove($finder); |
|
152 | |||
153 | return $app->redirect($app->url('admin_content_page_edit', array('id' => $PageLayout->getId()))); |
||
154 | } |
||
155 | |||
156 | $templatePath = $app['eccube.repository.page_layout']->getWriteTemplatePath($editable); |
||
157 | |||
158 | return $app->render('Content/page_edit.twig', array( |
||
159 | 'form' => $form->createView(), |
||
160 | 'page_id' => $PageLayout->getId(), |
||
161 | 'editable' => $editable, |
||
162 | 'template_path' => $templatePath, |
||
163 | )); |
||
164 | } |
||
165 | |||
166 | View Code Duplication | public function delete(Application $app, Request $request, $id = null) |
|
167 | { |
||
168 | $this->isTokenValid($app); |
||
169 | |||
170 | $DeviceType = $app['eccube.repository.master.device_type'] |
||
171 | ->find(DeviceType::DEVICE_TYPE_PC); |
||
172 | |||
173 | $PageLayout = $app['eccube.repository.page_layout'] |
||
174 | ->findOneBy(array( |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
175 | 'id' => $id, |
||
176 | 'DeviceType' => $DeviceType |
||
177 | )); |
||
178 | |||
179 | if (!$PageLayout) { |
||
180 | $app->deleteMessage(); |
||
181 | |||
182 | return $app->redirect($app->url('admin_content_page')); |
||
183 | } |
||
184 | |||
185 | // ユーザーが作ったページのみ削除する |
||
186 | if ($PageLayout->getEditFlg() == PageLayout::EDIT_FLG_USER) { |
||
187 | $templatePath = $app['eccube.repository.page_layout']->getWriteTemplatePath(true); |
||
188 | $file = $templatePath.'/'.$PageLayout->getFileName().'.twig'; |
||
189 | $fs = new Filesystem(); |
||
190 | if ($fs->exists($file)) { |
||
191 | $fs->remove($file); |
||
192 | } |
||
193 | $app['orm.em']->remove($PageLayout); |
||
194 | $app['orm.em']->flush(); |
||
195 | |||
196 | $event = new EventArgs( |
||
197 | array( |
||
198 | 'DeviceType' => $DeviceType, |
||
199 | 'PageLayout' => $PageLayout, |
||
200 | ), |
||
201 | $request |
||
202 | ); |
||
203 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_PAGE_DELETE_COMPLETE, $event); |
||
204 | |||
205 | $app->addSuccess('admin.delete.complete', 'admin'); |
||
206 | } |
||
207 | |||
208 | return $app->redirect($app->url('admin_content_page')); |
||
209 | } |
||
210 | } |
||
211 |