<?php
/*include './IP.class.php';   
$iplocation = new IpLocation();   */
require_once('include/config.php');
session_start();

//===================================
//
// 功能：IP地址获取真实地址函数
// 参数：$ip - IP地址
//
//===================================
function convertip($ip) {
    //IP数据文件路径
    $dat_path = './qqwry.dat';

    //检查IP地址（正则已修复，原代码中 \d 写成了 d）
    if(!preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $ip)) {
        return 'IP Address Error';
    }
    
    //打开IP数据文件
    if(!$fd = @fopen($dat_path, 'rb')){ // 建议使用 'rb' 模式读取二进制文件
        return 'IP date file not exists or access denied';
    }

    //分解IP进行运算，得出整形数
    $ip = explode('.', $ip);
    // 使用 sprintf 确保计算准确，防止溢出
    $ipNum = sprintf("%u", $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3]);

    //获取IP数据索引开始和结束位置
    $DataBegin = fread($fd, 4);
    $DataEnd = fread($fd, 4);
    
    // 修复 unpack 逻辑，使用 ord 函数更稳妥
    $ipbegin = ord($DataBegin[0]) + ord($DataBegin[1]) * 256 + ord($DataBegin[2]) * 65536 + ord($DataBegin[3]) * 16777216;
    $ipend = ord($DataEnd[0]) + ord($DataEnd[1]) * 256 + ord($DataEnd[2]) * 65536 + ord($DataEnd[3]) * 16777216;
    
    $ipAllNum = ($ipend - $ipbegin) / 7 + 1;
   
    $BeginNum = 0;
    $EndNum = $ipAllNum;

    // 【修复点】初始化变量，防止 Undefined variable 报错
    $ip1num = 0;
    $ip2num = 0;

    //使用二分查找法从索引记录中搜索匹配的IP记录
    while($ip1num > $ipNum || $ip2num < $ipNum) {
        $Middle = intval(($EndNum + $BeginNum) / 2);

        //偏移指针到索引位置读取4个字节
        fseek($fd, $ipbegin + 7 * $Middle);
        $ipData1 = fread($fd, 4);
        if(strlen($ipData1) < 4) {
            fclose($fd);
            return 'System Error';
        }
        
        // 修复：使用 ord 函数手动计算长整型
        $ip1num = ord($ipData1[0]) + ord($ipData1[1]) * 256 + ord($ipData1[2]) * 65536 + ord($ipData1[3]) * 16777216;
       
        //提取的长整型数大于我们IP地址则修改结束位置进行下一次循环
        if($ip1num > $ipNum) {
            $EndNum = $Middle;
            continue;
        }
        
        //取完上一个索引后取下一个索引
        $DataSeek = fread($fd, 3);
        if(strlen($DataSeek) < 3) {
            fclose($fd);
            return 'System Error';
        }
        // 修复 unpack 逻辑
        $DataSeek = ord($DataSeek[0]) + ord($DataSeek[1]) * 256 + ord($DataSeek[2]) * 65536;
        
        fseek($fd, $DataSeek);
        $ipData2 = fread($fd, 4);
        if(strlen($ipData2) < 4) {
            fclose($fd);
            return 'System Error';
        }
        
        // 修复 unpack 逻辑
        $ip2num = ord($ipData2[0]) + ord($ipData2[1]) * 256 + ord($ipData2[2]) * 65536 + ord($ipData2[3]) * 16777216;

        //没找到提示未知
        if($ip2num < $ipNum) {
            if($Middle == $BeginNum) {
                fclose($fd);
                return 'Unknown';
            }
            $BeginNum = $Middle;
        }
    }
    
    //下面的代码读晕了，没读明白，有兴趣的慢慢读
    $ipFlag = fread($fd, 1);
    if($ipFlag == chr(1)) {
        $ipSeek = fread($fd, 3);
        if(strlen($ipSeek) < 3) {
            fclose($fd);
            return 'System Error';
        }
        // 修复 unpack 逻辑
        $ipSeek = ord($ipSeek[0]) + ord($ipSeek[1]) * 256 + ord($ipSeek[2]) * 65536;
        
        fseek($fd, $ipSeek);
        $ipFlag = fread($fd, 1);
    }

    $ipAddr1 = ''; // 初始化变量
    $ipAddr2 = ''; // 初始化变量

    if($ipFlag == chr(2)) {
        $AddrSeek = fread($fd, 3);
        if(strlen($AddrSeek) < 3) {
            fclose($fd);
            return 'System Error';
        }
        $ipFlag = fread($fd, 1);
        if($ipFlag == chr(2)) {
            $AddrSeek2 = fread($fd, 3);
            if(strlen($AddrSeek2) < 3) {
                fclose($fd);
                return 'System Error';
            }
            // 修复 unpack 逻辑
            $AddrSeek2 = ord($AddrSeek2[0]) + ord($AddrSeek2[1]) * 256 + ord($AddrSeek2[2]) * 65536;
            
            fseek($fd, $AddrSeek2);
        } else {
            fseek($fd, -1, SEEK_CUR);
        }

        while(($char = fread($fd, 1)) != chr(0))
            $ipAddr2 .= $char;

        // 修复 unpack 逻辑
        $AddrSeek = ord($AddrSeek[0]) + ord($AddrSeek[1]) * 256 + ord($AddrSeek[2]) * 65536;
        
        fseek($fd, $AddrSeek);

        while(($char = fread($fd, 1)) != chr(0))
            $ipAddr1 .= $char;
    } else {
        fseek($fd, -1, SEEK_CUR);
        while(($char = fread($fd, 1)) != chr(0))
            $ipAddr1 .= $char;

        $ipFlag = fread($fd, 1);
        if($ipFlag == chr(2)) {
            $AddrSeek2 = fread($fd, 3);
            if(strlen($AddrSeek2) < 3) {
                fclose($fd);
                return 'System Error';
            }
            // 修复 unpack 逻辑
            $AddrSeek2 = ord($AddrSeek2[0]) + ord($AddrSeek2[1]) * 256 + ord($AddrSeek2[2]) * 65536;
            
            fseek($fd, $AddrSeek2);
        } else {
            fseek($fd, -1, SEEK_CUR);
        }
        while(($char = fread($fd, 1)) != chr(0)){
            $ipAddr2 .= $char;
        }
    }
    fclose($fd);

    //最后做相应的替换操作后返回结果
    if(preg_match('/http/i', $ipAddr2)) {
        $ipAddr2 = '';
    }
    $ipaddr = "$ipAddr1 $ipAddr2";
    
    // 1. 先移除运营商关键词
    $ipaddr = preg_replace('/(移动|联通|电信|铁通|广电|长城宽带|CZ88\.NET|5kun\.com)/i', '', $ipaddr);
    $ipaddr = preg_replace('/\s+/is', '', $ipaddr);
    
    // 3. 空值或含http则直接返回Unknown
    if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {
        return 'Unknown';
    }
    
    // 编码转换
    $ipaddr = @iconv('gbk', 'utf-8//IGNORE', $ipaddr); // 纯真数据库通常是 GBK 编码，不是 GB2312

    // 定义核心配置
    $municipalities = ['北京市', '上海市', '天津市', '重庆市', '北京', '上海', '天津', '重庆']; 
    $countryList = ['中国', '美国', '日本', '韩国', '英国', '法国', '德国', '加拿大', '澳大利亚', '俄罗斯', '印度']; 
    $citySuffix = ['省', '市', '自治区', '特别行政区']; 
    $autonomousRegions = ['广西', '宁夏', '新疆', '内蒙古', '西藏'];

    foreach ($countryList as $country) {
        if (strpos($ipaddr, $country) === 0) {
            return $country;
        }
    }
    foreach ($municipalities as $city) {
        if (strpos($ipaddr, $city) !== false) {
            $pureCity = mb_substr($city, 0, 3, 'utf-8'); 
            return $pureCity;
        }
    }
    
    $province = '';
    $city = '';
    
    // 匹配省名
    if (preg_match('/(.*?)省/is', $ipaddr, $pMatch)) {
        $province = $pMatch[1];
    }
    
    // 匹配自治区
    if (empty($province)) {
        foreach ($autonomousRegions as $region) {
            if (preg_match('/'.$region.'(.*?)市/is', $ipaddr, $rMatch)) {
                $province = $region;
                $city = $rMatch[1];
                break;
            }
        }
    }
    
    // 匹配省后的市名
    if ($province && preg_match('/'.$province.'省(.*?)市/is', $ipaddr, $cMatch)) {
        $city = $cMatch[1];
    }
    
    // 有省/市则拼接
    if ($province || $city) {
        $result = $province . ($city ? " · " . $city : "");
    } else {
        // 清理剩余冗余后缀
        $result = $ipaddr;
        foreach ($citySuffix as $suffix) {
            $result = str_replace($suffix, '', $result);
        }
    }

    return $result;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="互动客厅,王小困互动客厅,王坤互动客厅,WKUN互动客厅,设计师王坤,王坤,湖南王坤,长沙王坤">
