output->enable_profiler(TRUE);
$this->load->model('Area_model');
$this->load->model('InfoStructures_model');
$this->load->model('Information_model');
$this->load->model('Coupon_model');
}
public function index() {
$this->download_sitemap();
}
public function save($site_code) {
$site_array = $this->config->item('site');
$site = $site_array[$site_code];
$site_url = $site['site_url'];
$sitemap_name = $site['site_sitemap'];
if (!empty($sitemap_name)) {
$this->create($site_url, $sitemap_name);
} else {
echo 'no set sitemap name';
}
}
public function download_sitemap() {
@set_time_limit(0);
ini_set('max_execution_time', '0');
ini_set ('memory_limit', '512M');
$this->permission->is_admin();
$site_url = $this->config->item('site_url');
$site_code = $this->config->item('site_code');
$index_list = $this->Information_model->get_index_list($site_code);
$sitemap_string = ' ';
foreach ($index_list as $item) {
if ($item->im_value == 'noindex,nofollow' || $item->im_value == 'noindex,nofollow') {
continue;
} else {
$sitemap_string.='' . $site_url . $item->ic_url . '' . date('c', strtotime($item->ic_datetime)) . '';
}
}
$sitemap_string.=' ';
$this->load->helper('download');
force_download('sitemap.xml', $sitemap_string);
}
public function create($site_url, $site_sitemap = false) {
@set_time_limit(0);
ini_set('max_execution_time', '0');
ini_set ('memory_limit', '512M');
$data = array();
$sitemap_string = ' ';
$data['lastEditList'] = $this->Information_model->get_last_edit_list(false);
foreach ($data['lastEditList'] as $item) {
if ($item->ic_status == 1 && $item->ic_url != '' && strlen($item->ic_content)>50 ) {
$sitemap_string.='' . $site_url . $item->ic_url . '' . date('c', strtotime($item->ic_datetime)) . '';
}
}
$sitemap_string.=' ';
if ($site_sitemap) {
$this->load->helper('file');
if (!write_file($site_sitemap, $sitemap_string)) {
echo 'Unable to write the file';
} else {
echo 'File written!';
}
} else {
$this->load->helper('download');
force_download('sitemap.xml', $sitemap_string);
}
//echo $sitemap_string;die();
// $this->load->view('bootstrap/header', $data);
//$this->load->view('bootstrap/sitemap');
// $this->load->view('bootstrap/footer');
}
}