<?php
  
  function loadingdate($userid){
        echo "<center>正在从ETW国外总服务器中心下载询盘数据，请稍等。。。。。。</center>";
       $allid=allchatid($userid);	
       $filename="http://data.etwservice.com/etw_xml/".$userid.".xml";
      // if(remote_file_exists($filename)){
            $xml = ""; 
             if($f = @fopen( $filename, 'r' )){ 
            while( $data = fread( $f, 4096 ) ) { $xml .= $data; } 
            fclose( $f ); 
	        preg_match_all( "/\<item\>(.*?)\<\/item\>/s",$xml, $items ); 
            $k=1;
            foreach( $items[1] as $item ){
			    $flat=1;
				preg_match_all( "/\<id\>(.*?)\<\/id\>/", $item, $chatid ); 
                
				for($i=0;$i<count($allid);$i++){
		           if($chatid[1][0]==$allid[$i]){
			            $flat=0;
				         break;
			       }
			     }
			   if($flat==1){
                   preg_match_all( "/\<title\>(.*?)\<\/title\>/", $item, $title ); 
                   preg_match_all( "/\<contacter\>(.*?)\<\/contacter\>/", $item, $contacter ); 
                   preg_match_all( "/\<telephone\>(.*?)\<\/telephone\>/", $item, $telephone ); 
                   preg_match_all( "/\<fax\>(.*?)\<\/fax\>/", $item, $fax ); 
                   preg_match_all( "/\<email\>(.*?)\<\/email\>/", $item, $email ); 
                   preg_match_all( "/\<address\>(.*?)\<\/address\>/", $item, $address ); 
                   preg_match_all( "/\<content\>(.*?)\<\/content\>/", $item, $content ); 
                   preg_match_all( "/\<languages\>(.*?)\<\/languages\>/", $item, $languages ); 
                   preg_match_all( "/\<senddate\>(.*?)\<\/senddate\>/", $item, $senddate ); 
                   preg_match_all( "/\<ip\>(.*?)\<\/ip\>/", $item, $ip ); 
                   preg_match_all( "/\<url\>(.*?)\<\/url\>/", $item, $url );
				   
				   $mysql="insert into etw_onlines(yid,title,contacter,telephone,fax,email,address,content,language,senddate,url,usernameid,ip,readed) value('".$chatid[1][0]."','".$title[1][0]."','".$contacter[1][0]."','".$telephone[1][0]."','".$fax[1][0]."','".$email[1][0]."','".$address[1][0]."','".$content[1][0]."','".$languages[1][0]."','".$senddate[1][0]."','".$url[1][0]."','".$userid."','".$ip[1][0]."','0' )";
	      
		            mysql_query($mysql) or die("sfsdfsfa");
               }  
            }  
       }
	
   
  }
 
 
 
	
				
?>