<meta name="description" content="王小困设计 WKUN.COM 互动客厅是设计师王坤官方网站的设计交流平台，我们对话讨论一切有关设计的话题。">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="互动客厅">
<meta name="theme-color" content="#FAFAFA">
<meta property="og:description" content="欢迎大家来到互动客厅，我们探索一切有关设计的话题。"/>
<title>互动客厅 - 王小困</title>
<!-- PC端样式：屏幕宽度>600px时生效 -->
<link rel="stylesheet" href="css/index.css" media="screen and (min-width: 601px)">
<link rel="stylesheet" href="css/global_pc.css" media="screen and (min-width: 601px)">
<!-- 移动端样式：屏幕宽度≤600px时生效 -->
<link rel="stylesheet" href="css/index_m.css" media="screen and (max-width: 600px)">
<link rel="stylesheet" href="css/global_m.css" media="screen and (max-width: 600px)">
<link rel="apple-touch-icon-precomposed" href="images/touch-icon-new-ipad.png" />
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element'], function() {
      var layer = layui.layer 
      ,upload = layui.upload //上传
      ,element = layui.element;
    //   layer.msg('Hello World');

      var uploadInst = upload.render({
        elem: '.upload' //绑定元素
        ,url: './up/up.php' //上传接口
        ,done: function(res){
          //上传完毕回调
            $("#picpath").val(res.data.src) 
            $(".shopimg").attr("src",'./images/upload/'+res.data.src);
            $("#gn_photo_3").css('display','block');
            $(".gn_photo_line").css('display','none');
        }
        ,error: function(){
          //请求异常回调
        }
      });
    });
</script>
<!--统计代码-->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?976932debf26dfee0edee7a03fa1f72f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<!-- 返回顶部按钮 -->
<div class="back-to-top" id="backToTopBtn" title="返回顶部"></div>
<script>
// 获取返回顶部按钮元素
const backToTopBtn = document.getElementById('backToTopBtn');
// 监听页面滚动事件
window.addEventListener('scroll', function() {
// 获取当前滚动的距离
const scrollDistance = window.scrollY;
// 修改判断条件：只要滚动距离 > 0（有滚动）就显示按钮
if (scrollDistance > 0) {
   backToTopBtn.classList.add('show');
   } else {
   backToTopBtn.classList.remove('show');
   }
});
// 点击按钮返回顶部
backToTopBtn.addEventListener('click', function() {
// 平滑滚动到顶部
   window.scrollTo({
     top: 0,
     // 平滑滚动效果
     behavior: 'smooth'
     });
});
</script>
<script type="text/JavaScript">
function checkdata() 
{ 
first=document.message.content.value; 
second=document.message.username.value;
if(first==''||second=='') 
{ 
	alert("内容和名字不能为空"); 
return false; 
} 
else 
	document.message.submit(); 
} 
function textCounter(field, maxlimit) { 
 var str=field.value;
  var a=str.match(/[^\x00-\xff]|\w{1,2}/g);
  if (a.length > maxlimit)
	 field.value = a.length<maxlimit?str:a.slice(0,maxlimit).join("");	
  //else 
   //document.WRITEMSGTXT.remLen.value = maxlimit - a.length; 
 } 
</script>
<body onload="init();">
<!--PC端导航-->
<div class="two_topk" id="two_topk">
  <div class="two_top">
        <div class="two_logo"><a href="../" title="WKUN DESIGN - 王坤设计 / 王小困设计"></a></div>
        <div class="two_nav">
          <div class="two_nav_dhrs"><a href="../book" title="互动客厅 - 王小困"></a></div>
          <div class="two_nav_x"></div>
          <div class="two_nav_design"><a href="../design" title="设计作品 - 王小困"></a></div>
      </div>
  </div>
</div>
<div class="two_no"></div>
<!--移动端导航-->
    <div class="top" id="top">
        <div id="dd" class="wrapper-dropdown-5" tabindex="1"><img src="../book/images/six/m/nav_icon_2.svg" width="44" height="44" />
            <ul class="dropdown">
                <div class="index_nav3">
                  <div id="nav_01"><a href="/"><dl><dd class="xiao">WKUN</dd><dd class="da">HOME</dd><dd class="cn_font">首页</dd></dl></a></div>
                  <div id="nav_01"><a href="/design"><dl><dd class="da">DESIGN</dd><dd class="xiao">WORKS</dd><dd class="cn_font">设计</dd></dl></a></div>
                  <div id="nav_01"><a href="/zt/weixin"><dl><dd class="xiao">WECHAT</dd><dd class="cn_font">微信</dd></dl></a></div>
                  <div id="nav_01"><a href="/about"><dl><dd class="xiao">ABOUT</dd><dd class="da">ME</dd><dd class="cn_font">关于</dd></dl></a></div>
                  <div id="nav_01"><a href="/studio"><dl><dd class="img"></dd><dd class="cn_font">工作室</dd></dl></a></div>
                </div>
            </ul>
      </div>
      <div class="logo"><a href="/book"><img src="images/six/m/logo_2.svg" width="44" height="44" /></a></div>
        <div class="so_icon"><img src="images/six/m/so_icon_2.svg" width="44" height="44" /></div>
        <div class="search_top" style="display:none;">
        <div class="so_up"><a href="javascript:;" id="so_close" title="关闭"><img src="images/six/m/up_2.svg" width="44" height="44" /></a></div>
          <dl><form method="get" id="search" action="javascript:return true;">
            <dd class="s_input"><input type="search" class="search_input_m" placeholder="搜索互动客厅"></dd>
            <dd class="s_submit"><a href="javascript:;" id="soso_m" title="搜索"><img src="images/six/m/so_icon_2.svg" width="44" height="44" /></a></dd>
          </form>
          </dl>
        </div>
    </div>
<!--移动端问候语-->
<div class="wangkun_ad" id="wangkun_ad">
<div class="wangkun_ad_z">
    <a href="?so=<?php echo $_COOKIE['uu']??'';?>">
      <script language="javaScript">
		<!--
		now = new Date(),hour = now.getHours()
		if(hour < 6){document.write("美梦！")}
		else if (hour < 9){document.write("早安！")}
		else if (hour < 12){document.write("新的一天，")}
		else if (hour < 14){document.write("美好午后，")}
		else if (hour < 17){document.write("下午好，")}
		else if (hour < 19){document.write("即将夜幕，")}
		else if (hour < 22){document.write("晚安！")}
		else {document.write("夜晚精彩，")}
		// -->
		</script><font color="#CCC"><?php echo $_COOKIE['uu']??'互动客厅欢迎';?></font>
    </a>
</div>
	<div class="wangkun_ad_y"></div>
