Esempio n. 1
0
 public function getStbParams()
 {
     if (!empty($this->mac)) {
         $user = $this->db->from('users')->where(array('mac' => $this->mac))->get()->first();
     } elseif (User::isInitialized() && User::getInstance()->getId()) {
         $user = $this->db->from('users')->where(array('id' => (int) User::getInstance()->getId()))->get()->first();
     }
     if (!empty($user)) {
         $this->params = $user;
         $this->id = $user['id'];
         $this->hd = $user['hd'];
         $this->locale = empty($user['locale']) && Config::exist('default_locale') ? Config::get('default_locale') : $user['locale'];
         if (Config::getSafe('default_city_id', 0) == 0 && $user['city_id'] == 0) {
             $this->city_id = 0;
         } else {
             $this->city_id = empty($user['city_id']) && Config::exist('default_city_id') ? Config::get('default_city_id') : intval($user['city_id']);
         }
         if (Config::getSafe('default_openweathermap_city_id', 0) == 0 && $user['openweathermap_city_id'] == 0) {
             $this->openweathermap_city_id = 0;
         } else {
             $this->openweathermap_city_id = empty($user['openweathermap_city_id']) && Config::exist('default_openweathermap_city_id') ? Config::get('default_openweathermap_city_id') : intval($user['openweathermap_city_id']);
         }
         $this->timezone = empty($this->timezone) && Config::exist('default_timezone') ? Config::get('default_timezone') : $this->timezone;
         self::$server_timezone = date_default_timezone_get();
         date_default_timezone_set($this->timezone);
         $date_server = new DateTime();
         $date_server->setTimezone(new DateTimeZone(Stb::$server_timezone));
         $date_stb = new DateTime();
         $date_stb->setTimezone(new DateTimeZone($this->timezone));
         $this->timezone_diff = $date_server->format('Z') - $date_stb->format('Z');
         $date = new DateTime();
         $offset = $date->format('e');
         if (!Mysql::getInstance()->set_timezone($offset)) {
             // if mysql.time_zone_name is not populated
             $offset = $date->format('P');
             Mysql::getInstance()->set_timezone($offset);
         }
         $this->additional_services_on = $user['additional_services_on'];
         if (!empty($user['country'])) {
             $this->user_agent .= '; Country: ' . $user['country'];
         }
         $this->initLocale($this->stb_lang);
     }
 }