gigawarn
Registered User
از تیتر معلومه دیگه یه سایتی که خروجی خوان باشه مثل ویگذر ولی می خوام سرعتش بسیار بالا باشه
قوی
قوی
از تیتر معلومه دیگه یه سایتی که خروجی خوان باشه مثل ویگذر ولی می خوام سرعتش بسیار بالا باشه
قوی
<?php
$RSS_Content = array();
function RSS_Tags($item, $type)
{
$y = array();
$tnl = $item->getElementsByTagName("title");
$tnl = $tnl->item(0);
$title = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("link");
$tnl = $tnl->item(0);
$link = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("description");
$tnl = $tnl->item(0);
$description = $tnl->firstChild->data;
$tnl = $item->getElementsByTagName("pubDate");
$tnl = $tnl->item(0);
$pubDate = $tnl->firstChild->data;
$y["title"] = $title;
$y["link"] = $link;
$y["description"] = $description;
$y["pubDate"] = $pubDate;
$y["type"] = $type;
return $y;
}
function RSS_Channel($channel)
{
global $RSS_Content;
$items = $channel->getElementsByTagName("item");
// Processing channel
$y = RSS_Tags($channel, 0); // get description of channel, type 0
array_push($RSS_Content, $y);
// Processing articles
foreach($items as $item)
{
$y = RSS_Tags($item, 1); // get description of article, type 1
array_push($RSS_Content, $y);
}
}
function RSS_Retrieve($url)
{
global $RSS_Content;
$doc = new DOMDocument();
$doc->load($url);
$channels = $doc->getElementsByTagName("channel");
$RSS_Content = array();
foreach($channels as $channel)
{
RSS_Channel($channel);
}
}
function RSS_RetrieveLinks($url)
{
global $RSS_Content;
$doc = new DOMDocument();
$doc->load($url);
$channels = $doc->getElementsByTagName("channel");
$RSS_Content = array();
foreach($channels as $channel)
{
$items = $channel->getElementsByTagName("item");
foreach($items as $item)
{
$y = RSS_Tags($item, 1); // get description of article, type 1
array_push($RSS_Content, $y);
}
}
}
function RSS_Links($url, $size)
{
global $RSS_Content;
$page = "<ul>";
RSS_RetrieveLinks($url);
if($size > 0)
$recents = array_slice($RSS_Content, 0, $size);
foreach($recents as $article)
{
$type = $article["type"];
if($type == 0) continue;
$title = $article["title"];
$link = $article["link"];
$page .= "<li><a href=\"$link\">$title</a></li>\n";
}
$page .="</ul>\n";
return $page;
}
function RSS_Display($url, $size)
{
global $RSS_Content;
$opened = false;
$page = "";
RSS_Retrieve($url);
if($size > 0)
$recents = array_slice($RSS_Content, 0, $size);
foreach($recents as $article)
{
$type = $article["type"];
if($type == 0)
{
if($opened == true)
{
$page .="";
$opened = false;
}
$page .="";
}
else
{
if($opened == false)
{
$page .= "";
$opened = true;
}
}
$title = $article["title"];
$link = $article["link"];
$description = $article["description"];
$pubDate = $article["pubDate"];
if($title == 'Fars News Agency')
{
$page .= "";
}else{
$page .= "<table border=0 cellpadding=0 cellspacing=0 width=420>
<tr>
<td width=7 height=7 background=img/n2.gif></td>
<td background=img/ng3.gif></td>
<td width=7 height=7 background=img/n1.gif></td>
</tr>
<tr>
<td background=img/ng2.gif></td>
<td bgcolor=#FFFFFF>
<p style=\"font-size: 12;font-weight:bold; text-align: right; color : #cc3300;\">$title<hr>
<p style=\"line-height: 18px;font-size: 11;\">$description<br>تاریخ خبر : $pubDate</p>
<p style=\"font-size: 11;font-weight:bold;text-align: left;\"><a target=_blank href=$link>ادامه خبر</a></p>
</td>
<td background=img/ng1.gif></td>
</tr>
<tr>
<td width=7 height=7 background=img/n4.gif></td>
<td background=img/ng4.gif></td>
<td width=7 height=7 background=img/n3.gif></td>
</tr>
</table><br>";}
if($description != false)
{
$page .= "";
}
$page .= "";
if($type==0)
{
$page .="";
}
}
if($opened == true)
{
$page .="";
}
return $page."\n";
}
?>
require_once("rsslib.php");
$url = "http://www.farsnews.net/rss/";
echo RSS_Display($url, 15);
سلام.جناب asadiweb لطفا کمکم کنید.
من فایل rsslib.php رو در آدرسی مثلا (http://www.mysite.com/1/rsslib.php ) آپلود کردم.
بعد داخل یک صفحه html بین تگ body ، قسمت دومی که فرمودید نوشتم.
اما وقتی فایل HTML رو اجرا میکنم ، کار نمیکنه!!!
لطفا یکم بیشتر توضیح بدید.
ممنونم