permission->is_admin();
//$this->output->enable_profiler(TRUE);
// $this->load->model('Area_model');
$this->load->model('Import_model');
// $this->load->model('InfoContents_model');
$this->load->model('InfoStructures_model');
$this->load->library('simple_html_dom_lib');
}
public function index()
{
//@set_time_limit(0);
ini_set('max_execution_time', '0');
// $this->Import_model->import_from_other_database(69690,63564);
//$this->Import_model->import_clear();
//$this->Import_model->import_info();
//$this->Import_model->import_xxoo();
//$this->Import_model->update_root();
/*$data = $this->Import_model->import_test();
foreach ($data as $item)
{
for ($i = 0; $i <= $item->is_level; $i++)
{
echo ' ';
}
echo $item->ic_url_title . '
';
}*/
}
public function html_to_database($sitecode)
{
ini_set('max_execution_time', '0');
$file_array=$this->Import_model->not_done_html_info($sitecode);
if (empty($file_array)) {
echo 'HTML文件都处理完毕!';
return;
}
foreach ($file_array as $item) {
$h_id=$item->h_id;
$file=$item->h_file;
$h_done=1;
//$file='f:\asiahighlights\myanmar\top-restaurants';
if (!is_file($file)) {
echo '文件不存在:'.$file;
continue;
}
$html_object=file_get_html($file);
if (empty($html_object)) {
echo '文件加载失败:'.$file;
continue;
}
$h_source=$html_object->outertext;
$h_content=$html_object->find('div[id=mainContentRight]', 0);
if (empty($h_content)) {
$h_content=$html_object->find('div[id=content]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div.Information', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div[id=content_main]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div[id=mainContent]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div[id=contentRight]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div[id=MainhotelContent]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div.col-md-19', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div[id=historyLine]', 0);
}
if (empty($h_content)) {
$h_content=$html_object->find('div.container', 0);
}
if (empty($h_content)) {
$h_content='';
$h_done=2;
} else {
$h_content=$h_content->innertext;
}
//echo $h_content;die();
$h_url=str_replace('\\', '/', $file);
$h_url=str_replace('F:/recovery-html/chinahighlights/', '/', $h_url);
$h_url=str_replace('F:/recovery-html/asiahighlights/', '/', $h_url);
$h_url=str_replace('d:/asiahighlights-htm/', '/', $h_url);
$h_url=str_replace('index-md.htm', '', $h_url);
$h_url=str_replace('-md.htm', '.htm', $h_url);
foreach ($html_object->find('meta') as $item) {
if ($item->name == 'description' && !empty($item->content)) {
$h_description = $item->content;
break;
}
}
if (empty($h_description)) {
$h_description='';
$h_done=2;
}
$h_title=$html_object->find('title', 0);
if (empty($h_title)) {
$h_title='';
$h_done=2;
} else {
$h_title=$h_title->innertext;
}
$h_h1=$html_object->find('h1', 0);
if (empty($h_h1)) {
$h_h1='';
$h_done=2;
} else {
$h_h1=$h_h1->innertext;
}
echo 'file:'.$file.'';
echo 'h_title:'.$h_title.'';
echo 'h_url:'.$h_url.'';
echo 'h_description:'.$h_description.'';
echo '