home-js.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <?PHP
  2. /**
  3. * Copyright (c) 2016, 2026 5 Mode
  4. *
  5. * This file is part of Buzzcing.
  6. *
  7. * Buzzcing 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. * Buzzcing 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 Buzzcing. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home-js.php
  21. *
  22. * Buzzcing js for the Home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2026 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 Musicing\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 listings, in the form 'Company~Listing Title.txt';\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 Musicing:\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 i tuoi annunci, attenendoti a 'Company~Titolo annuncio.txt'\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文件以形成您的博客:'Company~Listing Title.txt'.\n" +
  72. " b. 放入图片以塑造画廊; 第一个作为您的头像.\n" +
  73. " b. 删除带有链接<enter>分隔的链接以塑造您的朋友的文本.\n" +
  74. "\n" +
  75. "Enjoy!");
  76. <?PHP endif; ?>
  77. }
  78. function playSample() {
  79. //document.getElementById("myPlayer").src = "http://<?PHP echo(APP_HOST);?>/media/sample.mp3";
  80. document.getElementById("myPlayer").src = "/audio?av=<?PHP echo($AVATAR_NAME); ?>&f=/sample.mp3";
  81. document.getElementById("myPlayer").volume = 1;
  82. document.getElementById("myPlayer").play();
  83. }
  84. function playSong(playlist, song, songid, blogEntry) {
  85. if ($(".modal-content .song"+songid).get(0)) {
  86. $(".songtxt").hide();
  87. $(".song"+songid).show();
  88. } else {
  89. selectVideo(blogEntry);
  90. }
  91. }
  92. function stopSong() {
  93. stopPlayList();
  94. document.getElementById("myPlayer").pause();
  95. }
  96. var curPlayF = -1;
  97. var ih;
  98. function playList(playlist, allowed, onclick) {
  99. if (allowed) {
  100. /*
  101. if (onclick) {
  102. if ($(".play-list-img2").attr("src") ==="/res/stopicon.png") {
  103. stopPlayList();
  104. return;
  105. }
  106. } */
  107. if (document.getElementById("myPlayer").readyState===0 || document.getElementById("myPlayer").ended || document.getElementById("myPlayer").paused) {
  108. //$(".play-list-img2").attr("src","/res/stopicon.png");
  109. $("#playListImg"+playlist).attr("src","/res/stopicon.png");
  110. curPlayF++;
  111. if (document.getElementsByClassName("playf"+playlist)[curPlayF]) {
  112. $(document.getElementsByClassName("playf"+playlist)[curPlayF]).click();
  113. clearInterval(ih);
  114. ih = setInterval("playList("+playlist+", true, false)", 5000);
  115. } else {
  116. //stopPlayList();
  117. curPlayF = -1;
  118. }
  119. } else {
  120. if (onclick) {
  121. //if ($(".play-list-img2").attr("src") ==="/res/stopicon.png") {
  122. stopPlayList();
  123. return;
  124. //}
  125. }
  126. }
  127. }
  128. return;
  129. }
  130. function stopPlayList() {
  131. curPlayF = -1;
  132. clearInterval(ih);
  133. $(".play-list-img").attr("src","/res/playicon.png");
  134. $(".play-list-img2").attr("src","/res/playicon.png");
  135. document.getElementById("myPlayer").pause();
  136. }
  137. function settingsOn() {
  138. $(".settingson").hide();
  139. $(".magicjar1").show();
  140. $(".magicjar2").show();
  141. $(".magicjar3").show();
  142. $(".settingsoff").show();
  143. setTimeout("settingsOff()",6000);
  144. }
  145. function settingsOff() {
  146. $(".settingsoff").hide("slow");
  147. $(".magicjar1").hide("slow");
  148. $(".magicjar2").hide("slow");
  149. $(".magicjar3").hide("slow");
  150. $(".settingson").show();
  151. }
  152. function toolsOn() {
  153. settingsOn();
  154. $(".tools").show("slow");
  155. clearInterval(myToolsOnIntID);
  156. }
  157. function setJar1On() {
  158. $(".magicjar1").css("background","url(/res/magicjar1.png)");
  159. $(".magicjar1").css("background-size","120px 120px");
  160. document.getElementsByClassName("magicjar1")[0].onclick=setJar1Off;
  161. document.getElementById("txtMagicJar1").value="1";
  162. document.getElementById("frmUpload").submit();
  163. }
  164. function setJar1Off() {
  165. $(".magicjar1").css("background","url(/res/magicjar1dis.png)");
  166. $(".magicjar1").css("background-size","120px 120px");
  167. document.getElementsByClassName("magicjar1")[0].onclick=setJar1On;
  168. document.getElementById("txtMagicJar1").value="0";
  169. document.getElementById("frmUpload").submit();
  170. }
  171. function setJar2On() {
  172. $(".magicjar2").css("background","url(/res/magicjar2.png)");
  173. $(".magicjar2").css("background-size","120px 120px");
  174. document.getElementsByClassName("magicjar2")[0].onclick=setJar2Off;
  175. document.getElementById("txtMagicJar2").value="1";
  176. document.getElementById("frmUpload").submit();
  177. }
  178. function setJar2Off() {
  179. $(".magicjar2").css("background","url(/res/magicjar2dis.png)");
  180. $(".magicjar2").css("background-size","120px 120px");
  181. document.getElementsByClassName("magicjar2")[0].onclick=setJar2On;
  182. document.getElementById("txtMagicJar2").value="0";
  183. document.getElementById("frmUpload").submit();
  184. }
  185. function setJar3On() {
  186. $(".magicjar3").css("background","url(/res/magicjar3.png)");
  187. $(".magicjar3").css("background-size","120px 120px");
  188. document.getElementsByClassName("magicjar3")[0].onclick=setJar3Off;
  189. document.getElementById("txtMagicJar3").value="1";
  190. document.getElementById("frmUpload").submit();
  191. }
  192. function setJar3Off() {
  193. $(".magicjar3").css("background","url(/res/magicjar3dis.png)");
  194. $(".magicjar3").css("background-size","120px 120px");
  195. document.getElementsByClassName("magicjar3")[0].onclick=setJar3On;
  196. document.getElementById("txtMagicJar3").value="0";
  197. }
  198. function startApp() {
  199. hidePassword();
  200. }
  201. function hidePassword() {
  202. $("#passworddisplay").css("visibility","hidden");
  203. }
  204. /*
  205. * call to startApp
  206. *
  207. * @returns void
  208. */
  209. function _startApp() {
  210. setTimeout("startApp()", 1000);
  211. }
  212. /*
  213. * Display the current hash for the config file
  214. *
  215. * @returns void
  216. */
  217. function showEncodedPassword() {
  218. if ($("#Password").val() === "") {
  219. $("#Password").addClass("emptyfield");
  220. return;
  221. }
  222. //if ($("#Salt").val() === "") {
  223. // $("#Salt").addClass("emptyfield");
  224. // return;
  225. //}
  226. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  227. msg = "<?PHP echo(getResource0("Please set your hash in the config file with this value", $lang, "/js/home-js.php"));?>:";
  228. alert(msg + "\n\n" + passw);
  229. }
  230. function changeLang(tthis) {
  231. window.open("/<?PHP echo($AVATAR_NAME);?>?hl="+$(tthis).val(),"_self");
  232. }
  233. function adminView() {
  234. document.getElementById("_reqView").value="<?PHP echo(ADMIN_VIEW);?>";
  235. document.getElementById("frmUpload").submit();
  236. }
  237. function privateView() {
  238. document.getElementById("_reqView").value="<?PHP echo(PRIVATE_VIEW);?>";
  239. document.getElementById("frmUpload").submit();
  240. }
  241. function reload() {
  242. //window.location.reload();
  243. document.getElementById("frmUpload").submit();
  244. }
  245. $("div.dragover").on("dragover", function(e) {
  246. e.stopPropagation();
  247. e.preventDefault();
  248. e.originalEvent.dataTransfer.dropEffect = "copy";
  249. return false;
  250. });
  251. $("div.dragover").on("drop", function(e) {
  252. e.stopPropagation();
  253. e.preventDefault();
  254. // Get the current Upload form obejct..
  255. var form = document.getElementById("frmUpload");
  256. // Create a FormData object including the actual form data..
  257. var fd = new FormData(form);
  258. // Get the array of files dropped..
  259. var dt = e.originalEvent.dataTransfer;
  260. var files = dt.files;
  261. var count = files.length;
  262. //alert("File Count: " + count + "\n");
  263. if (count !== 0) {
  264. for (var i = 0; i < count; i++) {
  265. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  266. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  267. if (files[i].size > <?PHP echo(APP_FILE_MAX_SIZE); ?>) {
  268. alert("ERROR: file size (" + files[i].size +") exceeds app limit: <?PHP echo(APP_FILE_MAX_SIZE); ?>");
  269. return;
  270. }
  271. if (files[i].size > <?PHP echo(ini_get('upload_max_filesize'));?>) {
  272. alert("ERROR: file size (" + files[i].size +") exceeds PHP upload limit: <?PHP echo(ini_get('upload_max_filesize')); ?>");
  273. return;
  274. }
  275. if (files[i].size > <?PHP echo(ini_get('post_max_size'));?>) {
  276. alert("ERROR: file size (" + files[i].size +") exceeds PHP post limit: <?PHP echo(ini_get('post_max_size')); ?>");
  277. return;
  278. }
  279. fd.append("filesdd[]", files[i]);
  280. }
  281. // Submit of the FormData..
  282. $.ajax("/<?PHP echo($AVATAR_NAME);?>", {
  283. method: "POST",
  284. processData: false,
  285. contentType: false,
  286. data: fd//,
  287. //success: function (data) {
  288. //$("body").html(data);
  289. //}
  290. });
  291. setTimeout("reload()", 2000);
  292. } else {
  293. mytext = e.originalEvent.dataTransfer.getData('text/plain');
  294. re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  295. matches = mytext.matchAll(re);
  296. ffriends="";
  297. if (matches !== null) {
  298. for(const match of matches) {
  299. if (ffriends==="") {
  300. ffriends+=match[0];
  301. } else {
  302. ffriends+="|"+match[0];
  303. }
  304. }
  305. }
  306. if (ffriends!=="") {
  307. //fd.append("f", ffriends);
  308. document.getElementById("f").value = ffriends;
  309. //alert(document.getElementById("f").value);
  310. document.getElementById("frmUpload").submit();
  311. } else {
  312. //alert("ale!");
  313. }
  314. }
  315. return false;
  316. });
  317. $("input#files").on("change", function(e) {
  318. frmUpload.submit();
  319. });
  320. function setContentPos() {
  321. h=parseInt(window.innerHeight);
  322. w=parseInt(window.innerWidth);
  323. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  324. $("#fireupload").css("top", ((h - 255) / 2) + "px");
  325. $("#fireupload").css("left", ((w - 255) / 2) + "px");
  326. $("#fireupload").css("display", "inline");
  327. //$("#picavatar").css("top", ((h - 255) / 2) + "px");
  328. //$("#picavatar").css("left", ((w - 255) / 2) + "px");
  329. $("#picavatar").css("display", "inline");
  330. <?PHP else: ?>
  331. if (window.innerWidth<800) {
  332. $("#header").css("display", "none");
  333. $("#headerMob").css("display", "inline");
  334. $("#cudoz").css("display", "none");
  335. } else {
  336. $("#header").css("display", "inline");
  337. $("#headerMob").css("display", "none");
  338. $("#cudoz").css("display", "inline");
  339. }
  340. <?PHP endif; ?>
  341. $(".dragover").css("height", h + "px");
  342. $(".dragover").css("width", w + "px");
  343. newleft=parseInt(window.innerWidth - 145);
  344. $(".tools").css("left",newleft+"px");
  345. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  346. $("#passworddisplay").css("top", mytop+"px");
  347. }
  348. function setFooterPos() {
  349. if (document.getElementById("footerCont")) {
  350. tollerance = 16;
  351. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  352. $("#footer1").css("top", parseInt( window.innerHeight - $("#footer1").height() - tollerance ) + "px");
  353. $("#footer2").css("top", parseInt( window.innerHeight - $("#footer2").height() - tollerance ) + "px");
  354. $("#footer2").css("left", parseInt( window.innerWidth - $("#footer2").width() - tollerance ) + "px");
  355. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  356. }
  357. }
  358. window.addEventListener("load", function() {
  359. setTimeout("setContentPos()", 500);
  360. setTimeout("setFooterPos()", 1000);
  361. <?PHP if ($CURRENT_VIEW ==ADMIN_VIEW): ?>
  362. $("#AFHint").hide();
  363. myToolsOnIntID = setInterval("toolsOn()", 2000);
  364. <?PHP else: ?>
  365. // display cudoz
  366. //for (i=1;i<=<?PHP echo($CUDOZ);?>;i++) {
  367. // $("#cudozentry"+i).get(0).src="/res/chicca_<?PHP echo($shortLang);?>.png";
  368. //}
  369. <?PHP endif; ?>
  370. setTimeout("_startApp()", 10000);
  371. }, true);
  372. window.addEventListener("resize", function() {
  373. setTimeout("setContentPos()", 500);
  374. setTimeout("setFooterPos()", 1000);
  375. }, true);