<link href="css/layout.css" rel="stylesheet" type="text/css" /> <script src="js/request.js"></script> |
"password=mypassword |
<body onload="javascript:makeRequest('request.php?request=' + document.feedForm.feed.value + '"password=mypassword');"> <form name="feedForm" method="post" action="javascript:makeRequest('request.php?request=' + document.feedForm.feed.value + '"password=mypassword');"> Enter a feed: <input type="text" name="feed" id="feed" size="20"> <input type="submit" name="submit" value="Add Feed"> </form> <div id="logo"></div> <hr/> <div id="copy"></div> <div id="details"></div> </body> |
//如果不存在目录就创建一个 $dir = "rss"; if(!is_dir($dir)) { mkdir($dir, 0666); } |
//创建唯一的命名 $file=md5($rss_url); $path="$dir/$file.xml"; |
//复制馈送到本地服务器 copy($rss_url,"$path"); return $path; Following is the small, yet powerful RSS class in its entirety: <?php class RSS { function get($rss_url) { if($rss_url != "") { //如果不存在目录就创建一个 $dir = "rss"; if(!is_dir($dir)) { mkdir($dir, 0666); } // 创建一个唯一的名字 $file = md5($rss_url); $path = "$dir/$file.xml"; //复制馈送到本地服务器 copy($rss_url, "$path"); return $path; } } } ?> |
<? if($password == "mypassword") { require_once('classes/RSS.class.php'); $rss = new RSS(); echo $rss->get($request); } else { echo "You are an unauthorized user"; } ?> |
function sendFeed(url){ post.onreadystatechange = sendRequest; post.open("POST", url, true); post.send(url); } |
function sendRequest(){ if(checkReadyState(post)){ request = createRequestObject(); request.onreadystatechange = onResponse; request.open("GET", post.responseText, true); request.send(null); } } |
var _logo = ""; var _title = response.getElementsByTagName('title')[0].firstChild.data; var _link = response.getElementsByTagName('link')[0].firstChild.data;; _logo += "<a href='" + _link + "' target='_blank'>" + _title + "</a><br/>"; if(checkForTag(response.getElementsByTagName('image')[0])) { var _url = response.getElementsByTagName('url')[0].firstChild.data; _logo += "<img src='" + _url + "' border='0'><br/>" } document.getElementById('logo').innerHTML = _logo; |
if(checkForTag(response.getElementsByTagName('image')[0]) "" i>0){ var _title=response.getElementsByTagName('title')[i+1].firstChild.data; var _link=response.getElementsByTagName('link')[i+1].firstChild.data; } else{ var _title =response.getElementsByTagName('title')[i].firstChild.data; var _link = response.getElementsByTagName('link')[i].firstChild.data; } |
function checkForTag(tag){ if(tag != undefined) { return true; } else{ return false; } } |
if(i>1){ var previousPubDate = response.getElementsByTagName('pubDate')[i-1].firstChild.data; } if(pubDate != previousPubDate || previousPubDate == undefined){ _copy += "<div id='detail'>" + pubDate + "</div><hr align='left' width='90%'/>"; } _copy += "<a href=\"javascript:showDetails('" + i + "');\">" + _title + "</a><br/><br/>"; document.getElementById('copy').innerHTML += _copy; |
function showDetails(index){ document.getElementById('details').innerHTML = response.getElementsByTagName('description')[index].firstChild.data; } |