home.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. <?php
  2. /**
  3. * Copyright 2021, 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.php
  21. *
  22. * Home of Avatar Free.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2024, 5 Mode
  26. */
  27. // CONSTANTS AND VARIABLE DECLARATION
  28. $CURRENT_VIEW = PUBLIC_VIEW;
  29. $CUDOZ = 1;
  30. $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . AVATAR_NAME;
  31. $CV_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "cv";
  32. $FRIENDS_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "friends";
  33. $BLOG_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "blog";
  34. $GALLERY_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "gallery";
  35. $MAGICJAR1_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar1";
  36. $MAGICJAR2_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar2";
  37. $MAGICJAR3_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar3";
  38. $profilePic = APP_DEF_PROFILE_PIC;
  39. // PAGE PARAMETERS
  40. $lang = APP_DEF_LANG;
  41. $lang1 = substr(strip_tags(filter_input(INPUT_GET, "hl")??""), 0, 5);
  42. if ($lang1 !== PHP_STR) {
  43. $lang = $lang1;
  44. }
  45. $shortLang = getShortLang($lang);
  46. $blogSP = (int)substr(strip_tags(filter_input(INPUT_GET, "blogSP")??""), 0, 5);
  47. $password = filter_input(INPUT_POST, "Password")??"";
  48. $password = strip_tags($password);
  49. if ($password !== PHP_STR) {
  50. $hash = hash("sha256", $password . APP_SALT, false);
  51. if (defined("APP_" . strtoupper(AVATAR_NAME) . "_HASH")) {
  52. if ($hash !== constant("APP_" . strtoupper(AVATAR_NAME) . "_HASH")) {
  53. $password=PHP_STR;
  54. }
  55. } else {
  56. if ($hash !== APP_HASH) {
  57. $password=PHP_STR;
  58. }
  59. }
  60. // if ($hash !== APP_HASH) {
  61. // $password=PHP_STR;
  62. // }
  63. }
  64. if ($password !== PHP_STR) {
  65. $CURRENT_VIEW = ADMIN_VIEW;
  66. } else {
  67. $CURRENT_VIEW = PUBLIC_VIEW;
  68. }
  69. $magicJar1 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar1")??""), 0, 1);
  70. $magicJar2 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar2")??""), 0, 1);
  71. $magicJar3 = (int)substr(strip_tags(filter_input(INPUT_POST, "txtMagicJar3")??""), 0, 1);
  72. function uploadNewRes() {
  73. global $AVATAR_PATH;
  74. global $CV_PATH;
  75. global $FRIENDS_PATH;
  76. global $BLOG_PATH;
  77. global $GALLERY_PATH;
  78. global $MAGICJAR1_PATH;
  79. global $MAGICJAR2_PATH;
  80. global $MAGICJAR3_PATH;
  81. global $magicJar1;
  82. global $magicJar2;
  83. global $magicJar3;
  84. //echo_ifdebug(true, "AVATAR_PATH#1=");
  85. //echo_ifdebug(true, $AVATAR_PATH);
  86. if (!empty($_FILES['files']['tmp_name'][0]) || !empty($_FILES['filesdd']['tmp_name'][0])) {
  87. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  88. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  89. $uploads = (array)fixMultipleFileUpload($_FILES['filesdd']);
  90. }
  91. //if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  92. // echo("WARNING: No file uploaded.");
  93. // return;
  94. //}
  95. $google = "abcdefghijklmnopqrstuvwxyz";
  96. if (count($uploads)>strlen($google)) {
  97. echo("WARNING: Too many uploaded files.");
  98. return;
  99. }
  100. $i=1;
  101. foreach($uploads as &$upload) {
  102. switch ($upload['error']) {
  103. case PHP_UPLOAD_ERR_OK:
  104. break;
  105. case PHP_UPLOAD_ERR_NO_FILE:
  106. echo("WARNING: One or more uploaded files are missing.");
  107. return;
  108. case PHP_UPLOAD_ERR_INI_SIZE:
  109. echo("WARNING: File exceeded INI size limit.");
  110. return;
  111. case PHP_UPLOAD_ERR_FORM_SIZE:
  112. echo("WARNING: File exceeded form size limit.");
  113. return;
  114. case PHP_UPLOAD_ERR_PARTIAL:
  115. echo("WARNING: File only partially uploaded.");
  116. return;
  117. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  118. echo("WARNING: TMP dir doesn't exist.");
  119. return;
  120. case PHP_UPLOAD_ERR_CANT_WRITE:
  121. echo("WARNING: Failed to write to the disk.");
  122. return;
  123. case PHP_UPLOAD_ERR_EXTENSION:
  124. echo("WARNING: A PHP extension stopped the file upload.");
  125. return;
  126. default:
  127. echo("WARNING: Unexpected error happened.");
  128. return;
  129. }
  130. if (!is_uploaded_file($upload['tmp_name'])) {
  131. echo("WARNING: One or more file have not been uploaded.");
  132. return;
  133. }
  134. // name
  135. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  136. if ($name == PHP_STR) {
  137. echo("WARNING: Invalid file name: " . $name);
  138. return;
  139. }
  140. $upload['name'] = $name;
  141. // fileType
  142. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  143. $upload['type'] = $fileType;
  144. // tmp_name
  145. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  146. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  147. echo("WARNING: Invalid file temp path: " . $tmp_name);
  148. return;
  149. }
  150. $upload['tmp_name'] = $tmp_name;
  151. //size
  152. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  153. if ($size == "") {
  154. echo("WARNING: Invalid file size.");
  155. return;
  156. }
  157. $upload["size"] = $size;
  158. $tmpFullPath = $upload["tmp_name"];
  159. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  160. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  161. $fileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  162. $date = date("Ymd-His");
  163. $rnd = mt_rand(1000000000, 9999999999);
  164. if ($originalFileExt!==PHP_STR) {
  165. $destFileName = $date . "-" . $rnd . substr($google, $i-1, 1) . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt";
  166. } else {
  167. return;
  168. }
  169. //$CV_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "cv";
  170. //$FRIENDS_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "friends";
  171. //$BLOG_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "blog";
  172. //$GALLERY_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "gallery";
  173. $destPaths = [];
  174. $destFullPaths = [];
  175. if ($magicJar1 != 0) {
  176. $destPaths[] = $MAGICJAR1_PATH;
  177. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  178. }
  179. if ($magicJar2 != 0) {
  180. $destPaths[] = $MAGICJAR2_PATH;
  181. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  182. }
  183. if ($magicJar3 != 0) {
  184. $destPaths[] = $MAGICJAR3_PATH;
  185. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  186. }
  187. if (empty($destPaths)) {
  188. switch ($fileExt) {
  189. case "doc":
  190. case "docx":
  191. case "pdf":
  192. $destPaths[] = $CV_PATH;
  193. break;
  194. case "txt":
  195. $destPaths[] = $BLOG_PATH;
  196. break;
  197. case "png":
  198. case "jpg":
  199. case "jpeg":
  200. case "gif":
  201. case "webp":
  202. $destPaths[] = $GALLERY_PATH;
  203. break;
  204. default:
  205. $destPaths[] = $MAGICJAR1_PATH;
  206. break;
  207. }
  208. $destFullPaths[] = $destPaths[0] . DIRECTORY_SEPARATOR . $destFileName;
  209. }
  210. $iPath = 0;
  211. foreach($destFullPaths as $destFullPath) {
  212. if (file_exists($destFullPath)) {
  213. echo("WARNING: destination already exists");
  214. exit(1);
  215. }
  216. if (filesize($tmpFullPath) > APP_FILE_MAX_SIZE) {
  217. echo("ERROR: file size(" . filesize($tmpFullPath) . ") exceeds app limit:" . APP_FILE_MAX_SIZE);
  218. exit(1);
  219. }
  220. if (!is_readable($AVATAR_PATH)) {
  221. mkdir($AVATAR_PATH, 0777);
  222. }
  223. if (!is_readable($destPaths[$iPath])) {
  224. mkdir($destPaths[$iPath], 0777);
  225. }
  226. $pattern = $destPaths[$iPath] . DIRECTORY_SEPARATOR . "*" . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt";
  227. $aExistingPaths = glob($pattern);
  228. if (!empty($aExistingPaths)) {
  229. continue;
  230. }
  231. copy($tmpFullPath, $destFullPath);
  232. $iPath++;
  233. }
  234. // Cleaning up..
  235. // Delete the tmp file..
  236. unlink($tmpFullPath);
  237. $i++;
  238. }
  239. } else {
  240. //echo("WARNING: No file uploaded (err-pip-po).");
  241. }
  242. }
  243. function writeFriends() {
  244. global $FRIENDS_PATH;
  245. $destPath = $FRIENDS_PATH;
  246. $s = filter_input(INPUT_POST, "f")??"";
  247. $s = strip_tags($s);
  248. if ($s != PHP_STR) {
  249. //echo($s);
  250. //exit(0);
  251. $friends=explode("|", $s);
  252. if (!is_readable($destPath)) {
  253. mkdir($destPath, 0777);
  254. }
  255. foreach($friends as $friend) {
  256. $a = explode("://",$friend);
  257. $s = $a[1];
  258. $a = explode("/", $s);
  259. $friendName = $a[0] . ".txt";
  260. file_put_contents($destPath . DIRECTORY_SEPARATOR . $friendName, $friend);
  261. }
  262. }
  263. }
  264. function grabProfileImage() {
  265. global $GALLERY_PATH;
  266. $pattern = $GALLERY_PATH . DIRECTORY_SEPARATOR . "*";
  267. $aImagePaths = glob($pattern);
  268. if (isset($aImagePaths[0])) {
  269. $retval = basename($aImagePaths[0]);
  270. } else {
  271. $retval = null;
  272. }
  273. return $retval;
  274. }
  275. function startApp() {
  276. global $CURRENT_VIEW;
  277. global $profilePic;
  278. if ($CURRENT_VIEW == ADMIN_VIEW) {
  279. uploadNewRes();
  280. writeFriends();
  281. }
  282. $profilePic = grabProfileImage() ?? APP_DEF_PROFILE_PIC;
  283. //echo("profile pic=" . $profilePic);
  284. }
  285. startApp();
  286. ?>
  287. <!DOCTYPE html>
  288. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  289. <head>
  290. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  291. <!--<?PHP echo(APP_LICENSE);?>-->
  292. <title><?PHP echo(APP_TITLE);?></title>
  293. <link rel="shortcut icon" href="/favicon.ico" />
  294. <meta name="description" content="Welcome to Avatar Free! Let everyone have its social presence."/>
  295. <meta name="keywords" content="Avatar Free,social,presence,avatarfree.org,on,premise,solution"/>
  296. <meta name="robots" content="index,follow"/>
  297. <meta name="author" content="5 Mode"/>
  298. <script src="/js/jquery-3.6.0.min.js" type="text/javascript"></script>
  299. <script src="/js/sha.js" type="text/javascript"></script>
  300. <script src="/js/common.js" type="text/javascript"></script>
  301. <link href="/css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  302. <link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
  303. </head>
  304. <?PHP if ($CURRENT_VIEW == ADMIN_VIEW): ?>
  305. <body style="background:url('/res/bg1.jpg') no-repeat; background-size: cover; background-attachment: fixed; background-position: center;">
  306. <div id="AFHint" style="z-index:0;">
  307. <button type="button" class="close" aria-label="Close" onclick="closeMe(this);" style="position:relative; top:5px; left:-7px;">
  308. <span aria-hidden="true" style="color:black; font-weight:900;">&times;</span>
  309. </button>
  310. <br>
  311. <span onclick="showHowTo();"><?PHP echo(getResource0("How-to: Manage your avatars in Avatar Free", $lang));?></span>
  312. <br><br>
  313. </div>
  314. <form id="frmUpload" role="form" method="post" action="/<?PHP echo(AVATAR_NAME);?>?hl=<?PHP echo($lang);?>" target="_self" enctype="multipart/form-data">
  315. <div class="dragover" dropzone="copy">
  316. <div id="fireupload" onclick="$('#files').click()">
  317. <img id="picavatar" src="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($profilePic);?>" align="middle">
  318. </div>
  319. <input id="files" name="files[]" type="file" accept=".*" style="visibility: hidden;" multiple>
  320. <input type="hidden" id="a" name="a">
  321. <input type="hidden" id="f" name="f">
  322. </div>
  323. <div class="tools">
  324. <div class="settingson" onclick="settingsOn();"></div>
  325. <?PHP if ($magicJar1 == 0): ?>
  326. <div class="magicjar1" style="background:url(/res/magicjar1dis.png);" onclick="setJar1On()"></div>
  327. <?PHP else: ?>
  328. <div class="magicjar1" style="background:url(/res/magicjar1.png);" onclick="setJar1Off()"></div>
  329. <?PHP endif; ?>
  330. <?PHP if ($magicJar2 == 0): ?>
  331. <div class="magicjar2" style="background:url(/res/magicjar2dis.png);" onclick="setJar2On()"></div>
  332. <?PHP else: ?>
  333. <div class="magicjar2" style="background:url(/res/magicjar2.png);" onclick="setJar2Off()"></div>
  334. <?PHP endif; ?>
  335. <?PHP if ($magicJar3 == 0): ?>
  336. <div class="magicjar3" style="background:url(/res/magicjar3dis.png);" onclick="setJar3On()"></div>
  337. <?PHP else: ?>
  338. <div class="magicjar3" style="background:url(/res/magicjar3.png);" onclick="setJar3Off()"></div>
  339. <?PHP endif; ?>
  340. <div class="settingsoff" onclick="settingsOff();"></div>
  341. </div>
  342. <input type="hidden" id="txtMagicJar1" name="txtMagicJar1" value="<?PHP echo($magicJar1);?>">
  343. <input type="hidden" id="txtMagicJar2" name="txtMagicJar2" value="<?PHP echo($magicJar2);?>">
  344. <input type="hidden" id="txtMagicJar3" name="txtMagicJar3" value="<?PHP echo($magicJar3);?>">
  345. <input type="hidden" id="Password" name="Password" value="<?PHP echo($password);?>">
  346. </form>
  347. <div id="footerCont">&nbsp;</div>
  348. <div id="footer"><span style="background:#FFFFFF; opacity:0.7;">&nbsp;&nbsp;<a class="aaa" href="dd.html">Disclaimer</a>.&nbsp;&nbsp;A <a href="http://5mode.com" class="aaa">5 Mode</a> project and <a href="http://demo.5mode.com" class="aaa">WYSIWYG</a> system. <?PHP echo(getResource0("Some rights reserved", $lang));?></span></div>
  349. <?PHP else: ?>
  350. <body style="background:#dadada no-repeat; background-size: cover; background-attachment: fixed; background-position: center;">
  351. <div id="AFHint">
  352. <button type="button" class="close" aria-label="Close" onclick="closeMe(this);" style="position:relative; top:5px; left:-7px;">
  353. <span aria-hidden="true" style="color:black; font-weight:900;">&times;</span>
  354. </button>
  355. <br>
  356. <span onclick="showHowTo();"><?PHP echo(getResource0("How-to: Manage your avatars in Avatar Free", $lang));?></span>
  357. <br><br>
  358. </div>
  359. <div class="header" style="margin-top:18px;margin-bottom:18px;">
  360. <a href="http://avatarfree.5mode-foss.eu" target="_self" style="color:#000000; text-decoration: none;">&nbsp;<img src="Public/res/AFlogo.png" align="middle" style="position:relative;top:-5px;width:22px;">&nbsp;Avatar Free</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/par7133/AvatarFree" style="color:#000000;"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:posta@elettronica.lol" style="color:#000000;"><span style="color:#119fe2">for</span> feedback</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="tel:+39-378-0812391" style="font-size:13px;background-color:#15c60b;border:2px solid #15c60b;color:#000000;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a>
  361. </div>
  362. <form id="frmUpload" role="form" method="post" action="/<?PHP echo(AVATAR_NAME);?>?hl=<?PHP echo($lang);?>" target="_self" enctype="multipart/form-data">
  363. <div id="title">
  364. <div id="avatarLogo">
  365. <img id="picavatar" src="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($profilePic);?>" align="middle" style="position:relative;display:inline;">
  366. </div>
  367. <div id="avatarName">
  368. &nbsp;<?PHP echo(strtoupper(AVATAR_NAME));?>&nbsp;&nbsp;&nbsp;
  369. </div>
  370. <div id="cudoz">
  371. <?PHP for ($i=1;$i<=$CUDOZ;$i++): ?>
  372. <img id="cudozentry<?PHP echo($i);?>" class="cudoz-entry" src="/res/chicca_<?PHP echo($shortLang);?>.png">
  373. <?PHP endfor; ?>
  374. <?PHP for ($i=$CUDOZ+1;$i<=5;$i++): ?>
  375. <img id="cudozentry<?PHP echo($i);?>" class="cudoz-entry" src="/res/chiccadis.png">
  376. <?PHP endfor; ?>
  377. </div>
  378. <div id="cvs">
  379. <div style="float:left;width:47px;margin-top:20px;margin-left:7px;"><?PHP echo(getResource0("CV", $lang));?></div>
  380. <?PHP
  381. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*";
  382. $aFilePaths = glob($pattern);
  383. if (empty($aFilePaths)): ?>
  384. <img class="cv-entry" src="/res/wordicondis.png">&nbsp;&nbsp;<img class="cv-entry" src="/res/pdficondis.png">
  385. <?PHP else: ?>
  386. <?PHP
  387. $CUDOZ++;
  388. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*.doc";
  389. $aFilePaths = glob($pattern);
  390. if (empty($aFilePaths)): ?>
  391. <img class="cv-entry" src="/res/wordicondis.png">&nbsp;&nbsp;
  392. <?PHP else: ?>
  393. <a href="/doc?av=<?PHP echo(AVATAR_NAME);?>&re=cv&doc=<?PHP echo(basename($aFilePaths[0]));?>"><img class="cv-entry" src="/res/wordicon.png"></a>&nbsp;&nbsp;
  394. <?PHP endif; ?>
  395. <?PHP
  396. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*.pdf";
  397. $aFilePaths = glob($pattern);
  398. if (empty($aFilePaths)): ?>
  399. <img class="cv-entry" src="/res/pdficondis.png">
  400. <?PHP else: ?>
  401. <a href="/doc?av=<?PHP echo(AVATAR_NAME);?>&re=cv&doc=<?PHP echo(basename($aFilePaths[0]));?>"><img class="cv-entry" src="/res/pdficon.png"></a>
  402. <?PHP endif; ?>
  403. <?PHP endif; ?>
  404. </div>
  405. </div>
  406. <br>
  407. <div id="blog">
  408. <?PHP
  409. $pattern = $BLOG_PATH . DIRECTORY_SEPARATOR . "*.txt";
  410. $aFilePaths = glob($pattern);
  411. if (empty($aFilePaths)): ?>
  412. <div class="blog-content">
  413. <div class="blog-entry">
  414. <?PHP echo(getResource0("Hello from 5 Mode", $lang));?>,<br>
  415. <?PHP echo(getResource0("This is just an example of blog entry", $lang));?>.
  416. </div>
  417. </div>
  418. <?PHP else: ?>
  419. <?PHP
  420. $CUDOZ++;
  421. $iEntry = 1;
  422. $iCurEntry = 1;
  423. arsort($aFilePaths, SORT_STRING);
  424. //echo("blogSP=".$blogSP);
  425. foreach ($aFilePaths as $filePath) {
  426. //echo("iCurEntry=".$iCurEntry);
  427. if ($iCurEntry<($blogSP+1)) {
  428. $iCurEntry++;
  429. continue;
  430. }
  431. if ($iEntry>APP_BLOG_MAX_POSTS) {
  432. break;
  433. }
  434. $s=file_get_contents($filePath);
  435. if ($iEntry === count($aFilePaths) || $iEntry==APP_BLOG_MAX_POSTS) {
  436. $marginbottom = "0px";
  437. } else {
  438. $marginbottom = "5px";
  439. }
  440. ?>
  441. <div class="blog-content" style="margin-bottom:<?PHP echo($marginbottom);?>;">
  442. <div class="blog-entry" style="width:100%;margin-bottom:0px;">
  443. <?PHP echo(enableEmoticons(HTMLencode($s, true)));?>
  444. </div>
  445. </div>
  446. <?PHP
  447. $iEntry++;
  448. $iCurEntry++;
  449. }?>
  450. <?PHP endif; ?>
  451. <?PHP
  452. $totPages = (int)(count($aFilePaths)/APP_BLOG_MAX_POSTS);
  453. if ($totPages < (count($aFilePaths)/APP_BLOG_MAX_POSTS)) {
  454. $totPages++;
  455. }
  456. $firstPost = 0;
  457. $prevPost = $blogSP - APP_BLOG_MAX_POSTS;
  458. if ($prevPost < 0) {
  459. $prevPost = 0;
  460. }
  461. $nextPost = $blogSP + APP_BLOG_MAX_POSTS;
  462. if ($nextPost > (($totPages - 1) * APP_BLOG_MAX_POSTS)) {
  463. $nextPost = (($totPages - 1) * APP_BLOG_MAX_POSTS);
  464. }
  465. if ($nextPost < 0) {
  466. $nextPost = 0;
  467. }
  468. $lastPost = (($totPages - 1) * APP_BLOG_MAX_POSTS);
  469. if ($lastPost < 0) {
  470. $lastPost = 0;
  471. }
  472. ?>
  473. <?PHP if (defined("APP_PAGINATION") && APP_PAGINATION): ?>
  474. <br><br>
  475. <div style="text-align:center;">
  476. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($firstPost);?>"><img src="/res/first.png" style="width:45px;"></a>
  477. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($prevPost);?>"><img src="/res/arrow-left2.png" style="width:45px;"></a>
  478. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($nextPost);?>"><img src="/res/arrow-right2.png" style="width:45px;"></a>
  479. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($lastPost);?>"><img src="/res/last.png" style="width:45px;"></a>
  480. </div>
  481. <?PHP endif; ?>
  482. <br><br>
  483. </div>
  484. <div id="gallery">
  485. <div class="gallery-content">
  486. <?PHP
  487. $pattern = $GALLERY_PATH . DIRECTORY_SEPARATOR . "*";
  488. $aFilePaths = glob($pattern);
  489. if (empty($aFilePaths)): ?>
  490. <div class="image-entry">
  491. <div style="width:100%;border:0px solid black;"><img class="image-ico" src="/res/imgicon.png" align="center"></div>
  492. <div style="margin-top:10px;"><?PHP echo(getResource0("Sample", $lang));?></div>
  493. </div>
  494. <?PHP else: ?>
  495. <?PHP
  496. $CUDOZ++;
  497. $iEntry = 1;
  498. foreach ($aFilePaths as $filePath) {
  499. $orifilename = basename($filePath);
  500. $filename = explode("|",basename($filePath))[1];
  501. if ($iEntry === count($aFilePaths)) {
  502. $marginbottom = "0px";
  503. } else {
  504. $marginbottom = "5px";
  505. }
  506. ?>
  507. <div class="image-entry">
  508. <a href="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($orifilename);?>">
  509. <div style="width:100%;border:0px solid black;"><img class="image-ico" src="/res/imgicon.png" align="center"></div>
  510. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  511. </a>
  512. </div>
  513. <?PHP
  514. $iEntry++;
  515. }?>
  516. <?PHP endif; ?>
  517. </div>
  518. </div>
  519. <?PHP
  520. $pattern = $MAGICJAR1_PATH . DIRECTORY_SEPARATOR . "*";
  521. $aFilePaths = glob($pattern);
  522. if (!empty($aFilePaths)): ?>
  523. <div id="magicjar1">
  524. <div class="magicjar1-content">
  525. <div class="magicjar-num">&nbsp;1&nbsp;</div>
  526. <?PHP
  527. $iEntry = 1;
  528. foreach ($aFilePaths as $filePath) {
  529. $orifilename = basename($filePath);
  530. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  531. $filename = explode("|",basename($filePath))[1];
  532. if ($iEntry === count($aFilePaths)) {
  533. $marginbottom = "0px";
  534. } else {
  535. $marginbottom = "5px";
  536. }
  537. ?>
  538. <div class="file-entry">
  539. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  540. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=1&fn=<?PHP echo($orifilename);?>">
  541. <?PHP else: ?>
  542. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=1&fn=<?PHP echo($orifilename);?>">
  543. <?PHP endif; ?>
  544. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  545. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  546. </a>
  547. </div>
  548. <?PHP
  549. $iEntry++;
  550. }?>
  551. </div>
  552. </div>
  553. <?PHP endif; ?>
  554. <?PHP
  555. $pattern = $MAGICJAR2_PATH . DIRECTORY_SEPARATOR . "*";
  556. $aFilePaths = glob($pattern);
  557. if (!empty($aFilePaths)): ?>
  558. <div id="magicjar2">
  559. <div class="magicjar2-content">
  560. <div class="magicjar-num">&nbsp;2&nbsp;</div>
  561. <?PHP
  562. $iEntry = 1;
  563. foreach ($aFilePaths as $filePath) {
  564. $orifilename = basename($filePath);
  565. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  566. $filename = explode("|",basename($filePath))[1];
  567. if ($iEntry === count($aFilePaths)) {
  568. $marginbottom = "0px";
  569. } else {
  570. $marginbottom = "5px";
  571. }
  572. ?>
  573. <div class="file-entry">
  574. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  575. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=2&fn=<?PHP echo($orifilename);?>">
  576. <?PHP else: ?>
  577. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=2&fn=<?PHP echo($orifilename);?>">
  578. <?PHP endif; ?>
  579. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  580. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  581. </a>
  582. </div>
  583. <?PHP
  584. $iEntry++;
  585. }?>
  586. </div>
  587. </div>
  588. <?PHP endif; ?>
  589. <?PHP
  590. $pattern = $MAGICJAR3_PATH . DIRECTORY_SEPARATOR . "*";
  591. $aFilePaths = glob($pattern);
  592. if (!empty($aFilePaths)): ?>
  593. <div id="magicjar3">
  594. <div class="magicjar3-content">
  595. <div class="magicjar-num">&nbsp;3&nbsp;</div>
  596. <?PHP
  597. $iEntry = 1;
  598. foreach ($aFilePaths as $filePath) {
  599. $orifilename = basename($filePath);
  600. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  601. $filename = explode("|",basename($filePath))[1];
  602. if ($iEntry === count($aFilePaths)) {
  603. $marginbottom = "0px";
  604. } else {
  605. $marginbottom = "5px";
  606. }
  607. ?>
  608. <div class="file-entry">
  609. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  610. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=3&fn=<?PHP echo($orifilename);?>">
  611. <?PHP else: ?>
  612. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=3&fn=<?PHP echo($orifilename);?>">
  613. <?PHP endif; ?>
  614. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  615. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  616. </a>
  617. </div>
  618. <?PHP
  619. $iEntry++;
  620. }?>
  621. </div>
  622. </div>
  623. <?PHP endif; ?>
  624. <div id="friends">
  625. <div class="friends-content">
  626. <div id="mynetworkTitle"><?PHP echo(getResource0("My Network", $lang));?>:<br><br>
  627. <?PHP
  628. $pattern = $FRIENDS_PATH . DIRECTORY_SEPARATOR . "*.txt";
  629. $aFilePaths = glob($pattern);
  630. if (empty($aFilePaths)): ?>
  631. <div class="friend-entry">
  632. <a href="http://5mode.com">
  633. <div style="width:100%;border:0px solid black;"><img class="friend-ico" src="/res/pic1.png" align="center"></div>
  634. <div style="margin-top:10px;"><?PHP echo(getResource0("Sample", $lang));?></div>
  635. </a>
  636. </div>
  637. <?PHP else: ?>
  638. <?PHP
  639. $CUDOZ++;
  640. $iEntry = 1;
  641. foreach ($aFilePaths as $filePath) {
  642. $orifilename = basename($filePath);
  643. $link=file_get_contents($filePath);
  644. $filename = pathinfo($filePath, PATHINFO_FILENAME);
  645. if ($iEntry === count($aFilePaths)) {
  646. $marginbottom = "0px";
  647. } else {
  648. $marginbottom = "5px";
  649. }
  650. ?>
  651. <div class="friend-entry">
  652. <a href="<?PHP echo($link);?>">
  653. <div style="width:100%;border:0px solid black;"><img class="friend-ico" src="/res/pic1.png" align="center"></div>
  654. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  655. </a>
  656. </div>
  657. <?PHP
  658. $iEntry++;
  659. }?>
  660. <?PHP endif; ?>
  661. </div>
  662. </div>
  663. </div>
  664. <div id="passworddisplay">
  665. <br>
  666. &nbsp;&nbsp;<input type="password" id="Password" name="Password" placeholder="password" value="<?php echo($password);?>" autocomplete="off">&nbsp;<input type="submit" value="<?PHP echo(getResource0("Go", $lang));?>" style="text-align:left;width:25%;color:#000000;"><br>
  667. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" autocomplete="off"><br>
  668. <div style="text-align:center;">
  669. <a id="hashMe" href="#" onclick="showEncodedPassword();"><?PHP echo(getResource0("Hash Me", $lang));?>!</a>
  670. </div>
  671. </div>
  672. </form>
  673. <div id="footerCont">&nbsp;</div>
  674. <div id="footer">
  675. <div style="float:left">
  676. <select id="cbLang" onchange="changeLang(this);">
  677. <option value="en-US" <?PHP echo($lang==PHP_EN?"selected":"");?>>en</option>
  678. <option value="it-IT" <?PHP echo($lang==PHP_IT?"selected":"");?>>it</option>
  679. <option value="zh-CN" <?PHP echo($lang==PHP_CN?"selected":"");?>>cn</option>
  680. </select>
  681. </div>
  682. <span style="background:#FFFFFF; opacity:0.7;">&nbsp;&nbsp;A <a href="http://5mode.com" class="aaa">5 Mode</a> project and <a href="http://demo.5mode.com" class="aaa">WYSIWYG</a> system. <?PHP echo(getResource0("Some rights reserved", $lang));?>.</span></div>
  683. <?PHP endif; ?>
  684. <script src="/js/home-js.php?hl=<?PHP echo($lang);?>&av=<?PHP echo(AVATAR_NAME);?>&cv=<?PHP echo($CURRENT_VIEW);?>&cu=<?PHP echo($CUDOZ);?>" type="text/javascript"></script>
  685. <?PHP if ($CURRENT_VIEW == PUBLIC_VIEW): ?>
  686. <!-- SKINNER CODE -->
  687. <?php if (is_readable($AVATAR_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  688. <?php include($AVATAR_PATH . DIRECTORY_SEPARATOR . "skinner.html"); ?>
  689. <?php else: ?>
  690. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  691. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html"); ?>
  692. <?php endif; ?>
  693. <?php endif; ?>
  694. <!-- METRICS CODE -->
  695. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  696. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  697. <?php endif; ?>
  698. <?php endif; ?>
  699. </body>
  700. </html>