home-js.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?PHP
  2. /**
  3. * Copyright (c) 2016, 2024, 5 Mode
  4. *
  5. * This file is part of Avatar Free.
  6. *
  7. * Avatar Free is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Avatar Free is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Avatar Free. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home-js.php
  21. *
  22. * Avatar Free js for the Home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2024, 5 Mode
  26. * @license https://opensource.org/licenses/BSD-3-Clause
  27. */
  28. require "../../../Private/core/init.inc";
  29. header("Content-Type: text/javascript");
  30. // PARAMETERS AND VARIABLES INIT
  31. $lang = APP_DEF_LANG;
  32. $lang1 = substr(filter_input(INPUT_GET, "hl", FILTER_SANITIZE_STRING), 0, 5);
  33. if ($lang1 !== PHP_STR) {
  34. $lang = $lang1;
  35. }
  36. $shortLang = getShortLang($lang);
  37. $AVATAR_NAME=filter_input(INPUT_GET, "av", FILTER_SANITIZE_STRING);
  38. $CURRENT_VIEW=filter_input(INPUT_GET, "cv", FILTER_SANITIZE_STRING);
  39. $CUDOZ=filter_input(INPUT_GET, "cu", FILTER_SANITIZE_STRING);
  40. ?>
  41. function showHowTo() {
  42. <?PHP if ($lang == PHP_EN): ?>
  43. alert("Here how to manage your avatars in Avatar Free:\n" +
  44. "- Type in the url of your avatar like http://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<your avatar>.\n" +
  45. "- Login with your pasword.\n" +
  46. "- Drag-n-drop in the browser window all the resources you like: \n" +
  47. " a. Drop in .txt files to shape your blog.\n" +
  48. " b. Drop in pic to shape your gallery; the first one as yr avatar picture.\n" +
  49. " c. Drop in texts with link separeted by <ENTER> to shape your friends.\n" +
  50. "\n" +
  51. "Enjoy!");
  52. <?PHP elseif ($lang == PHP_IT): ?>
  53. alert("Ecco come gestire i tuoi avatar in Avatar Free:\n" +
  54. "- Scrivi l'url del tuo avatar come http://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<tuo avatar>.\n" +
  55. "- Loggati con la pasword.\n" +
  56. "- Fai il drag-n-drop nella finestra del browser di tutte le risorse che ritieni: \n" +
  57. " a. Trascina file .txt per creare il tuo blog.\n" +
  58. " b. Trascina immagini per creare la galleria; la prima sara' il tuo avatar.\n" +
  59. " c. Trascina link da testo separati da <INVIO> per creare i tuoi amici.\n" +
  60. "\n" +
  61. "Buon proseguimento!");
  62. <?PHP elseif ($lang == PHP_CN): ?>
  63. alert("在这里如何免费管理您的化身:\n" +
  64. "- 以以下格式输入阿凡达的URLhttp://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<你的头像>.\n" +
  65. "- 使用密码登录.\n" +
  66. "- 在浏览器窗口中拖动n-drop您喜欢的所有资源: \n" +
  67. " a. 放入.txt文件以形成您的博客.\n" +
  68. " b. 放入图片以塑造画廊; 第一个作为您的头像.\n" +
  69. " c. 删除带有链接<enter>分隔的链接以塑造您的朋友的文本.\n" +
  70. "\n" +
  71. "Enjoy!");
  72. <?PHP endif; ?>
  73. }
  74. function startApp() {
  75. hidePassword();
  76. }
  77. function hidePassword() {
  78. $("#passworddisplay").css("visibility","hidden");
  79. }
  80. /*
  81. * call to startApp
  82. *
  83. * @returns void
  84. */
  85. function _startApp() {
  86. setTimeout("startApp()", 1000);
  87. }
  88. /*
  89. * Display the current hash for the config file
  90. *
  91. * @returns void
  92. */
  93. function showEncodedPassword() {
  94. if ($("#Password").val() === "") {
  95. $("#Password").addClass("emptyfield");
  96. return;
  97. }
  98. //if ($("#Salt").val() === "") {
  99. // $("#Salt").addClass("emptyfield");
  100. // return;
  101. //}
  102. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  103. msg = "<?PHP echo(getResource0("Please set your hash in the config file with this value", $lang, "/js/home-js.php"));?>:";
  104. alert(msg + "\n\n" + passw);
  105. }
  106. function changeLang(tthis) {
  107. window.open("/<?PHP echo($AVATAR_NAME);?>?hl="+$(tthis).val(),"_self");
  108. }
  109. function reload() {
  110. //window.location.reload();
  111. document.getElementById("frmUpload").submit();
  112. }
  113. $("div.dragover").on("dragover", function(e) {
  114. e.stopPropagation();
  115. e.preventDefault();
  116. e.originalEvent.dataTransfer.dropEffect = "copy";
  117. return false;
  118. });
  119. $("div.dragover").on("drop", function(e) {
  120. e.stopPropagation();
  121. e.preventDefault();
  122. // Get the current Upload form obejct..
  123. var form = document.getElementById("frmUpload");
  124. // Create a FormData object including the actual form data..
  125. var fd = new FormData(form);
  126. // Get the array of files dropped..
  127. var dt = e.originalEvent.dataTransfer;
  128. var files = dt.files;
  129. var count = files.length;
  130. //alert("File Count: " + count + "\n");
  131. if (count !== 0) {
  132. for (var i = 0; i < count; i++) {
  133. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  134. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  135. fd.append("filesdd[]", files[i]);
  136. }
  137. // Submit of the FormData..
  138. $.ajax("/<?PHP echo($AVATAR_NAME);?>", {
  139. method: "POST",
  140. processData: false,
  141. contentType: false,
  142. data: fd//,
  143. //success: function (data) {
  144. // $("body").html(data);
  145. //}
  146. });
  147. setTimeout("reload()", 2000);
  148. } else {
  149. mytext = e.originalEvent.dataTransfer.getData('text/plain');
  150. re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  151. matches = mytext.matchAll(re);
  152. ffriends="";
  153. if (matches !== null) {
  154. for(const match of matches) {
  155. if (ffriends==="") {
  156. ffriends+=match[0];
  157. } else {
  158. ffriends+="|"+match[0];
  159. }
  160. }
  161. }
  162. if (ffriends!=="") {
  163. //fd.append("f", ffriends);
  164. document.getElementById("f").value = ffriends;
  165. //alert(document.getElementById("f").value);
  166. document.getElementById("frmUpload").submit();
  167. } else {
  168. //alert("ale!");
  169. }
  170. }
  171. return false;
  172. });
  173. function setContentPos() {
  174. h=parseInt(window.innerHeight);
  175. w=parseInt(window.innerWidth);
  176. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  177. $("#picavatar").css("top", ((h - 255) / 2) + "px");
  178. $("#picavatar").css("left", ((w - 255) / 2) + "px");
  179. $("#picavatar").css("display", "inline");
  180. <?PHP endif; ?>
  181. $(".dragover").css("height", h + "px");
  182. $(".dragover").css("width", w + "px");
  183. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  184. $("#passworddisplay").css("top", mytop+"px");
  185. }
  186. function setFooterPos() {
  187. if (document.getElementById("footerCont")) {
  188. tollerance = 16;
  189. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  190. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  191. }
  192. }
  193. window.addEventListener("load", function() {
  194. setTimeout("setContentPos()", 500);
  195. setTimeout("setFooterPos()", 1000);
  196. // display cudoz
  197. for (i=1;i<=<?PHP echo($CUDOZ);?>;i++) {
  198. $("#cudozentry"+i).get(0).src="/res/chicca_<?PHP echo($shortLang);?>.png";
  199. }
  200. setTimeout("_startApp()", 10000);
  201. }, true);
  202. window.addEventListener("resize", function() {
  203. setTimeout("setContentPos()", 500);
  204. setTimeout("setFooterPos()", 1000);
  205. }, true);