',$e); print '
The following errors were detected:
'.$error_list.'Your MODX installation appears to be set up correctly. This is not a guarantee that your site is running correctly! It means that your site is free from the bigger errors and misconfigurations.
MODX_CORE_PATH
';
}
// Test MODX_PROCESSORS_PATH
// Should be folders for 'browser', 'context', 'element', 'resource', 'security', 'source', 'system', 'workspace'
$folders = array('browser', 'context', 'element', 'resource', 'security', 'source', 'system', 'workspace');
foreach ($folders as $f) {
if(!file_exists(MODX_PROCESSORS_PATH.$f)) {
$errors[] = MODX_PROCESSORS_PATH.$f.' folder does not exist!';
}
}
// Test MODX_CONNECTORS_PATH
// Should be folders for browser, context, element, layout, resource, security, source, system, workspace
$folders = array('browser', 'context', 'element', 'layout', 'resource', 'security', 'source', 'system', 'workspace');
foreach ($folders as $f) {
if(!file_exists(MODX_CONNECTORS_PATH.$f)) {
$errors[] = MODX_CONNECTORS_PATH.$f.' folder does not exist!';
}
}
// Test MODX_MANAGER_PATH
// Folders for assets, controllers, min, templates
$folders = array('assets', 'controllers', 'min', 'templates');
foreach ($folders as $f) {
if(!file_exists(MODX_MANAGER_PATH.$f)) {
$errors[] = MODX_MANAGER_PATH.$f.' folder does not exist!';
}
}
if (!empty($errors)) {
print_errors($errors);
exit;
}
// Test config.core.php files
// 1. root
// 2. manager
// 3. connectors
if (!file_exists(MODX_BASE_PATH.'config.core.php')) {
$errors[] = 'Missing configuration file at '.MODX_BASE_PATH.'config.core.php';
}
if (!file_exists(MODX_MANAGER_PATH.'config.core.php')) {
$errors[] = 'Missing configuration file at '.MODX_MANAGER_PATH.'config.core.php';
}
if (!file_exists(MODX_CONNECTORS_PATH.'config.core.php')) {
$errors[] = 'Missing configuration file at '.MODX_CONNECTORS_PATH.'config.core.php';
}
$config_files = array();
$config_files[] = array(
'file' => MODX_BASE_PATH.'config.core.php',
'contents' => file_get_contents(MODX_BASE_PATH.'config.core.php')
);
$config_files[] = array(
'file' => MODX_MANAGER_PATH.'config.core.php',
'contents' => file_get_contents(MODX_MANAGER_PATH.'config.core.php')
);
$config_files[] = array(
'file' => MODX_CONNECTORS_PATH.'config.core.php',
'contents' => file_get_contents(MODX_CONNECTORS_PATH.'config.core.php')
);
// Config files should define a path in one of the following ways:
// define('MODX_CORE_PATH', dirname(__FILE__) . '/core/');
// define('MODX_CORE_PATH', dirname(dirname(__FILE__)) . '/core/');
// define('MODX_CORE_PATH', '/path/to/core/');
foreach ($config_files as $c) {
preg_match('#'. preg_quote("define('MODX_CORE_PATH',") .'(.*)\);#', $c['contents'], $matches);
if (isset($matches[1])) {
$path = trim($matches[1]);
$path = preg_replace("/^'/", '', $path);
$path = preg_replace("/'$/", '', $path);
$path = preg_replace('/^"/', '', $path);
$path = preg_replace('/"$/', '', $path);
$path = preg_replace('/\s/', '', $path);
// does this file use dirname(__FILE__)?
if (preg_match('#'.preg_quote('dirname(dirname(__FILE__))').'#',$path)) {
$path = preg_replace('#'.preg_quote("dirname(dirname(__FILE__)).'",'/').'#', dirname(dirname($c['file'])), $path);
}
elseif (preg_match('#'.preg_quote('dirname(__FILE__)').'#',$path)) {
$path = preg_replace('#'.preg_quote("dirname(__FILE__).'",'/').'#', dirname($c['file']), $path);
}
if (!test_core($path)) {
$errors[] = 'Your '.$c['file'].' file has defined an incorrect MODX_CORE_PATH
';
}
}
else {
$errors[] = $c['file'] . ' did not define the MODX_CORE_PATH
constant!';
}
}
// Test to make sure these files are pointing to the correct spot
$modx = new modx();
if (!is_object($modx)) {
$errors[] = 'Unable to instantiate modX object.';
print_errors($errors);
exit;
}
// Test Database
foreach($modx->query("SELECT NOW() as now") as $row) {
if (!isset($row['now']) || empty($row['now'])) {
$errors[] = 'Unable to issue database query.';
}
break;
}
// Check database: workspace
$Workspace = $modx->getObject('modWorkspace',1);
if (!is_object($Workspace)) {
$errors[] = 'Error reading workspaces table.';
}
else {
$path = $Workspace->get('path');
if ($path != '{core_path}' && $path != MODX_CORE_PATH) {
$errors[] = 'Workspace path does not match MODX_CORE_PATH';
}
}
// Permissions
if (!is_writable(MODX_CORE_PATH.'cache')) {
$errors[] = MODX_CORE_PATH.'cache directory is not writable!';
}
if (!is_writable(MODX_ASSETS_PATH.'components')) {
$errors[] = MODX_ASSETS_PATH.'components directory is not writable!';
}
// Summary
if (!empty($errors)) {
print_errors($errors);
exit;
}
else {
print_success();
}
/*EOF*/