Ok
I have to admit defeat on this :(
I did have it running OK up until Friday but something has changed.
Maybe it is to do with the file name.
I am downloading the clickbank marketplace
and trying to unzip it using cUrl and ZipArchive.
Here is my little script with all the logging.
-
$target_url = "http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip";
-
$userAgent = 'EasyDL/3.xx';
-
$file_zip = $file_dir."a_zip_clickbank.zip";
-
$cef = "curl_err.txt";
-
$ceh = fopen($cef, 'wb');
-
-
write_log("Target_url: $target_url\r\n");
-
-
// make the cURL request to $target_url
-
$ch = curl_init();
-
$fp = fopen("$file_zip", "wb");
-
-
if ($fp === FALSE ) {
-
write_log("Problem opening $file_zip\r\n");
-
exit;
-
}
-
-
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);
-
-
$output = curl_exec($ch);
-
$info = curl_getinfo($ch);
-
-
if ($output === FALSE || $info['http_code'] != 200) {
-
write_log("No cURL data returned for $target_url [". $info['http_code']. "]\r\n ");
-
if (curl_error($ch)) write_log($output."CURL error number: curl_errno($ch)\r\n CURL error: curl_error($ch)\r\n");
-
exit;
-
}
-
else {
-
write_log("CURL completed successfully.\r\n");
-
}
-
-
curl_close($ch);
-
-
if(file_exists($file_zip)) {
-
$fsz = filesize($file_zip);
-
}
-
else {
-
write_log("File: $file_zip does not exist \r\n");
-
exit;
-
}
-
-
write_log("Downloaded file: $target_url\r\n-Saved as file: $file_zip\r\n-File size: $fsz bytes \r\n");
-
-
// Un zip the file
-
-
// After curl code:
-
fclose($fp);
-
fclose($ceh);
-
-
if (!class_exists('ZipArchive')) {
-
write_log("Class ZipArchive not found\r\n");
-
exit;
-
}
-
else {
-
$zip = new ZipArchive;
-
}
-
-
if (!$file_zip) {
-
write_log("Could not find $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("Found: $file_zip\r\n");
-
}
-
-
if (($err = $zip->open($file_zip)) !== true) {
-
write_log("Could not open $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("File opened\r\n");
-
}
-
-
if (!$zip->extractTo($file_dir)) {
-
write_log("Extraction error\r\n");
-
exit;
-
}
-
This is my log that gets written by the scrpt.
Target_url: http://www.clickbank.com/feeds/marke...eed_v1.xml.zip
CURL completed successfully.
Downloaded file: http://www.clickbank.com/feeds/marke...eed_v1.xml.zip
-Saved as file: /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
-File size: 2764800 bytes
Found: /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
Could not open /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
Error # 19
The file
a_zip_clickbank.zip shows up on my server
and if I ftp it to my desktop, I can unzip it.
I don't know why I amp getting the error, but I think i is something to do
with defining the file name: $file_zip = $file_dir."a_zip_clickbank.zip";
Any ideas where I have gone wrong ?
Thanks.
.