<?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 'userPhoto':
                $this->userPhoto();
                break;
            case 'seeUserPhoto':
                $this->seeUserPhoto();
                break;
            case 'delUserPhoto':
                $this->doAdminOrder("您确定要删除此人头像吗？");
                break;
            case 'delUserPhoto2':
                $this->delUserPhoto();
                break;   
            case 'searchUserPhoto':
                $this->searchUserPhoto();
                break;  
			//
			default:
                $this->userPhoto();
                break;

			//
        }
    } // end func

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

//=============================================================================
//发送邮件
    function userPhoto()
		{

		$userFaceArry = $this->getFileNameList("../".$this->set[dataPath]."/upface");
		
		//
		$p = $this->input['p'];
		if ( !$p ) { $p = 1; } 
		$totalFile = count($userFaceArry);
		$recnum = 20;//$userlist;
		$totalnum = ($totalFile % $recnum) == "0" ? intval(($totalFile)/$recnum) : intval(($totalFile)/$recnum)+1;
		
		//exit("ccc:".$totalFile);
		$num = 0;
		for( $i = $totalFile-(($p-1)*$recnum); $i > $totalFile-($p*$recnum);$i--) {

		
			if ($userFaceArry[$i]) {
				$fileInfo = split("_", $userFaceArry[$i]);
                $getUserName = $this->getNameFromId($fileInfo[0]);
				$getFaceTime = date("Y-m-d H:i:s",$fileInfo[1]);
				//
				$fileTypeInfo = split("\.", $userFaceArry[$i]);
                $$fileTypeInfoNum=count($fileTypeInfo)-1;
			    $fileType = $fileTypeInfo[$$fileTypeInfoNum];
				//
				$fSize = filesize("../".$this->set[dataPath]."/upface/".$userFaceArry[$i]);
				$fSize = $fSize/1024;
				$fSize = substr($fSize, 0,4); 
				//
                $num++;
				$userFaceList .= " <tr bgcolor='#f5f5f5'> 
				<td  align=center>$num</td>
				<td>&nbsp;$getUserName</td>
				<td>$userFaceArry[$i]</td>
				<td  align=center>$fileType</td>
				<td  align=center>$getFaceTime</td>
				<td  align=center>$fSize</td>

				<td  align=center><a href=\"main.php?mod=userphoto&action=seeUserPhoto&id=$userFaceArry[$i]\" target=_blank>查看</a></td>
				<td  align=center><a href=\"main.php?mod=userphoto&action=delUserPhoto&id=$userFaceArry[$i]\">删除</a></td>

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

//=============================================================================
//显示头像
	function seeUserPhoto()
	{
		$getImageDir = $this->set[dataPath];

		$memberFace = "../".$getImageDir."/upface/".$this->input[id];
        header("location:$memberFace");  
	}//end func 

//=============================================================================
//显示头像
	function delUserPhoto()
	{
        if (@unlink("../".$this->set[dataPath]."/upface/".$this->input['id'])){
        //
            $this->adminShowMsg("./main.php?mod=userphoto","您已经成功删除此人上传头像");
        }else {
            $this->adminShowWrong("./main.php?mod=userphoto","删除失败");
        }
	}//end func 

//=============================================================================
//发送邮件
    function searchUserPhoto(){
		$openUserFace=opendir("../".$this->set[dataPath]."/upface");
		$userFaceName = array();
		$num = 0;
		while ($userFace=readdir($openUserFace)) {
			if (($userFace!="") and ($userFace!=".") and ($userFace!="..")) {
				$fileInfo = split("_", $userFace);
                //通过名字取得id
                $getUserId = $this->getIdFromName($this->input[searchName]);

				if($getUserId == $fileInfo[0]){
                $getUserName = $this->getNameFromId($fileInfo[0]);
				$getFaceTime = date("Y-m-d H:i:s",$fileInfo[1]);
				//
				$fileTypeInfo = split("\.", $userFace);
                $$fileTypeInfoNum=count($fileTypeInfo)-1;
			    $fileType = $fileTypeInfo[$$fileTypeInfoNum];
				//
				$fSize = filesize("../".$this->set[dataPath]."/upface/".$userFace);
				$fSize = $fSize/1024;
				$fSize = substr($fSize, 0,4); 
				//
				$userFaceList .= " <tr bgcolor='#f5f5f5'> 
				<td  align=center>$num</td>
				<td>&nbsp;$getUserName</td>
				<td>$userFace</td>
				<td  align=center>$fileType</td>
				<td  align=center>$getFaceTime</td>
				<td  align=center>$fSize</td>

				<td  align=center><a href=\"main?mod=userphoto&action=seeUserPhoto&id=$userFace\" target=_blank>查看</a></td>
				<td  align=center><a href=\"main?mod=userphoto&action=delUserPhoto&id=$userFace\">删除</a></td>

				</tr>";
 
                $num++;
				}//end if
			 }
		}
		closedir($openUserFace);
		$userFaceNum = count($userFaceName);

		//
    	eval("\$this->outPut(\"".$this->getTemplate("userPhoto")."\");");
    } // end func


//<<
//=============================================================================
} //end class
