fix Mime type method (no HEAD http request)
This commit is contained in:
@@ -402,35 +402,7 @@ class Databap extends PhpObject
|
||||
|
||||
public function goLive()
|
||||
{
|
||||
$sUrl = 'http://img-9gag-ftw.9cache.com/photo/a5dmY7G_700b.jpg';
|
||||
$asResult = array();
|
||||
|
||||
$oCurl = curl_init($sUrl);
|
||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($oCurl, CURLOPT_HEADER, true);
|
||||
//curl_setopt($oCurl, CURLOPT_NOBODY, true);
|
||||
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_exec($oCurl);
|
||||
$asResult[] = 'curl: '.curl_getinfo($oCurl, CURLINFO_CONTENT_TYPE);
|
||||
curl_close($oCurl);
|
||||
|
||||
$asResult[] = 'get_headers: '.print_r(get_headers($sUrl, 1), true);
|
||||
|
||||
stream_context_set_default(array('http' => array('method' => 'HEAD')));
|
||||
$asResult[] = 'get_headers HEAD: '.print_r(get_headers($sUrl, 1), true);
|
||||
|
||||
file_get_contents($sUrl);
|
||||
$asResult[] = '$http_response_header: '.print_r($http_response_header, true);
|
||||
|
||||
$size = getimagesize($sUrl);
|
||||
$asResult[] = 'getimagesize: '.$size['mime'];
|
||||
|
||||
$oFileInfo = new finfo(FILEINFO_MIME);
|
||||
$asResult[] = 'finfo: '.$oFileInfo->file($sUrl);
|
||||
|
||||
return implode('<br />', $asResult);
|
||||
|
||||
}
|
||||
|
||||
private function setUserId($iUserId)
|
||||
@@ -763,10 +735,7 @@ class Databap extends PhpObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$sUrl = $o9gagImage->getAttribute('src');
|
||||
$sFilePath = self::DOC_TMP_FOLDER.uniqid();
|
||||
$asResult = ToolBox::createThumbnail($sUrl, self::CHAT_IMG_MAX_WIDTH, self::CHAT_IMG_MAX_HEIGHT, $sFilePath, false, array());
|
||||
$asResult = $this->downloadToTmp($o9gagImage->getAttribute('src'));
|
||||
|
||||
if($asResult['error']=='')
|
||||
{
|
||||
|
||||
@@ -140,11 +140,12 @@ class ToolBox
|
||||
}
|
||||
else //Remote
|
||||
{
|
||||
//get_headers($sUrl, 1)
|
||||
$oCurl = curl_init($sPath);
|
||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($oCurl, CURLOPT_HEADER, true);
|
||||
curl_setopt($oCurl, CURLOPT_NOBODY, true);
|
||||
//curl_setopt($oCurl, CURLOPT_NOBODY, true);
|
||||
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_exec($oCurl);
|
||||
|
||||
Reference in New Issue
Block a user