<?php
/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
?>
<link type="text/css" rel="stylesheet" href="css/list.css" /> 
<?php if($view==""){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pm" class="on tag-item"><span>全部私信</span></a>
	<a href="index.php?ac=pm&view=new" class="tag-item"><span>未读私信</span></a>
	<a href="do.php?ac=delmessage&id=0" onClick="return confirm('确定要清空吗?');" class="tag-item"><span>清空私信</span></a>
    </div>  	
   </div> 
   <div class="message"> 
    <div class="head"><strong>全部私信</strong></div> 
    <ul class="list"> 
<?php
$sql="select * from " . tname('message') . " where cd_uids='" . $CcTvAi_com_userid . "' and cd_dataid=0 order by cd_addtime desc";
$Arr=getuserpage($sql, 30); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>暂无私信</center>';
} else {
if($result) {
	while($row=$db->fetch_array($result)) {
		$cd_content=preg_replace("/\[em:(\d+)]/is", "<img src=\"" . cd_webpath . "user/static/images/emot/e\\1.gif\" class=\"face\">", $row['cd_content']);
		$user=$db->getrow("select cd_nicheng from " . tname('user') . " where cd_id='" . $row['cd_uid'] . "'");
		if($row['cd_readid']==1) {$yuedup= '<font size="1">(未阅读)</font>';} else {$yuedup=  '<font size="1">(已阅读)</font>';}
		
		if($row['cd_uid']) {
			echo'<li>
<a href="do.php?ac=delmessage&id='.$row['cd_id'].'" style="float: right;padding: 0 0px;" onClick="return confirm(\'确定要删除吗?\');"><i class="delete"></i></a>
<a href="index.php?ac=pm&view=msgDetail&classid=' . $row['cd_id'] . '"> 
<span class="t-i"><img src="' . linkuserphoto($row['cd_uid'], 48) . '" /></span> 
<span class="t-t"><strong>' . $user['cd_nicheng'] . '<font size="1"> ' . datetime($row['cd_addtime']) . '</font> '.$yuedup.'</strong>
<em>'.$cd_content.'</em>
</span></a> 
</li>';
       }else{
		$db->query("update " . tname('message') . " set cd_readid='0' where cd_id='" . $row['cd_id'] . "'");	
		echo'<li>
<a href="do.php?ac=delmessage&id='.$row['cd_id'].'" style="float: right;padding: 0 0px;" onClick="return confirm(\'确定要删除吗?\');"><i class="delete"></i></a>
<a href=""> 
<span class="t-i"><img src="' . cd_webpath . 'user/static/images/systempm.gif" /></span> 
<span class="t-t"><strong>' . $row['cd_uname'] . '<font size="1"> ' . datetime($row['cd_addtime']) . '</font> '.$yuedup.'</strong>
<em>'.$cd_content.'</em>
</span></a> 
</li>';
} 
	
}
}
}
?>
</ul>
  <div class="page"><?php echo $Arr[0];?></div>
</div>
<?php }elseif($view=="new"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pm" class="tag-item"><span>全部私信</span></a>
	<a href="index.php?ac=pm&view=new" class="on tag-item"><span>未读私信</span></a>
	<a href="do.php?ac=delmessage&id=0" onClick="return confirm('确定要清空吗?');" class="tag-item"><span>清空私信</span></a>
    </div>  	
   </div> 
   <div class="message"> 
    <div class="head"><strong>未读私信</strong></div> 
    <ul class="list"> 
<?php
$sql="select * from " . tname('message') . " where cd_uids='" . $CcTvAi_com_userid . "' and cd_dataid=0 and cd_readid=1 order by cd_addtime desc";
$Arr=getuserpage($sql, 30); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>暂无私信</center>';
} else {
if($result) {
	while($row=$db->fetch_array($result)) {
		$cd_content=preg_replace("/\[em:(\d+)]/is", "<img src=\"" . cd_webpath . "user/static/images/emot/e\\1.gif\" class=\"face\">", $row['cd_content']);
		$user=$db->getrow("select cd_nicheng from " . tname('user') . " where cd_id='" . $row['cd_uid'] . "'");
		if($row['cd_readid']==1) {$yuedup= '<font size="1">(未阅读)</font>';} else {$yuedup=  '<font size="1">(已阅读)</font>';}
		
		if($row['cd_uid']) {
			echo'<li>
<a href="do.php?ac=delmessage&id='.$row['cd_id'].'" style="float: right;padding: 0 0px;" onClick="return confirm(\'确定要删除吗?\');"><i class="delete"></i></a>
<a href="index.php?ac=pm&view=msgDetail&classid=' . $row['cd_id'] . '"> 
<span class="t-i"><img src="' . linkuserphoto($row['cd_uid'], 48) . '" /></span> 
<span class="t-t"><strong>' . $user['cd_nicheng'] . '<font size="1"> ' . datetime($row['cd_addtime']) . '</font> '.$yuedup.'</strong>
<em>'.$cd_content.'</em>
</span></a> 
</li>';
       }else{
		$db->query("update " . tname('message') . " set cd_readid='0' where cd_id='" . $row['cd_id'] . "'");	
		echo'<li>
<a href="do.php?ac=delmessage&id='.$row['cd_id'].'" style="float: right;padding: 0 0px;" onClick="return confirm(\'确定要删除吗?\');"><i class="delete"></i></a>
<a href=""> 
<span class="t-i"><img src="' . cd_webpath . 'user/static/images/systempm.gif" /></span> 
<span class="t-t"><strong>' . $row['cd_uname'] . '<font size="1"> ' . datetime($row['cd_addtime']) . '</font> '.$yuedup.'</strong>
<em>'.$cd_content.'</em>
</span></a> 
</li>';
} 
	
}
}
}
?>
</ul>
  <div class="page"><?php echo $Arr[0];?></div>
