WapegoShare code album ảnh trong tường nhà

15 bài đăng
Tags:
21.08.2016 / 12:34
thaian2009
Bài đăng: 709
Member

Bước 1: Thêm 1 shoutbox lịch sử:

Ô 1:

TWIG
  1. {{_self.env.addGlobal('album_message_list',message_list)}}
  2. {{_self.env.addGlobal('album_url',form_url)}}

Ô 2:

TWIG
  1. {{message}}[-date-]{{message_date|date('U')}}[-xoa-]{{delete_post_button}}[-msS-]

Số tin nhắn để 100, Dòng mới Không

Bước 2: Thêm 1 shoutbox lịch sử

Ô 1:

TWIG
  1. {%set msg=message_list|split('[-msS-]')%}
  2. {%set sdata=_self.env.getGlobals()['sdata']%}
  3. {%set sdata=sdata~message_list%}{{_self.env.addGlobal('sdata',sdata)}}
  4. {%set surl=_self.env.getGlobals()['surl']%}
  5. {%if msg|length>=99%}
  6. {%if surl is empty%}
  7. {%set url=''%}
  8. {%else%}
  9. {%set url=surl%}
  10. {%endif%}
  11. {%else%}
  12. {%if surl is not empty%}
  13. {%set url=surl%}
  14. {%else%}
  15. {%set url=form_url%}
  16. {%endif%}
  17. {%endif%}
  18. {{_self.env.addGlobal('surl',url)}}

Ô 2:

TWIG
  1. {{message}}[-date-]{{message_date|date('U')}}[-xoa-]{{delete_post_button}}[-msS-]

Số tin nhắn để 100, Dòng mới Không

Bước 3: Thêm Mã HTML (style)

