Skip to content

Instantly share code, notes, and snippets.

@TomHAnderson
Created February 17, 2012 18:18
Show Gist options
  • Save TomHAnderson/1854704 to your computer and use it in GitHub Desktop.
Save TomHAnderson/1854704 to your computer and use it in GitHub Desktop.
public function checkPaths($e) {
$response = $e->getTarget()->getResponse();
$return = '';
$errors = array();
// Check directories
$checkDirs = array(
'Session Save Path' => session_save_path(),
'Upload Temp' => ini_get('upload_tmp_dir'),
'Search' => APPLICATION_PATH . '/data/Search/',
'Cache' => APPLICATION_PATH . '/data/Cache/',
'Doctrine Proxies' => APPLICATION_PATH . '/data/DoctrineORMModule/Proxy'
);
$return .= '<style>span.fail {color: red;}</style>';
$return .= "<h1>Stuki Installation Step 1 - Paths</h1><pre>";
foreach ($checkDirs as $key => $checkDir) {
$return .= "Testing $key Directory\n";
// Directory testing from Smarty->testInstall();
if (!is_dir($checkDir)) {
$status = false;
$message = "<span class=\"fail\">FAILED</span>: {$checkDir} is not a directory";
$return .= $message . ".\n\n";
$errors['compile_dir'] = $message;
} elseif (!is_readable($checkDir)) {
$status = false;
$message = "<span class=\"fail\">FAILED</span>: {$checkDir} is not readable";
$return .= $message . ".\n\n";
$errors['compile_dir'] = $message;
} elseif (!is_writable($checkDir)) {
$status = false;
$message = "<span class=\"fail\">FAILED</span>: {$checkDir} is not writable";
$return .= $message . ".\n\n";
$errors['compile_dir'] = $message;
} else {
$return .= "{$checkDir} is OK.\n\n";
}
}
$return .= '</pre>
You must fix these errors to continue.
';
if ($errors) {
echo $return;
$e->stopPropagation();
return $response;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment