diff options
-rw-r--r-- | core/controllers/welcome.php | 29 | ||||
-rw-r--r-- | installer/data/init_var.php | 30 |
2 files changed, 29 insertions, 30 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 876e48f9..d91bf0f1 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -492,22 +492,33 @@ class Welcome_Controller extends Template_Controller { } $var_dir = dir(VARPATH); - $init_g3 = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");", - "function create_var_directories() {"); + $init_g3 = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");"); - // @todo generate a check for the existance of the var directory + $init_g3 = array_merge($init_g3, array( + "if (!file_exists(VARPATH)) {", + " if (!mkdir(VARPATH)) {", + " throw new Exception(\"Unable to create directory '\" . VARPATH . \"'\");", + " }", + " chmod(VARPATH, 0777);", + "}")); + + $sub_dirs = array(); while (false !== $entry = $var_dir->read()) { if ($entry == "." || $entry == "..") { continue; } - if (is_dir(VARPATH . $entry)) { - $init_g3[] = " if (!@mkdir(\"$entry\");) {"; - $init_g3[] = " throw new Exception(\"Unable to create directory '$entry'\");"; - $init_g3[] = " }"; + if (is_dir(VARPATH . $entry) & $entry != "g3_installer") { + $sub_dirs[] = "\"$entry\""; } - } - $init_g3[] = "}"; + } $var_dir->close(); + + $init_g3 = array_merge($init_g3, array( + "foreach (array(" . implode(", ", $sub_dirs) . ") as \$dir) {", + " if (!@mkdir(\$dir)) {", + " throw new Exception(\"Unable to create directory '\$dir'\");", + " }", + "}")); $install_data = VARPATH . "g3_installer/"; if (!file_exists($install_data)) { diff --git a/installer/data/init_var.php b/installer/data/init_var.php index 6f83ac0e..76a1855a 100644 --- a/installer/data/init_var.php +++ b/installer/data/init_var.php @@ -1,24 +1,12 @@ <?php defined("SYSPATH") or die("No direct script access."); -function create_var_directories() { - if (!@mkdir("resizes");) { - throw new Exception("Unable to create directory 'resizes'"); - } - if (!@mkdir("g3_installer");) { - throw new Exception("Unable to create directory 'g3_installer'"); - } - if (!@mkdir("modules");) { - throw new Exception("Unable to create directory 'modules'"); - } - if (!@mkdir("uploads");) { - throw new Exception("Unable to create directory 'uploads'"); - } - if (!@mkdir("logs");) { - throw new Exception("Unable to create directory 'logs'"); - } - if (!@mkdir("albums");) { - throw new Exception("Unable to create directory 'albums'"); - } - if (!@mkdir("thumbs");) { - throw new Exception("Unable to create directory 'thumbs'"); +if (!file_exists(VARPATH)) { + if (!mkdir(VARPATH)) { + throw new Exception("Unable to create directory '" . VARPATH . "'"); + } + chmod(VARPATH, 0777); +} +foreach (array("resizes", "modules", "uploads", "logs", "albums", "thumbs") as $dir) { + if (!@mkdir($dir)) { + throw new Exception("Unable to create directory '$dir'"); } }
\ No newline at end of file |