home-js.php 10 KB

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