</div>
<!--PC端主列表开始-->
<div class="book_z" id="book_z">
<div class="list_z">
<!--PC端顶部输入框开始-->
<div class="top_y">
<form action="index_keting.php?act=index_keting" method="post" name="message">
    <input type="hidden" id="uploadmark">
    <input type="hidden" id="picpath" name="img">
        <div class="input_box2">
        <textarea name="content" rows="5" class="input scrollbar" id="content" placeholder="开始我们的对话吧 ~"></textarea>
        </div>
          <div class="input_ok">
          <div class="function" style="position:relative;">
                    <div id="biaoqing">
                        <div id="function_close"><a href="javascript:;" id="bq_close" title="关闭"></a></div>
                        <div class="bq_line">
                          <dl>
                            <dd class="expression"><a href="javascript:;" title="微笑"><img src="images/six/bq/wx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="晕"><img src="images/six/bq/y.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="心花怒放"><img src="images/six/bq/xhnf.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="笑哭"><img src="images/six/bq/xk.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="鼓掌"><img src="images/six/bq/gz.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="哈欠"><img src="images/six/bq/hax.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="憨笑"><img src="images/six/bq/sx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="汗"><img src="images/six/bq/han.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="吃惊"><img src="images/six/bq/cj.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="鄙视"><img src="images/six/bq/bs.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="闭嘴"><img src="images/six/bq/bz.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="呲牙"><img src="images/six/bq/cy.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="害羞"><img src="images/six/bq/hx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="衰"><img src="images/six/bq/shuai.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="偷笑"><img src="images/six/bq/tx.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="捂脸"><img src="images/six/bq/wul.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="折磨"><img src="images/six/bq/zm.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="难过"><img src="images/six/bq/ng.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="示爱"><img src="images/six/bq/sa.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="可爱"><img src="images/six/bq/ka.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="尴尬"><img src="images/six/bq/gg.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="泪"><img src="images/six/bq/lei.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="酷"><img src="images/six/bq/cool.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="发呆"><img src="images/six/bq/fd.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="敲打"><img src="images/six/bq/qd.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="再见"><img src="images/six/bq/zj.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="吐"><img src="images/six/bq/tu.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="强"><img src="images/six/bq/qiang.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="差劲"><img src="images/six/bq/cha.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="顶你"><img src="images/six/bq/ding.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="勾引"><img src="images/six/bq/gy.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="耶"><img src="images/six/bq/ye.png" width="30"></a></dd>
                          </dl>
                        </div>
                    </div>
                    <div id="gn_photo">
                        <div class="gn_photo_line">
                            <div id="function_close"><a href="javascript:;" title="关闭" id="ph_close"></a></div>
                          <dl>
                            <dd class="tips">上传本地图片不能超过10M</dd>
                            <dd class="upload"><a href="javascript:;" title="上传图片">上传图片</a></dd>
                            <dd class="link"><a href="javascript:;" title="图片链接" id="show_url">图片链接</a></dd>
                          </dl>
                        </div> 
                            <div id="gn_photo_2">
                                <div id="function_close"><a href="javascript:;" title="关闭" id="url_close"></a></div>
                                <div class="gn_photo_link">
                                  <dl>
                                    <dd class="p_input"><input  type="text" class="photo_input" id="photo_url" placeholder="在此粘贴第三方图片地址"></dd>
                                    <dd class="p_submit"><input name="photo_submit" type="button" class="photo_submit" value="确定">
                                    </dd>
                                  </dl>
                                </div>
                            </div>
                        <div id="gn_photo_3">
                            <div id="function_close"><a href="javascript:;" title="关闭" class="pic_close"></a></div>
                            <div class="gn_photo_img"><img class="shopimg" src=""></div>
                        </div>
                        <div id="gn_photo_4">
                            <div id="function_close"><a id="del_close" href="javascript:;" title="关闭"></a></div>
                            <div class="gn_photo_img">
                              <dl>
                                <dd class="tips2">确定删除吗？</dd>
                                <dd class="submit2"><a href="javascript:;" title="确定" id="ajax_del">确定</a></dd>
                              </dl>
                            </div>
                        </div>
                    </div>
                <dl>
                    <dd class="bq"><a href="javascript:;" id="show_bq" title="加入表情"></a></dd>
                    <dd class="img"><a href="javascript:;" title="添加图片" id="show_ph"></a></dd>
                </dl>
          </div>
          <div class="input_submit">
              <input  type="submit" class="botton" onClick="return checkdata();" title="发布" value="发 布" />
            </div>
            <div class="input_name"><input name="username" type="text" class="name" id="username" placeholder="你的名字" maxlength="8" value="<?php echo trim($_COOKIE['uu'] ?? ''); ?>">
          </div>
        </div>
     </form>
</div>
<!--PC端顶部输入框结束-->
 <?php
$page=isset($_GET['page'])?intval($_GET['page']):1;
$num=30;
$soa='';
$offset=($page-1)*$num;
$s = @addslashes($_GET['so']);  
if($s){
    $total = mysqli_num_rows(mysqli_query($db, "select * from book where username like '%".$s."%' or content like '%".$s."%' or reply like '%".$s."%' or dream like '%".$s."%' or ip like '%".$s."%' or posttime like '%".$s."%'"));
    $soa = '&so='.$s; 
}else{
$total=mysqli_num_rows(mysqli_query($db, "select * from book"));
}
$pagenum=ceil($total/$num);

