1. rss ที่ดึงมาแสดงเป็นแบบนี้
(เป็นแบบ php แบบที่ 8 อย่างในเว็บนี้
http://www.rssthai.com/howtouse.php )
**ต้องมีรูปภาพ ** ตามด้วยชื่อหัวข้อข่าว
แต่ตอนนี้แสดงแบบนี้
Warning: fread(): supplied argument is not a valid stream resource in C:\AppServ\www\ithai\public_html\rssthai\rssthaireader.php on line 220
Warning: fclose(): supplied argument is not a valid stream resource in C:\AppServ\www\ithai\public_html\rssthai\rssthaireader.php on line 221
**ไม่มีรูปภาพ ** มีหัวข้อข่าว
2. โค้ด ที่ใช้ อ่าน rss เขียนไว้ แบบนี้(เอามาจากไฟล์ thaireader.php)
function getimage($itemlink,$imageuri,$imagedir,$imageresize,$imagewidth,$imageheight)
{
if ($imageuri != "") return $imageuri;
$parsedlink = parse_url($itemlink);
list($tx,$rx) = split("&",$parsedlink["query"]);
list($t,$type) = split("=",$tx);
list($r,$rid) = split("=",$rx);
$urlquery = "
http://www.rssthai.com/images/?t=$type&r=$rid";
if (! (strpos($itemlink,"mreader.php") === false)) $urlquery = "
http://www.rssthai.com/images/?u=$type&r=$rid";
if (! file_exists($imagedir))
{
mkdir($imagedir);
}
$imagefilename = $imagedir.$type."_".$rid."_" . $imagewidth . "x" . $imageheight .".jpg";
if (! file_exists($imagefilename))
{
$imgContents = null;
//echo $urlquery;
$fileHandle = @fopen($urlquery, "r");
$fileuri = fread($fileHandle, 8192);
fclose($fileHandle);
$fileHandle = @fopen($fileuri, "rb");
if($fileHandle)
{
while (!feof($fileHandle))
{
$imgContents .= fread($fileHandle, 8192);
}
fclose($fileHandle);
if ($imgContents)
{
if ($imageresize==false || function_exists("imagecreatefromstring")==false)
{
$handle = fopen($imagefilename, "wb");
fwrite($handle, $imgContents);
fclose($handle);
}
else
{
$source = imagecreatefromstring($imgContents);
$imageX = imagesx($source);
$imageY = imagesy($source);
if ($imagewidth >= $imageX)
{
$handle = fopen($imagefilename, "wb");
fwrite($handle, $imgContents);
fclose($handle);
}
else
{
$thumbX = $imagewidth;
$thumbY = (int)(($thumbX*$imageY) / $imageX );
$dest = imagecreatetruecolor($thumbX, $thumbY);
imagecopyresampled ($dest, $source, 0, 0, 0, 0, $thumbX, $thumbY, $imageX, $imageY);
imagejpeg($dest,$imagefilename,75);
imagedestroy($dest);
}
imagedestroy($source);
}
}
}
}
return $imagefilename;
}
ช่วยตอบหน่อยนะคะ ขอบคุณมากค่ะ
1. rss ที่ดึงมาแสดงเป็นแบบนี้
(เป็นแบบ php แบบที่ 8 อย่างในเว็บนี้ http://www.rssthai.com/howtouse.php )
**ต้องมีรูปภาพ ** ตามด้วยชื่อหัวข้อข่าว
แต่ตอนนี้แสดงแบบนี้
Warning: fread(): supplied argument is not a valid stream resource in C:\AppServ\www\ithai\public_html\rssthai\rssthaireader.php on line 220
Warning: fclose(): supplied argument is not a valid stream resource in C:\AppServ\www\ithai\public_html\rssthai\rssthaireader.php on line 221
**ไม่มีรูปภาพ ** มีหัวข้อข่าว
2. โค้ด ที่ใช้ อ่าน rss เขียนไว้ แบบนี้(เอามาจากไฟล์ thaireader.php)
function getimage($itemlink,$imageuri,$imagedir,$imageresize,$imagewidth,$imageheight)
{
if ($imageuri != "") return $imageuri;
$parsedlink = parse_url($itemlink);
list($tx,$rx) = split("&",$parsedlink["query"]);
list($t,$type) = split("=",$tx);
list($r,$rid) = split("=",$rx);
$urlquery = "http://www.rssthai.com/images/?t=$type&r=$rid";
if (! (strpos($itemlink,"mreader.php") === false)) $urlquery = "http://www.rssthai.com/images/?u=$type&r=$rid";
if (! file_exists($imagedir))
{
mkdir($imagedir);
}
$imagefilename = $imagedir.$type."_".$rid."_" . $imagewidth . "x" . $imageheight .".jpg";
if (! file_exists($imagefilename))
{
$imgContents = null;
//echo $urlquery;
$fileHandle = @fopen($urlquery, "r");
$fileuri = fread($fileHandle, 8192);
fclose($fileHandle);
$fileHandle = @fopen($fileuri, "rb");
if($fileHandle)
{
while (!feof($fileHandle))
{
$imgContents .= fread($fileHandle, 8192);
}
fclose($fileHandle);
if ($imgContents)
{
if ($imageresize==false || function_exists("imagecreatefromstring")==false)
{
$handle = fopen($imagefilename, "wb");
fwrite($handle, $imgContents);
fclose($handle);
}
else
{
$source = imagecreatefromstring($imgContents);
$imageX = imagesx($source);
$imageY = imagesy($source);
if ($imagewidth >= $imageX)
{
$handle = fopen($imagefilename, "wb");
fwrite($handle, $imgContents);
fclose($handle);
}
else
{
$thumbX = $imagewidth;
$thumbY = (int)(($thumbX*$imageY) / $imageX );
$dest = imagecreatetruecolor($thumbX, $thumbY);
imagecopyresampled ($dest, $source, 0, 0, 0, 0, $thumbX, $thumbY, $imageX, $imageY);
imagejpeg($dest,$imagefilename,75);
imagedestroy($dest);
}
imagedestroy($source);
}
}
}
}
return $imagefilename;
}
ช่วยตอบหน่อยนะคะ ขอบคุณมากค่ะ