jeddi
01-26-2010, 06:41 PM
Hi,
I am trying to download a file and unzip it
but I get this error
Could not open /home/guru54gt5/public_html/sys/clickbank.zip
Error # 11
I keep a log which opens at the start
of the code (not shown).
This is my code:
$target_url = "http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip";
$userAgent = 'EasyDL/3.xx';
$file_zip = "clickbank.zip";
$cef = "curl_err.txt";
$ceh = fopen($cef, 'w');
// write to log
$content = "Target_url: $target_url\r\n";
fwrite($handle, $content);
// make the cURL request to $target_url
$ch = curl_init();
$fp = fopen("$file_zip", "wb");
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_STDERR, $ceh);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FILE, $fp);
$page = curl_exec($ch);
if (!$page) {
$content = "CURL error number: curl_errno($ch)\r\n CURL error: curl_error($ch)\r\n";
fwrite($handle, $content);
exit;
}
curl_close($ch);
$fsz = filesize($file_zip);
$content = "Downloaded file: $target_url\r\n Saved as file: $file_zip\r\n File size: $fsz bytes \r\n";
fwrite($handle, $content);
// Un zip the file
// After curl code:
fclose($fp);
fclose($ceh);
$file_zip = '/home/guru54gt5/public_html/sys/'.$file_zip;
if (!class_exists('ZipArchive')) {
$content = "Class ZipArchive not found\r\n";
fwrite($handle, $content);
exit;
} else {
$zip = new ZipArchive;
}
if (($err = $zip->open($file_zip)) !== true) {
$content = "Could not open $file_zip\r\n Error # $err\r\n";
fwrite($handle, $content);
exit;
} else {
$content = "File opened\r\n";
fwrite($handle, $content);
}
if (!$zip->extractTo($file_dir)) {
$content = "Extraction error\r\n";
fwrite($handle, $content);
}
$zipSS = $zip->getStatusString();
$content = "StatusString: $zipSS\r\n";
fwrite($handle, $content);
if (!$zip->close()) {
$content = "Error on close\r\n";
fwrite($handle, $content);
} else {
$content = "Unzipped file to: $file_dir\r\n";
fwrite($handle, $content);
}
$file = $file_dir.'clickbank.xml';
exit;
My log file shows this:
Notice that the filesize() doesn't appear to work - probably no file ?
New record - Time Stamp: 11:06:33 Tuesday, 26 January 2010
This script: sys/auto_cb_update.php, This file: /home/guru54gt5/public_html/sys/a_log_cb_update.txt
Target_url: http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip
Downloaded file: http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip
Saved as file: clickbank.zip
File size: filesize(clickbank.zip) bytes
Could not open /home/guru54gt5/public_html/sys/clickbank.zip
Error # 11
And the error file (curl_err.txt) shows:
* About to connect() to www.clickbank.com port 80
* Trying 74.63.153.33... * connected
* Connected to www.clickbank.com (74.63.153.33) port 80
> GET /feeds/marketplace_feed_v1.xml.zip HTTP/1.1
User-Agent: EasyDL/3.xx
Host: www.clickbank.com
Accept: */*
< HTTP/1.1 200 OK
< Date: Tue, 26 Jan 2010 18:34:58 GMT
< Server: Apache
< ETag: W/"2325066-1264507973000"
< Last-Modified: Tue, 26 Jan 2010 12:12:53 GMT
< Content-Length: 2325066
< Content-Type: application/zip
* Connection #0 to host www.clickbank.com left intact
* Closing connection #0
So does this mean that it did not download the zip file ?
If if didn't - what could be the problem ?
If you can see any obvious erros in my
code, I would appreciate any advice,
thanks.
.
I am trying to download a file and unzip it
but I get this error
Could not open /home/guru54gt5/public_html/sys/clickbank.zip
Error # 11
I keep a log which opens at the start
of the code (not shown).
This is my code:
$target_url = "http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip";
$userAgent = 'EasyDL/3.xx';
$file_zip = "clickbank.zip";
$cef = "curl_err.txt";
$ceh = fopen($cef, 'w');
// write to log
$content = "Target_url: $target_url\r\n";
fwrite($handle, $content);
// make the cURL request to $target_url
$ch = curl_init();
$fp = fopen("$file_zip", "wb");
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_STDERR, $ceh);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FILE, $fp);
$page = curl_exec($ch);
if (!$page) {
$content = "CURL error number: curl_errno($ch)\r\n CURL error: curl_error($ch)\r\n";
fwrite($handle, $content);
exit;
}
curl_close($ch);
$fsz = filesize($file_zip);
$content = "Downloaded file: $target_url\r\n Saved as file: $file_zip\r\n File size: $fsz bytes \r\n";
fwrite($handle, $content);
// Un zip the file
// After curl code:
fclose($fp);
fclose($ceh);
$file_zip = '/home/guru54gt5/public_html/sys/'.$file_zip;
if (!class_exists('ZipArchive')) {
$content = "Class ZipArchive not found\r\n";
fwrite($handle, $content);
exit;
} else {
$zip = new ZipArchive;
}
if (($err = $zip->open($file_zip)) !== true) {
$content = "Could not open $file_zip\r\n Error # $err\r\n";
fwrite($handle, $content);
exit;
} else {
$content = "File opened\r\n";
fwrite($handle, $content);
}
if (!$zip->extractTo($file_dir)) {
$content = "Extraction error\r\n";
fwrite($handle, $content);
}
$zipSS = $zip->getStatusString();
$content = "StatusString: $zipSS\r\n";
fwrite($handle, $content);
if (!$zip->close()) {
$content = "Error on close\r\n";
fwrite($handle, $content);
} else {
$content = "Unzipped file to: $file_dir\r\n";
fwrite($handle, $content);
}
$file = $file_dir.'clickbank.xml';
exit;
My log file shows this:
Notice that the filesize() doesn't appear to work - probably no file ?
New record - Time Stamp: 11:06:33 Tuesday, 26 January 2010
This script: sys/auto_cb_update.php, This file: /home/guru54gt5/public_html/sys/a_log_cb_update.txt
Target_url: http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip
Downloaded file: http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip
Saved as file: clickbank.zip
File size: filesize(clickbank.zip) bytes
Could not open /home/guru54gt5/public_html/sys/clickbank.zip
Error # 11
And the error file (curl_err.txt) shows:
* About to connect() to www.clickbank.com port 80
* Trying 74.63.153.33... * connected
* Connected to www.clickbank.com (74.63.153.33) port 80
> GET /feeds/marketplace_feed_v1.xml.zip HTTP/1.1
User-Agent: EasyDL/3.xx
Host: www.clickbank.com
Accept: */*
< HTTP/1.1 200 OK
< Date: Tue, 26 Jan 2010 18:34:58 GMT
< Server: Apache
< ETag: W/"2325066-1264507973000"
< Last-Modified: Tue, 26 Jan 2010 12:12:53 GMT
< Content-Length: 2325066
< Content-Type: application/zip
* Connection #0 to host www.clickbank.com left intact
* Closing connection #0
So does this mean that it did not download the zip file ?
If if didn't - what could be the problem ?
If you can see any obvious erros in my
code, I would appreciate any advice,
thanks.
.