Example #1
0
 function __construct()
 {
     parent::__construct();
     $this->Store = HDStore::getInstance();
     $this->Extra = new HDExtra();
 }
Example #2
0
 /**
  * This is the main constructor for the class HD4
  *
  * @param mixed $config can be an array of config options or a fully qualified path to an alternate config file.
  * @return void
  */
 function __construct($config = null)
 {
     parent::__construct();
     if (!empty($config) && is_array($config)) {
         $this->config = array_merge($this->config, $config);
     } elseif (!empty($config) && is_string($config) && file_exists($config)) {
         $hdconfig = array();
         require $config;
         $this->config = array_merge($this->config, (array) $hdconfig);
     } elseif (!file_exists($this->configFile)) {
         throw new Exception('Error : Invalid config file and no config passed to constructor');
     } else {
         $hdconfig = array();
         require $this->configFile;
         $this->config = array_merge($this->config, (array) $hdconfig);
     }
     if (empty($this->config['filesdir'])) {
         $this->config['filesdir'] = dirname(__FILE__);
     }
     if (empty($this->config['username'])) {
         throw new \Exception('Error : API username not set. Download a premade config from your Site Settings.');
     } elseif (empty($this->config['secret'])) {
         throw new \Exception('Error : API secret not set. Download a premade config from your Site Settings.');
     }
     $this->debug = $this->config['debug'];
     //$this->log('Config '.print_r($this->config, true));
     $this->Store = HDStore::getInstance();
     $this->Store->setPath($this->config['filesdir'], true);
     $this->Cache = new HDCache();
     $this->Device = new HDDevice();
     $this->setup();
     if (!empty($this->config['use_local']) && !class_exists('ZipArchive')) {
         throw new \Exception('Ultimate detection needs ZipArchive to unzip archive files. Please install this php module.');
     }
 }