/** * System checkup * @return void * @uses MeCms\Core\Plugin::all() * @uses MeCms\Core\Plugin::path() * @uses MeTools\Utility\Apache::module() * @uses MeTools\Utility\Apache::version() */ public function checkup() { $checkup['apache'] = ['expires' => Apache::module('mod_expires'), 'rewrite' => Apache::module('mod_rewrite'), 'version' => Apache::version()]; $checkup['backups'] = ['path' => rtr(Configure::read('MysqlBackup.target') . DS), 'writeable' => folderIsWriteable(Configure::read('MysqlBackup.target'))]; $checkup['cache'] = Cache::enabled(); //Checks for PHP's extensions foreach (['exif', 'imagick', 'mcrypt', 'zip'] as $extension) { $checkup['phpExtensions'][$extension] = extension_loaded($extension); } $checkup['plugins'] = ['cakephp' => Configure::version(), 'mecms' => trim(file_get_contents(Plugin::path(MECMS, 'version')))]; //Gets plugins versions foreach (Plugin::all(['exclude' => MECMS]) as $plugin) { $file = Plugin::path($plugin, 'version', true); if ($file) { $checkup['plugins']['plugins'][$plugin] = trim(file_get_contents($file)); } else { $checkup['plugins']['plugins'][$plugin] = __d('me_cms', 'n.a.'); } } //Checks for temporary directories foreach ([LOGS, TMP, Configure::read('Assets.target'), CACHE, LOGIN_LOGS, Configure::read('Thumbs.target')] as $path) { $checkup['temporary'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)]; } //Checks for webroot directories foreach ([BANNERS, PHOTOS, WWW_ROOT . 'files', WWW_ROOT . 'fonts'] as $path) { $checkup['webroot'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)]; } array_walk($checkup, function ($value, $key) { $this->set($key, $value); }); }
/** * Called after the controller's `beforeFilter()` method, but before the * controller executes the current action handler * @param \Cake\Event\Event $event Event instance * @return void * @uses configure() * @throws InternalErrorException */ public function startup(\Cake\Event\Event $event) { //Checks for KCFinder if (!is_readable(WWW_ROOT . 'vendor' . DS . 'kcfinder' . DS . 'index.php')) { throw new InternalErrorException(__d('me_tools', '{0} is not available', 'KCFinder')); } //Checks for the files directory (`APP/webroot/files`) if (!folderIsWriteable(UPLOADED)) { throw new InternalErrorException(__d('me_tools', 'File or directory {0} not writeable', rtr(UPLOADED))); } //Configures KCFinder $this->configure(); }
use Cake\Cache\Cache; use Cake\Core\Configure; use Cake\Core\Plugin; use Cake\Log\Log; use Cake\Network\Exception\InternalErrorException; require_once __DIR__ . DS . 'constants.php'; /** * Loads MeTools plugins */ if (!Plugin::loaded('MeTools')) { Plugin::load('MeTools', ['bootstrap' => true]); } if (!is_writeable(BANNERS)) { throw new InternalErrorException(sprintf('File or directory %s not writeable', BANNERS)); } if (!folderIsWriteable(PHOTOS)) { throw new InternalErrorException(sprintf('File or directory %s not writeable', PHOTOS)); } /** * Loads the MeCms configuration */ Configure::load('MeCms.me_cms'); //Merges with the configuration from application, if exists if (is_readable(CONFIG . 'me_cms.php')) { Configure::load('me_cms'); } /** * Forces debug on localhost, if required */ if (isLocalhost() && config('main.debug_on_localhost') && !config('debug')) { Configure::write('debug', true);