home-js.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. $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. function showHowTo() {
  41. alert("Here how to manage your avatars in Avatar Free:\n" +
  42. "- Type in the url of your avatar like http://" + "<?PHP echo($_SERVER['HTTP_HOST']);?>" + "/<your avatar>.\n" +
  43. "- Login with your pasword.\n" +
  44. "- Drag-n-drop in the browser window all the resources you like: \n" +
  45. " a. Drop in .txt files to shape your blog.\n" +
  46. " b. Drop in pic to shape your gallery; the first one as yr avatar picture.\n" +
  47. " c. Drop in texts with link separeted by <ENTER> to shape your friends.\n" +
  48. "\n" +
  49. "Enjoy!");
  50. }
  51. function startApp() {
  52. hidePassword();
  53. }
  54. function hidePassword() {
  55. $("#passworddisplay").css("visibility","hidden");
  56. }
  57. /*
  58. * call to startApp
  59. *
  60. * @returns void
  61. */
  62. function _startApp() {
  63. setTimeout("startApp()", 1000);
  64. }
  65. /*
  66. * Display the current hash for the config file
  67. *
  68. * @returns void
  69. */
  70. function showEncodedPassword() {
  71. if ($("#Password").val() === "") {
  72. $("#Password").addClass("emptyfield");
  73. return;
  74. }
  75. //if ($("#Salt").val() === "") {
  76. // $("#Salt").addClass("emptyfield");
  77. // return;
  78. //}
  79. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  80. msg = "Please set your hash in the config file with this value:";
  81. alert(msg + "\n\n" + passw);
  82. }
  83. function reload() {
  84. //window.location.reload();
  85. document.getElementById("frmUpload").submit();
  86. }
  87. $("div.dragover").on("dragover", function(e) {
  88. e.stopPropagation();
  89. e.preventDefault();
  90. e.originalEvent.dataTransfer.dropEffect = "copy";
  91. return false;
  92. });
  93. $("div.dragover").on("drop", function(e) {
  94. e.stopPropagation();
  95. e.preventDefault();
  96. // Get the current Upload form obejct..
  97. var form = document.getElementById("frmUpload");
  98. // Create a FormData object including the actual form data..
  99. var fd = new FormData(form);
  100. // Get the array of files dropped..
  101. var dt = e.originalEvent.dataTransfer;
  102. var files = dt.files;
  103. var count = files.length;
  104. //alert("File Count: " + count + "\n");
  105. if (count !== 0) {
  106. for (var i = 0; i < count; i++) {
  107. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  108. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  109. fd.append("filesdd[]", files[i]);
  110. }
  111. // Submit of the FormData..
  112. $.ajax("/<?PHP echo($AVATAR_NAME);?>", {
  113. method: "POST",
  114. processData: false,
  115. contentType: false,
  116. data: fd//,
  117. //success: function (data) {
  118. // $("body").html(data);
  119. //}
  120. });
  121. setTimeout("reload()", 2000);
  122. } else {
  123. mytext = e.originalEvent.dataTransfer.getData('text/plain');
  124. re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  125. matches = mytext.matchAll(re);
  126. ffriends="";
  127. if (matches !== null) {
  128. for(const match of matches) {
  129. if (ffriends==="") {
  130. ffriends+=match[0];
  131. } else {
  132. ffriends+="|"+match[0];
  133. }
  134. }
  135. }
  136. if (ffriends!=="") {
  137. //fd.append("f", ffriends);
  138. document.getElementById("f").value = ffriends;
  139. //alert(document.getElementById("f").value);
  140. document.getElementById("frmUpload").submit();
  141. } else {
  142. alert("ale!");
  143. }
  144. }
  145. return false;
  146. });
  147. function setContentPos() {
  148. h=parseInt(window.innerHeight);
  149. w=parseInt(window.innerWidth);
  150. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  151. $("#picavatar").css("top", ((h - 255) / 2) + "px");
  152. $("#picavatar").css("left", ((w - 255) / 2) + "px");
  153. $("#picavatar").css("display", "inline");
  154. <?PHP endif; ?>
  155. $(".dragover").css("height", h + "px");
  156. $(".dragover").css("width", w + "px");
  157. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  158. $("#passworddisplay").css("top", mytop+"px");
  159. }
  160. function setFooterPos() {
  161. if (document.getElementById("footerCont")) {
  162. tollerance = 16;
  163. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  164. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  165. }
  166. }
  167. window.addEventListener("load", function() {
  168. setTimeout("setContentPos()", 500);
  169. setTimeout("setFooterPos()", 1000);
  170. // display cudoz
  171. for (i=1;i<=<?PHP echo($CUDOZ);?>;i++) {
  172. $("#cudozentry"+i).get(0).src="/res/chicca_it.png";
  173. }
  174. setTimeout("_startApp()", 10000);
  175. }, true);
  176. window.addEventListener("resize", function() {
  177. setTimeout("setContentPos()", 500);
  178. setTimeout("setFooterPos()", 1000);
  179. }, true);