home-js.php 11 KB

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