home-js.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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")??"", 0, 5);
  33. $lang1 = strip_tags($lang1);
  34. if ($lang1 !== PHP_STR) {
  35. $lang = $lang1;
  36. }
  37. $shortLang = getShortLang($lang);
  38. $AVATAR_NAME=filter_input(INPUT_GET, "av")??"";
  39. $AVATAR_NAME = strip_tags($AVATAR_NAME);
  40. $CURRENT_VIEW=filter_input(INPUT_GET, "cv")??"";
  41. $CURRENT_VIEW = strip_tags($CURRENT_VIEW);
  42. $CUDOZ=filter_input(INPUT_GET, "cu")??"";
  43. $CUDOZ = strip_tags($CUDOZ);
  44. ?>
  45. var myToolsOnIntID;
  46. function showHowTo() {
  47. <?PHP if ($lang == PHP_EN): ?>
  48. alert("Here how to manage your avatars in Avatar Free:\n" +
  49. "- Type in the url of your avatar like http://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<your avatar>.\n" +
  50. "- Login with your pasword.\n" +
  51. "- Drag-n-drop in the browser window all the resources you like: \n" +
  52. " a. Drop in .txt files to shape your blog.\n" +
  53. " b. Drop in pic to shape your gallery; the first one as yr avatar picture.\n" +
  54. " c. Drop in texts with link separeted by <ENTER> to shape your friends.\n" +
  55. "\n" +
  56. "Enjoy!");
  57. <?PHP elseif ($lang == PHP_IT): ?>
  58. alert("Ecco come gestire i tuoi avatar in Avatar Free:\n" +
  59. "- Scrivi l'url del tuo avatar come http://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<tuo avatar>.\n" +
  60. "- Loggati con la pasword.\n" +
  61. "- Fai il drag-n-drop nella finestra del browser di tutte le risorse che ritieni: \n" +
  62. " a. Trascina file .txt per creare il tuo blog.\n" +
  63. " b. Trascina immagini per creare la galleria; la prima sara' il tuo avatar.\n" +
  64. " c. Trascina link da testo separati da <INVIO> per creare i tuoi amici.\n" +
  65. "\n" +
  66. "Buon proseguimento!");
  67. <?PHP elseif ($lang == PHP_CN): ?>
  68. alert("在这里如何免费管理您的化身:\n" +
  69. "- 以以下格式输入阿凡达的URLhttp://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<你的头像>.\n" +
  70. "- 使用密码登录.\n" +
  71. "- 在浏览器窗口中拖动n-drop您喜欢的所有资源: \n" +
  72. " a. 放入.txt文件以形成您的博客.\n" +
  73. " b. 放入图片以塑造画廊; 第一个作为您的头像.\n" +
  74. " c. 删除带有链接<enter>分隔的链接以塑造您的朋友的文本.\n" +
  75. "\n" +
  76. "Enjoy!");
  77. <?PHP endif; ?>
  78. }
  79. function settingsOn() {
  80. $(".settingson").hide();
  81. $(".magicjar1").show();
  82. $(".magicjar2").show();
  83. $(".magicjar3").show();
  84. $(".settingsoff").show();
  85. setTimeout("settingsOff()",6000);
  86. }
  87. function settingsOff() {
  88. $(".settingsoff").hide("slow");
  89. $(".magicjar1").hide("slow");
  90. $(".magicjar2").hide("slow");
  91. $(".magicjar3").hide("slow");
  92. $(".settingson").show();
  93. }
  94. function toolsOn() {
  95. settingsOn();
  96. $(".tools").show("slow");
  97. clearInterval(myToolsOnIntID);
  98. }
  99. function setJar1On() {
  100. $(".magicjar1").css("background","url(/res/magicjar1.png)");
  101. $(".magicjar1").css("background-size","120px 120px");
  102. document.getElementsByClassName("magicjar1")[0].onclick=setJar1Off;
  103. document.getElementById("txtMagicJar1").value="1";
  104. document.getElementById("frmUpload").submit();
  105. }
  106. function setJar1Off() {
  107. $(".magicjar1").css("background","url(/res/magicjar1dis.png)");
  108. $(".magicjar1").css("background-size","120px 120px");
  109. document.getElementsByClassName("magicjar1")[0].onclick=setJar1On;
  110. document.getElementById("txtMagicJar1").value="0";
  111. document.getElementById("frmUpload").submit();
  112. }
  113. function setJar2On() {
  114. $(".magicjar2").css("background","url(/res/magicjar2.png)");
  115. $(".magicjar2").css("background-size","120px 120px");
  116. document.getElementsByClassName("magicjar2")[0].onclick=setJar2Off;
  117. document.getElementById("txtMagicJar2").value="1";
  118. document.getElementById("frmUpload").submit();
  119. }
  120. function setJar2Off() {
  121. $(".magicjar2").css("background","url(/res/magicjar2dis.png)");
  122. $(".magicjar2").css("background-size","120px 120px");
  123. document.getElementsByClassName("magicjar2")[0].onclick=setJar2On;
  124. document.getElementById("txtMagicJar2").value="0";
  125. document.getElementById("frmUpload").submit();
  126. }
  127. function setJar3On() {
  128. $(".magicjar3").css("background","url(/res/magicjar3.png)");
  129. $(".magicjar3").css("background-size","120px 120px");
  130. document.getElementsByClassName("magicjar3")[0].onclick=setJar3Off;
  131. document.getElementById("txtMagicJar3").value="1";
  132. document.getElementById("frmUpload").submit();
  133. }
  134. function setJar3Off() {
  135. $(".magicjar3").css("background","url(/res/magicjar3dis.png)");
  136. $(".magicjar3").css("background-size","120px 120px");
  137. document.getElementsByClassName("magicjar3")[0].onclick=setJar3On;
  138. document.getElementById("txtMagicJar3").value="0";
  139. }
  140. function startApp() {
  141. hidePassword();
  142. }
  143. function hidePassword() {
  144. $("#passworddisplay").css("visibility","hidden");
  145. }
  146. /*
  147. * call to startApp
  148. *
  149. * @returns void
  150. */
  151. function _startApp() {
  152. setTimeout("startApp()", 1000);
  153. }
  154. /*
  155. * Display the current hash for the config file
  156. *
  157. * @returns void
  158. */
  159. function showEncodedPassword() {
  160. if ($("#Password").val() === "") {
  161. $("#Password").addClass("emptyfield");
  162. return;
  163. }
  164. //if ($("#Salt").val() === "") {
  165. // $("#Salt").addClass("emptyfield");
  166. // return;
  167. //}
  168. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  169. msg = "<?PHP echo(getResource0("Please set your hash in the config file with this value", $lang, "/js/home-js.php"));?>:";
  170. alert(msg + "\n\n" + passw);
  171. }
  172. function changeLang(tthis) {
  173. window.open("/<?PHP echo($AVATAR_NAME);?>?hl="+$(tthis).val(),"_self");
  174. }
  175. function reload() {
  176. //window.location.reload();
  177. document.getElementById("frmUpload").submit();
  178. }
  179. $("div.dragover").on("dragover", function(e) {
  180. e.stopPropagation();
  181. e.preventDefault();
  182. e.originalEvent.dataTransfer.dropEffect = "copy";
  183. return false;
  184. });
  185. $("div.dragover").on("drop", function(e) {
  186. e.stopPropagation();
  187. e.preventDefault();
  188. // Get the current Upload form obejct..
  189. var form = document.getElementById("frmUpload");
  190. // Create a FormData object including the actual form data..
  191. var fd = new FormData(form);
  192. // Get the array of files dropped..
  193. var dt = e.originalEvent.dataTransfer;
  194. var files = dt.files;
  195. var count = files.length;
  196. //alert("File Count: " + count + "\n");
  197. if (count !== 0) {
  198. for (var i = 0; i < count; i++) {
  199. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  200. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  201. if (files[i].size > <?PHP echo(APP_FILE_MAX_SIZE); ?>) {
  202. alert("ERROR: file size (" + files[i].size +") exceeds app limit: <?PHP echo(APP_FILE_MAX_SIZE); ?>");
  203. return;
  204. }
  205. fd.append("filesdd[]", files[i]);
  206. }
  207. // Submit of the FormData..
  208. $.ajax("/<?PHP echo($AVATAR_NAME);?>", {
  209. method: "POST",
  210. processData: false,
  211. contentType: false,
  212. data: fd//,
  213. //success: function (data) {
  214. // $("body").html(data);
  215. //}
  216. });
  217. setTimeout("reload()", 2000);
  218. } else {
  219. mytext = e.originalEvent.dataTransfer.getData('text/plain');
  220. re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  221. matches = mytext.matchAll(re);
  222. ffriends="";
  223. if (matches !== null) {
  224. for(const match of matches) {
  225. if (ffriends==="") {
  226. ffriends+=match[0];
  227. } else {
  228. ffriends+="|"+match[0];
  229. }
  230. }
  231. }
  232. if (ffriends!=="") {
  233. //fd.append("f", ffriends);
  234. document.getElementById("f").value = ffriends;
  235. //alert(document.getElementById("f").value);
  236. document.getElementById("frmUpload").submit();
  237. } else {
  238. //alert("ale!");
  239. }
  240. }
  241. return false;
  242. });
  243. $("input#files").on("change", function(e) {
  244. frmUpload.submit();
  245. });
  246. function setContentPos() {
  247. h=parseInt(window.innerHeight);
  248. w=parseInt(window.innerWidth);
  249. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  250. $("#fireupload").css("top", ((h - 255) / 2) + "px");
  251. $("#fireupload").css("left", ((w - 255) / 2) + "px");
  252. $("#fireupload").css("display", "inline");
  253. //$("#picavatar").css("top", ((h - 255) / 2) + "px");
  254. //$("#picavatar").css("left", ((w - 255) / 2) + "px");
  255. $("#picavatar").css("display", "inline");
  256. <?PHP else: ?>
  257. if (window.innerWidth<800) {
  258. $("#header").css("display", "none");
  259. $("#headerMob").css("display", "inline");
  260. $("#cudoz").css("display", "none");
  261. } else {
  262. $("#header").css("display", "inline");
  263. $("#headerMob").css("display", "none");
  264. $("#cudoz").css("display", "inline");
  265. }
  266. <?PHP endif; ?>
  267. $(".dragover").css("height", h + "px");
  268. $(".dragover").css("width", w + "px");
  269. newleft=parseInt(window.innerWidth - 145);
  270. $(".tools").css("left",newleft+"px");
  271. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  272. $("#passworddisplay").css("top", mytop+"px");
  273. }
  274. function setFooterPos() {
  275. if (document.getElementById("footerCont")) {
  276. tollerance = 16;
  277. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  278. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  279. }
  280. }
  281. window.addEventListener("load", function() {
  282. setTimeout("setContentPos()", 500);
  283. setTimeout("setFooterPos()", 1000);
  284. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  285. myToolsOnIntID = setInterval("toolsOn()", 2000);
  286. <?PHP else: ?>
  287. // display cudoz
  288. for (i=1;i<=<?PHP echo($CUDOZ);?>;i++) {
  289. $("#cudozentry"+i).get(0).src="/res/chicca_<?PHP echo($shortLang);?>.png";
  290. }
  291. <?PHP endif; ?>
  292. setTimeout("_startApp()", 10000);
  293. }, true);
  294. window.addEventListener("resize", function() {
  295. setTimeout("setContentPos()", 500);
  296. setTimeout("setFooterPos()", 1000);
  297. }, true);