/** * Create cache folders * * Check individual cache folder for existance, check if folder is writable and create folder if it doesn't exist */ function cache_create_folders($dir, $levels = 0) { if (!is_dir($dir)) { if (!@mkdir($dir, 0700)) { $error = 'Directory <code>' . $dir . '</code> does not exist.<br/>'; } } elseif (!is_writable($dir)) { $error = 'Directory <code>' . $dir . '</code> is not writable.<br/>'; } // check hierarchical folders if (empty($error) && $levels > 0) { for ($i = 0; $i < 16; $i++) { $error .= cache_create_folders($dir . '/' . dechex($i), $levels - 1); } } return $error; }
/** * Checks if the cache directories exist and are writable by the webserver. * If they don't exist it tries to create them. If this fails, too a simple * error page is displayed. * The function checks if the MySQL PHP extensions is loaded, too. */ function verify_installation($return = false) { global $config; // check MySQL extension if (!extension_loaded('mysqli')) { errorpage('MySQL extension for PHP not loaded', '<p>The MySQL extension for PHP is not loaded.</p> <p>Please make sure the MySQL module for PHP is installed and enabled in your <code>php.ini</code></p>'); } // collect all directory-specific errors $error = ''; // check cache foreach (array(CACHE => 0, CACHE . '/smarty' => 0, CACHE . '/imdb' => 1, CACHE . '/img' => 1, CACHE . '/thumbs' => 1) as $dir => $hierarchical) { // check top-level folders $error .= cache_create_folders($dir, $hierarchical ? (int) $config['hierarchical'] : 0); } if ($return) { return $error; } if ($error) { errorpage('Cache directories not writable', '<p>The cache directories have to be writable by the webserver!</p> <p>Please fix the following errors:</p> <p>' . $error . '</p>'); } }