Esempio n. 1
0
 function init()
 {
     self::$site = $this;
     $this->dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $this->config = new Config();
     $this->db = new DataConcierge();
     $this->config->load();
     $this->session = new Session();
     $this->actions = new Actions();
     $this->template = new Template();
     $this->plugins = new Plugins();
 }
Esempio n. 2
0
 function init()
 {
     self::$site = $this;
     $this->dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $this->config = new Config();
     if ($this->config->isDefaultConfig()) {
         header('Location: ./warmup/');
         exit;
         // Load the installer
     }
     switch (trim(strtolower($this->config->database))) {
         case 'mongodb':
             $this->db = new DataConcierge();
             break;
         case 'mysql':
             $this->db = new \Idno\Data\MySQL();
             break;
         case 'beanstalk-mysql':
             // A special instance of MYSQL designed for use with Amazon Elastic Beanstalk
             $this->config->dbhost = $_SERVER['RDS_HOSTNAME'];
             $this->config->dbuser = $_SERVER['RDS_USERNAME'];
             $this->config->dbpass = $_SERVER['RDS_PASSWORD'];
             $this->config->dbport = $_SERVER['RDS_PORT'];
             if (empty($this->config->dbname)) {
                 $this->config->dbname = $_SERVER['RDS_DB_NAME'];
             }
             $this->db = new \Idno\Data\MySQL();
             break;
         default:
             if (class_exists("Idno\\Data\\{$this->config->database}")) {
                 $db = "Idno\\Data\\{$this->config->database}";
                 if (is_subclass_of($db, "Idno\\Core\\DataConcierge")) {
                     $this->db = new $db();
                 }
             }
             if (empty($this->db) && class_exists("{$this->config->database}")) {
                 $db = "{$this->config->database}";
                 if (is_subclass_of($db, "Idno\\Core\\DataConcierge")) {
                     $this->db = new $db();
                 }
             }
             if (empty($this->db)) {
                 $this->db = new DataConcierge();
             }
             break;
     }
     switch ($this->config->filesystem) {
         case 'local':
             $this->filesystem = new \Idno\Files\LocalFileSystem();
             break;
         default:
             if (class_exists("Idno\\Files\\{$this->config->filesystem}")) {
                 $filesystem = "Idno\\Files\\{$this->config->filesystem}";
                 $this->filesystem = new $filesystem();
             }
             if (empty($this->filesystem)) {
                 if ($fs = $this->db()->getFilesystem()) {
                     $this->filesystem = $fs;
                 }
             }
             break;
     }
     $this->config->load();
     $this->session = new Session();
     $this->actions = new Actions();
     $this->template = new Template();
     $this->language = new Language();
     $this->syndication = new Syndication();
     $this->logging = new Logging($this->config->log_level);
     $this->reader = new Reader();
     $this->helper_robot = new HelperRobot();
     // Attempt to create a cache object, making use of support present on the system
     if (extension_loaded('xcache')) {
         $this->cache = new \Idno\Caching\XCache();
     }
     // TODO: Support other persistent caching methods
     // No URL is a critical error, default base fallback is now a warning (Refs #526)
     if (!$this->config->url) {
         throw new \Exception('Known was unable to work out your base URL! You might try setting url="http://yourdomain.com/" in your config.ini');
     }
     if ($this->config->url == '/') {
         \Idno\Core\Idno::site()->logging->log('Base URL has defaulted to "/" because Known was unable to detect your server name. ' . 'This may be because you\'re loading Known via a script. ' . 'Try setting url="http://yourdomain.com/" in your config.ini to remove this message', LOGLEVEL_WARNING);
     }
     // Connect to a Known hub if one is listed in the configuration file
     // (and this isn't the hub!)
     if (empty(site()->session()->hub_connect)) {
         site()->session()->hub_connect = 0;
     }
     if (!empty($this->config->known_hub) && !substr_count($_SERVER['REQUEST_URI'], '.') && $this->config->known_hub != $this->config->url) {
         site()->session()->hub_connect = time();
         \Idno\Core\Idno::site()->known_hub = new \Idno\Core\Hub($this->config->known_hub);
         \Idno\Core\Idno::site()->known_hub->connect();
     }
     site()->session()->APIlogin();
     User::registerEvents();
     site()->session()->refreshCurrentSessionuser();
 }
Esempio n. 3
0
 function init()
 {
     self::$site = $this;
     $this->dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $this->config = new Config();
     if ($this->config->isDefaultConfig()) {
         header('Location: ./warmup/');
         exit;
         // Load the installer
     }
     switch ($this->config->database) {
         case 'mongodb':
             $this->db = new DataConcierge();
             break;
         case 'mysql':
             $this->db = new \Idno\Data\MySQL();
             break;
         case 'beanstalk-mysql':
             // A special instance of MYSQL designed for use with Amazon Elastic Beanstalk
             $this->config->dbhost = $_SERVER['RDS_HOSTNAME'];
             $this->config->dbuser = $_SERVER['RDS_USERNAME'];
             $this->config->dbpass = $_SERVER['RDS_PASSWORD'];
             $this->config->dbport = $_SERVER['RDS_PORT'];
             if (empty($this->config->dbname)) {
                 $this->config->dbname = $_SERVER['RDS_DB_NAME'];
             }
             $this->db = new \Idno\Data\MySQL();
             break;
         default:
             if (class_exists("Idno\\Data\\{$this->config->database}")) {
                 $db = "Idno\\Data\\{$this->config->database}";
                 $this->db = new $db();
             }
             if (empty($this->db)) {
                 $this->db = new DataConcierge();
             }
             break;
     }
     switch ($this->config->filesystem) {
         case 'local':
             $this->filesystem = new \Idno\Files\LocalFileSystem();
             break;
         default:
             if (class_exists("Idno\\Files\\{$this->config->filesystem}")) {
                 $filesystem = "Idno\\Files\\{$this->config->filesystem}";
                 $this->filesystem = new $filesystem();
             }
             if (empty($this->filesystem)) {
                 if ($fs = $this->db()->getFilesystem()) {
                     $this->filesystem = $fs;
                 }
             }
             break;
     }
     $this->config->load();
     $this->session = new Session();
     $this->actions = new Actions();
     $this->template = new Template();
     $this->syndication = new Syndication();
     $this->logging = new Logging($this->config->log_level);
     $this->plugins = new Plugins();
     // This must be loaded last
     $this->themes = new Themes();
     $this->helper_robot = new HelperRobot();
     // Connect to a Known hub if one is listed in the configuration file
     // (and this isn't the hub!)
     if (empty(site()->session()->hub_connect)) {
         site()->session()->hub_connect = 0;
     }
     if (!empty($this->config->known_hub) && !substr_count($_SERVER['REQUEST_URI'], '.') && site()->session()->hub_connect < time() - 10 && $this->config->known_hub != $this->config->url) {
         site()->session()->hub_connect = time();
         \Idno\Core\site()->logging->log('Connecting to ' . $this->config->known_hub);
         \Idno\Core\site()->known_hub = new \Idno\Core\Hub($this->config->known_hub);
         \Idno\Core\site()->known_hub->connect();
     }
     User::registerEvents();
 }