/install/ to complete the installation."; } elseif( ! is_readable( $config ) ) { $message = "Error config file is not readable, please check permissions."; } echo $message; exit(); } else { require_once( $config ); } } $bases = self::BASES; $this->register_constants(); foreach( $bases as $base ) { $name = strtolower( $base ); $class = ucfirst( $base ); require_once( COMPONENTS . "/$name/class.$name.php" ); } $this->register_globals(); if( ! $installing ) { $this->check_extensions(); $this->check_paths(); } } public static function check_extensions() { $extensions = self::EXTENSIONS; $pass = true; foreach( $extensions as $extension ) { if( extension_loaded( $extension ) ) { } else { $pass = false; break; } } return $pass; } public static function check_paths() { $paths = self::PATHS; $pass = true; foreach( $paths as $path ) { if( is_dir( constant( $path ) ) ) { if( ! is_writable( constant( $path ) ) ) { $pass = false; break; } } else { mkdir( constant( $path ) ); } } return $pass; } /** * Return an instance of this class. * * @since ${current_version} * @return object A single instance of this class. */ public static function get_instance() { if( null == self::$instance ) { self::$instance = new self; } return self::$instance; } public static function is_installing() { return ! ( strpos( $_SERVER["SCRIPT_NAME"], "install" ) === false ); } function register_constants() { if( ! defined( 'AUTH_TYPE' ) ) { define( 'AUTH_TYPE', "default" ); } if( ! defined( 'BASE_PATH' ) ) { $base_path = rtrim( realpath( __DIR__ . "/../../" ), '/' ); define( 'BASE_PATH', $base_path ); } if( ! defined( 'COMPONENTS' ) ) { define( 'COMPONENTS', BASE_PATH . '/components' ); } if( ! defined( 'DATA' ) ) { define( 'DATA', BASE_PATH . '/data' ); } if( ! defined( 'PLUGINS' ) ) { define( 'PLUGINS', BASE_PATH . '/plugins' ); } if( ! defined( 'SESSIONS_PATH' ) ) { define( 'SESSIONS_PATH', BASE_PATH . '/data/sessions' ); } if( ! defined( 'SITE_NAME' ) ) { define( 'SITE_NAME', "Codiad" ); } if( ! defined( 'THEME' ) ) { define( "THEME", "default" ); } if( ! defined( 'THEMES' ) ) { define( "THEMES", BASE_PATH . "/themes" ); } if( ! defined( 'UPLOAD_CACHE' ) ) { if( ! is_dir( sys_get_temp_dir() ) ) { define( "UPLOAD_CACHE", DATA . "/uploads" ); } else { define( "UPLOAD_CACHE", rtrim( sys_get_temp_dir(), "/" ) ); } } if( ! defined( 'WORKSPACE' ) ) { define( "WORKSPACE", BASE_PATH . "/workspace" ); } } function register_globals() { $GLOBALS["data"] = Data::get_instance(); } } ?>