主要功能是读取远程页面的代码放到需要调用的地方。可以代替DEDE系统默认的include标签使用。系统默认的include只能读取本地文件。而我所写的readfile标签,能读取远程文件。代码很简单,不过,也很实用使用方法:
{dede:readfile url='需要读取的页面地址'}{/dede:readfile}在模板管理里面,新建标签源码,文件名为:readfile.lib.php代码如下:代码如下:<?phpif(!defined('DEDEINC')){exit("Request Error!");}function lib_readfile(&$ctag,&$refObj){global $dsql,$envs;//属性处理$attlist="url|";FillAttsDefault($ctag->CAttribute->Items,$attlist);extract($ctag->CAttribute->Items, EXTR_SKIP);if($url != ''){$contents = file_get_contents($url);//如果出现中文乱码使用下面代码//$contents = iconv(”gb2312″, “utf-8″,file_get_contents($url));}else{$contents = '远程地址不能为空';}$revalue = $contents;return $revalue;}?>主要功能是读取远程页面的代码放到需要调用的地方。可以代替DEDE系统默认的include标签使用。系统默认的include只能读取本地文件。而我所写的readfile标签,能读取远程文件。
代码很简单,不过,也很实用使用方法:{dede:readfile url='需要读取的页面地址'}{/dede:readfile}在模板管理里面,新建标签源码,文件名为:readfile.lib.php代码如下:代码如下:<?phpif(!defined('DEDEINC')){exit("Request Error!");}function lib_readfile(&$ctag,&$refObj){global $dsql,$envs;//属性处理$attlist="url|";FillAttsDefault($ctag->CAttribute->Items,$attlist);extract($ctag->CAttribute->Items, EXTR_SKIP);if($url != ''){$contents = file_get_contents($url);//如果出现中文乱码使用下面代码//$contents = iconv(”gb2312″, “utf-8″,file_get_contents($url));}else{$contents = '远程地址不能为空';}$revalue = $contents;return $revalue;}?>