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\Customer; |
||
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 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
36 | |||
37 | class CustomerController extends AbstractController |
||
38 | { |
||
39 | public function index(Application $app, Request $request, $page_no = null) |
||
40 | { |
||
41 | $session = $request->getSession(); |
||
42 | $pagination = array(); |
||
43 | $builder = $app['form.factory'] |
||
44 | ->createBuilder('admin_search_customer'); |
||
45 | |||
46 | $event = new EventArgs( |
||
47 | array( |
||
48 | 'builder' => $builder, |
||
49 | ), |
||
50 | $request |
||
51 | ); |
||
52 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_INDEX_INITIALIZE, $event); |
||
53 | |||
54 | $searchForm = $builder->getForm(); |
||
55 | |||
56 | //アコーディオンの制御初期化( デフォルトでは閉じる ) |
||
57 | $active = false; |
||
58 | |||
59 | $pageMaxis = $app['eccube.repository.master.page_max']->findAll(); |
||
60 | |||
61 | // 表示件数は順番で取得する、1.SESSION 2.設定ファイル |
||
62 | $page_count = $session->get('eccube.admin.customer.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.customer.search.page_count', $page_count); |
||
72 | break; |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | |||
77 | if ('POST' === $request->getMethod()) { |
||
78 | |||
79 | $searchForm->handleRequest($request); |
||
80 | |||
81 | View Code Duplication | if ($searchForm->isValid()) { |
|
82 | $searchData = $searchForm->getData(); |
||
83 | |||
84 | // paginator |
||
85 | $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData); |
||
86 | $page_no = 1; |
||
87 | |||
88 | $event = new EventArgs( |
||
89 | array( |
||
90 | 'form' => $searchForm, |
||
91 | 'qb' => $qb, |
||
92 | ), |
||
93 | $request |
||
94 | ); |
||
95 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_INDEX_SEARCH, $event); |
||
96 | |||
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.customer.search', $viewData); |
||
106 | $session->set('eccube.admin.customer.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.customer.search'); |
||
112 | $session->remove('eccube.admin.customer.search.page_no'); |
||
113 | $session->remove('eccube.admin.customer.search.page_count'); |
||
114 | } else { |
||
115 | // pagingなどの処理 |
||
116 | if (is_null($page_no)) { |
||
117 | $page_no = intval($session->get('eccube.admin.customer.search.page_no')); |
||
118 | } else { |
||
119 | $session->set('eccube.admin.customer.search.page_no', $page_no); |
||
120 | } |
||
121 | $viewData = $session->get('eccube.admin.customer.search'); |
||
122 | View Code Duplication | if (!is_null($viewData)) { |
|
123 | // sessionに保持されている検索条件を復元. |
||
124 | $searchData = \Eccube\Util\FormUtil::submitAndGetData($searchForm, $viewData); |
||
125 | |||
126 | // 表示件数 |
||
127 | $page_count = $request->get('page_count', $page_count); |
||
128 | |||
129 | $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData); |
||
130 | |||
131 | $event = new EventArgs( |
||
132 | array( |
||
133 | 'form' => $searchForm, |
||
134 | 'qb' => $qb, |
||
135 | ), |
||
136 | $request |
||
137 | ); |
||
138 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_INDEX_SEARCH, $event); |
||
139 | |||
140 | $pagination = $app['paginator']()->paginate( |
||
141 | $qb, |
||
142 | $page_no, |
||
143 | $page_count |
||
144 | ); |
||
145 | } |
||
146 | } |
||
147 | } |
||
148 | return $app->render('Customer/index.twig', array( |
||
149 | 'searchForm' => $searchForm->createView(), |
||
150 | 'pagination' => $pagination, |
||
151 | 'pageMaxis' => $pageMaxis, |
||
152 | 'page_no' => $page_no, |
||
153 | 'page_count' => $page_count, |
||
154 | 'active' => $active, |
||
155 | )); |
||
156 | } |
||
157 | |||
158 | public function resend(Application $app, Request $request, $id) |
||
159 | { |
||
160 | $this->isTokenValid($app); |
||
161 | |||
162 | $Customer = $app['orm.em'] |
||
163 | ->getRepository('Eccube\Entity\Customer') |
||
164 | ->find($id); |
||
165 | |||
166 | if (is_null($Customer)) { |
||
167 | throw new NotFoundHttpException(); |
||
168 | } |
||
169 | |||
170 | $activateUrl = $app->url('entry_activate', array('secret_key' => $Customer->getSecretKey())); |
||
171 | |||
172 | // メール送信 |
||
173 | $app['eccube.service.mail']->sendAdminCustomerConfirmMail($Customer, $activateUrl); |
||
174 | |||
175 | $event = new EventArgs( |
||
176 | array( |
||
177 | 'Customer' => $Customer, |
||
178 | 'activateUrl' => $activateUrl, |
||
179 | ), |
||
180 | $request |
||
181 | ); |
||
182 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_RESEND_COMPLETE, $event); |
||
183 | |||
184 | $app->addSuccess('admin.customer.resend.complete', 'admin'); |
||
185 | |||
186 | return $app->redirect($app->url('admin_customer')); |
||
187 | } |
||
188 | |||
189 | public function delete(Application $app, Request $request, $id) |
||
190 | { |
||
191 | $this->isTokenValid($app); |
||
192 | |||
193 | log_info('会員削除開始', array($id)); |
||
194 | |||
195 | $session = $request->getSession(); |
||
196 | $page_no = intval($session->get('eccube.admin.customer.search.page_no')); |
||
197 | $page_no = $page_no ? $page_no : Constant::ENABLED; |
||
198 | |||
199 | $Customer = $app['orm.em'] |
||
200 | ->getRepository('Eccube\Entity\Customer') |
||
201 | ->find($id); |
||
202 | |||
203 | if (!$Customer) { |
||
204 | $app->deleteMessage(); |
||
205 | return $app->redirect($app->url('admin_customer_page', array('page_no' => $page_no)).'?resume='.Constant::ENABLED); |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
206 | } |
||
207 | |||
208 | $Customer->setDelFlg(Constant::ENABLED); |
||
209 | $app['orm.em']->persist($Customer); |
||
210 | $app['orm.em']->flush(); |
||
211 | |||
212 | log_info('会員削除完了', array($id)); |
||
213 | |||
214 | $event = new EventArgs( |
||
215 | array( |
||
216 | 'Customer' => $Customer, |
||
217 | ), |
||
218 | $request |
||
219 | ); |
||
220 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_DELETE_COMPLETE, $event); |
||
221 | |||
222 | $app->addSuccess('admin.customer.delete.complete', 'admin'); |
||
223 | |||
224 | return $app->redirect($app->url('admin_customer_page', array('page_no' => $page_no)).'?resume='.Constant::ENABLED); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * 会員CSVの出力. |
||
229 | * @param Application $app |
||
230 | * @param Request $request |
||
231 | * @return StreamedResponse |
||
232 | */ |
||
233 | public function export(Application $app, Request $request) |
||
234 | { |
||
235 | // タイムアウトを無効にする. |
||
236 | set_time_limit(0); |
||
237 | |||
238 | // sql loggerを無効にする. |
||
239 | $em = $app['orm.em']; |
||
240 | $em->getConfiguration()->setSQLLogger(null); |
||
241 | |||
242 | $response = new StreamedResponse(); |
||
243 | $response->setCallback(function () use ($app, $request) { |
||
244 | |||
245 | // CSV種別を元に初期化. |
||
246 | $app['eccube.service.csv.export']->initCsvType(CsvType::CSV_TYPE_CUSTOMER); |
||
247 | |||
248 | // ヘッダ行の出力. |
||
249 | $app['eccube.service.csv.export']->exportHeader(); |
||
250 | |||
251 | // 会員データ検索用のクエリビルダを取得. |
||
252 | $qb = $app['eccube.service.csv.export'] |
||
253 | ->getCustomerQueryBuilder($request); |
||
254 | |||
255 | // データ行の出力. |
||
256 | $app['eccube.service.csv.export']->setExportQueryBuilder($qb); |
||
257 | View Code Duplication | $app['eccube.service.csv.export']->exportData(function ($entity, $csvService) use ($app, $request) { |
|
258 | |||
259 | $Csvs = $csvService->getCsvs(); |
||
260 | |||
261 | /** @var $Customer \Eccube\Entity\Customer */ |
||
262 | $Customer = $entity; |
||
263 | |||
264 | $ExportCsvRow = new \Eccube\Entity\ExportCsvRow(); |
||
265 | |||
266 | // CSV出力項目と合致するデータを取得. |
||
267 | foreach ($Csvs as $Csv) { |
||
268 | // 会員データを検索. |
||
269 | $ExportCsvRow->setData($csvService->getData($Csv, $Customer)); |
||
270 | |||
271 | $event = new EventArgs( |
||
272 | array( |
||
273 | 'csvService' => $csvService, |
||
274 | 'Csv' => $Csv, |
||
275 | 'Customer' => $Customer, |
||
276 | 'ExportCsvRow' => $ExportCsvRow, |
||
277 | ), |
||
278 | $request |
||
279 | ); |
||
280 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_CSV_EXPORT, $event); |
||
281 | |||
282 | $ExportCsvRow->pushData(); |
||
283 | } |
||
284 | |||
285 | //$row[] = number_format(memory_get_usage(true)); |
||
286 | // 出力. |
||
287 | $csvService->fputcsv($ExportCsvRow->getRow()); |
||
288 | }); |
||
289 | }); |
||
290 | |||
291 | $now = new \DateTime(); |
||
292 | $filename = 'customer_' . $now->format('YmdHis') . '.csv'; |
||
293 | $response->headers->set('Content-Type', 'application/octet-stream'); |
||
294 | $response->headers->set('Content-Disposition', 'attachment; filename=' . $filename); |
||
295 | |||
296 | $response->send(); |
||
297 | |||
298 | log_info("会員CSVファイル名", array($filename)); |
||
299 | |||
300 | return $response; |
||
301 | } |
||
302 | } |
||
303 |