<?php
	//引入语言包
	$m_langpackage=new msglp;
	
  //变量获得
  $msg_id=short_check(get_argg("id"));
  $user_uid=get_sess_userid();

  //数据表定义
  $t_msg_inbox = $tablePreStr."msg_inbox";
  $t_msg_outbox = $tablePreStr."msg_outbox";

  $sql="";
  $relaUserStr="";
  $reTurnUrl="";
  if(short_check(get_argg("t"))=="0"){
  	
  	//刷新提醒页面
        echo "<script type='text/javascript'>
  parent.frames['remind'].location.reload();
  </script>";
  
	$dbo = new dbex;
	//读写分离定义函数
	dbtarget('r',$dbServs);

    $sql="select mess_title,mess_content,from_user_id,from_user,from_user_ico,add_time,mesinit_id,mess_id,readed "
         ."from $t_msg_inbox where mess_id='$msg_id' and user_id='$user_uid'";
		$rs = $dbo ->getRow($sql);
    $relaUserStr="$m_langpackage->m_from_user";
    $reTurnTxt="$m_langpackage->m_in";
    $reTurnUrl="?app=msg_minbox";
    $reButTxt="$m_langpackage->m_b_com";
    $reButUrl="?app=msg_creator&2id=$rs[2]&rt=".urlencode($rs[0]);

	//读写分离定义函数
	dbtarget('w',$dbServs);
    if($rs[8]=="0"){
      $sql="update $t_msg_inbox set readed='1' where mess_id='$rs[7]'";
      $dbo ->exeUpdate($sql);
      $sql="update $t_msg_outbox set state='2' where mess_id='$rs[6]'";
      $dbo ->exeUpdate($sql);
    }
    
  }else if(get_argg("t")=="1"){
  	$dbo = new dbex;

	//读写分离定义函数
	dbtarget('r',$dbServs);

    $sql="select mess_title,mess_content,to_user_id,to_user,to_user_ico,add_time,state,mess_id "
         ."from $t_msg_outbox where mess_id='$msg_id' and user_id='$user_uid'";
		$rs = $dbo ->getRow($sql);

    $relaUserStr="$m_langpackage->m_to_user";
    $reTurnTxt="$m_langpackage->m_out";
    $reTurnUrl="?app=msg_moutbox";

    if($rs[6]=="0"){
       $reButTxt="$m_langpackage->m_b_sed";
       $reButUrl="do.php?act=msg_send&to_id=$rs[7]";
    }else{
       $reButTxt="$m_langpackage->m_b_con";
       $reButUrl="$reTurnUrl";
    }
  }
?>