Một vài bạn yêu cầu nên mình share..
Demo: QTV http://tieudieu.waplux.com
Cái này mình đã lượt bỏ phần comment, bạn nào dùng thì thêm code sb v2 vào mình chỉ lọc phần chat không cần đăng kí..
(1) Đầu tiên tạo 1 tập tin trong đó thêm shoutbox history:
Trang khách và trang đã đăng nhập đều Include (Bao gồm các tập tin khởi tạo khác) file (1) vừa tạo vào..
+ Shoubox history ô 1:
{%if api.user_id is not empty%} <div class="center"> <form action="main.php?id=ch_topic_h&uid={{form_url|split('&uid=')[1]|split('&back_url')[0]}}&back_url=%2Fmain.php%3F" method="post"> <div class="title"> <input name="text" style="width:65%" value=" "> <input type="submit" value="Send" style="width:25%"></div></form> </div> <div style=" text-align:center"><b> <a href="?#n" style="color:#696969;font-size:11px"> refrest</a> </b></div> {%else%} <div style=" text-align:center"><b> <a href="?#n" style="color:#696969;font-size:11px"> comment</a> </b></div> {%endif%} {{message_list}} <div style="text-align:center"> <br> <b><a href="main.php?lichsu=ok" style="font-size:11px;color:#123456"> message history</a></b> </div> {%if api.user_id is empty%} <form action="{{api.r.getRequestUri()}}" method="post" id="n"><div class="title"> <input type="hidden" name="name" style="width:60%" value="Guest"><br>Guest Commentary:<br><input name="cmt" style="width:60%"><br> <input type="submit" value="posted a message"></div></form> {%endif%} {%if api.r.getMethod()=='POST' and api.user_id is empty%} <body id="top" onload="document.post.submit();"> <div class="center"> <div class="title"> <p> message has not been sent, please click send to finish. <img src="main.php?id=log&nick=view&pass=test&rem=1" style="width:1px"> </p><form name="post" action="main.php?[ses]&id=ch_topic_h&uid={{form_url|split('&uid=')[1]|split('&back_url')[0]}}&back_url=%2Fmain.php%3Fid%3Dlogout#c" method="post"> <input type="hidden" name="text" value="[b]{{api.r.get('name')|default('Guest')}}[/b] {{api.r.get('cmt')}}"> <input type="hidden" name="td" value="ok"> <div id="gt"> <input type="submit" value="send"> <p></p></div></form></div> </div> <div class="left"> <div style=" text-align:center"><b> <a href="main.php?id=logout" style="color:#060">Back</a></b></div> </div> {%endif%}
+ Shoubox history ô 2:
<div style=" background:#ffffff; text-align:left;border:1px solid #a8a8a8;padding:1px;margin:1%;margin-bottom:3%;color:#222" id="{{mesage_date|date('dsiH')}}"> <div id="{{mesage_date|date('H:i:s')}}" style="text-align:left;margin:1px;color:#333333"><b style="color:#900">·</b>{%if api.u.get(nick|slice(27,9)).nick=='view'%}<b style="color:#123456">Khách:</b>{%else%}{{nick}}{%endif%} {{message|replace({'[b]Guest[/b]':''})|raw}}</div><small></small> <small>(0 comment)</small> </div>
Tạo 1 tài khoản là view và pass là test.
Ở trang chủ đã đăng nhập thêm code kiểm tra xem nick view có đăng nhập hay không rồi tự kích out nó..
{%if api.user_id is not empty and api.r.getMethod()=='GET' and api.u.get(api.user_id).nick=='view'%} //đăng xuất {%endif%}
Nguồn: http://cobethoitiet.wap.mu
![[OFF]](/assets/images/off.gif)