if($page>$pagenum || $page==0)
{
    //header("location:index.php?page=1");
}
else{ 
    if ( $s ){
        $row=mysqli_query($db, "select * from book where username like '%".$s."%' or content like '%".$s."%' or reply like '%".$s."%' or dream like '%".$s."%' or ip like '%".$s."%' or posttime like '%".$s."%' order by id desc limit $offset,$num");
    }else{
$row=mysqli_query($db, "select * from book order by id desc limit $offset,$num");
} 
$row1=mysqli_num_rows(mysqli_query($db, "select * from book order by id"));
$a = ($row1-(($page-1)*$num))+1;
if ( $s ){
$a = ($total-(($page-1)*$num))+1;
}
 //$a = ($page-1)*$num;
    //内容表情
    $arr = array(
        '[湖南卫视]'=>'images/six/bq/hntv.gif',
        '[晕]'=>'images/six/bq/y.png',
        '[微笑]'=>'images/six/bq/wx.png',
        '[心花怒放]'=>'images/six/bq/xhnf.png',
		'[笑哭]'=>'images/six/bq/xk.png',
        '[鼓掌]'=>'images/six/bq/gz.png',
        '[哈欠]'=>'images/six/bq/hax.png',
        '[憨笑]'=>'images/six/bq/sx.png',
        '[汗]'=>'images/six/bq/han.png',
        '[吃惊]'=>'images/six/bq/cj.png',
        '[鄙视]'=>'images/six/bq/bs.png',
        '[闭嘴]'=>'images/six/bq/bz.png',
        '[呲牙]'=>'images/six/bq/cy.png',
        '[害羞]'=>'images/six/bq/hx.png',
        '[衰]'=>'images/six/bq/shuai.png',
        '[偷笑]'=>'images/six/bq/tx.png',
		'[捂脸]'=>'images/six/bq/wul.png',
        '[折磨]'=>'images/six/bq/zm.png',
        '[难过]'=>'images/six/bq/ng.png',
        '[示爱]'=>'images/six/bq/sa.png',
        '[可爱]'=>'images/six/bq/ka.png',
		'[尴尬]'=>'images/six/bq/gg.png',
        '[泪]'=>'images/six/bq/lei.png',
        '[酷]'=>'images/six/bq/cool.png',
		'[发呆]'=>'images/six/bq/fd.png',
		'[敲打]'=>'images/six/bq/qd.png',
		'[再见]'=>'images/six/bq/zj.png',
		'[吐]'=>'images/six/bq/tu.png',
		'[强]'=>'images/six/bq/qiang.png',
		'[差劲]'=>'images/six/bq/cha.png',
		'[顶你]'=>'images/six/bq/ding.png',
		'[勾引]'=>'images/six/bq/gy.png',
		'[耶]'=>'images/six/bq/ye.png'
    );
while($rs=mysqli_fetch_array($row))
{
    foreach( $arr as $key=>$v ){
          $rs['content'] = str_replace($key,'<img src="'.$v.'" />',$rs['content']);
          $rs['reply'] = str_replace($key,'<img src="'.$v.'" />',$rs['reply']);
          }
//$a=$a+1;
$a=$a-1;
?>
<div class="list_user_content">
<div>
  <div class="list_user_zdy"><a href="../book/?so=<?php echo $rs['username'];?>" title="只看有关“<?php echo $rs['username'];?>”的对话"><?php echo $rs['user_img'];?></a></div>
  <div class="list_user_z">
      <?php
        mt_srand( (int)(microtime(true) * 1000000) );
        $num = rand( 1, 7 );

        switch( $num )
        {
        case 1: $image_file = "images/six/user_2026_01.jpg";
                break;
        case 2: $image_file = "images/six/user_2026_02.jpg";
                break;
        case 3: $image_file = "images/six/user_2026_03.jpg";
                break;
        case 4: $image_file = "images/six/user_2026_04.jpg";
                break;
        case 5: $image_file = "images/six/user_2026_05.jpg";
                break;
        case 6: $image_file = "images/six/user_2026_06.jpg";
                break;
        case 7: $image_file = "images/six/user_2026_07.jpg";
                break;
        }
        echo "<img src=$image_file />";
      ?>
  </div>
</div>
<div class="list_user_content_top">
       <div class="list_user_content_message">
       <a href="../book/?so=<?php echo $rs['username'];?>" title="只看有关“<?php echo $rs['username'];?>”的对话"><?php echo $rs['username'];?><?php echo $rs['verify'];?></a>：<?php echo $rs['content'];?>
       </div>
       <?php if($rs['reply']){
           echo "
           <div class='list_user_content_reply2'>
               <div class='reply_content'><b>王坤：</b>".$rs['reply']." <font color='#999'>- ".((date('Y') != substr($rs['replytime'],0,4)) ? substr($rs['replytime'],0,4).'年':'').substr($rs['replytime'],5,2).'月'.substr($rs['replytime'],8,2).'日'.substr($rs['replytime'],10,6)."</font></div>
           </div>";
           }
           else
           {
               echo "<div class='list_user_content_reply3'>
           <div class='list_user_content_no'></div>
     </div>";
               }
           ?>
       <div class="content_information_k">
       <div class="content_information">
       <a href="../book/?so=<?php echo $rs['posttime'];?>" title="<?php echo substr($rs['posttime'],0,4),'年', substr($rs['posttime'],5,2),'月',substr($rs['posttime'],8,2),'日',substr($rs['posttime'],10,6);?> 发布"><?php echo (date('Y') != substr($rs['posttime'],0,4)) ? substr($rs['posttime'],0,4).'年' : '',substr($rs['posttime'],5,2),'月',substr($rs['posttime'],8,2),'日',substr($rs['posttime'],10,6);?></a>　　<?php if($rs['ip'] != ""){echo convertip($rs['ip']);}?>　　<?php echo $rs['dream'];?>
    <?php if(isset($_SESSION['admin_name'])){?>　　<a href="msgreply.php?id=<?php echo $rs['id'];?>" title="回复">回复</a>　　<a href="msgreply.php?act=del&id=<?php echo $rs['id'];?>" onClick="{if(confirm('你确定要删除此对话吗？')){return true;}return false;}" title="删除">删除</a><?php }?></div>
        <div class="look_img"><?php if(!empty($rs['img'])){ ?><a href="<?php echo './images/upload/',$rs['img']; ?>" title="查看图片">查看图片</a><?php }else{echo '';} ?></div>
       <div class="content_lc"><a href="../book/?so=<?php echo $rs['posttime'];?>" title="第 <?php echo $a;?> 楼"><?php echo $a;?></a></div>
       </div>
</div>
</div>
    <?php
  } 
}
?>
</div>
<div class="list_y">
	<div class="wangkun_hi">
		<dd class="one"><script language="javaScript">
		<!--
		now = new Date(),hour = now.getHours()
		if(hour < 6){document.write("GOOD NIGHT！")}
		else if (hour < 12){document.write("GOOD MORNING！")}
		else if (hour < 18){document.write("GOOD AFTERNOON！")}
		else if (hour < 22){document.write("GOOD EVENING！")}
		else {document.write("GOOD NIGHT！")}
		// -->
		</script></dd>
		<dd class="two"><script language="javaScript">
		<!--
		now = new Date(),hour = now.getHours()
		if(hour < 6){document.write("美梦！")}
		else if (hour < 9){document.write("早安！")}
		else if (hour < 12){document.write("新的一天，")}
		else if (hour < 14){document.write("美好午后，")}
		else if (hour < 17){document.write("下午好，")}
		else if (hour < 19){document.write("即将夜幕，")}
		else if (hour < 22){document.write("晚安！")}
		else {document.write("夜晚精彩，")}
		// -->
		</script><a href="?so=<?php echo $_COOKIE['uu'] ?? ''; ?>"><?php echo $_COOKIE['uu'] ?? '我是王小困'; ?></a>，<br />
		欢迎你来到互动客厅，<br />
		现在来与我对话吧。<br />
		</dd>
		<font color="#999">王小困</font> 😜</div>
    <div class="search_top">
      <dl><form method="get" id="search">
        <dd class="s_input"><input type="text" class="search_input" placeholder="搜索互动客厅"></dd>
        <dd class="s_submit"><a href="javascript:;" id="soso" title="搜索"></a></dd></form>
      </dl>
    </div>
    <div class="search_hot">
      <dl>
        <dd class="hot_wz">热搜</dd>
        <dd class="hot_keyword"><a href="?so=王小困" title="搜索王小困">王小困</a></dd>
        <dd class="hot_keyword"><a href="?so=微信" title="搜索微信">微信</a></dd>
        <dd class="hot_keyword"><a href="?so=海报" title="搜索海报">海报</a></dd>
        <dd class="hot_keyword"><a href="?so=郎朗" title="搜索郎朗">郎朗</a></dd>
        <dd class="hot_keyword"><a href="?so=素材" title="搜索素材">素材</a></dd>
		<dd class="hot_keyword"><a href="?so=伦敦设计奖" title="搜索伦敦设计奖">伦敦设计奖</a></dd>
        <dd class="hot_keyword"><a href="?so=芒果TV" title="搜索芒果TV">芒果TV</a></dd>
        <dd class="hot_keyword"><a href="?so=移动" title="搜索移动版">移动版</a></dd>
        <dd class="hot_keyword"><a href="?so=梦想演唱会" title="搜索梦想演唱会">梦想演唱会</a></dd>
		<div class="fix"></div>
      </dl>
    </div>
    <?php if($s){ ?>
    <div class="search_result">
      <dl>
        <dd class="result_key"><?php if ( !$s ) {echo '搜索一下'; }else{echo $s;} ?></dd>
        <dd class="result_close"><a href="../book" title="关闭返回"></a></dd>
        <dd class="result_quantity"><?php echo !empty($total)?$total:0; ?></dd>
        <dd class="result_tips">条相关对话，左侧为你呈现</dd>
      </dl>
    </div><?php } ?>
	<div class="youce_top">王小困微信公众号</div>
	<div class="wechat_qun">
	  <p><img src="images/six/wechat_wk.svg" width="60%"/></p>
	  <p><img class="wechat_icon" src="images/six/wechat_logo.svg" width="20"/>公众号搜索：王小困</p>
	</div>
	<div class="youce_top">王小困设计小程序</div>
	<div class="wechat_qun">
	  <p><img src="images/six/wechat_xcx.svg" width="66%"/></p>
	  <p><img class="wechat_icon" src="images/six/xcx_logo.svg" width="16"/>小程序搜索：王小困设计</p>
	</div>
    <div class="youce_top">常用的好站 给最好的你</div>
    <div class="recommend">
      <dl>
        <dd class="recommend_web">图片 - <a href="https://alpha.wallhaven.cc/" title="最伟大的高清图库站" target="_blank">Wallhaven</a></dd>
        <dd class="recommend_web">图片 - <a href="https://www.pexels.com/zh-cn/" title="可免费商用的高质量高清图" target="_blank">Pexels</a></dd>
		<dd class="recommend_web">摄影 - <a href="https://1x.com" title="拥有丰富分类的高质量高清图" target="_blank">1X.com</a></dd>
		<dd class="recommend_web">字体 - <a href="https://www.fonts.net.cn/" title="最全的字体下载网站" target="_blank">字体天下</a></dd>
        <dd class="recommend_web">灵感 - <a href="https://www.zcool.com.cn" title="最具人气的经验、分享与灵感平台" target="_blank">站酷ZCOOL</a></dd>
        <dd class="recommend_web">灵感 - <a href="https://www.behance.net/" title="Adobe官方设计分享网站" target="_blank">Behance</a></dd>
        <dd class="recommend_web">素材 - <a href="http://www.sccnn.com/" title="免费素材共享平台" target="_blank">素材中国</a></dd>
		<dd class="recommend_web">图标 - <a href="https://www.iconfont.cn/" title="最全矢量图标管理、交流平台" target="_blank">Iconfont</a></dd>
        <dd class="recommend_web">酷站 - <a href="https://www.awwwards.com/" title="评选全球设计最优秀的CSS3、HTML5网站" target="_blank">Awwwards</a></dd>
        <dd class="recommend_web">源码 - <a href="https://sc.chinaz.com/jiaoben/" title="免费网页特效代码" target="_blank">CHINAZ</a></dd>
		<dd class="recommend_web">抠图 - <a href="https://www.fococlipping.com/" title="免费在线一键抠图" target="_blank">OFFICIAL</a></dd>
		<dd class="recommend_web">GIF - <a href="https://icons8.com/preloaders/" title="最强大的GIF、Loading自定义生成网站" target="_blank">Preloaders</a></dd>
      </dl>
      <div class="fix"></div>
    </div>
    <div class="youce_top">互动客厅 QQ群 （暂停加入）</div>
    <div class="qun">
      <dl>
        <dd class="qun1">26647298</dd>
        <dd class="qun_j"><a href="https://wp.qq.com/wpa/qunwpa?idkey=ecfca9bde381d811f6aa445410a2c3c343cd4ba8761048aa0107e2fccd7c89f9" title="加入互动客厅" target="_blank"></a></dd>
      </dl>
    </div>
    <div class="qun">
      <dl>
        <dd class="qun1">26647316</dd>
        <dd class="qun_j"><a href="https://wp.qq.com/wpa/qunwpa?idkey=c5e309516b9413e6949a923565d08423589c72a9327fc4c05ce0e0745dc1b083" title="加入互动客厅" target="_blank"></a></dd>
      </dl>
    </div>
    <div class="fb_weibo"><a href="https://widget.weibo.com/dialog/PublishWeb.php?default_text=%E8%BF%99%E6%98%AF%E4%B8%80%E6%9D%A1%E6%9D%A5%E8%87%AA%20WKUN%20%E7%9A%84%E5%BE%AE%E5%8D%9A&uid=1390455004&refer=y&language=zh_cn&uniqueID=15129838528291&app_src=1g7Iq2&button=pubilish" title="发布一条来自 WKUN 的微博" target="_blank"><img src="images/six/weibo.svg" width="29" height="24" /><strong>发布一条微博</strong></a></div>
    <div class="book_ad_r"><a href="../xiazai/book7.html" title="下载互动客厅 7.0 源码" target="_blank"><img src="images/ad/book_ad_01.jpg"/></a></div>
    <div class="book_ad_r"><a href="https://pan.baidu.com/share/link?shareid=389418&uk=2114447430" title="前往下载王先生的字库" target="_blank"><img src="images/ad/book_ad_02.jpg"/></a></a></div>
    <div class="book_weibo">WKUN.COM © <script>document.write( new Date().getFullYear() );</script> 互动客厅</div>