</div>
<?php }elseif($view=="msgDetail"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pm" class="tag-item"><span>全部私信</span></a>
	<a href="index.php?ac=pm&view=new" class="tag-item"><span>未读私信</span></a>
	<a href="do.php?ac=delmessage&id=0" onClick="return confirm('确定要清空吗?');" class="tag-item"><span>清空私信</span></a>
	<a href="do.php?ac=delmessage&id=<?php echo $classid;?>" onClick="return confirm('确定要删除该对话吗?');" class="tag-item"><span>删除对话</span></a>
    </div>  	
   </div>  
<?php
global $db;
$sql="select * from " . tname('message') . " where cd_uid<>0 and cd_uids='$CcTvAi_com_userid' and cd_id='$classid'";
if($row=$db->getrow($sql)) {
	$db->query("update " . tname('message') . " set cd_readid='0' where cd_id='$classid'");
	$user=$db->getrow("select cd_nicheng from " . tname('user') . " where cd_id='" . $row['cd_uid'] . "'");
	echo'   <div class="message"> <div class="head"><strong>与' . $user['cd_nicheng'] . '私信对话</strong></div> </div><div class="message-bubbleDiv"> ';
	$query=$db->query("select * from " . tname('message') . " where cd_dataid='" . $row['cd_id'] . "' order by cd_id asc");
	while($rows=$db->fetch_array($query)) {
		$cd_content=preg_replace("/\[em:(\d+)]/is", "<img src=\"" . cd_webpath . "user/static/images/emot/e\\1.gif\" class=\"face\">", $rows['cd_content']);
		$users=$db->getrow("select cd_nicheng,cd_id from " . tname('user') . " where cd_id='" . $rows['cd_uid'] . "'");
		if($users['cd_id']==$CcTvAi_com_userid){
			echo'    <div class="message-bubbleItem clearfix">  
			<span class="im-avatar"><a href="do.php?ac=delmessagedt&id=' . $rows['cd_id'] . '&iid='.$CcTvAi_com_userid.'"><img src="' . linkuserphoto($rows['cd_uid'], 48) . '"/><font style="margin-left: 10px;">删除</font></a></span> 
        <span class="message-bubble message-rightBubble"><p>' . $cd_content . '</p><p style="float: right;font-size: 12px;color: #666;line-height: 12px;">' . $row['cd_addtime'] . '</p>
            <span class="bottomLevel"></span>  
            <span class="topLevel"></span>  
        </span>  
    </div>  ';
		}else{
			echo'    <div class="message-bubbleItem">
	<img src="' . linkuserphoto($rows['cd_uid'], 48) . '" class="avatar" onclick="window.open(\'../singer/index.php?id='.$rows['cd_uid'].'\',\'_self\')"/> 
        <span class="message-bubble message-leftBubble"><p>' . $cd_content . '</p><p style="float: right;font-size: 12px;color: #666;line-height: 12px;">' . $row['cd_addtime'] . '</p>
            <span class="bottomLevel"></span>  
            <span class="topLevel"></span>  
        </span>  
    </div> ';
		}
	}
	echo'</div>';
} else {
		echo '<center>私信不存在</center>';
}
?>  

    <div class="message-reply-box">
        <form method="post" action="do.php?ac=messageadd" autocomplete="off">
            <div>
                <textarea class="content" name="note" id ="note" style="height: 90px" rows="7" ></textarea>
            </div>
            <div class="form" style="margin-top: 10px;">
                <input type="hidden" name="uid" value="<?php echo $row['cd_uid'];?>">
                <input class="form-btn" type="submit" value="回复">
            </div>
        </form>
		<div class="biaoqing">
		<h1>选择表情:</h1>
<?php 
$bqid=100;
while($bqid<=155) {
echo '<img onclick="document.getElementById(\'note\').value+=\'[em:'.$bqid.']\'" src="'.cd_webpath.'user/static/images/emot/e'.$bqid.'.gif">';
  $bqid++;
} 
?>
		</div>
    </div>
<?php }elseif($view=="add"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pm" class="tag-item"><span>全部私信</span></a>
	<a href="index.php?ac=pm&view=new" class="tag-item"><span>未读私信</span></a>
	<a href="do.php?ac=delmessage&id=0" onClick="return confirm('确定要清空吗?');" class="tag-item"><span>清空私信</span></a>
    </div>  	
   </div> 
   <div class="message"> 
    <div class="head"><strong>发送私信给<?php echo GetAlias("cctvai_user", "cd_nicheng", "cd_id", $classid);?></strong></div> 
	</div>
    <div class="message-reply-box">
        <form method="post" action="do.php?ac=messageadd" autocomplete="off">
            <div>
                <textarea class="content" name="note" id ="note" style="height: 90px" rows="7" ></textarea>
            </div>
            <div class="form" style="margin-top: 10px;">
                <input type="hidden" name="uid" value="<?php echo $classid;?>">
                <input class="form-btn" type="submit" value="发送">
            </div>
        </form>
		<div class="biaoqing">
		<h1>选择表情:</h1>
<?php 
$bqid=100;
while($bqid<=155) {
echo '<img onclick="document.getElementById(\'note\').value+=\'[em:'.$bqid.']\'" src="'.cd_webpath.'user/static/images/emot/e'.$bqid.'.gif">';
  $bqid++;
} 
?>
		</div>
    </div>
<?php }?>

