发信人: showtop()
整理人: jackyz(2000-08-10 11:24:27), 站内信件
|
好了,快写完了,最后一节了。
把一些小功能也做个介绍吧。大家如果想下课了的,可以先走了。
1、搜索功能
我们只打开info文件,所以只能在标题中搜索关键字了。代码如下:
<?php
function search_key($key) {
$dire="../page/";
$hd=opendir($dire);
while($fl=readdir($hd)) {
if($fl=="." or $fl=="..") continue;
if(strpos($fl,".info")){
$fc=file($dire.$fl);
if(strstr($fc[0],$key)==FALSE)continue;
$tmp=explode(".",$fl);
$ft=$tmp[0];
$re_var[$ft]=$fc;
}
}
return $re_var;
}
$r1=search_key($key);
?>
2、发信给我
其实就是从表单中接收一些参数,然后调用了mail()函数而已。
<?php
require("err.php3"); //还记得这两个文件吧。
require("isemail.php3");
if($name =="" or $emailadd =="" or $title ==""){
show_err("朋友,有什么不可以说的呢?请填写完整吧。");
exit;
}
else {
if(!is_valid_email_addr($emailadd)) {
show_err("别玩我了,朋友!给个真的email吧。");
exit;
}
$subject = $name."从自由岛给你发来留言";
$message = $name."提出建议=> ".$title."\n 联系信箱".$emailadd."\n具体 内容:\n ".$content;
$endmail = "From: sharetop \nReply-To: ".$emailadd."\nX-Mailer: PHP/ ".phpversion();
$r=mail("[email protected]",$subject,$message,$endmail);
if(!$r){
show_err("不能发送邮件!");
exit;
}
}
?>
3、岛主管理
对一些不太雅观的文章,我可不想每次都用FTP连上去删除,所以也写了一个函数 来在线删除文件。
<?php
if($password!="123456789"){ //就我一个人,密码干脆放在程序中了。
echo "对不起,你不是老土人,不给你这个权利。";
exit;
}
//以下找出所有info文件,读出标题
$dire="../page/";
$hd=opendir($dire);
while($fl=readdir($hd)) {
if($fl=="." or $fl=="..") continue;
if(strpos($fl,".info")){
$tmp=explode(".",$fl);
$ft=$tmp[0];
$fc=file($dire.$fl);
$res[$ft]=$fc[0];
}
}
if(count($res)==0) {echo "现在还没有帖子,无须管理。";exit;}
?>
然后把读出的标题放入一个列表框中,值 。
<?php
while( list($key,$var)=each($res) ) {
echo "<option value=\"".$key."\">".$var."</option>";
}
?>
对于选择的文件,删除它。
<?php
if($pw!="9111019"){echo "你无权访问本页!";exit;}
for($i=0;$i<count($select);$i++){
unlink("../page/".$select[$i].".info");
unlink("../page/".$select[$i].".body");
}
echo "已完成删除操作!";
?>
到此结束。
总算把这个论坛的源码一点点地招供出来。只是想与大家交流一下编程经验,我 学PHP时间也不长,所以有什么不妥的地方(我想肯定有很多地方是可以优化的), 请务必要告诉我!!!!
我的联系地址是:[email protected]
OICQ = 11783627
个人主页:
http://www.sbiotech.onchina.net
生物技术快报(用PHP+文本实现动态新闻更新)
http://www.sharetop.onchina.net
自由岛(用PHP+Mysql做的)
http://sharetop.e-chome.net
自由岛II(用PHP+文本做的)
-- 让我的所欲渐化虚无
让我的付出渐近无倦
E-mail : [email protected]
url : http://sbiotech.onchina.net《生物技术快报》
http://www.sharetop.onchina.net 《自由岛论坛》
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.75.57.220]
|
|