/** * Creates a new site in centralized stat tracker * @param sitename - name of the instance * @param url - base url */ public function create_site($sitename, $url) { $stat_url = 'https://tracker.ushahidi.com/px.php?task=cs&sitename=' . urlencode($sitename) . '&url=' . urlencode($url); // Ignore errors since we are error checking later $xml = simplexml_load_string(Stats_Model::_curl_req($stat_url)); $stat_id = (string) $xml->id[0]; $stat_key = (string) $xml->key[0]; if ($stat_id > 0) { $settings = ORM::factory('settings', 1); $settings->stat_id = $stat_id; $settings->stat_key = $stat_key; $settings->save(); return $stat_id; } return false; }
/** * Creates a new site in centralized stat tracker * @param sitename - name of the instance * @param url - base url */ public function create_site($sitename, $url) { $stat_url = Kohana::config('config.external_site_protocol') . '://tracker.ushahidi.com/px.php?task=cs&sitename=' . urlencode($sitename) . '&url=' . urlencode($url); // Ignore errors since we are error checking later $xml = simplexml_load_string(Stats_Model::_curl_req($stat_url)); if ($xml == false) { return false; } $stat_id = (string) $xml->id[0]; $stat_key = (string) $xml->key[0]; if ($stat_id > 0) { Settings_Model::save_setting('stat_id', $stat_id); Settings_Model::save_setting('stat_key', $stat_key); return $stat_id; } return false; }