if (empty($GLOBALS['redirector'])) { $GLOBALS['redirector'] = ''; } if (empty($GLOBALS['disablesessionprotection'])) { $GLOBALS['disablesessionprotection'] = false; } if (empty($GLOBALS['privateLinkByDefault'])) { $GLOBALS['privateLinkByDefault'] = false; } if (empty($GLOBALS['titleLink'])) { $GLOBALS['titleLink'] = '?'; } // I really need to rewrite Shaarli with a proper configuation manager. if (!is_file($GLOBALS['config']['CONFIG_FILE'])) { // Ensure Shaarli has proper access to its resources $errors = ApplicationUtils::checkResourcePermissions($GLOBALS['config']); if ($errors != array()) { $message = '<p>Insufficient permissions:</p><ul>'; foreach ($errors as $error) { $message .= '<li>' . $error . '</li>'; } $message .= '</ul>'; header('Content-Type: text/html; charset=utf-8'); echo $message; exit; } // Display the installation form if no existing config is found install(); } $GLOBALS['title'] = !empty($GLOBALS['title']) ? escape($GLOBALS['title']) : ''; $GLOBALS['titleLink'] = !empty($GLOBALS['titleLink']) ? escape($GLOBALS['titleLink']) : '';
/** * Checks resource permissions for a non-existent Shaarli installation */ public function testCheckCurrentResourcePermissionsErrors() { $config = array('CACHEDIR' => 'null/cache', 'CONFIG_FILE' => 'null/data/config.php', 'DATADIR' => 'null/data', 'DATASTORE' => 'null/data/store.php', 'IPBANS_FILENAME' => 'null/data/ipbans.php', 'LOG_FILE' => 'null/data/log.txt', 'PAGECACHE' => 'null/pagecache', 'RAINTPL_TMP' => 'null/tmp', 'RAINTPL_TPL' => 'null/tpl', 'UPDATECHECK_FILENAME' => 'null/data/lastupdatecheck.txt'); $this->assertEquals(array('"null/tpl" directory is not readable', '"null/cache" directory is not readable', '"null/cache" directory is not writable', '"null/data" directory is not readable', '"null/data" directory is not writable', '"null/pagecache" directory is not readable', '"null/pagecache" directory is not writable', '"null/tmp" directory is not readable', '"null/tmp" directory is not writable'), ApplicationUtils::checkResourcePermissions($config)); }