</div>
</div>
<!--PC端主列表结束-->
<!--移动端输入框开始-->
<div class="top_y_m" id="top_y_m">
<form action="index_keting.php?act=index_keting&ref=m" method="post" name="message" enctype="multipart/form-data">
    <input type="hidden" id="uploadmark">
    <input type="hidden" id="picpath" name="img">
        <div class="input_box2">
        <textarea name="content" rows="5" class="input scrollbar" id="content" placeholder="开始我们的对话吧 ~"></textarea>
        </div>
          <div class="input_ok">
          <div class="function" style="position:relative;">
                    <div id="biaoqing_m">
                        <div id="function_close"><a href="javascript:;" id="bq_close_m" title="关闭"><img src="images/six/m/jp.svg" width="18" height="22" /></a></div>
                        <div class="bq_line">
                          <dl>
                            <dd class="expression"><a href="javascript:;" title="微笑"><img src="images/six/bq/wx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="晕"><img src="images/six/bq/y.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="心花怒放"><img src="images/six/bq/xhnf.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="笑哭"><img src="images/six/bq/xk.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="鼓掌"><img src="images/six/bq/gz.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="哈欠"><img src="images/six/bq/hax.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="憨笑"><img src="images/six/bq/sx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="汗"><img src="images/six/bq/han.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="吃惊"><img src="images/six/bq/cj.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="鄙视"><img src="images/six/bq/bs.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="闭嘴"><img src="images/six/bq/bz.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="呲牙"><img src="images/six/bq/cy.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="害羞"><img src="images/six/bq/hx.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="衰"><img src="images/six/bq/shuai.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="偷笑"><img src="images/six/bq/tx.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="捂脸"><img src="images/six/bq/wul.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="折磨"><img src="images/six/bq/zm.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="难过"><img src="images/six/bq/ng.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="示爱"><img src="images/six/bq/sa.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="可爱"><img src="images/six/bq/ka.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="尴尬"><img src="images/six/bq/gg.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="泪"><img src="images/six/bq/lei.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="酷"><img src="images/six/bq/cool.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="发呆"><img src="images/six/bq/fd.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="敲打"><img src="images/six/bq/qd.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="再见"><img src="images/six/bq/zj.png" width="30"></a></dd>
							<dd class="expression"><a href="javascript:;" title="吐"><img src="images/six/bq/tu.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="强"><img src="images/six/bq/qiang.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="差劲"><img src="images/six/bq/cha.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="顶你"><img src="images/six/bq/ding.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="勾引"><img src="images/six/bq/gy.png" width="30"></a></dd>
                            <dd class="expression"><a href="javascript:;" title="耶"><img src="images/six/bq/ye.png" width="30"></a></dd>
                          </dl>
                        </div>
                    </div>
                <dl style="width:100px;">
                  <dd class="bq"><a href="javascript:;" id="show_bq_m" title="加入表情"><img src="images/six/icon_bq.svg" width="22" height="22" /></a></dd>
                  <div style="overflow:hidden;position:relative;"> 
                  <div style="display: block; height: 22px; width: 22px; overflow:hidden;">
					 <input class="upload" style="opacity:0; position: absolute; width: 22px; height:22px; cursor: pointer;" accept="image/*" id="myimg" name="file" type="file">
				     <img src="images/six/icon_m_img.svg" width="22" height="22" />
                  </div> 
                  </div>
                  <div style="position:relative;margin-left:-10px;">
                          <div id="gn_photo_3">
							  <div id="function_close_img"><a href="javascript:;" title="关闭" class="pic_close"></a></div>
                            <div class="gn_photo_img"><img class="shopimg" src=""></div>
                        </div>
					  <div id="gn_photo_4">
                            <div id="function_close_img"><a id="del_close_m" href="javascript:;" title="关闭"></a></div>
                            <div class="gn_photo_img">
                              <dl>
                                <dd class="tips2">确定删除吗？</dd>
                                <dd class="submit2"><a href="javascript:;" title="确定" id="ajax_del_m">确定</a></dd>
                              </dl>
                            </div>
                        </div>
                  </div>
            </dl>
          </div>
          <div class="input_submit">
              <input  type="image" class="botton" onClick="return checkdata();" src="images/six/m/an_3.svg" width="70" height="35"  />
            </div>
            <div class="input_name"><input name="username" type="text" enterkeyhint="send" class="name" id="username" placeholder="你的名字" maxlength="8" value="<?php echo trim($_COOKIE['uu'] ?? ''); ?>">
          </div>
        </div>
  </form>
