Exemplo n.º 1
0
 public function index()
 {
     $this->template->content = new View('admin/stats_hits');
     $this->template->content->title = Kohana::lang('ui_admin.statistics');
     // Retrieve Current Settings
     $settings = ORM::factory('settings', 1);
     if ($settings->stat_id === null || $settings->stat_id == 0) {
         $sitename = $settings->site_name;
         $url = url::base();
         $this->template->content->stat_id = Stats_Model::create_site($sitename, $url);
     }
     // Show the hits page since stats are already set up
     $this->hits();
 }
Exemplo n.º 2
0
 public function index()
 {
     $this->template->content = new View('admin/stats/hits');
     $this->template->content->title = Kohana::lang('ui_admin.statistics');
     // Retrieve Current Settings
     $stat_id = Settings_Model::get_setting('stat_id');
     if ($stat_id === NULL or $stat_id == 0) {
         $sitename = Settings_Model::get_setting('site_name');
         $url = url::base();
         $this->template->content->stat_id = Stats_Model::create_site($sitename, $url);
     }
     // Show the hits page since stats are already set up
     $this->hits();
 }
Exemplo n.º 3
0
 public static function populate_db($db_name, $user, $settings)
 {
     $mhi_db = Kohana::config('database.default');
     $table_prefix = $mhi_db['table_prefix'];
     $mhi_db_name = $mhi_db['connection']['database'];
     // Switch to new DB for a moment
     mysql_query('USE ' . $db_name);
     $db_schema = file_get_contents('sql/ushahidi.sql');
     // If a table prefix is specified, add it to sql
     if ($table_prefix) {
         $find = array('CREATE TABLE IF NOT EXISTS `', 'INSERT INTO `', 'ALTER TABLE `', 'UPDATE `');
         $replace = array('CREATE TABLE IF NOT EXISTS `' . $table_prefix . '_', 'INSERT INTO `' . $table_prefix . '_', 'ALTER TABLE `' . $table_prefix . '_', 'UPDATE `' . $table_prefix . '_');
         $db_schema = str_replace($find, $replace, $db_schema);
     }
     // Split by ; to get the sql statement for creating individual tables.
     $tables = explode(';', $db_schema);
     foreach ($tables as $query) {
         $result = mysql_query($query);
     }
     // Set up admin user on new site
     $usr = ORM::factory('user', '1');
     $usr->username = $user['username'];
     $usr->name = $user['name'];
     $usr->password = $user['password'];
     $usr->email = $user['email'];
     $usr->save();
     // Save site settings (name, tagline, etc)
     $setgs = new Settings_Model(1);
     $setgs->site_name = $settings['site_name'];
     $setgs->site_tagline = $settings['site_tagline'];
     $setgs->api_google = Kohana::config('settings.api_google');
     $setgs->date_modify = date("Y-m-d H:i:s", time());
     $setgs->save();
     // Set up stats
     $domain = str_ireplace(array('http://', 'https://'), '', url::base());
     Stats_Model::create_site($settings['site_name'], 'http://' . $settings['site_domain'] . '.' . $domain);
     // Switch back to the appropriate DB
     mysql_query('USE ' . $mhi_db_name);
     return true;
 }