1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.lockon.co.jp/ |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or |
11
|
|
|
* modify it under the terms of the GNU General Public License |
12
|
|
|
* as published by the Free Software Foundation; either version 2 |
13
|
|
|
* of the License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU General Public License |
21
|
|
|
* along with this program; if not, write to the Free Software |
22
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Symfony\Component\Debug\Debug; |
26
|
|
|
use Symfony\Component\Yaml\Yaml; |
27
|
|
|
|
28
|
|
|
// This check prevents access to debug front controllers that are deployed by accident to production servers. |
29
|
|
|
// Feel free to remove this, extend it, or make something more sophisticated. |
30
|
|
|
|
31
|
|
|
$allow = array( |
32
|
|
|
'127.0.0.1', |
33
|
|
|
'fe80::1', |
34
|
|
|
'::1', |
35
|
|
|
); |
36
|
|
|
|
37
|
|
|
if (isset($_SERVER['HTTP_CLIENT_IP']) |
38
|
|
|
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) |
39
|
|
|
|| !in_array(@$_SERVER['REMOTE_ADDR'], $allow) |
40
|
|
|
) { |
41
|
|
|
header('HTTP/1.0 403 Forbidden'); |
42
|
|
|
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
//[INFO]index.php,install.phpをEC-CUBEルート直下に移動させる場合は、コメントアウトしている行に置き換える |
46
|
|
|
require_once __DIR__.'/../autoload.php'; |
47
|
|
|
//require_once __DIR__.'/autoload.php'; |
|
|
|
|
48
|
|
|
|
49
|
|
|
Debug::enable(); |
50
|
|
|
|
51
|
|
|
// see http://silex.sensiolabs.org/doc/web_servers.html#php-5-4 |
52
|
|
|
$filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']); |
53
|
|
|
if (php_sapi_name() === 'cli-server' && is_file($filename)) { |
54
|
|
|
return false; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// output_config_php = true に設定することで、Config Yaml ファイルを元に Config PHP ファイルが出力されます。 |
58
|
|
|
// app/config/eccube, src/Eccube/Resource/config 以下に書き込み権限が必要です。 |
59
|
|
|
// Config PHP ファイルが存在する場合は、 Config Yaml より優先されます。 |
60
|
|
|
// Yaml ファイルをパースする必要が無いため、高速化が期待できます。 |
61
|
|
|
$app = \Eccube\Application::getInstance(array('output_config_php' => false)); |
62
|
|
|
|
63
|
|
|
// debug enable. |
64
|
|
|
$app['debug'] = true; |
65
|
|
|
|
66
|
|
|
// initialize servicies. |
67
|
|
|
$app->initialize(); |
68
|
|
|
$app->initializePlugin(); |
69
|
|
|
|
70
|
|
|
// load config dev |
71
|
|
|
$conf = $app['config']; |
72
|
|
|
$app['config'] = $app->share(function () use ($conf) { |
73
|
|
|
$confarray = array(); |
74
|
|
|
$config_dev_file = __DIR__.'/../app/config/eccube/config_dev.yml'; |
75
|
|
|
if (file_exists($config_dev_file)) { |
76
|
|
|
$config_dev = Yaml::parse(file_get_contents($config_dev_file)); |
77
|
|
|
if (isset($config_dev)) { |
78
|
|
|
$confarray = array_replace_recursive($confarray, $config_dev); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return array_replace_recursive($conf, $confarray); |
83
|
|
|
}); |
84
|
|
|
// config_dev.ymlにmailが設定されていた場合、config_dev.ymlの設定内容を反映 |
85
|
|
|
$app['swiftmailer.options'] = $app['config']['mail']; |
86
|
|
|
|
87
|
|
|
// Mail |
88
|
|
|
if (isset($app['config']['delivery_address'])) { |
89
|
|
|
$app['mailer']->registerPlugin(new \Swift_Plugins_RedirectingPlugin($app['config']['delivery_address'])); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// Silex Web Profiler |
93
|
|
|
$app->register(new \Silex\Provider\WebProfilerServiceProvider(), array( |
94
|
|
|
'profiler.cache_dir' => __DIR__.'/../app/cache/profiler', |
95
|
|
|
'profiler.mount_prefix' => '/_profiler', |
96
|
|
|
)); |
97
|
|
|
|
98
|
|
|
// Debug出力 |
99
|
|
|
$app->register(new \Eccube\ServiceProvider\DebugServiceProvider()); |
100
|
|
|
|
101
|
|
|
$app->register(new \Saxulum\SaxulumWebProfiler\Provider\SaxulumWebProfilerProvider()); |
102
|
|
|
|
103
|
|
|
$app->run(); |
104
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.