TWIG
  1. <!--Album Ảnh-->
  2. <style type="text/css">
  3. .album_img{
  4. border: 1px solid #dcdcdc;
  5. border-radius: 2px;
  6. padding: 1px;
  7. box-shadow: 1px 1px 3px 1px #928686;
  8. background-color: #fff;
  9. }
  10. input, textarea, select, button {
  11. background: #fff;
  12. border: 1px solid #d8d8d8;
  13. color: #686868;
  14. margin: 1px;
  15. padding: 4px;
  16. border-radius: 3px;
  17. }
  18. .title a:link{color:white}
  19. .title a:hover{color:#f00}
  20. body {
  21. background-color: #fff ;
  22. color: #000;
  23. margin: 0 auto;
  24. padding: 0;
  25. max-width: 800px;
  26. }
  27. body, td, input, textarea {
  28. font-family: Arial,Tahoma,sans-serif;
  29. font-size: small;
  30. }
  31.  
  32. .body {
  33. background-color: #EBEBEC;
  34. padding: 4px;
  35. border: 1px solid #DEDEE0;
  36. box-shadow: 0 0 10px #343434;
  37. }
  38. * {
  39. word-wrap: break-word;
  40. }
  41. * {
  42. box-sizing: border-box;
  43. }
  44.  
  45. .title {
  46. background-color: #009688;
  47. border: 1px solid;
  48. border-color: #009688;
  49. padding: 5px;
  50. color: #fff;
  51. margin-top: 4px;
  52. text-align: left;
  53. }
  54.  
  55. .menu, .topmenu, .noti {
  56. background: #fff;
  57. -moz-border: 1px solid;
  58. border: 1px solid;
  59. -moz-border-color: #DCDBDB #CACACA;
  60. border-color: #DCDBDB #CACACA;
  61. border-top: none;
  62. padding: 6px;
  63. color: #00796B;
  64. margin-top: 0;
  65. }
  66. a:link, a:visited {
  67. color: #00796B;
  68. text-decoration: none;
  69. }
  70.  
  71. </style>

Bước 4: Thêm Mã Twig

TWIG
  1. {%set u=api.u.get(api.r.get('uid'))%}
  2. {%set user=api.u.get(api.user_id)%}
  3. {%set album_url='/user_info.php?uid='~u.uid~'&album='%}
  4. {%set image_url='/user_info.php?uid='~u.uid~'&album=view_album&image='%}
  5. {%set list=_self.env.getGlobals()['album_message_list']|split('[-msS-]')%}
  6. {%set sdata=_self.env.getGlobals()['sdata']|split('[-msS-]')%}
  7.  
  8. {%if user.uid==u.uid%}<div class="title"><a href="{{album_url}}upload">Upload ảnh</a> | <a href="{{album_url}}view_album">Xem album ảnh</a> | <a href="{{album_url}}add_album">Thêm album ảnh</a> | <a href="{{album_url}}list_album">Danh sách album</a></div>{%endif%}
  9. {%if user.uid!=u.uid or api.r.get('album')=='view_album'%}<div class="title"><a href="{{image_url}}all_image">Tất cả ảnh</a>
  10. {%for i in 0..list|length-2%}
  11. | <a href="{{image_url}}all_image&sid={{list[i]|split('[-date-]')[1]|split('[-xoa-]')[0]|raw}}">{{list[i]|split('[-date-]')[0]|raw}}</a>
  12. {%endfor%}</div>{%endif%}
  13.  
  14. {%if api.r.get('album')=='add_album'%}
  15. <div class="title">Thêm album mới vào</div>
  16. <div class="menu">
  17. <form action="main.php?[ses]&id=ch_topic_h&uid={{_self.env.getGlobals()['album_url']|split('&uid=')[1][0:6]}}&uuid={{u.uid}}&back_url=%2Fuser_info.php%3Fuid%3D{{u.uid}}%26album%3Dlist_album" method="post">
  18. Nhập tên Album mới<br/>
  19. <input type="text" name="text" value="New Album"/><br/>
  20. <input name="submit" type="submit" value="Thêm"/>
  21. </form>
  22. </div>
  23. {%endif%}
  24. {%if api.r.get('album')=='list_album'%}
  25. <div class="title"><a href="{{album_url}}list_album">Danh sách album</a> | <a href="{{album_url}}list_album&act=del">Xóa</a></div>
  26. {%for i in 0..list|length-2%}
  27. <div class="menu">{{list[i]|split('[-date-]')[0]|raw}}{%if api.r.get('act')=='del'%} {{list[i]|split('[-xoa-]')[1]|raw}}{%endif%}</div>
  28. {%endfor%}
  29. {%endif%}
  30.  
  31. {%if api.r.get('album')=='upload'%}
  32. <div class="title">Thêm ảnh mới</div>
  33. <div class="menu">
  34. Chọn album ảnh<br/>
  35. <select id="album">
  36. <option value="0">Tất cả ảnh</option>
  37. {%for i in 0..list|length-2%}
  38. {%if list[i]|split('[-date-]')[0]|length >2%}
  39. <option value="{{list[i]|split('[-date-]')[1]|split('[-xoa-]')[0]|raw}}">{{list[i]|split('[-date-]')[0]|raw}}</option>
  40. {%endif%}
  41. {%endfor%}</select><br/>
  42. Nhập trạng thái (status):<br/>
  43. <input type="text" id="status" value="Cảm thấy: "/><br/><br/>
  44. <button onclick="document.querySelector('#input_frm').click();return false;" id="up_info"><b>Upload ảnh vào album của bạn</b></button><input style="visibility: collapse; width: 0px;display:none" type="file" onchange="upload(this.files[0])" id="input_frm"/>
  45. </div>
  46.  
  47. <script type="text/javascript">
  48. function upload(file) {
  49. if (!file || !file.type.match(/image.*/)) return;
  50. document.querySelector("#up_info").innerHTML='Đang upload ảnh..';
  51.  
  52. var fd = new FormData();
  53. fd.append("image", file);
  54. var xhr = new XMLHttpRequest()||new ActiveXObject("Microsoft.XMLHTTP")||new ActiveXObject("Msxml2.XMLHTTP");
  55. xhr.open("POST", "http://uploads.im/api?upload");
  56. xhr.onload = function() {
  57. document.querySelector("#up_info").innerHTML='Đã upload thành công^^';
  58. var link = JSON.parse(xhr.responseText);
  59. var slink=((link.data.thumb_url).replace('/t/','/d/'));
  60. //var mlink=((link.data.thumb_url).replace('/t/','/d/'));
  61. var http = new XMLHttpRequest()||new ActiveXObject("Microsoft.XMLHTTP")||new ActiveXObject("Msxml2.XMLHTTP");
  62. var url = "main.php?[ses]&id=ch_topic_h&uid={{_self.env.getGlobals()['surl']|split('&uid=')[1][0:6]}}&uuid={{u.uid}}";
  63. var sid=document.getElementById('album').value;
  64. var status=document.getElementById('status').value;
  65. var sdata=sid+'[-msg-]'+status+'[-status-]'+slink;
  66. var params = "text="+sdata;
  67. http.open("POST", url, true);
  68. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  69.  
  70. http.onreadystatechange = function() {
  71. if(http.readyState == 4 && http.status == 200) {
  72. window.location.href='{{album_url|raw}}view_album&sid='+sid;
  73. }
  74. }
  75. http.send(params);
  76.  
  77. }
  78. xhr.send(fd);
  79. }
  80. </script>
  81. {%endif%}
  82.  
  83. {%if api.r.get('album')=='view_album' or api.r.get('album') is empty%}
  84. {%set sid=api.r.get('sid')|default('0')%}
  85. <div class="menu">
  86. {%for i in 0..sdata|length-2%}
  87. {%if sdata[i]|split('[-msg-]')[0]==sid%}
  88. <a href="{{album_url}}view&sid={{sdata[i]|split('[-msg-]')[0]}}&img={{sdata[i]|split('[-date-]')[1]|split('[-xoa-]')[0]}}"><img src="{{sdata[i]|split('[-status-]')[1]|split('[-date-]')[0]}}" width="75" height="100" class="album_img"/></a>
  89. {%endif%}
  90. {%endfor%}
  91. </div>
  92. {%endif%}
  93. {%if api.r.get('album')=='view'%}
  94. <div class="title">Xem chi tiết ảnh | <a href="{{album_url}}view_album&image=all_image&sid={{api.r.get('sid')|default('0')}}">Quay v</a></div>
  95. <div class="menu">
  96. {%for i in 0..sdata|length-2%}
  97. {%if sdata[i]|split('[-date-]')[1]|split('[-xoa-]')[0]==api.r.get('img')%}
  98. <center><img src="{{sdata[i]|split('[-status-]')[1]|split('[-date-]')[0]}}" class="album_img"/></center>
  99. <br/>
  100. <b>Status: </b>{{sdata[i]|split('[-msg-]')[1]|split('[-status-]')[0]}}<br/>
  101. <b>Ngày tải lên: </b> {{api.r.get('img')[0:14]|date('d/m/Y H:i:s')}}<br/>
  102. {{sdata[i]|split('[-xoa-]')[1]|raw}}
  103. {%endif%}
  104. {%endfor%}
  105.  
  106. </div>
  107. {%endif%}

Demo: http://shoutboxgenerator.wap.mu

Nguồn: http://chonguoivotinh.wap.mu

21.08.2016 / 22:08
vov
Bài đăng: 60
Member
Namo Buddho

Copy toàn dính số...

Đã chỉnh sửa. vov (21.08.2016 / 22:09)
21.08.2016 / 23:15
huypy
Bài đăng: 35
Member
Ahihi
vov đã viết

Copy toàn dính số...

Quote copy cho nhanh :v

22.08.2016 / 07:59
vov
Bài đăng: 60
Member
Namo Buddho
huypy đã viết

Quote copy cho nhanh :v

Cảm ơn, bạn

24.08.2016 / 17:54
minhduc
Bài đăng: 292
Member
zKaiSoul

không phải dùng jquery load ảnh trong thư viện ạ.. cái đó nó tiện hơn

10.12.2016 / 15:20
thaian2009
Bài đăng: 709
Member

Hiện tại dùng link này nha. Uploads.im nó đang lỗi

PHP
  1. http://sql-kentz.rhcloud.com/upload/upload.php
10.12.2016 / 15:22
minhduc
Bài đăng: 292
Member
zKaiSoul
thaian2009 đã viết

Hiện tại dùng link này nha. Uploads.im nó đang lỗi

PHP
  1. http://sql-kentz.rhcloud.com/upload/upload.php

Nếu muốn dùng imgur thì s v thaian

10.12.2016 / 16:03
thaian2009
Bài đăng: 709
Member
minhduc đã viết

Nếu muốn dùng imgur thì s v thaian

cái đó là imgur đó.. an tích hợp lên host của an rồi

13.12.2016 / 19:47
aothiensuphu
Bài đăng: 32
Member
thaian2009 đã viết

cái đó là imgur đó.. an tích hợp lên host của an rồi

cho mình hỏi phát: bạn có code show bài viết mới ra index cho wapego không? ;d

13.12.2016 / 21:01
manhhung
Bài đăng: 458
Member

Đã share r