| 104 | } |
| 105 | |
| 106 | function validateRootDir($root_dir) |
| 107 | { |
| 108 | // 未配置直接返回 |
| 109 | $open_basedir = ini_get('open_basedir'); |
| 110 | if (empty($open_basedir)) { |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | // 避免因为斜杠匹配失败,暂时不做 realpath 处理 |
| 115 | $root_dir = rtrim($root_dir, '/'); |
| 116 | $valid = false; |
| 117 | |
| 118 | // TODO: 改为真实路径 + 前缀检查 |
| 119 | $allowed = explode(':', $open_basedir); |
| 120 | foreach ($allowed as $dir) |
| 121 | { |
| 122 | $dir = rtrim($dir, '/'); |
| 123 | if ($dir == $root_dir) |
| 124 | { |
| 125 | $valid = true; |
| 126 | break; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (! $valid) |
| 131 | { |
| 132 | echo "WARNING: open_basedir is configured and might affect the installation process\n"; |
| 133 | echo "Consider adding $root_dir to your open_basedir config\n"; |
| 134 | echo "Current value: $open_basedir\n"; |
| 135 | echo "\n"; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | class IniConfig |
| 140 | { |