<?php session_start();?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<STYLE type=text/css>
TD {
	FONT: 9pt/16pt '宋体'
}
A {
	TEXT-DECORATION: none; TEXT-TRANSFORM: none
}
A {
	TEXT-DECORATION: none
}
A:hover {
	COLOR: #0099FF;
	text-decoration: underline;
}
.c3 {font-size: 9pt; color: #0000ff; background-color: #ffffff; border: 1px solid #0000ff; }
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a:link {
	color: #000000;
	text-decoration: none;
}
a:visited {
	color: #000000;
	text-decoration: none;
}
a:active {
	color: #000000;
	text-decoration: none;
}
.style3 {color: #666666}
.style4 {color: #FF0000}
.style5 {color: #FFFFFF}
</STYLE></head>

<body>
<?php
if(isset($_GET["id"])){
$id=$_REQUEST['id'];
}
//echo $_SESSION["customer_first_name"];
?>
<?php include('conn_onlineanswer.php');?>
<?
//为了避免重复包含文件而造成错误，加了判断函数是否存在的条件：
//if(!function_exists(pageft)){ 
//定义函数pageft(),三个参数的含义为：
//$totle：信息总数；
//$displaypg：每页显示信息数，这里设置为默认是20；
//$url：分页导航中的链接，除了加入不同的查询信息“page”外的部分都与这个URL相同。
//　　　默认值本该设为本页URL（即$_SERVER["REQUEST_URI"]），但设置默认值的右边只能为常量，所以该默认值设为空字符串，在函数内部再设置为本页URL。
function pageft($totle,$displaypg=20,$url=''){

//定义几个全局变量： 
//$page：当前页码；
//$firstcount：（数据库）查询的起始项；
//$pagenav：页面导航条代码，函数内部并没有将它输出；
//$_SERVER：读取本页URL“$_SERVER["REQUEST_URI"]”所必须。
global $page,$firstcount,$pagenav,$_SERVER;

//为使函数外部可以访问这里的“$displaypg”，将它也设为全局变量。注意一个变量重新定义为全局变量后，原值被覆盖，所以这里给它重新赋值。
$GLOBALS["displaypg"]=$displaypg;

if(!$page) $page=1;

//如果$url使用默认，即空值，则赋值为本页URL：
if(!$url){ $url=$_SERVER["REQUEST_URI"];}

//URL分析：
if(!isset($_REQUEST["page"])){
   $url=$url."?page=1";
}
$parse_url=parse_url($url);
$url_query=$parse_url["query"]; //单独取出URL的查询字串
if($url_query){
//因为URL中可能包含了页码信息，我们要把它去掉，以便加入新的页码信息。
//这里用到了正则表达式，请参考“PHP中的正规表达式”（http://www.pconline.com.cn/pcedu/empolder/wz/php/10111/15058.html）
$url_query=ereg_replace("(^|&)page=$page","",$url_query);

//将处理后的URL的查询字串替换原来的URL的查询字串：
$url=str_replace($parse_url["query"],$url_query,$url);

//在URL后加page查询信息，但待赋值： 
if($url_query) $url.="&page"; else $url.="page";
}else {
$url.="?page";
}

//页码计算：
$lastpg=ceil($totle/$displaypg); //最后页，也是总页数
$page=min($lastpg,$page);
$prepg=$page-1; //上一页
$nextpg=($page==$lastpg ? 0 : $page+1); //下一页
$firstcount=($page-1)*$displaypg;

//开始分页导航条代码：
$pagenav="显示第 <B>".($totle?($firstcount+1):0)."</B>-<B>".min($firstcount+$displaypg,$totle)."</B> 条记录，共 $totle 条记录<BR>";

//如果只有一页则跳出函数：
if($lastpg<=1) return false;

$pagenav.=" <a href='$url=1'>首页</a> ";
if($prepg) $pagenav.=" <a href='$url=$prepg'>前页</a> "; else $pagenav.=" 前页 ";
if($nextpg) $pagenav.=" <a href='$url=$nextpg'>后页</a> "; else $pagenav.=" 后页 ";
$pagenav.=" <a href='$url=$lastpg'>尾页</a> ";

//下拉跳转列表，循环列出所有页码：
$pagenav.="　到第 <select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";
for($i=1;$i<=$lastpg;$i++){
if($i==$page) $pagenav.="<option value='$i' selected>$i</option>\n";
else $pagenav.="<option value='$i'>$i</option>\n";
}
$pagenav.="</select> 页，共 $lastpg 页";
}
//}

?>


<?php
//if ($_REQUEST['id']){
//}
function cn()
{
   $connection = @mysql_connect("209.132.211.150","gogomarket","ggmlishiming49" )or die("无法连接到数据库!");
   mysql_select_db("gogomarket",$connection)or die("无法选择数据库!"); 
$id=$_REQUEST['id'];
$result=mysql_query("select * from answer where id=".$id."",$connection);
   if($myrow = mysql_fetch_array($result)){
   
       $connection2 = @mysql_connect("66.226.21.111","gogomarket","ggmlishiming49" )or die("无法连接到数据库!");
       mysql_select_db("gogomarket",$connection2)or die("无法选择数据库!"); 
       $userid=$myrow['userid'];
       $result2=mysql_query("select * from customers where customers_id=".$userid."",$connection2);
        if($myrow2 = mysql_fetch_array($result2)){
		   $name=$myrow2['customers_firstname'].' '.$myrow2['customers_lastname'];
		   $email=$myrow2['customers_email_address'];
		}
echo '<form action="update3.php?ac=history" method="post" name="form1">
      复制:---------------客服回复-----------------
		              <table width="100%" height="36"  border="1" cellpadding="0" cellspacing="0" bordercolor="#F5F5F5" bgcolor="#999999">
              <tr bgcolor="#CCCCCC">
                  <td bgcolor="#EEEEEE"><strong>　</strong><font color="#000000">新问题：</font></td>
                </tr>
  </table>
            <table width="100%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#F5F5F5" style="TABLE-LAYOUT: fixed">
              <tr>
                <td width="496" rowspan="2" align="left" style="LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word; 130; 0pt" ><p>　标　题：
				      <strong>'.$myrow['title'].'</strong><br>　姓　名:'.$name.'　　　　　　　　email:'.$email.'
					<input name="id" type="hidden" value="'.$myrow['id'].'">
                    <br>
                      
					
					<br>
                      　
                  　内容：<br>
                  <textarea name="answer" cols="80" rows="10" id="answer" style="font-size: 9pt;">'.$myrow['answer'].'</textarea>
                  <br>　　　　　　　　　
                  <input type="submit" name="Submit" value="继续发表">
                </p></td>
              </tr>
  </table>
</form>';
}
}
?>
<?php
function info($id){
   $connection = @mysql_connect("209.132.211.150","gogomarket","ggmlishiming49" )or die("无法连接到数据库!");
   mysql_select_db("gogomarket",$connection)or die("无法选择数据库!"); 
$result=mysql_query("select * from answer where id=".$id."",$connection);
if ($myrow = mysql_fetch_array($result)){
   //while($myrow = mysql_fetch_array($result)){
echo '  <tr bgcolor="#FFFFFF">
    <td align="center">'.$myrow['id'].'</td>
    <td align="center" style="LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word; 130; 0pt" ><a href="history.php?id='.$myrow['id'].'"><font color="#000000">'.$myrow['title'].'</font></a></td>
	<td align="center">'.$myrow['date'].'<br>    </td>
    <td align="center"> ';
	switch ($myrow['leixin']){
	      case 1:
		    echo "新问题";
			break;
		  case 2:
		    echo "解决中";
			break;
		  case 3:
		    echo "已回复";
			break;
		  case 4:
		     echo "结束";
			 break;
		   default:
		      break;
			  	
	}
	echo '</td>
    <td align="center"><a href="history.php?id='.$myrow['id'].'"><font color="#000000">回复</font></a>　<a href="save.php?ac=result&id='.$myrow['id'].'"><font color="#000000">结束</font></a></td>
  </tr>
';

?>
<?php
}
}
?>

<table width="780"  border="0" align="center" cellpadding="0" cellspacing="0" background="onlineanswer/images/index_02.jpg">
  <tr>
    <td height="106" valign="top" background="/images/index_02.jpg"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
          <td width="20%" align="center" bgcolor="FBFAFA"><img src="images/logo_ebest24.gif" width="173" height="47"></td>
        <td width="80%" height="70" align="right" valign="bottom" bgcolor="FBFAFA">
			<?php
if (!session_is_registered("customer_id")){
            echo "<script>location.href='login.php';</script>";
            echo '<TABLE class=a12px1 height=20 cellSpacing=1 
                              cellPadding=3 width="602" 
                              border=0>
            <!-- 加入登录界面判断 -->
<FORM name=form1 action=login.php?action=add method=post>
              <TBODY>
                <TR>
                  <TD align=right width="138"><div align="right">用户名：</div></TD>
                  <TD width="84"><div align="right">
                      <input 
                                name=username id="username" size=12>
                  </div></TD>
                  <TD width="51"><div align="right">密 码：</div></TD>
                  <TD width="94"><div align="right">
                      <INPUT 
                                name=password type=password id="password" size=12>
                  </div></TD>
                  <TD width="199" height="26"><div align="right"><A 
                                href="http://www.ebest24.com/create_account.php"><IMG 
                                height=20 src="images/reg.gif" 
                                width=42 border=0></A> 
                        <INPUT type=image 
                                height=20 width=42 
                                src="images/login.gif" 
                                value=提交 name=Submit22>
                        <A 
                                href="/user/forget.asp"><IMG 
                                height=20 
                                src="images/forget.gif" 
                                width=65 border=0></A> </div></TD>
                </TR>
                <TR align=left>
                  <TD colSpan=5> </TD>
                </TR>
              </FORM>
            <!--   -->
        </TABLE>';
		}else{
			echo '<TABLE class=a12px1 height=20 cellSpacing=1 cellPadding=3 width="602" 
                              border=0>
  <!-- 加入登录界面判断 -->
  <TBODY>
    <TR> 
      <TD align=right width="116"><div align="right">用户ID：</div></TD>
      <TD width="36"><font color=#ff0000>'.$_SESSION['customer_id'].'</font> </TD>
      <TD width="70">用户名：</TD>
      <TD width="133"><font color=#ff0000>'.$_SESSION["customer_first_name"].'，欢迎你!</font></TD>
      <TD width="66" height="26">E-mail:</TD>
      <TD width="138"></TD>
    </TR>
    <TR align=left> 
      <TD colSpan=6> </TD>
    </TR>
    <!--   -->
</TABLE>';
		
		}
		?>
		</td>
      </tr>
    </table>
      <table width="100%"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="100" height="34" align="right"><a href="#"><font color="#FFFFFF">ebest24首页</font></a></td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
          <td width="80" align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="780" height="3" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#FFFFFF"></td>
  </tr>
</table>
<table width="780"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="166" valign="top"><table width="166" border="0" cellspacing="0" cellpadding="0">
      <tr>
          <td><img src="onlineanswer/images/bjd-556.gif" width="166" height="27"></td>
      </tr>
      <tr>
          <td valign="top" background="onlineanswer/images/bjd-112.gif"> 
            <p> <span style="color: #000000"><FONT style="FONT-SIZE: 9pt" face=webdings>&nbsp;&nbsp; 
              <img src="onlineanswer/images/1_04.jpg" width="7" height="8"> </FONT></span><strong>信息管理</strong><br>
              <SPAN id=mblist><strong> </strong></SPAN><span style="color: #0066FF"><FONT size=1> 
              <FONT size=1></FONT></FONT><FONT style="FONT-SIZE: 9pt" face=webdings>&nbsp;&nbsp;&nbsp;&nbsp; 
              <img src="onlineanswer/images/1_04.jpg" width="7" height="8"> </FONT></span><a href="/user/modify.asp"><font color="#000000">资料管理</font></a><br>
              <SPAN id=mblist><strong> </strong></SPAN><span style="color: #0066FF"><FONT size=1> 
              <FONT size=1></FONT></FONT></span> <SPAN id=mblist><strong> </strong></SPAN><span style="color: #0066FF"><FONT size=1> 
              <FONT size=1></FONT></FONT><FONT style="FONT-SIZE: 9pt" face=webdings>&nbsp;&nbsp;&nbsp;&nbsp; 
              <img src="onlineanswer/images/1_04.jpg" width="7" height="8"> </FONT></span><a href="/user/aws.asp"><font color="#000000">客服问答</font></a><br>
              <SPAN id=mblist><strong> </strong></SPAN> <SPAN id=mblist><strong> 
              </strong></SPAN><span style="color: #0066FF"><FONT size=1> <FONT size=1></FONT></FONT><FONT size=1> 
              </FONT><FONT style="FONT-SIZE: 9pt" face=webdings>&nbsp;&nbsp;&nbsp;&nbsp; 
              <img src="onlineanswer/images/1_04.jpg" width="7" height="8"> </FONT></span><a href="/user/default.asp"><font color="#000000">重新登陆</font></a><br>
              <SPAN id=mblist><strong> </strong></SPAN><span style="color: #0066FF"><FONT size=1> 
              <FONT size=1></FONT></FONT><FONT size=1> </FONT><FONT style="FONT-SIZE: 9pt" face=webdings>&nbsp;&nbsp;&nbsp;&nbsp; 
              <img src="onlineanswer/images/1_04.jpg" width="7" height="8"> </FONT></span><a href="http://wholesale.ebest24.com/logoff.php"><font color="#000000">注销登陆</font></a><br>
        </p></td>
      </tr>
      <tr>
          <td><img src="onlineanswer/images/bjd-2556.gif" width="166" height="27"></td>
      </tr>
    </table></td>
    <td valign="top"><table width="99%" border="0" align="right" cellpadding="0" cellspacing="0">
      <tr>
          <td width="30"><img src="onlineanswer/images/bjd-4.gif" width="30" height="27"></td>
          <td background="onlineanswer/images/bjd-6.gif">&nbsp;</td>
          <td width="30"><img src="onlineanswer/images/bjd-5.gif" width="30" height="27"></td>
      </tr>
      <tr>
          <td background="onlineanswer/images/bjd-7.gif">&nbsp;</td>
          <td valign="top" bgcolor="#FFFBFF"> 　客服问答 <a href="history.php" target="_blank">历史记录</a><br>
<br>
<?php
//session_register("user");
//$_SESSION["user"]="tomy";
if (session_is_registered("customer_id")){
?>

<?php 
$result=mysql_query("select * from answer where kefu='客服' order by date desc");
$total=mysql_num_rows($result);
//调用pageft()，每页显示10条信息（使用默认的20时，可以省略此参数），使用本页URL（默认，所以省略掉）。
pageft($total,10);
//现在产生的全局变量就派上用场了：
echo '<table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC" style="TABLE-LAYOUT: fixed">
  <tr bgcolor="#EEEEEE">
    <td width="7%" align="center">编号</td>    
    <td width="38%" align="center" bgcolor="#EEEEEE">标题</td>
	<td width="31%" align="center" bgcolor="#EEEEEE">时间</td>
    <td width="11%" align="center">状态</td>
    <td width="13%" align="center">操作</td>
  </tr>
';
$result2=mysql_query("select * from answer where kefu='客服' order by date desc limit $firstcount,$displaypg ");
while($row=mysql_fetch_array($result2)){
//echo "hi".$row['id'];
info($row['id']);
//（列表内容略）
}
//输出分页导航条代码：
echo '</table>';
echo $pagenav;

?>


<?php
}else{
 echo '<center>对不起！没有找到相关记录</center>';
}
?>
<?php
//$_REQUEST["id"];
//$id=$_GET["id"];
if(isset($_GET["id"])){
   cn();
}else{
//cn();
}
?>

<?php
 //  }else{
//     echo "<center>对不起！你还没有登陆！请先<a href=login.php><font color=#ff0000>登陆</font></a></center>";
//   }
?>
</td>
          <td background="onlineanswer/images/bjd-8.gif">&nbsp;</td>
      </tr>
      <tr>
          <td><img src="onlineanswer/images/bjd-1.gif" width="30" height="27"></td>
          <td background="onlineanswer/images/bjd-2.gif">&nbsp;</td>
          <td><img src="onlineanswer/images/bjd-3.gif" width="30" height="27"></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="5"></td>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25" bgcolor="#EFEBEF"><div align="center"><a href="/about.asp">关于我们</a> | <a href="/netpay.asp">如何交费</a> | <a href="/news/">站内新闻</a> | <a href="/user/">客户中心</a> | <a href="/agent/">代理专区</a> | <a href="/help/">帮助中心</a> | <a href="/contact.asp">联系我们</a></div></td>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    
  <td bgcolor="#F7F7F7"><a href="/help/icp.asp"><img src="onlineanswer/images/free_shipping_ger.gif" width="477" height="27" border="0">