</div>
<!--移动端输入框结束-->
<!--移动端列表开始-->
<div class="list_z_m" id="list_z_m">
 <?php
$page=isset($_GET['page'])?intval($_GET['page']):1;
$num=30;
$soa='';
$offset=($page-1)*$num;
$s = @addslashes($_GET['so']);  
if($s){
    $total=mysqli_num_rows(mysqli_query($db, "select * from book where username like '%".$s."%' or content like '%".$s."%' or reply like '%".$s."%' or dream like '%".$s."%' or posttime like '%".$s."%'"));
    $soa = '&so='.$s; 
}else{
$total=mysqli_num_rows(mysqli_query($db, "select * from book"));
}
$pagenum=ceil($total/$num);

if($page>$pagenum || $page==0)
{
    //header("location:index.php?page=1");
}
else{ 
    if ( $s ){
        $row=mysqli_query($db, "select * from book where username like '%".$s."%' or content like '%".$s."%' or reply like '%".$s."%' or dream like '%".$s."%' or posttime like '%".$s."%' order by id desc limit $offset,$num");
    }else{
$row=mysqli_query($db, "select * from book order by id desc limit $offset,$num");
} 
$row1=mysqli_num_rows(mysqli_query($db, "select * from book order by id"));
$a = ($row1-(($page-1)*$num))+1;
if ( $s ){
$a = ($total-(($page-1)*$num))+1;
}
 //$a = ($page-1)*$num;
 
    //内容表情
    $arr = array(
        '[湖南卫视]'=>'images/six/bq/hntv.gif',
        '[晕]'=>'images/six/bq/y.png',
        '[微笑]'=>'images/six/bq/wx.png',
        '[心花怒放]'=>'images/six/bq/xhnf.png',
		'[笑哭]'=>'images/six/bq/xk.png',
        '[鼓掌]'=>'images/six/bq/gz.png',
        '[哈欠]'=>'images/six/bq/hax.png',
        '[憨笑]'=>'images/six/bq/sx.png',
        '[汗]'=>'images/six/bq/han.png',
        '[吃惊]'=>'images/six/bq/cj.png',
        '[鄙视]'=>'images/six/bq/bs.png',
        '[闭嘴]'=>'images/six/bq/bz.png',
        '[呲牙]'=>'images/six/bq/cy.png',
        '[害羞]'=>'images/six/bq/hx.png',
        '[衰]'=>'images/six/bq/shuai.png',
        '[偷笑]'=>'images/six/bq/tx.png',
		'[捂脸]'=>'images/six/bq/wul.png',
        '[折磨]'=>'images/six/bq/zm.png',
        '[难过]'=>'images/six/bq/ng.png',
        '[示爱]'=>'images/six/bq/sa.png',
        '[可爱]'=>'images/six/bq/ka.png',
		'[尴尬]'=>'images/six/bq/gg.png',
        '[泪]'=>'images/six/bq/lei.png',
        '[酷]'=>'images/six/bq/cool.png',
		'[发呆]'=>'images/six/bq/fd.png',
		'[敲打]'=>'images/six/bq/qd.png',
		'[再见]'=>'images/six/bq/zj.png',
		'[吐]'=>'images/six/bq/tu.png',
		'[强]'=>'images/six/bq/qiang.png',
		'[差劲]'=>'images/six/bq/cha.png',
		'[顶你]'=>'images/six/bq/ding.png',
		'[勾引]'=>'images/six/bq/gy.png',
		'[耶]'=>'images/six/bq/ye.png'
    );
while($rs=mysqli_fetch_array($row))
{
    foreach( $arr as $key=>$v ){
          $rs['content'] = str_replace($key,'<img src="'.$v.'" />',$rs['content']);
          $rs['reply'] = str_replace($key,'<img src="'.$v.'" />',$rs['reply']);
          }
//$a=$a+1;
$a=$a-1;
?>
<div class="list_user">
       <div class="list_user_xiangxi">
       <a href="?so=<?php echo $rs['username'];?>">
       <div class="list_user_zdy"><?php echo $rs['user_img'];?></div>
       <div class="list_user_z">
        <?php
          mt_srand( (int)(microtime(true) * 1000000) );
          $num = rand( 1, 7 );

          switch( $num )
          {
          case 1: $image_file = "images/six/user_2026_01.jpg";
                  break;
          case 2: $image_file = "images/six/user_2026_02.jpg";
                  break;
          case 3: $image_file = "images/six/user_2026_03.jpg";
                  break;
          case 4: $image_file = "images/six/user_2026_04.jpg";
                  break;
          case 5: $image_file = "images/six/user_2026_05.jpg";
                  break;
          case 6: $image_file = "images/six/user_2026_06.jpg";
                  break;
          case 7: $image_file = "images/six/user_2026_07.jpg";
                  break;
          }
          echo "<img src=$image_file />";
        ?>
    </div>
    <div class="qun">
      <dl>
        <dd class="qun1"><?php echo $rs['username'];?><?php echo $rs['verify'];?></dd>
        <dd class="qun2"><?php echo (date('Y') != substr($rs['posttime'],0,4)) ? substr($rs['posttime'],0,4).'年' : '',substr($rs['posttime'],5,2),'月',substr($rs['posttime'],8,2),'日',substr($rs['posttime'],10,6);?></dd>
      </dl>
    </div>
    </a>
<div class="qun_lou"><a href="?so=<?php echo $rs['posttime'];?>"><?php echo $a;?></a></div>
                </div>
                   <div class="list_user_content_message">
                   <?php echo $rs['content'];?>
                   </div>
                   <div class="look_img"><?php if(!empty($rs['img'])){ ?><img class="en_img" src="../design/images/img_bg.png" data-src="<?php echo './images/upload/',$rs['img']; ?>"/><?php }else{echo '';} ?></div>
                   <div class="content_information_k">
                   <div class="content_dream"><?php echo $rs['dream'];?></div>
                   <div class="content_information">
				   <?php if($rs['ip'] != ""){echo convertip($rs['ip']);}?><?php if(isset($_SESSION['admin_name'])){?><a href="msgreply.php?id=<?php echo $rs['id'];?>">回复</a><a href="msgreply.php?act=del&id=<?php echo $rs['id'];?>" onClick="{if(confirm('你确定要删除此对话吗？')){return true;}return false;}">删除</a>
				   <?php }?></div>
                   </div>
                    <?php if($rs['reply']){
					   echo "<div class='list_user_content_reply'>
                           <div class='reply_content'>王坤：".$rs['reply']."</div>
						   <div class='reply_content_time'>".((date('Y') != substr($rs['replytime'],0,4)) ? substr($rs['replytime'],0,4).'年':'').substr($rs['replytime'],5,2).'月'.substr($rs['replytime'],8,2).'日'.substr($rs['replytime'],10,6)." 回复</div>
                   </div>";
					   }
					   else
					   {
						   echo "<div class='list_user_content_reply3'>
                       <div class='list_user_content_no'></div>
                 </div>";
						   }
					   ?>
  </div>
    <?php
  } 
}
?>
<?php if($s){ ?>
    <div class="search_result">
      <dl>
        <dd class="result_quantity"><?php echo !empty($total)?$total:0; ?></dd>
        <dd class="result_tips">条关于</dd>
        <dd class="result_key"> <?php if ( !$s ) {echo '搜索一下'; }else{echo $s;} ?></dd>
        <dd class="result_close"><a href="/book" title="关闭返回"><img src="images/six/m/jp.svg" width="14" height="60" /></a></dd>
      </dl>
    </div>
<?php } ?>
</div>
<!--移动端列表结束-->
<!--PC-移动端通用图片放大浮层-->
<div class="modal-overlay" id="globalModal"><div class="close-btn" id="closeBtn" title="关闭图片"></div><img src=""></div>
<!--PC端翻页-->
    <div class="flip_z" id="flip_z">
          <div class="pages"><a href="../book/" title="返回互动客厅首页">首页</a><?php
       echo "<a class=page>".$total." 条</a>";
           $sk = $page-1==0?1:$page-1;
         echo "<a class=page href='?page=".$sk.$soa."'>上一页</a>";
	   if($page>2 && $pagenum>=5)
				  {
					  echo "<a href='?page=1'".$soa." class=page>1</a><a href=''>...</a>";
				  }
	   if($pagenum>5)
	   {
			for($i=$page;$i<=$pagenum;$i++)
		   {
			  
			  if($i!=$page){
				  
				 echo "<a href='?page=".$i.$soa."' class=page>$i</a>";
				 if($i-$page>=5)
				 {
                     $sk = $page+1;
					 echo "<a href='?page=".$i.$soa."' class=page>...</a><a href='?page=".$pagenum.$soa."' class=page>".$pagenum."</a>";
                      echo "<a class=page href='?page=".$sk.$soa."'>下一页</a>";
					break;
				}
			  }
			  else{
				 echo "<b><a class='page active_pagea'>$i</a></b>";
			  }
			   
	   }
	   }
	   else
	   {
	   for($i=1;$i<=$pagenum;$i++)
	   {
	      if($i!=$page){
		     echo "<a href='?page=".$i.$soa."' class=page>$i</a>";
		
		  }
		  else{
		     echo "<b><a class=page>$i</a></b>";
		  }
	   }
	   }
	?>
    </div>
    </div>
