예제 #1
0
 /**
  * Init database.
  */
 public function initDatabase()
 {
     // get port
     $port = SpoonSession::exists('db_port') && SpoonSession::get('db_port') != '' ? SpoonSession::get('db_port') : 3306;
     // database instance
     $this->db = new SpoonDatabase('mysql', SpoonSession::get('db_hostname'), SpoonSession::get('db_username'), SpoonSession::get('db_password'), SpoonSession::get('db_database'), $port);
     // utf8 compliance & MySQL-timezone
     $this->db->execute('SET CHARACTER SET utf8, NAMES utf8, time_zone = "+0:00"');
     // store
     Spoon::set('database', $this->db);
 }
예제 #2
0
 /**
  * Installs the required and optional modules
  *
  * @return	void
  */
 private function installModules()
 {
     // get port
     $port = SpoonSession::exists('db_port') && SpoonSession::get('db_port') != '' ? SpoonSession::get('db_port') : 3306;
     // database instance
     $this->db = new SpoonDatabase('mysql', SpoonSession::get('db_hostname'), SpoonSession::get('db_username'), SpoonSession::get('db_password'), SpoonSession::get('db_database'), $port);
     // utf8 compliance & MySQL-timezone
     $this->db->execute('SET CHARACTER SET utf8, NAMES utf8, time_zone = "+0:00"');
     /**
      * First we need to install the core. All the linked modules, settings and sql tables are
      * being installed.
      */
     require_once PATH_WWW . '/backend/core/installer/install.php';
     // install the core
     $install = new CoreInstall($this->db, SpoonSession::get('languages'), SpoonSession::get('interface_languages'), SpoonSession::get('example_data'), array('default_language' => SpoonSession::get('default_language'), 'default_interface_language' => SpoonSession::get('default_interface_language'), 'spoon_debug_email' => SpoonSession::get('email'), 'api_email' => SpoonSession::get('email'), 'site_domain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'fork.local', 'site_title' => 'Fork CMS', 'smtp_server' => '', 'smtp_port' => '', 'smtp_username' => '', 'smtp_password' => ''));
     // variables passed to module installers
     $variables = array();
     $variables['email'] = SpoonSession::get('email');
     $variables['default_interface_language'] = SpoonSession::get('default_interface_language');
     // loop required modules
     foreach ($this->modules['required'] as $module) {
         // install exists
         if (SpoonFile::exists(PATH_WWW . '/backend/modules/' . $module . '/installer/install.php')) {
             // users module needs custom variables
             if ($module == 'users') {
                 $variables['password'] = SpoonSession::get('password');
             }
             // load file
             require_once PATH_WWW . '/backend/modules/' . $module . '/installer/install.php';
             // class name
             $class = SpoonFilter::toCamelCase($module) . 'Install';
             // execute installer
             $install = new $class($this->db, SpoonSession::get('languages'), SpoonSession::get('interface_languages'), SpoonSession::get('example_data'), $variables);
         }
     }
     // optional modules
     foreach (SpoonSession::get('modules') as $module) {
         if (!in_array($module, $this->modules['required'])) {
             // install exists
             if (SpoonFile::exists(PATH_WWW . '/backend/modules/' . $module . '/installer/install.php')) {
                 // load file
                 require_once PATH_WWW . '/backend/modules/' . $module . '/installer/install.php';
                 // class name
                 $class = SpoonFilter::toCamelCase($module) . 'Install';
                 // execute installer
                 $install = new $class($this->db, SpoonSession::get('languages'), SpoonSession::get('interface_languages'), SpoonSession::get('example_data'), $variables);
             }
         }
     }
 }