<?php
class Bysoft_Myimage_Helper_Data extends Mage_Core_Helper_Abstract
{
function common_filesize($url) {
$user='';
$pass='';
$parse = parse_url($url);
$host = $parse['host'];
if ($host == 'gogear.preprodbysoftchina.com') {
$user='gogear';
$pass='bysoft2014';
return $this->remote_filesize($url, $user, $pass);
} else {
return getimagesize($url);
}
}
function remote_filesize($url, $user, $pass) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
$data = curl_exec($ch);
curl_close($ch);
$ext = pathinfo($url,PATHINFO_EXTENSION);
$filename = BP.DS.'media'.DS.'remote_file'.DS.time().'.'.$ext;
$fp = @fopen($filename, "w+");
fwrite($fp, $data);
fclose($fp);
$info = getimagesize($filename);
@unlink($filename);
return $info;
}
}