| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | if (php_sapi_name() !== 'cli') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |     exit(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | set_time_limit(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | ini_set('display_errors', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | define('COMPOSER_FILE', 'composer.phar'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | define('COMPOSER_SETUP_FILE', 'composer-setup.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | setUseAnsi($argv); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | $argv = is_array($argv) ? $argv : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | $argv[1] = isset($argv[1]) ? $argv[1] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | $argv[2] = isset($argv[2]) ? $argv[2] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | if (in_array('--help', $argv) || empty($argv[1])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     displayHelp($argv); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     exit(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | if (in_array('-v', $argv) || in_array('--version', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     require __DIR__.'/src/Eccube/Common/Constant.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     echo 'EC-CUBE '.Eccube\Common\Constant::VERSION.PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     exit(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | out('EC-CUBE3 installer use database driver of ', null, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | $database_driver = 'pdo_sqlite'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | switch($argv[1]) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     case 'mysql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $database_driver = 'pdo_mysql'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     case 'pgsql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $database_driver = 'pdo_pgsql'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     case 'sqlite': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     case 'sqlite3': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     case 'sqlite3-in-memory': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $database_driver = 'pdo_sqlite'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | out($database_driver); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | initializeDefaultVariables($database_driver); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | if (in_array('-V', $argv) || in_array('--verbose', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     displayEnvironmentVariables(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | $database = getDatabaseConfig($database_driver); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | $connectionParams = $database['database']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | if ($argv[2] != 'none') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     composerSetup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     composerInstall(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | require __DIR__.'/autoload.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | out('update permissions...'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | updatePermissions($argv); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | createConfigFiles($database_driver); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | if (!in_array('--skip-createdb', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     createDatabase($connectionParams); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | if (!in_array('--skip-initdb', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     $app = createApplication(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     initializeDatabase($app); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | out('EC-CUBE3 install finished successfully!', 'success'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | $root_urlpath = getenv('ROOT_URLPATH'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | if (PHP_VERSION_ID >= 50400 && empty($root_urlpath)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     out('PHP built-in web server to run applications, `php -S localhost:8080 -t html`', 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     out('Open your browser and access the http://localhost:8080/', 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | exit(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | function displayHelp($argv) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     echo <<<EOF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | EC-CUBE3 Installer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | ------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | Usage: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | ${argv[0]} [mysql|pgsql|sqlite3] [none] [options] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | Arguments[1]: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | Specify database types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | Arguments[2]: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | Specifying the "none" to skip the installation of Composer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | Options: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | -v, --version        print ec-cube version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | -V, --verbose        enable verbose output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | --skip-createdb      skip to create database | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | --skip-initdb        skip to initialize database | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | --help               this help | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | --ansi               force ANSI color output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | --no-ansi            disable ANSI color output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | Environment variables: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | EOF; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     foreach (getExampleVariables() as $name => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         echo $name.'='.$value.PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | function initializeDefaultVariables($database_driver) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     $database_url = getenv('DATABASE_URL'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     if ($database_url) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $url = parse_url($database_url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         putenv('DBSERVER='.$url['host']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         putenv('DBNAME='.substr($url['path'], 1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         putenv('DBUSER='.$url['user']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         putenv('DBPORT='.$url['port']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         putenv('DBPASS='.$url['pass']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     switch ($database_driver) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         case 'pdo_pgsql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             putenv('ROOTUSER='.(getenv('ROOTUSER') ? getenv('ROOTUSER') : (getenv('DBUSER') ? getenv('DBUSER') : 'postgres'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             putenv('ROOTPASS='.(getenv('ROOTPASS') ? getenv('ROOTPASS') : (getenv('DBPASS') ? getenv('DBPASS') : 'password'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             putenv('DBSERVER='.(getenv('DBSERVER') ? getenv('DBSERVER') : 'localhost')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             putenv('DBNAME='.(getenv('DBNAME') ? getenv('DBNAME') : 'cube3_dev')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             putenv('DBUSER='.(getenv('DBUSER') ? getenv('DBUSER') : 'cube3_dev_user')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             putenv('DBPORT='.(getenv('DBPORT') ? getenv('DBPORT') : '5432')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         case 'pdo_mysql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             putenv('ROOTUSER='.(getenv('ROOTUSER') ? getenv('ROOTUSER') : (getenv('DBUSER') ? getenv('DBUSER') : 'root'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             putenv('DBSERVER='.(getenv('DBSERVER') ? getenv('DBSERVER') : 'localhost')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             putenv('DBNAME='.(getenv('DBNAME') ? getenv('DBNAME') : 'cube3_dev')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             putenv('DBUSER='.(getenv('DBUSER') ? getenv('DBUSER') : 'cube3_dev_user')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             putenv('DBPORT='.(getenv('DBPORT') ? getenv('DBPORT') : '3306')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             if (getenv('TRAVIS')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                 putenv('DBPASS='); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                 putenv('ROOTPASS='); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                 putenv('ROOTPASS='.(getenv('ROOTPASS') ? getenv('ROOTPASS') : (getenv('DBPASS') ? getenv('DBPASS') : 'password'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         case 'pdo_sqlite': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     putenv('SHOP_NAME='.(getenv('SHOP_NAME') ? getenv('SHOP_NAME') : 'EC-CUBE SHOP')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     putenv('ADMIN_MAIL='.(getenv('ADMIN_MAIL') ? getenv('ADMIN_MAIL') : '[email protected]')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     putenv('ADMIN_USER='.(getenv('ADMIN_USER') ? getenv('ADMIN_USER') : 'admin')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     putenv('ADMIN_PASS='.(getenv('ADMIN_PASS') ? getenv('ADMIN_PASS') : 'password')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     putenv('MAIL_BACKEND='.(getenv('MAIL_BACKEND') ? getenv('MAIL_BACKEND') : 'smtp')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     putenv('MAIL_HOST='.(getenv('MAIL_HOST') ? getenv('MAIL_HOST') : 'localhost')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     putenv('MAIL_PORT='.(getenv('MAIL_PORT') ? getenv('MAIL_PORT') : 25)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     putenv('MAIL_USER='.(getenv('MAIL_USER') ? getenv('MAIL_USER') : null)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     putenv('MAIL_PASS='.(getenv('MAIL_PASS') ? getenv('MAIL_PASS') : null)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     putenv('ADMIN_ROUTE='.(getenv('ADMIN_ROUTE') ? getenv('ADMIN_ROUTE') : 'admin')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     putenv('ROOT_URLPATH='.(getenv('ROOT_URLPATH') ? getenv('ROOT_URLPATH') : null)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     putenv('AUTH_MAGIC='.(getenv('AUTH_MAGIC') ? getenv('AUTH_MAGIC') : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |                           substr(str_replace(array('/', '+', '='), '', base64_encode(openssl_random_pseudo_bytes(32 * 2))), 0, 32))); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | function getExampleVariables() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     return array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         'ADMIN_USER' => 'admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         'ADMIN_MAIL' => '[email protected]', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         'SHOP_NAME' => 'EC-CUBE SHOP', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         'ADMIN_ROUTE' => 'admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         'ROOT_URLPATH' => '<ec-cube install path>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         'DBSERVER' => '127.0.0.1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         'DBNAME' => 'cube3_dev', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         'DBUSER' => 'cube3_dev_user', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         'DBPASS' => 'password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         'DBPORT' => '<database port>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         'ROOTUSER' => 'root|postgres', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         'ROOTPASS' => 'password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         'MAIL_BACKEND' => 'smtp', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         'MAIL_HOST' => 'localhost', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         'MAIL_PORT' => '25', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         'MAIL_USER' => '<SMTP AUTH user>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         'MAIL_PASS' => '<SMTP AUTH password>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         'AUTH_MAGIC' => '<auth_magic>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | function displayEnvironmentVariables() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     echo 'Environment variables:'.PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     foreach (array_keys(getExampleVariables()) as $name) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         echo $name.'='.getenv($name).PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | function composerSetup() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     if (!file_exists(__DIR__.'/'.COMPOSER_FILE)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         if (!file_exists(__DIR__.'/'.COMPOSER_SETUP_FILE)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             copy('https://getcomposer.org/installer', COMPOSER_SETUP_FILE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $sha = hash_file('SHA384', COMPOSER_SETUP_FILE).PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         out(COMPOSER_SETUP_FILE.': '.$sha); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $command = 'php '.COMPOSER_SETUP_FILE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         out("execute: $command", 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         passthru($command); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         unlink(COMPOSER_SETUP_FILE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $command = 'php '.COMPOSER_FILE.' self-update'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         passthru($command); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | function composerInstall() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     $command = 'php '.COMPOSER_FILE.' install --dev --no-interaction'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     passthru($command); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | function createDatabase(array $connectionParams) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     $dbname = $connectionParams['dbname']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     switch ($connectionParams['driver']) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 236 |  | View Code Duplication |         case 'pdo_pgsql': | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             $connectionParams['dbname'] = 'postgres'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             $connectionParams['user'] = getenv('ROOTUSER'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             $connectionParams['password'] = getenv('ROOTPASS'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             break; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 241 |  | View Code Duplication |         case 'pdo_mysql': | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             $connectionParams['dbname'] = 'mysql'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             $connectionParams['user'] = getenv('ROOTUSER'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             $connectionParams['password'] = getenv('ROOTPASS'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         case 'pdo_sqlite': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             $connectionParams['dbname'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             if (file_exists($dbname)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |                 out('remove database to '.$dbname, 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |                 unlink($dbname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     $config = new \Doctrine\DBAL\Configuration(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     $sm = $conn->getSchemaManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     out('Created database connection...', 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     if ($connectionParams['driver'] != 'pdo_sqlite') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         $databases = $sm->listDatabases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         if (in_array($dbname, $databases)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             out('database exists '.$dbname, 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             out('drop database to '.$dbname, 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             $sm->dropDatabase($dbname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     out('create database to '.$dbname, 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     $sm->createDatabase($dbname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  * @return \Eccube\Application | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | function createApplication() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |     $app = \Eccube\Application::getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     $app['debug'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |     $app->initDoctrine(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     $app->initSecurity(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     $app->register(new \Silex\Provider\FormServiceProvider()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     $app->register(new \Eccube\ServiceProvider\EccubeServiceProvider()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     $app->boot(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |     return $app; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 287 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 288 |  |  | function initializeDatabase(\Eccube\Application $app) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 289 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |     // Get an instance of your entity manager | 
            
                                                                        
                            
            
                                    
            
            
                | 291 |  |  |     $entityManager = $app['orm.em']; | 
            
                                                                        
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 293 |  |  |     // Clear Doctrine to be safe | 
            
                                                                        
                            
            
                                    
            
            
                | 294 |  |  |     $entityManager->getConnection()->getConfiguration()->setSQLLogger(null); | 
            
                                                                        
                            
            
                                    
            
            
                | 295 |  |  |     $entityManager->clear(); | 
            
                                                                        
                            
            
                                    
            
            
                | 296 |  |  |     gc_collect_cycles(); | 
            
                                                                        
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 298 |  |  |     // Schema Tool to process our entities | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  |     $tool = new \Doctrine\ORM\Tools\SchemaTool($entityManager); | 
            
                                                                        
                            
            
                                    
            
            
                | 300 |  |  |     $classes = $entityManager->getMetaDataFactory()->getAllMetaData(); | 
            
                                                                        
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 302 |  |  |     // Drop all classes and re-build them for each test case | 
            
                                                                        
                            
            
                                    
            
            
                | 303 |  |  |     out('Dropping database schema...', 'info'); | 
            
                                                                        
                            
            
                                    
            
            
                | 304 |  |  |     $tool->dropSchema($classes); | 
            
                                                                        
                            
            
                                    
            
            
                | 305 |  |  |     out('Creating database schema...', 'info'); | 
            
                                                                        
                            
            
                                    
            
            
                | 306 |  |  |     $tool->createSchema($classes); | 
            
                                                                        
                            
            
                                    
            
            
                | 307 |  |  |     out('Database schema created successfully!', 'success'); | 
            
                                                                        
                            
            
                                    
            
            
                | 308 |  |  |     $config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($app['db']); | 
            
                                                                        
                            
            
                                    
            
            
                | 309 |  |  |     $config->setMigrationsNamespace('DoctrineMigrations'); | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |     $loader = new \Eccube\Doctrine\Common\CsvDataFixtures\Loader(); | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |     $loader->loadFromDirectory(__DIR__.'/src/Eccube/Resource/doctrine/import_csv'); | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |     $Executor = new \Eccube\Doctrine\Common\CsvDataFixtures\Executor\DbalExecutor($entityManager); | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |     $fixtures = $loader->getFixtures(); | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  |     $Executor->execute($fixtures); | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |     $migrationDir = __DIR__.'/src/Eccube/Resource/doctrine/migration'; | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  |     $config->setMigrationsDirectory($migrationDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |     $config->registerMigrationsFromDirectory($migrationDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  |     $migration = new \Doctrine\DBAL\Migrations\Migration($config); | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  |     $migration->migrate(); | 
            
                                                                        
                            
            
                                    
            
            
                | 323 |  |  |     out('Database migration successfully!', 'success'); | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  |     $login_id = getenv('ADMIN_USER'); | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  |     $login_password = getenv('ADMIN_PASS'); | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |     $passwordEncoder = new \Eccube\Security\Core\Encoder\PasswordEncoder($app['config']); | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |     $salt = \Eccube\Util\Str::random(32); | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |     $encodedPassword = $passwordEncoder->encodePassword($login_password, $salt); | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |     out('Creating admin accounts...', 'info'); | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |     $member_id = ('postgresql' === $app['db']->getDatabasePlatform()->getName()) | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |         ? $app['db']->fetchColumn("select nextval('dtb_member_member_id_seq')") | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |         : null; | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |     $app['db']->insert('dtb_member', [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |         'member_id' => $member_id, | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |         'login_id' => $login_id, | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |         'password' => $encodedPassword, | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |         'salt' => $salt, | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |         'work' => 1, | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |         'del_flg' => 0, | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |         'authority' => 0, | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |         'creator_id' => 1, | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |         'rank' => 1, | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |         'update_date' => new \DateTime(), | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |         'create_date' => new \DateTime(), | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |         'name' => '管理者', | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |         'department' => 'EC-CUBE SHOP', | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |         'discriminator_type' => 'member' | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |     ], [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |         'update_date' => Doctrine\DBAL\Types\Type::DATETIME, | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |         'create_date' => Doctrine\DBAL\Types\Type::DATETIME, | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |     ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |     $shop_name = getenv('SHOP_NAME'); | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |     $admin_mail = getenv('ADMIN_MAIL'); | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |     $id = ('postgresql' === $app['db']->getDatabasePlatform()->getName()) | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |         ? $app['db']->fetchColumn("select nextval('dtb_base_info_id_seq')") | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |         : null; | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |     $app['db']->insert('dtb_base_info', [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |         'id' => $id, | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |         'shop_name' => $shop_name, | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |         'email01' => $admin_mail, | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |         'email02' => $admin_mail, | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |         'email03' => $admin_mail, | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |         'email04' => $admin_mail, | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |         'update_date' => new \DateTime(), | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |         'discriminator_type' => 'baseinfo' | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |     ], [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  |         'update_date' => \Doctrine\DBAL\Types\Type::DATETIME | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |     ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | function updatePermissions($argv) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |     $finder = \Symfony\Component\Finder\Finder::create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |     $finder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         ->in('html')->notName('.htaccess') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         ->in('app')->notName('console'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |     $verbose = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |     if (in_array('-V', $argv) || in_array('--verbose', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         $verbose = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |     foreach ($finder as $content) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |         $permission = $content->getPerms(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         // see also http://www.php.net/fileperms | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         if (!($permission & 0x0010) || !($permission & 0x0002)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |             $realPath = $content->getRealPath(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             if ($verbose) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |                 out(sprintf('%s %s to ', $realPath, substr(sprintf('%o', $permission), -4)), 'info', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |             $permission = !($permission & 0x0020) ? $permission += 040 : $permission; // g+r | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |             $permission = !($permission & 0x0010) ? $permission += 020 : $permission; // g+w | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             $permission = !($permission & 0x0004) ? $permission += 04 : $permission;  // o+r | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |             $permission = !($permission & 0x0002) ? $permission += 02 : $permission;  // o+w | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |             $result = chmod($realPath, $permission); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |             if ($verbose) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                 if ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                     out(substr(sprintf('%o', $permission), -4), 'info'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                     out('failure', 'error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | function createConfigFiles($database_driver) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |     $config_path = __DIR__.'/app/config/eccube'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |     createYaml(getConfig(), $config_path.'/config.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     createYaml(getDatabaseConfig($database_driver), $config_path.'/database.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     createYaml(getMailConfig(), $config_path.'/mail.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |     createYaml(getPathConfig(), $config_path.'/path.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | function createYaml($config, $path) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |     $content = \Symfony\Component\Yaml\Yaml::dump($config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |     $fs = new \Symfony\Component\Filesystem\Filesystem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     $fs->dumpFile($path, $content); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | function getConfig() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |     $config = array ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         'auth_magic' => getenv('AUTH_MAGIC'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         'password_hash_algos' => 'sha256', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |         'shop_name' => getenv('SHOP_NAME'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         'force_ssl' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         'admin_allow_host' => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |         array ( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |         'cookie_lifetime' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |         'locale' => 'ja', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         'timezone' => 'Asia/Tokyo', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         'eccube_install' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |     return $config; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | function getDatabaseConfig($database_driver) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |     $database = array ( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         'database' => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         array ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |             'driver' => $database_driver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |     switch ($database_driver) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         case 'pdo_sqlite': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |             $database['database']['dbname'] = $database['database']['path'] = __DIR__.'/app/config/eccube/eccube.db'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |         case 'pdo_pgsql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         case 'pdo_mysql': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |             $database['database']['host'] = getenv('DBSERVER'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |             $database['database']['dbname'] = getenv('DBNAME'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |             $database['database']['user'] = getenv('DBUSER'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             $database['database']['port'] = getenv('DBPORT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             $database['database']['password'] = getenv('DBPASS'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             $database['database']['port'] = getenv('DBPORT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |     $database['database']['charset'] = 'utf8'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |     $database['database']['defaultTableOptions'] = array('collate' => 'utf8_general_ci'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |     return $database; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | function getMailConfig() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |     $mail = array ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |         'mail' => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |         array ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |             'transport' => getenv('MAIL_BACKEND'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |             'host' => getenv('MAIL_HOST'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |             'port' => getenv('MAIL_PORT'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |             'username' => getenv('MAIL_USER'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             'password' => getenv('MAIL_PASS'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |             'encryption' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |             'auth_mode' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             'charset_iso_2022_jp' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |     return $mail; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  * @see \Eccube\Controller\Install\InstallController::createPathYamlFile() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |  */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | function getPathConfig() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |     $ADMIN_ROUTE = getenv('ADMIN_ROUTE'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |     $TEMPLATE_CODE = 'default'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     $USER_DATA_ROUTE = 'user_data'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |     $ROOT_DIR = realpath(__DIR__); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     $ROOT_URLPATH = getenv('ROOT_URLPATH'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |     $ROOT_PUBLIC_URLPATH = $ROOT_URLPATH.RELATIVE_PUBLIC_DIR_PATH; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |     $target = array('${ADMIN_ROUTE}', '${TEMPLATE_CODE}', '${USER_DATA_ROUTE}', '${ROOT_DIR}', '${ROOT_URLPATH}', '${ROOT_PUBLIC_URLPATH}'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |     $replace = array($ADMIN_ROUTE, $TEMPLATE_CODE, $USER_DATA_ROUTE, $ROOT_DIR, $ROOT_URLPATH, $ROOT_PUBLIC_URLPATH); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |     $content = str_replace( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $target, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         $replace, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         file_get_contents(__DIR__.'/src/Eccube/Resource/config/path.yml.dist') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     return \Symfony\Component\Yaml\Yaml::parse($content); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |  * @link https://github.com/composer/windows-setup/blob/master/src/php/installer.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | function setUseAnsi($argv) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |     // --no-ansi wins over --ansi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |     if (in_array('--no-ansi', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |         define('USE_ANSI', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |     } elseif (in_array('--ansi', $argv)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         define('USE_ANSI', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         // On Windows, default to no ANSI, except in ANSICON and ConEmu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         // Everywhere else, default to ANSI if stdout is a terminal. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         define( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |             'USE_ANSI', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             (DIRECTORY_SEPARATOR == '\\') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |                 ? (false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |                 : (function_exists('posix_isatty') && posix_isatty(1)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | /** | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |  * @link https://github.com/composer/windows-setup/blob/master/src/php/installer.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | function out($text, $color = null, $newLine = true) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |     $styles = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         'success' => "\033[0;32m%s\033[0m", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         'error' => "\033[31;31m%s\033[0m", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         'info' => "\033[33;33m%s\033[0m" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |     $format = '%s'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |     if (isset($styles[$color]) && USE_ANSI) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         $format = $styles[$color]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |     if ($newLine) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |         $format .= PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |     printf($format, $text); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 555 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 556 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.