[原创]将远程网页的内容抄到自己的网站当中,大家改改, |
<?php
/***************************************************************
@explain : get html content and write to another html file. *
@auther : bianjiang *
@date : 2006-08-29 *
@version :1.0
@parameter: $source_file is somefile you want to write
$dest_file is somefile you want to read *
****************************************************************/
//Fnc Begin
function wt_html(&$source_file,$dest_file)
{
if(!fopen($dest_file,'rb')){
echo '无法读取目标文件!';
exit;
}
//判断文件是否可写
if (is_writable($source_file)) {
if (!($msg = file_get_contents($dest_file))) {
echo '读取文件: '.$dest_file.' 失败';
exit;
}
if(!(@$handle = fopen($source_file,'wb'))){
echo '请检查文件是否可写!';
exit;
}
//将文件写入目标文件
if (fwrite($handle, $msg) === FALSE){
echo '<b><center>信息写入失败!</center></b>';
exit;
}
else
echo '<b><center>信息写入成功!</center></b>';
}
else
{
echo '文件 : '.$source_file.' 不可写';
exit;
}
}
$s_file = 'write.html';
$d_file = 'http://bbs.17php.com/index.php';
if(wt_html(&$s_file,$d_file))
echo '操作成功';
else
echo '操作失败,请检在文件权限!';
exit;
?>
|
|
|