Shoubox bằng trao đổi tập tin chỉ load lại khi có nội dung mới và âm thanh báo.
Đầu tiên tạo file [*]_Trang chủ mxh ajax
Thêm vào mã Twig
{%set category_id=398486%} {%set content=3463504%} {%set time=3463298%} <script src="/files/1020011/jquery.min.js"></script> <style type="text/css"> .instta { height: 100px!important; outline: 0px; border: 1px solid gray; -webkit-transition: all 0.5s; background-image: url('/files/169089/buombay.gif'); } .xkhung{box-shadow: 1px 1px 5px #7c7c7c;position: relative;padding: 5px 5px 0px 10px; border-bottom: 1px solid #eee;line-height: 27px;} .instt { resize: none; height: 50px; border: 1px solid #efefef!important; } .instt:focus { height: 100px; outline: 0px; border: 1px solid gray; -webkit-transition: all 0.5s; background-image: url('/files/169089/buombay.gif'); } .xbogoc{border-radius:50%;padding:1px;border:1px solid gray; vertical-align: top;float:left} .ztopic{line-height: 20px; padding: 0px 5px 0px 0px;} .zlogin{ padding: 5px 10px 0px;border-bottom: 1px solid #c3c3c3;border-radius:0px 0px 5px 5px} .tkhung{border: 1px solid #d3d6db; border-radius: 3px 3px 0px 0px; background: #fff; padding: 10px 10px 3px 10px; margin-bottom: 10px;margin:3px 5px 0px 5px; position: relative;} .vtable,.htable{border-bottom: 1px dotted #efefef;} .arrow{background: transparent url(/files/116849/artop.png) no-repeat 10% 100%; height: 6px; width: 11px; background-size: auto; position: absolute; left: 14%; top: -6px; z-index: 1; margin-left: -3px; display: block;} .kcmt{padding: 4px 10px 0px 10px; line-height: 20px;clear:both} .vdata{border: 1px solid #d3d6db;margin:0px 5px;background-color:#F6F7F8;border-top: 0px solid gray} .ctime{float:left;} .vtable:hover{animation: labelanim .5s forwards;z-index:200;} .arrowr{background: transparent url(/files/1049801/arrowl.png) no-repeat 10% 100%; height: 15px; width: 8px; background-size: auto; position: absolute;left: -5px; top: 20px; z-index: 1; margin-left: -3px; display: block;} .dtext{height: 30px; border: 1px solid#EAEAEA; display: block; margin: 0; min-height: 16px; outline: none; padding: 2px; resize: none; width: 100%;overflow:hidden} .mnut{padding: 6px 10px!important;margin: 0px 10px;} </style> {%if api.r.get("cmt")==true%}<div class="titles">Bình luận - Chia sẻ</div>{%else%} <div class="titles">{%if api.r.get("error")=="null"%}<b style="color:red">Lỗi: </b>Chưa nhập nội dung.{%else%}Cộng đồng{%endif%}</div> <div class="ititle" align="right" style="background-color: #F1F1F1;"><img src="/files/1049801/smxh.gif" valign="middle"/> Cập nhật tâm trạng</div> <div class="xkhung"> <i class="arrow"></i> <form action="#" method="post" enctype="multipart/form-data" name="formx" id="frm_chat"> <table width="100%" cellpadding="0" cellspacing="1"> <tbody> <tr valign="top"><td width="6%"><img src="{{api.u.get(api.user_id).profilephotourl(3,true)}}"/></td><td width="94%"><input name="url" value="http://cobethoitiet.wap.mu/files/1049801/maunick.gif" type="hidden"/> <input name="file_name" value="file{{"now"|date("YmdHis")}}.gif" type="hidden"/> <input name="type" value="1" type="hidden"/> <input type="hidden" name="status" value="0"/> <textarea name="desc" style="width:98%" placeholder="Nhập trạng thái" class="instt" id="chat_text" onclick="this.className='instt instta'"></textarea> </td></tr></tbody></table> <div align="right" style="text-align:right"><input type="submit" value="Đăng stt" style="padding: 6px 20px!important;"/></div> </form> </div> {%endif%} <div id="scontent"></div> <script type="text/javascript"> a=1; var chuong=new Audio('/files/1050632/chuong.mp3'); navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate; function writef(ff,vl) { var md=ff.text.value; ff.desc.value=vl+"[-xcmt-]"+md; $.ajax({ url: "file_exchange.php?ses=[ses]&id=upload_url&category_id={{category_id}}", type: "post", data: $(ff).serialize(), success: function(d) { load_data(); } }); } function rung(i){ if(i==0){ chuong.play(); navigator.vibrate(700); } if(i==1) chuong.play(); if(i==2) navigator.vibrate(700); } function load_data() { $('#scontent').load('/main.php?f={{content}} #content'); } $('#frm_chat').submit(function(e){ e.preventDefault(); $.ajax({ url: "file_exchange.php?ses=[ses]&id=upload_url&category_id={{category_id}}", type: "post", data: $(this).serialize(), success: function(d) { load_data(); } }); $('#chat_text').val(''); }); $('#chat_text').keypress(function(e){if((e.keyCode == 10 || e.keyCode == 13) && !e.shiftKey){e.preventDefault();$('#frm_chat').trigger('submit')}}) function load(){ $('<div/>').load('/main.php?f={{time}} #time',function(data){ var b=$(data).find('#time').text(); if(a < b) { if(a!=1) rung(0); load_data(); a=b; } }); } $( document ).ready(function(){ load_data(); }); setInterval(function(){load()},1000); </script> <style type="text/css"> ::-webkit-scrollbar { height: 13px; width: 13px; } ::-webkit-scrollbar-thumb { -webkit-box-shadow: inset 2px 2px 3px #696969; background: #696969; border: 1px solid #D5D4D4; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 2px 2px 3px #e0e0e0; background: #fff; border: 0 solid #000; } @-webkit-keyframes hue { 100% { -webkit-filter:hue-rotate(360deg); } } img:hover,a:link:hover{ -webkit-animation:hue 1s linear infinite; } ::-moz-selection { color: #FF0000;text-shadow:1px 1px 1px #FF99FF,2px 2px 2px #FF99FF,3px 3px 3px #FF99FF,4px 4px 4px #ff000d; font-size:16px;font-style:bold;font-family:Monotype Corsiva,Times New Roman; } ::selection { color: #FF0000;text-shadow:1px 1px 1px #FF99FF,2px 2px 2px #FF99FF,3px 3px 3px #FF99FF,4px 4px 4px #ff000d; font-size:16px;font-style:bold;font-family:Monotype Corsiva,Times New Roman; } *{max-width:99.9%!important}.login,.xlogin,body,.klogin{line-height:27px;}input:hover, a:hover, textarea:hover, label, select{cursor:url("/files/1049801/hinhanh.gif"), auto; }.footer,.wcontainer .center div{text-align:left;}.ititle,.stext,.topic,.xtopic{font-weight:700}.page-naved,.pagenav,a:link,a:visited{text-decoration:none}body{color:#888;font-family:sans-serif;background-color:#fff;word-wrap:break-word;max-width:640px!important;border:1px solid #eee;margin:0 auto;font-size:14px;border-radius: 4px; box-shadow: 0px 0px 8px #343434;cursor: url("/files/1049801/muiten.gif"), auto;font-family: Comicsansms, cursive;}.login,.xlogin,.klogin{padding: 5px 5px 5px 10px;border-bottom:1px solid #eee}.wcontainer .center div a img{width:139px;height:13px}.title{border-width:0;padding:15px 20px;border-bottom:1px solid #eee!important;background-color:transparent}.ititle,.line,.shadow,.titles{border-bottom:1px solid #eee}.header{background-color:#9E9E9E;padding:5px 5px 0;color:#fff;box-shadow:0 5px 10px -2px #aaa}.stext{font-size:19px;padding-left:10px;color:#fff}.titles{padding:10px 5px 5px 10px;height:100%}.footer{background-color:#212121;padding:5px 5px 5px 10px;color:#e0e0e0;box-shadow:0 0 10px #aaa}.buttons{background-image:url(/files/1049801/menus.png);background-color:transparent;border:0;height:23px;width:23px}.buttons:hover{box-shadow:0 5px 10px -2px #aaa;animation:labelanim .5s forwards;border-radius:50%}.shadow{height:1px;width:100%;background-color:#dedede;border-top:1px solid #b4b4b4}a:visited{color:#545454}a:hover{color:#4fc3f7;animation:ahoveranim .3s forwards}.btng a:hover,.xlogin:active,input:hover,select:hover,xmsg:active{animation:labelanim .5s forwards}a:link{padding:5px 0;color:#29b6f6}input,input[type=password],input[type=text],select{border:1px solid #D8D6D6;box-shadow:0 0 5px #D3D5D7;margin:5px 2px;padding:5px;border-radius:5px;font-size:15px}input[type=submit],input[type=button]{background-image:-webkit-linear-gradient(top,#D0D0D0,#9e9e9e);box-shadow: 0 1px 1px rgba(240, 240, 240, 0.1);border:none;background-color:#9E9E9E;color:#fff;font-weight:700;padding:6px 50px;border-radius:5px}input:hover,select:hover{box-shadow:0 0 5px #444545}.line{height:1px;width:50%}input:-webkit-autofill,input:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 50px #fffafe inset;-webkit-text-fill-color:red;border:1px solid #D0D0D0;font-size:16px}.ititle{background-color:#FDFDFD;padding:5px 5px 5px 10px;height:100%}.ititle a:link{color:#888}div.btng{text-align:right!important}.btng a.abtng,.btng a.bbtng{padding:8px 10px 4px;border:1px solid #eee;border-bottom:0 solid gray;background-color:#f2f2f2}.btng a.bbtng{padding:8px 10px 0!important}.btng a:hover{background-color:#f7f7f7!important;box-shadow:1px 1px 5px #7c7c7c}.topic,.xtopic{padding:5px 5px 5px 10px;border-bottom:1px solid #eee;background-color:#F1F1F1}.xlogin,.xtopic,.klogin{position:relative}.smsdate,.smsgid,.xmsgid{position:absolute}.xtopic a:link{color:#000!important}.xtopic a:hover{color:#00AFFF!important}.xlogin:hover,.xmsg:hover,.xtopic img:hover,.xtopic:hover{box-shadow:1px 1px 5px #7c7c7c;animation:labelanim .5s forwards}.xlogin:active,xmsg:active{box-shadow:1px 1px 5px #212121}.bogoc{border-radius:50%;border:1px solid #D1EBD2}.bogoc:hover{box-shadow:0 0 5px rgba(144,144,144,.76)}.msg img{vertical-align:text-top}.pagenav{background-color:#fff;border:1px solid #ccc;padding:2px 6px!important;border-radius:2px;color:#67696A!important}.pagenav:hover{background-color:#222;border:1px solid #222;text-shadow:none;color:#fff!important}.page-naved{background-color:#222;border:1px solid #ccc;padding:2px 6px;border-radius:2px;color:#fff}.login .paging-new{text-align:center!important}.xmsg .xlogin:hover,.xmsg .xtopic:hover{box-shadow:1px 1px 5px transparent;animation:lanim .5s forwards!important}.xmsg .xlogin,.xmsg .slogin{padding:10px 20px 15px}.xmsgid{right:0;top:0;background-color:#d0d0d0;border:1px solid #c2aeae}.smsgid{right:0;top:0;background-color:#f6f6f6;border:1px solid #eee}.smsdate{right:0;bottom:0;font-size:12px;font-weight:400}.smenu .xlogin,.smenu .klogin{padding:5px 5px 5px 10px}.ititle img{vertical-align: middle;}@keyframes labelanim{to{box-shadow:0 0 10px #888;-webkit-transform:scale(1.08,1.08);-ms-transform:scale(1.08,1.08);transform:scale(1.08,1.08)}.vtext a{font-size:9px!important}} .numb{background-color: whitesmoke; color: black; border: 1px solid#E2E2E2; padding: 0px 4px; font-weight: 900; box-shadow: 1px 1px 1px 1px rgb(152, 152, 152);}.vlight{border-radius: 4px; box-shadow: 0px 0px 8px #343434;} </style>
Thay category_id cho đúng.
Thay
{%set content=3463504%} là id shoubox data
{%set time=3463298%} là id shoubox data 2
--------------------------------------------------------
Tạo file shoubox data 2.
Thêm Trao đổi tập tin: danh sách các tập tin
Số lượng tập tin hiển thị trên một trang: 1
Sắp xếp theo : Ngày tải lên
Sắp xếp loại: Giảm dần
Ô 1:
<div id="time">{{file_list}}</div>
Ô 2:
{%set date=name|split("file")[1]%}{%set d=date|slice(6,2)%}{%set m=date|slice(4,2)%}{%set Y=date|slice(0,4)%}{%set h=date|slice(8,2)%}{%set i=date|slice(10,2)%}{%set s=date|slice(12,2)%}{{(d~"-"~m~"-"~Y~" "~h~":"~i~":"~s)|date('U')}}
--------------------------------------------------------
Tạo file shoubox data 2.
Thêm Trao đổi tập tin: danh sách các tập tin
Số lượng tập tin hiển thị trên một trang: 99
Sắp xếp theo : Ngày tải lên
Sắp xếp loại: Giảm dần
Ô 1:
{%set category_id=398486%}{%set f='f=3463292'%}<div id="content">{%set xmsg=file_list|split("[-end-]")%}{%set sid=0%}{%set sdata={}%} {%for i in 0..xmsg|length-1%} {%if "[-uid-]" in xmsg[i] and "[-xcmt-]" not in xmsg[i]%} {%set uid=xmsg[i]|split("[-uid-]")[1]|split("[-msg-]")[0]%} {%set msg=xmsg[i]|split("[-msg-]")[1]|split("[-url-]")[0]%} {%set date=xmsg[i]|split("[-date-]")[1]|split("[-lin-]")[0]%} {%set nicks=api.u.get(xmsg[i]|split("[-nick-]")[1]|split("[-date-]")[0])%} {%set socmt=0%}{%set comment=""%}{%set datecmt="-"%} {%if "[-hidden-]" in msg and api.u.get(api.user_id).uid!=nicks.uid%}{%set ghidden="true"%}{%else%}{%set ghidden=""%}{%endif%} {%for i in xmsg|length-1..0%} {%set amsg=xmsg[i]|split("[-msg-]")[1]|split("[-url-]")[0]%} {%set adate=xmsg[i]|split("[-date-]")[1]|split("[-lin-]")[0]%} {%set anicks=api.u.get(xmsg[i]|split("[-nick-]")[1]|split("[-date-]")[0])%} {%if amsg|split("[-xcmt-]")[0]==uid and "[-xcmt-]" in amsg%}{%set socmt=socmt+1%} {%set binhluan%} <div class="kcmt"><table class="vtable" width="100%" cellpadding="0" cellspacing="1"> <tbody> <tr valign="top"> <td colspan="2" rowspan="2" scope="col" width="6%"><img src="{{anicks.profilephotourl(2,true)}}" class="xbogoc"/></td> <td width="94%" scope="col" align="left"><div class="ctime"><a href="">{{anicks.nick}}</a> {{amsg|split("[-xcmt-]")[1]|raw}}</div></td> </tr> <tr> <td align="left"><img src="/files/1049801/slike.png"> 0 · <a href="" rel="nofollow"> Thích</a> · (<small>{%set ngay=adate|date("d-m-Y H:i:s")%}{%set b="now"|date("d-m-Y H:i:s")%}{% set c = date( b ).diff(date( ngay ))%}{%if c.h==0 and c.i==0 and c.s<=3%}Vừa xong.{%elseif c.h==0 and c.i==0%}{{c.s}} giây trước.{%elseif c.h==0 and c.i>=0%}{{c.i}} phút {{c.s}} giây trước.{%elseif c.h>=1%}{{c.h}} giờ {{c.i}} phút trước.{%elseif c.d>=1%}{{c.d}} ngày trước.{%endif%}</small>)</td> </tr> </tbody> </table></div> {%endset%} {%set comment=comment~binhluan%} {%set datecmt=xmsg[i]|split("[-uid-]")[1]|split("[-msg-]")[0]%} {%endif%} {%endfor%} {%if datecmt=="-"%}{%set datecmt=uid%}{%endif%} {%set status%}{%set ngay=date|date("d-m-Y H:i:s")%}{%set b="now"|date("d-m-Y H:i:s")%}{% set c = date( b ).diff(date( ngay ))%} [-xtcmt-]{{datecmt}}[-page-]<div class="tkhung" {%if "[-hidden-]" in msg%}style="border: 1px solid #38F7C4;"{%endif%}{%if c.h==0 and c.i==0 and c.s<=25%} style="background-color: #FFFEF3; border: 1px solid #FFD2D2;"{%endif%}><i class="arrowr"></i><table class="htable" width="100%" cellpadding="0" cellspacing="1"> <tbody> <tr valign="top"> <td colspan="2" rowspan="2" scope="col" width="10%"><img src="{{nicks.profilephotourl(2,true)}}" class="xbogoc"/></td> <td width="90%" scope="col" align="left"><a href="">{{nicks.nick}}</a></td> </tr> <tr> <td align="left"><span style="font-size: smaller;text-align:right;color: rgb(203, 202, 200);">{%if c.h==0 and c.i==0 and c.s<=3%}Vừa xong.{%elseif c.h==0 and c.i==0%}{{c.s}} giây trước.{%elseif c.h==0 and c.i>=0%}{{c.i}} phút {{c.s}} giây trước.{%elseif c.h>=1 and c.d==0%}{{c.h}} giờ {{c.i}} phút trước.{%elseif c.d>=1%}{{c.d}} ngày trước.{%endif%}</span></td> </tr> </tbody> </table> <div class="xlogin zlogin">{{msg|replace({"[-hidden-]":''})|raw}}<div><img src="/files/1049801/slike.png"> 0 · <a href="" onclick="return false">Thích</a> · <a href="/main.php?{{f}}&cmt=true&suid={{uid}}" onclick="return false;">{%if socmt>0%}{{socmt}}{%endif%} Bình luận</a></div></div></div> {%endset%} {%set form%}<form action="#" method="post" enctype="multipart/form-data" onsubmit="writef(this,'{{uid}}'); return false;"><div class="kcmt" style="padding-bottom: 5px;"><table width="100%" cellpadding="0" cellspacing="1"> <tbody> <tr valign="top"><td width="6%"><img src="{{api.u.get(api.user_id).profilephotourl(2,true)}}"/></td><td scope="col" width="74%"><input name="url" value="http://cobethoitiet.wap.mu/files/1049801/maunick.gif" type="hidden"/> <input name="file_name" value="file{{"now"|date("YmdHis")}}.gif" type="hidden"/> <input name="type" value="1" type="hidden"/><input type="hidden" name="status" value="0"/><input type="hidden" name="suid" value="{{uid}}"/><input type="hidden" name="desc" value=""/><textarea name="text" class="dtext" placeholder="Nhập bình luận.."></textarea></td><td width="20%"><input type="submit" value="Đăng" class="mnut"/></td> </tr> </tbody> </table></div></form>{%endset%} {%set message=status~'<div class="vdata">'~comment~form~'</div>'%} {%if ghidden=="true"%}{%set message=""%}{%endif%} {% set sdata = sdata|merge({ ("thaian"~sid): message}) %} {% set sid=sid+1%} {%endif%} {%endfor%} {%for i in 0..sid%} {%for j in (i+1)..sid%} {%if (sdata["thaian"~i]|split("[-xtcmt-]")[1]|slice(0,14))*1 < (sdata["thaian"~j]|split("[-xtcmt-]")[1]|slice(0,14))*1 %} {%set temp=sdata["thaian"~j]%} {%set sdata=sdata|merge({("thaian"~j):sdata["thaian"~i]})%} {%set sdata=sdata|merge({("thaian"~i):temp})%} {%endif%} {%endfor%} {%endfor%} {%set spage=api.r.get("pusl")|default(0)%} {%if spage>0%}{%set dau=spage*7%}{%set cuoi=((spage+1)*7)-1%}{%else%}{%set dau=spage*7%}{%set cuoi=((spage+1)*7)-1%}{%endif%} <div style="background-color:#e9eaed;padding-bottom:5px">{%for i in dau..cuoi%}{{sdata["thaian"~i]|split("[-page-]")[1]|raw}}{%endfor%}</div> <center>{%if spage>0%}<a href="main.php?{%if api.r.get('f')>=5%}f={{api.r.get('f')}}{%endif%}&pusl={%if spage==null%}1{%else%}{{spage-1}}{%endif%}#chatne"><<Trang trước</a> | {%endif%}<a href="main.php?{%if api.r.get('f')>=5%}f={{api.r.get('f')}}{%endif%}&pusl={%if spage==null%}1{%else%}{{spage+1}}{%endif%}#chatne">Trang sau>></a></center></div>
Ô 2:
{%set date=name|split("file")[1]%}{%set d=date|slice(6,2)%}{%set m=date|slice(4,2)%}{%set Y=date|slice(0,4)%}{%set h=date|slice(8,2)%}{%set i=date|slice(10,2)%}{%set s=date|slice(12,2)%}{%if "[-xcmt-]" in description|slice(0,14)%}[-cmt-]{{description|split("[-xcmt-]")[0]}}{%endif%}[-uid-]{{Y~m~d~h~i~s}}[-msg-]{{description}}[-url-]{{file_url}}[-nick-]{{user_profile_link|split("uid=")[1]}}[-date-]{{d~"-"~m~"-"~Y~" "~h~":"~i~":"~s}}[-lin-][-end-]
Nguồn: http://cobethoitiet.wap.mu