home-js.php 12 KB

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