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