您的位置:首页 > 其它

一个对WDB的帖子进行操作的类

2004-08-24 16:58 393 查看
一个处理WDB程序帖子的类[PHP][原创]

帖子原始地址:一个处理WDB程序帖子的类[PHP][原创]

surfchen我写这个类主要是为了重新制作YB的论坛,不过这个类可以用来对任何WDB的帖子数据进行操作。。只要进行几个简单的变量设置。。注意看构造函数上面的注释。。

Code:
=======begin=======
<?php
/*获得和处理帖子信息*/
class YbPost
{
   /*构造函数,获得指定帖子的信息*/
   /*$post_url--帖子相对于论坛数据文件夹的URI,例如forum11/f_252,$post_row指定每个主题的某个帖子,为0时为第一帖*/
   function YbPost($post_url,$post_row=0)
   {
      /*$old_post_dir--论坛根目录相对于本文件所在目录的URI,例如"bbs".$post_dir--帖子数据根目录,例如postdata*/
      global $old_bbs_dir,$post_dir,$post_info,$file_info,$post_n;
      $post_n=$post_row;
      $this->mPostUrl=$old_bbs_dir."/".$post_dir."/".$post_url;//帖子完全的url
      $file_info=file($this->mPostUrl);
      $post_info=explode("│",$file_info[$post_row]);
      list($post_title,$post_user,$post_content,$post_date,$post_address)=$post_info;
      $this->mTitle=$post_title;//帖子标题
      $this->mUser=$post_user;//发帖人
      $this->mContent=$post_content;//帖子内容
      $this->mDate=$post_date;//发表日期,格式为UNIX时间戳
      $this->mAddress=$post_address;//发帖人地址
      $file_info=file("{$old_bbs_dir}/{$post_dir}/forum{$_GET['fid']}/list.php");
      foreach ($file_info as $key => $value)
      {
         $topic_info=explode("│",$value);
         if ($topic_info[5]==basename($post_url))
         {
            // ?????犞魈獗晏??????楼猪 ????????牱⑻奔??????????点击数 ??????回复数
            list($this->mTopicTitle,$this->mTopicUser,$this->mTopicFirstTime,,,,$this->mTopicHits,$this->mTopicPosts,$last_post_info)
               =$topic_info;
            // ??????最后回帖主题 ????????犠詈蠡靥?????????最后回帖时间
            list($this->mTopicLastPostTitle,$this->mTopicLastPostUser,$this->mTopicLastPostTime)=explode(",",$last_post_info);
            break;
         }
      }
   }

      /*编辑帖子标题*/
   function EditPostTitle($title)
   {
      global $post_info,$post_n,$file_info;
      $post_info[0]=$title;
      $now_info=implode("│",$post_info);
      $file_info[$post_n]=$now_info;
      $file_t_info=implode("",$file_info);
      SavaEdited($file_t_info);
   }

   /*编辑帖子内容*/
   function EditPostContent($content)
   {
      global $post_info,$post_n,$file_info;
      $post_info[2]=$content;
      $now_info=implode("│",$post_info);
      $file_info[$post_n]=$now_info;
      $file_t_info=implode("",$file_info);
      SavaEdited($file_t_info);
   }

   /*保存编辑信息*/
   function SaveEdited($info)
   {
      $handle=fopen($this->mPostUrl,"w");
      flock($handle,LOCK_EX);
      fwrite($handle,$info);
      flock($handle,LOCK_UN);
      fclose($handle);
   }
?>

========end=======

[此贴被surfchen在2004年9月10日23:48动过手脚]
IT杂谈
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