⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadrss.php

📁 examples ajax + php tutorial
💻 PHP
字号:
<?php
// set the XML header
header('Content-type: text/xml'); 
// define an error message in case the feed cannot be found
$error='<?xml version="1.0"?><error>Cannot find feed</error>';
// clear the contents
$contents = '';
// read the url variable from the GET request
$rssurl=$_GET['url'];
// test if the url starts with http to prevent surfers being able 
// to call and display local files
if(preg_match('/^http:/',$rssurl)){
	// open the remote file, and store it contents
	$handle = @fopen($rssurl, "rb");
	if($handle==true){
		while (!feof($handle)) {
			$contents .= fread($handle, 8192);
		}
		fclose($handle);
	}
}
// if the file has no channel element, delete contents
if(!preg_match('/<channel/',$contents)){$contents='';}
// return either the contents or the error
echo $contents==''?$error:$contents;
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -