/** * write exception details to log file * * @access public * @ param timestamp $time * @ param object $ex * @ return void */ public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { if (!$ex) { return; } if (!$time) { $time = time(); } $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; $exception_log .= 'Stack trace: ' . PHP_EOL; $exception_log .= $ex['string'] . PHP_EOL; $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; EE_Registry::instance()->load_helper('File'); try { EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file); EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs'); if (!$clear) { //get existing log file and append new log info $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file) . $exception_log; } EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log); } catch (EE_Error $e) { EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); return; } }
/** * create_upload_directories * Creates folders in the uploads directory to facilitate addons and templates * * @access public * @static * @return boolean success of verifying upload directories exist */ public static function create_upload_directories() { EE_Registry::instance()->load_helper('File'); // Create the required folders $folders = array(EVENT_ESPRESSO_TEMPLATE_DIR, EVENT_ESPRESSO_GATEWAY_DIR, EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', EVENT_ESPRESSO_UPLOAD_DIR . 'css/', EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'); foreach ($folders as $folder) { try { EEH_File::ensure_folder_exists_and_is_writable($folder); @chmod($folder, 0755); } catch (EE_Error $e) { EE_Error::add_error(sprintf(__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), $folder, '<br />' . $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); //indicate we'll need to fix this later update_option(EEH_Activation::upload_directories_incomplete_option_name, true); return FALSE; } } //just add the .htaccess file to the logs directory to begin with. Even if logging //is disabled, there might be activation errors recorded in there EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); //remember EE's folders are all good delete_option(EEH_Activation::upload_directories_incomplete_option_name); return TRUE; }
/** * verify_filesystem * tests that the required files and folders exist and are writable * */ public function verify_filesystem() { try { EE_Registry::instance()->load_helper('File'); EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder . $this->_log_file); EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder . $this->_debug_file); EEH_File::add_htaccess_deny_from_all($this->_logs_folder); } catch (EE_Error $e) { EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' ' . $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); return; } }