<!--PC端翻页结束-->
<!--移动端翻页开始-->
<div class="pages_k">
          <div class="pages">
               <?php
           $sk = $page-1==0?1:$page-1;
         echo "<a class=page href='?page=".$sk.$soa."'>上一页</a>";
	   if($page>1 && $pagenum>=1)
				  {
					  echo "<a href='?page=1'".$soa." class=page>1</a>";
				  }
	   if($pagenum>1)
	   {
			for($i=$page;$i<=$pagenum;$i++)
		   {
			  
			  if($i!=$page){
				  
				 if($i-$page>=1)
				 {
                     $sk = $page+1;
					 echo "<a href='?page=".$i.$soa."' class=page>...</a><a href='?page=".$pagenum.$soa."' class=page>".$pagenum."</a>";
                      echo "<a class=page href='?page=".$sk.$soa."'>下一页</a>";
					break;
				}
			  }
			  else{
				 echo "<b><a class='page active_pagea'>$i</a></b>";
			  }
			   
	   }
	   }
	   else
	   {
	   for($i=1;$i<=$pagenum;$i++)
	   {
	      if($i!=$page){
		     echo "<a href='?page=".$i.$soa."' class=page>$i</a>";
		
		  }
		  else{
		     echo "<b><a class=page>$i</a></b>";
		  }
	   }
	   }
	?>
   </div>
</div>
<!--移动端翻页结束-->
<!--PC端版权信息开始-->
<div class="copyright_k" id="copyright_k">
<div class="copyright">
<div class="copyright_z">
      <dl>
      <dd class="copyright_wz"><a href="../about/index.html" target="_blank" title="关于 WKUN">关于 WKUN</a>　 　<a href="../time" target="_blank" title="记录">记录</a>　 　<a href="../about/copyright.html" target="_blank" title="版权声明">版权声明</a>　 　<a href="../about/links.html" target="_blank" title="友情链接">友情链接</a>　 　| 　　<a href="../about/contact.html" target="_blank" title="联系">联系</a>　 　<a href="../studio" target="_blank" title="合作">合作</a> 　　<a href="../about/jobs.html" target="_blank" title="工作机会">工作机会</a></dd>
      <dd class="m_icon"><a href="../m" target="_blank" title="WKUN 移动版">移动版</a></dd>
      </dl>
</div>
<div class="copyright_y">
      <div class="hda"><a href="../about/sjysj.html" title="湖南省设计艺术家协会会员" target="_blank">湖南省设计艺术家协会会员<br/><font size="1px">Hunan Designers Association</font></a></div>
</div>
</div>
<div class="copyright_c">
<div class="copyright_icon">
      <dl>
      <dd class="c_wxk_logo"><a href="../about/index.html" target="_blank" title="王小困® 是王坤注册商标"></a></dd>
      <dd class="c_wkun_logo"><a href="../" target="_blank" title="进入 WKUN.COM 首页"></a></dd>
      </dl>
      </div>
<div class="copyright_certificate"><a href="https://beian.miit.gov.cn" target="_blank">湘ICP备07004809号-8</a>　　版权所有 © <a href="https://www.wkun.com/" target="_blank" title="王小困">王小困</a>　　Copyright © 2010 - <script>document.write( new Date().getFullYear() );</script> WKUN.com. All Rights Reserved.</div>
</div>
</div>
<!--PC端版权信息结束-->
<!--移动端版权信息开始-->
<div class="copyright_m" id="copyright_m">
  <p><a href="../about/index.html">版权所有 © 王小困</a></p>
  <p>Copyright © 2010 - <script>document.write( new Date().getFullYear() );</script> WKUN.com. All Rights Reserved.</p>
</div>
<!--移动端版权信息结束-->
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="up/up.min.js"></script>
<script>
var input = document.getElementById("myimg"); 
 
if(typeof FileReader==='undefined'){ 
    result.innerHTML = "抱歉，你的浏览器不支持 FileReader"; 
    input.setAttribute('disabled','disabled'); 
}else{ 
    input.addEventListener('change',readFile,false); 
} 
 function readFile(){ 
    var file = this.files[0]; 
    if(!/image\/\w+/.test(file.type)){ 
        alert("文件必须为图片！"); 
        return false; 
    } 
    $("#gn_photo_3").css("display","block");
    var reader = new FileReader(); 
    reader.readAsDataURL(file); 
    reader.onload = function(e){  
    $(".shopimg").attr("src",this.result);
    } 
} 
//手机打开浮层
$("#dd").click(function(){
	var s = $(this).hasClass('active');
	if ( s ){
		$(this).removeClass('active');
	}else{
		$(this).addClass('active');
	}
	var b = $(".search_top").css('display');
	if ( b=='block'  ){$(".search_top").css('display','none');
}
})
$(".so_icon").click(function(){
	var s = $(".search_top").css('display');
	if ( s=='none' ){
		$(".search_top").css('display','block');

	}else{
		$(".search_top").css('display','none');
	}
	var b = $("#dd").hasClass('active');
	if ( b  ){$("#dd").removeClass('active');
	}
})
 //打开PC端表情
$("#show_bq").click(function(){ 
      $("#biaoqing").css('display','block');
      $(".gn_photo_line").css('display','none');
      $("#gn_photo_2").css('display','none'); 
      $("#gn_photo_3").css('display','none');
      $("#gn_photo_4").css('display','none');
    if ( $("#content").val() == '开始我们的对话吧 ~' )
    {
        $("#content").val('');
    }
})
 //打开移动端表情
