Code
- class import
- {
- var $data;
- function upload($file)
- {
- if ( @ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on' )
- {
- if ( !$this->data = @gzfile($file) )
- {
- return false;
- }
- }
- else
- {
- $file_url = parse_url($file);
- $fsock = @fsockopen($file_url['host'], 80, $errno, $errstr, 30);
- if (!$fsock)
- {
- return false;
- }
- $header = "GET ".$file_url['path']." HTTP/1.0".chr(10);
- $header .= "HOST: " . $file_url['host'].chr(10);
- $header .= "Connection: close".chr(10).chr(10);
- fwrite($fsock, $header);
- $file = trim(fgets($fsock, 4096));
- if (!strpos($file, "200"))
- {
- fclose($fsock);
- return FALSE;
- }
- while (trim(fgets($fsock, 4096)) != "");
- $this->data = "";
- while (!feof($fsock))
- {
- $this->data .= fgets($fsock, 128);
- }
- fclose($fsock);
- $this->data = gzinflate(substr($this->data, 10));
- $this->data = explode("\n", $this->data);
- }
- foreach ( $this->data as $id => $dummy )
- {
- $this->data[$id] = trim($this->data[$id]);
- $this->data[$id] = explode("\t", $this->data[$id]);
- if ( empty($this->data[$id][0]) )
- {
- unset($this->data[$id]);
- }
- }
- return true;
- }
- }