<?php
/*
\* ===========================================
\* 项目: CTB文本论坛
\* 版本:1.4
\* 团队: 实易数码
\* 小组: CTB文本论坛小组
\* 作者: 险情
\* 功能: 后台版块处理程式
\* ===========================================
\* Copyright (c) 2002
\* 团队主页: http://www.11cn.org
\* 团队信箱: ------
\* 创建日期: 2002/7/19
\* 修改日期: 2002-12-27
\* 修改说明: ------
\* 版权声明: 这个程序是免费软件.
\* ===========================================
*/

//=============================================================================

class Module extends CommonClass
{
    function execute()
    {
        switch($this->input['action']) {
			//
            case 'userMsgs':
                $this->userMsgs();
                break;
			//对单个人进行操作
            case 'delMsgsNew':
                $this->delMsgsNew();
                break;
            case 'delMsgsSent':
                $this->delMsgsSent();
                break;
            case 'delMsgsRead':
                $this->delMsgsRead();
                break;
			//对全体进行操作
            case 'delAllUserMsgs':
                $this->doAdminOrder("你确定要将所有用户的消息进行删除？");
                break;
            case 'delAllUserMsgs2':
                $this->delAllUserMsgs();
                break;
			//
        }
    } // end func

//-----------------------------------------------------------------------------
//---1、显示所有论坛用户------作者：险情
//---2、
//---3、
//-----------------------------------------------------------------------------

//=============================================================================
//显示所有被禁止发言的用户
    function userMsgs(){

    	//获取页
		$p = $this->input['p'];
		if ( !$p ) { 
			$p = 1; 
		} 
        
        //显示列表
        $this->file = "../".$this->set[dataPath]."/users/list.php";
        $listLine = $this->openfile();
		//获取所有有短信息的用户
    	for($i=0; $i<count($listLine);$i++)  { 
            $userMsgSent = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."old.php";
            $userMsgRead = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."new.php";
        	if (file_exists($userMsgSent) or file_exists($userMsgRead)) {
			    $getMsgsUser[] = $listLine[$i];
			}
		}
        //    
        $totalFile = count($getMsgsUser);
        $recnum = 20;//$userlist;
        $totalnum = ($totalFile % $recnum) == "0" ? intval(($totalFile)/$recnum) : intval(($totalFile)/$recnum)+1;
        //显示列表
		$num = 0;
    	for( $i = ($totalFile - ($p-1)*$recnum); $i > ($totalFile - $p*$recnum);$i--)  { 
            //获取消息数量
			if($getMsgsUser[$i]){
			$this->file = "../".$this->set[dataPath]."/users/".$getMsgsUser[$i][1]."old.php";
			$msgSentNum = count($this->select2(6, "0"));
			$msgReadNum = count($this->select2(6, "1"));
			//
			$this->file = "../".$this->set[dataPath]."/users/".$getMsgsUser[$i][1]."new.php";
            $msgNewNum = count($this->select2(6, "2"));
			//
			$userId = $getMsgsUser[$i][1];
			$userName = $getMsgsUser[$i][4];            
			//
			$num=$i+1;
			eval ("\$member_list .= \"".$this->getTemplate("userMsgsLine")."\";");
			}

        }
        $page = $this->getPage("$PHP_SELF?mod=usermsgs&action=userMsgs",$totalnum);
        eval("\$this->outPut(\"".$this->getTemplate("userMsgs")."\");");
    } // end func

//=============================================================================
//删除一个一个消息--没看的
    function delMsgsNew()
    {   
        $id = $this->input['id'];
		$this->file = "../".$this->set[dataPath]."/users/".$id."new.php";
        @unlink($this->file);

        $this->adminShowMsg("main.php?mod=usermsgs&action=userMsgs","您已经成功删除了此人的最新消息");
    } // end func

//=============================================================================
//删除一个一个消息---发送
    function delMsgsSent()
    {   
        $id = $this->input['id'];
		$this->file = "../".$this->set[dataPath]."/users/".$id."old.php";
        $this->delete(6,0);
        if(filesize($this->file)==0){
            @unlink($this->file);
		}
        $this->adminShowMsg("main.php?mod=usermsgs&action=userMsgs","您已经成功删除了此人的跟踪消息");
    } // end func

//=============================================================================
//删除一个一个消息---已读
    function delMsgsRead()
    {   
        $id = $this->input['id'];
		$this->file = "../".$this->set[dataPath]."/users/".$id."old.php";
        $this->delete(6,1);
        if(filesize($this->file)==0){
            @unlink($this->file);
		}
        $this->adminShowMsg("main.php?mod=usermsgs&action=userMsgs","您已经成功删除了此人的以读消息");
    } // end func


//=============================================================================
//对所有用户的消息进行操作
    function delAllUserMsgs()
    {   
        //删除最新
        if($this->input['id']=="new"){
            $this->file = "../".$this->set[dataPath]."/users/list.php";
            $listLine = $this->openfile();   
			for($i=0; $i<count($listLine);$i++){
                $userMsgRead = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."new.php";
                if(file_exists($userMsgRead)){
					unlink($userMsgRead);
				}
			}//end for
		}
		//删除已读
        elseif($this->input['id']=="read"){
            $this->file = "../".$this->set[dataPath]."/users/list.php";
            $listLine = $this->openfile();   
			for($i=0; $i<count($listLine);$i++){
                $userMsgRead = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."old.php";
                if(file_exists($userMsgRead)){
                    $this->file = $userMsgRead;
					$this->delete(6,1);
					if(filesize($userMsgRead)==0){
						@unlink($userMsgRead);
					}
				}
			}//end for
		}
		//删除跟踪
		elseif($this->input['id']=="sent"){
            $this->file = "../".$this->set[dataPath]."/users/list.php";
            $listLine = $this->openfile();   
			for($i=0; $i<count($listLine);$i++){
                $userMsgSent = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."old.php";
                if(file_exists($userMsgSent)){
                  $this->file = $userMsgSent;
					$this->delete(6,0);
					if(filesize($userMsgSent)==0){
						@unlink($userMsgSent);
					}
				}
			}//end for
		}
		//删除所有
		elseif($this->input['id']=="all"){
            $this->file = "../".$this->set[dataPath]."/users/list.php";
            $listLine = $this->openfile();   
			for($i=0; $i<count($listLine);$i++){
                $userMsgRead = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."old.php";
                if(file_exists($userMsgRead)){
					unlink($userMsgRead);
				}
                $userMsgNew = "../".$this->set[dataPath]."/users/".$listLine[$i][1]."new.php";
                if(file_exists($userMsgNew)){
					unlink($userMsgNew);
				}
			}//end for
		}
      
		//
        $this->adminShowMsg("main.php?mod=usermsgs&action=userMsgs","您已经成功进行了删除操作");
    } // end func
//<<
//=============================================================================
} //end class