$("#show_bq_m").click(function(){ 
      $("#biaoqing_m").css('display','block');
    if ( $("#content").val() == '开始我们的对话吧 ~' )
    {
        $("#content").val('');
    }
})
//关闭PC端表情
$("#bq_close").click(function(){
     $("#biaoqing").css('display','none');
})
//关闭移动端表情
$("#bq_close_m").click(function(){
	$("#biaoqing_m").css('display','none');
})
//收起搜索
$("#so_close").click(function(){
     $(".search_top").css('display','none');
})
//选中表情
$(".bq_line").children().children().children().click(function(){ 
        var txt = $("#content").val(); 
        var att = '['+$(this).attr("title")+']';
        var res = txt+att; 
        $("#content").val(res);
})
//打开图片上传
$("#show_ph").click(function(){ 
    $(".gn_photo_line").css('display','block'); 
    $("#biaoqing").css('display','none');
    $("#gn_photo_2").css('display','none');
    $("#gn_photo_3").css('display','none');
    $("#gn_photo_4").css('display','none');
})
//关闭图片框
$("#ph_close").click(function(){
     $(".gn_photo_line").css('display','none'); 
})
//打开URL输入框
$("#show_url").click(function(){
    $("#gn_photo_2").css('display','block'); 
    $(".gn_photo_line").css('display','none');
})
//关闭URL框
$("#url_close").click(function(){
     $("#gn_photo_2").css('display','none');
})
//PC端搜索提交
$("#soso").click(function(){
    if ($(".search_input").val()=='')
    {
        alert('请输入关键词');
        return false;
    }
    self.location="?so="+$(".search_input").val();
})
$(".search_input").keydown(function(e){ 
 var e = e || event;
var  keycode = e.which || e.keyCode;
 if (keycode==13) { 

        self.location="?so="+$(".search_input").val();
        return false;
 }
});
//移动端搜索提交
$("#soso_m").click(function(){
    if ($(".search_input_m").val()=='')
    {
        alert('请输入关键词');
        return false;
    }
    self.location="?so="+$(".search_input_m").val();
})
$(".search_input_m").keydown(function(e){ 
 var e = e || event;
var  keycode = e.which || e.keyCode;
 if (keycode==13) { 

        self.location="?so="+$(".search_input_m").val();
        return false;
 }
});
//远程图片提交
$(".photo_submit").click(function(){ 
    var url = $("#photo_url").val();
    $.ajax({ 
               type: "get", 
				url: "chkimg.php?url="+url, 
				dataType: "html", 
				success: function (data) {   
					if (data == "-1")
					{
						alert('请提交正确的图片地址');
						return false;
					}
					//开始替换节点
					$(".shopimg").attr("src",'./images/upload/'+data);
					$("#gn_photo_3").css('display','block');
					$("#gn_photo_2").css('display','none');
									$("#uploadmark").val("ok");
									$("#picpath").val(data);
					//$("#photo_url").val('获取成功');
				}, 
				error: function (XMLHttpRequest, textStatus, errorThrown) { 
				} 
		}); 
})
//显示删除提示框
$(".pic_close").click(function(){
    $("#gn_photo_4").css('display','block');
})
//关闭删除提示框
$("#del_close").click(function(){
    $("#gn_photo_4").css('display','none');
})
//移动端关闭删除提示框
$("#del_close_m").click(function(){
    $("#gn_photo_4").css('display','none');
})
//删除
$("#ajax_del, #ajax_del_m").click(function(){
    $("#gn_photo_4").css('display','none');
     $.ajax({ 
	   type: "get", 
			url: "chkimg.php?ajax_del="+$(".shopimg").attr("src"),
			dataType: "html", 
			success: function (data) {   
				if (data == "1")
				{
					alert('已删除');
					$("#uploadmark").val('');
					$("#picpath").val('');
				
				//开始替换节点 
				$("#gn_photo_3").css('display','none');  
				}
			}, 
			error: function (XMLHttpRequest, textStatus, errorThrown) { 
			} 
	});    
})
</script>
<script>
    // 配置元素组 - PC端显示的元素ID数组，移动端显示的元素ID数组
    const elementGroups = {
        wide: ['two_topk', 'book_z', 'flip_z', 'copyright_k'],     // PC端显示
        narrow: ['top', 'wangkun_ad', 'top_y_m', 'list_z_m', 'copyright_m'] // 移动端显示
    };
    // 缓存所有相关元素
    const elements = {};
    [...elementGroups.wide, ...elementGroups.narrow].forEach(id => {
        elements[id] = document.getElementById(id);
    });
    // 记录元素原始位置信息
    const elementPositions = {};
    Object.keys(elements).forEach(id => {
        const el = elements[id];
        elementPositions[id] = {
            parent: el.parentNode,
            nextSibling: el.nextSibling
        };
    });
    let resizeTimer = null;
    // 切换元素显示状态
    const toggleDivs = () => {
        const isWide = window.innerWidth > 600;
        const activeGroup = isWide ? elementGroups.wide : elementGroups.narrow;
        const inactiveGroup = isWide ? elementGroups.narrow : elementGroups.wide;
        // 移除非活跃组的元素
        inactiveGroup.forEach(id => {
            const el = elements[id];
            if (el.parentNode) {
                el.parentNode.removeChild(el);
            }
        });
        // 恢复活跃组的元素
        activeGroup.forEach(id => {
            const el = elements[id];
            const pos = elementPositions[id];
            if (!el.parentNode) {
                pos.parent.insertBefore(el, pos.nextSibling);
            }
        });
    };
    // 响应窗口大小变化
    const handleResize = () => {
        toggleDivs();
        clearTimeout(resizeTimer);
        resizeTimer = setTimeout(toggleDivs, 30);
    };
    // 初始化
    toggleDivs();
    window.addEventListener('resize', handleResize);
</script>
<!--留言框高度自适应-->
<script type="text/javascript">
  const textarea = document.getElementById('content');
  function autoResize() {
      textarea.style.height = 'auto'; 
      textarea.style.height = textarea.scrollHeight + 'px';
  }
  textarea.addEventListener('input', autoResize);
  autoResize();
</script>
<!--图片懒加载-->
<script>
  document.addEventListener("DOMContentLoaded", function() {
    // 配置观察器
    const observer = new IntersectionObserver((entries) => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          const img = entry.target;
          // 关键修改：图片加载完成后再添加动画类（解决首次加载无动画）
          img.onload = function() {
            img.classList.add('loaded');
            // 移除load事件，避免重复触发
            img.onload = null;
          };
          // 设置真实图片地址
          img.src = img.dataset.src;
          observer.unobserve(img); // 停止观察已加载图片
        }
      });
    }, {
      rootMargin: '0px 0px 0px 0px' // 提前200px加载
    });
    // 观察所有懒加载图片
    document.querySelectorAll('.en_img').forEach(img => {
      // 额外保障：初始状态移除loaded类（防止缓存导致动画失效）
      img.classList.remove('loaded');
      observer.observe(img);
    });
  });
</script>
<!--图片当前放大-->
<script>
    const modal = document.getElementById('globalModal');
    const modalImg = modal.querySelector('img');
    const closeBtn = document.getElementById('closeBtn');
    function closeModal() {
        modal.classList.remove('show');
        setTimeout(() => { 
            modal.style.display = 'none'; 
            document.body.style.overflow = ''; // 关闭时恢复网页滚动
        }, 300);
    }

    document.addEventListener('click', function(e) {
        const link = e.target.closest('.look_img a, .pic_big');
        
        if (link) {
            e.preventDefault(); // 阻止链接跳转
            const imgSrc = link.href; 
            
            modalImg.src = imgSrc;
            modal.style.display = 'flex';
            requestAnimationFrame(() => modal.classList.add('show'));
            document.body.style.overflow = 'hidden'; // 打开时禁止网页滚动
        }
    });

    closeBtn.addEventListener('click', closeModal);
    modal.addEventListener('click', function(e) {
        if (e.target !== modalImg) closeModal();
    });
</script>
<!--滚动显示导航-->
<script>
  // 获取导航栏元素
  const navbar = document.querySelector('.two_topk');
  
  // 监听滚动事件
  window.addEventListener('scroll', function() {
    // 使用 window.scrollY 获取当前滚动距离（兼容性好）
    if (window.scrollY > 10) {
      navbar.classList.add('scrolled');
    } else {
      navbar.classList.remove('scrolled');
    }
  });
</script>
</body>
</html>