Changeset 1908
- Timestamp:
- 06/07/10 04:52:20 (3 years ago)
- File:
-
- 1 edited
-
branches/1.4/libs/Initialize.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/libs/Initialize.php
r1816 r1908 53 53 $this->getCurrentSiteID(); 54 54 $this->errorReporting(); 55 55 56 56 $this->readSettings(); 57 57 $this->setUpDatabaseCache(); … … 153 153 public function getCurrentSiteID() 154 154 { 155 // if isActive($result) { 156 // $url = $this->cage->server->getRaw('HTTP_HOST'); // wanted to use sanitizeTags 157 // $sql = "SELECT site_id, site_adminuser_id FROM " . TABLE_SITE . " WHERE site_url = %s"; 158 // $settings = $this->db->get_row($this->db->prepare($sql, $url)); 159 // var_dump( $settings); 160 // 161 // if ($settings) { 162 // $siteid = $settings->site_id; 163 // } else { 164 // $siteid = 1; 165 // } 166 // } else { 155 // read settings for default siteid=1 first to check whether MULTISITE is TRUE 156 $sql = "SELECT settings_value FROM " . TABLE_SETTINGS . " WHERE settings_name = %s AND settings_siteid = %d"; 157 $multi_site = $this->db->get_var($this->db->prepare($sql, 'MULTI_SITE', 1)); 158 159 if ($multi_site == 'true') { 160 $url = $this->cage->server->getRaw('HTTP_HOST'); // wanted to use sanitizeTags 161 $sql = "SELECT site_id, site_adminuser_id FROM " . TABLE_SITE . " WHERE site_url = %s"; 162 $settings = $this->db->get_row($this->db->prepare($sql, $url)); 163 164 if ($settings) { 165 $siteid = $settings->site_id; 166 $siteurl = "http://" . $url; 167 } else { 168 $siteid = 1; 169 $siteurl = BASEURL; 170 } 171 172 } else { 167 173 $siteid = 1; 168 // } 169 if (!defined('SITEID')) { 170 define('SITEID', $siteid); 171 if (!defined('CACHE')) { define("CACHE", BASE . "cache/" . $siteid . "/"); } 174 $siteurl = BASEURL; 175 } 176 177 if (!defined('SITEID')) { define('SITEID', $siteid); } 178 if (!defined('SITEURL')) { define("SITEURL", $siteurl . "/"); } 179 180 if (!defined('CACHE')) { 181 182 define("CACHE", BASE . "cache/" . $siteid . "/"); 172 183 173 184 $dirs = array('', 'debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/'); // first array item is needed to create the SITEID base folder … … 178 189 } 179 190 } 191 180 192 } 181 193 … … 256 268 /** 257 269 * Returns all site settings 258 * @param int $multisite - site id 259 * 260 * @return bool 261 */ 262 public function readSettings($multisite = 0) 263 { 264 if (!$multisite) { 265 $sql = "SELECT settings_name, settings_value FROM " . TABLE_SETTINGS; 266 $settings = $this->db->get_results($this->db->prepare($sql)); 267 } else { 268 $sql = "SELECT settings_name, settings_value FROM " . TABLE_SETTINGS . " WHERE settings_siteid = %d"; 269 $settings = $this->db->get_results($this->db->prepare($sql, $multisite)); 270 } 271 272 if(!$settings) { return false; } 273 270 * @param <int> $siteid 271 * 272 * @return <bool> 273 */ 274 public function readSettings() { 275 $sql = "SELECT settings_name, settings_value FROM " . TABLE_SETTINGS . " WHERE settings_siteid = %d"; 276 $settings = $this->db->get_results($this->db->prepare($sql, SITEID)); 277 278 if(!$settings) { return false; } 279 274 280 // Make Hotaru settings global constants 275 281 foreach ($settings as $setting) 276 282 { 277 if (!defined($setting->settings_name)) { 283 if (!defined($setting->settings_name)) { 278 284 define($setting->settings_name, $setting->settings_value); 279 285 } 280 286 } 281 287 282 288 return true; 283 289 }
Note: See TracChangeset
for help on using the changeset viewer.