home.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  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'])) {
  87. if (!empty($_FILES['filesdd']['tmp_name'][0])) {
  88. //no file uploaded
  89. //$uploads = (array)fixMultipleFileUpload($_FILES['files']);
  90. //if ($uploads[0]['error'] === UPLOAD_ERR_NO_FILE) {
  91. $uploads = (array)fixMultipleFileUpload($_FILES['filesdd']);
  92. //}
  93. //if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  94. // echo("WARNING: No file uploaded.");
  95. // return;
  96. //}
  97. $google = "abcdefghijklmnopqrstuvwxyz";
  98. if (count($uploads)>strlen($google)) {
  99. echo("WARNING: Too many uploaded files.");
  100. return;
  101. }
  102. $i=1;
  103. foreach($uploads as &$upload) {
  104. switch ($upload['error']) {
  105. case PHP_UPLOAD_ERR_OK:
  106. break;
  107. case PHP_UPLOAD_ERR_NO_FILE:
  108. echo("WARNING: One or more uploaded files are missing.");
  109. return;
  110. case PHP_UPLOAD_ERR_INI_SIZE:
  111. echo("WARNING: File exceeded INI size limit.");
  112. return;
  113. case PHP_UPLOAD_ERR_FORM_SIZE:
  114. echo("WARNING: File exceeded form size limit.");
  115. return;
  116. case PHP_UPLOAD_ERR_PARTIAL:
  117. echo("WARNING: File only partially uploaded.");
  118. return;
  119. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  120. echo("WARNING: TMP dir doesn't exist.");
  121. return;
  122. case PHP_UPLOAD_ERR_CANT_WRITE:
  123. echo("WARNING: Failed to write to the disk.");
  124. return;
  125. case PHP_UPLOAD_ERR_EXTENSION:
  126. echo("WARNING: A PHP extension stopped the file upload.");
  127. return;
  128. default:
  129. echo("WARNING: Unexpected error happened.");
  130. return;
  131. }
  132. if (!is_uploaded_file($upload['tmp_name'])) {
  133. echo("WARNING: One or more file have not been uploaded.");
  134. return;
  135. }
  136. // name
  137. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  138. if ($name == PHP_STR) {
  139. echo("WARNING: Invalid file name: " . $name);
  140. return;
  141. }
  142. $upload['name'] = $name;
  143. // fileType
  144. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  145. $upload['type'] = $fileType;
  146. // tmp_name
  147. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  148. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  149. echo("WARNING: Invalid file temp path: " . $tmp_name);
  150. return;
  151. }
  152. $upload['tmp_name'] = $tmp_name;
  153. //size
  154. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  155. if ($size == "") {
  156. echo("WARNING: Invalid file size.");
  157. return;
  158. }
  159. $upload["size"] = $size;
  160. $tmpFullPath = $upload["tmp_name"];
  161. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  162. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  163. $fileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  164. $date = date("Ymd-His");
  165. $rnd = mt_rand(1000000000, 9999999999);
  166. if ($originalFileExt!==PHP_STR) {
  167. $destFileName = $date . "-" . $rnd . substr($google, $i-1, 1) . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt";
  168. } else {
  169. return;
  170. }
  171. //$CV_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "cv";
  172. //$FRIENDS_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "friends";
  173. //$BLOG_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "blog";
  174. //$GALLERY_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . "gallery";
  175. $destPaths = [];
  176. $destFullPaths = [];
  177. if ($magicJar1 != 0) {
  178. $destPaths[] = $MAGICJAR1_PATH;
  179. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  180. }
  181. if ($magicJar2 != 0) {
  182. $destPaths[] = $MAGICJAR2_PATH;
  183. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  184. }
  185. if ($magicJar3 != 0) {
  186. $destPaths[] = $MAGICJAR3_PATH;
  187. $destFullPaths[] = $destPaths[count($destPaths)-1] . DIRECTORY_SEPARATOR . $destFileName;
  188. }
  189. if (empty($destPaths)) {
  190. switch ($fileExt) {
  191. case "doc":
  192. case "docx":
  193. case "pdf":
  194. $destPaths[] = $CV_PATH;
  195. break;
  196. case "txt":
  197. $destPaths[] = $BLOG_PATH;
  198. break;
  199. case "png":
  200. case "jpg":
  201. case "jpeg":
  202. case "gif":
  203. case "webp":
  204. $destPaths[] = $GALLERY_PATH;
  205. break;
  206. default:
  207. $destPaths[] = $MAGICJAR1_PATH;
  208. break;
  209. }
  210. $destFullPaths[] = $destPaths[0] . DIRECTORY_SEPARATOR . $destFileName;
  211. }
  212. $iPath = 0;
  213. foreach($destFullPaths as $destFullPath) {
  214. if (file_exists($destFullPath)) {
  215. echo("WARNING: destination already exists");
  216. exit(1);
  217. }
  218. if (filesize($tmpFullPath) > APP_FILE_MAX_SIZE) {
  219. echo("ERROR: file size(" . filesize($tmpFullPath) . ") exceeds app limit:" . APP_FILE_MAX_SIZE);
  220. exit(1);
  221. }
  222. if (!is_readable($AVATAR_PATH)) {
  223. mkdir($AVATAR_PATH, 0777);
  224. }
  225. if (!is_readable($destPaths[$iPath])) {
  226. mkdir($destPaths[$iPath], 0777);
  227. }
  228. $pattern = $destPaths[$iPath] . DIRECTORY_SEPARATOR . "*" . "|" . str_replace(" ", "_", $originalFilename) . ".$fileExt";
  229. $aExistingPaths = glob($pattern);
  230. if (!empty($aExistingPaths)) {
  231. continue;
  232. }
  233. copy($tmpFullPath, $destFullPath);
  234. $iPath++;
  235. }
  236. // Cleaning up..
  237. // Delete the tmp file..
  238. unlink($tmpFullPath);
  239. $i++;
  240. }
  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.5mode-foss.eu,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. <img id="picavatar" src="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($profilePic);?>" align="middle">
  317. <input type="hidden" id="a" name="a">
  318. <input type="hidden" id="f" name="f">
  319. </div>
  320. <div class="tools">
  321. <div class="settingson" onclick="settingsOn();"></div>
  322. <?PHP if ($magicJar1 == 0): ?>
  323. <div class="magicjar1" style="background:url(/res/magicjar1dis.png);" onclick="setJar1On()"></div>
  324. <?PHP else: ?>
  325. <div class="magicjar1" style="background:url(/res/magicjar1.png);" onclick="setJar1Off()"></div>
  326. <?PHP endif; ?>
  327. <?PHP if ($magicJar2 == 0): ?>
  328. <div class="magicjar2" style="background:url(/res/magicjar2dis.png);" onclick="setJar2On()"></div>
  329. <?PHP else: ?>
  330. <div class="magicjar2" style="background:url(/res/magicjar2.png);" onclick="setJar2Off()"></div>
  331. <?PHP endif; ?>
  332. <?PHP if ($magicJar3 == 0): ?>
  333. <div class="magicjar3" style="background:url(/res/magicjar3dis.png);" onclick="setJar3On()"></div>
  334. <?PHP else: ?>
  335. <div class="magicjar3" style="background:url(/res/magicjar3.png);" onclick="setJar3Off()"></div>
  336. <?PHP endif; ?>
  337. <div class="settingsoff" onclick="settingsOff();"></div>
  338. </div>
  339. <input type="hidden" id="txtMagicJar1" name="txtMagicJar1" value="<?PHP echo($magicJar1);?>">
  340. <input type="hidden" id="txtMagicJar2" name="txtMagicJar2" value="<?PHP echo($magicJar2);?>">
  341. <input type="hidden" id="txtMagicJar3" name="txtMagicJar3" value="<?PHP echo($magicJar3);?>">
  342. <input type="hidden" id="Password" name="Password" value="<?PHP echo($password);?>">
  343. </form>
  344. <div id="footerCont">&nbsp;</div>
  345. <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>
  346. <?PHP else: ?>
  347. <body style="background:#dadada no-repeat; background-size: cover; background-attachment: fixed; background-position: center;">
  348. <div id="AFHint">
  349. <button type="button" class="close" aria-label="Close" onclick="closeMe(this);" style="position:relative; top:5px; left:-7px;">
  350. <span aria-hidden="true" style="color:black; font-weight:900;">&times;</span>
  351. </button>
  352. <br>
  353. <span onclick="showHowTo();"><?PHP echo(getResource0("How-to: Manage your avatars in Avatar Free", $lang));?></span>
  354. <br><br>
  355. </div>
  356. <div class="header" style="margin-top:18px;margin-bottom:18px;">
  357. <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>
  358. </div>
  359. <form id="frmUpload" role="form" method="post" action="/<?PHP echo(AVATAR_NAME);?>?hl=<?PHP echo($lang);?>" target="_self" enctype="multipart/form-data">
  360. <div id="title">
  361. <div id="avatarLogo">
  362. <img id="picavatar" src="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($profilePic);?>" align="middle" style="position:relative;display:inline;">
  363. </div>
  364. <div id="avatarName">
  365. &nbsp;<?PHP echo(strtoupper(AVATAR_NAME));?>&nbsp;&nbsp;&nbsp;
  366. </div>
  367. <div id="cudoz">
  368. <?PHP for ($i=1;$i<=$CUDOZ;$i++): ?>
  369. <img id="cudozentry<?PHP echo($i);?>" class="cudoz-entry" src="/res/chicca_<?PHP echo($shortLang);?>.png">
  370. <?PHP endfor; ?>
  371. <?PHP for ($i=$CUDOZ+1;$i<=5;$i++): ?>
  372. <img id="cudozentry<?PHP echo($i);?>" class="cudoz-entry" src="/res/chiccadis.png">
  373. <?PHP endfor; ?>
  374. </div>
  375. <div id="cvs">
  376. <div style="float:left;width:47px;margin-top:20px;margin-left:7px;"><?PHP echo(getResource0("CV", $lang));?></div>
  377. <?PHP
  378. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*";
  379. $aFilePaths = glob($pattern);
  380. if (empty($aFilePaths)): ?>
  381. <img class="cv-entry" src="/res/wordicondis.png">&nbsp;&nbsp;<img class="cv-entry" src="/res/pdficondis.png">
  382. <?PHP else: ?>
  383. <?PHP
  384. $CUDOZ++;
  385. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*.doc";
  386. $aFilePaths = glob($pattern);
  387. if (empty($aFilePaths)): ?>
  388. <img class="cv-entry" src="/res/wordicondis.png">&nbsp;&nbsp;
  389. <?PHP else: ?>
  390. <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;
  391. <?PHP endif; ?>
  392. <?PHP
  393. $pattern = $CV_PATH . DIRECTORY_SEPARATOR . "*.pdf";
  394. $aFilePaths = glob($pattern);
  395. if (empty($aFilePaths)): ?>
  396. <img class="cv-entry" src="/res/pdficondis.png">
  397. <?PHP else: ?>
  398. <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>
  399. <?PHP endif; ?>
  400. <?PHP endif; ?>
  401. </div>
  402. </div>
  403. <br>
  404. <div id="blog">
  405. <?PHP
  406. $pattern = $BLOG_PATH . DIRECTORY_SEPARATOR . "*.txt";
  407. $aFilePaths = glob($pattern);
  408. if (empty($aFilePaths)): ?>
  409. <div class="blog-content">
  410. <div class="blog-entry">
  411. <?PHP echo(getResource0("Hello from 5 Mode", $lang));?>,<br>
  412. <?PHP echo(getResource0("This is just an example of blog entry", $lang));?>.
  413. </div>
  414. </div>
  415. <?PHP else: ?>
  416. <?PHP
  417. $CUDOZ++;
  418. $iEntry = 1;
  419. $iCurEntry = 1;
  420. arsort($aFilePaths, SORT_STRING);
  421. //echo("blogSP=".$blogSP);
  422. foreach ($aFilePaths as $filePath) {
  423. //echo("iCurEntry=".$iCurEntry);
  424. if ($iCurEntry<($blogSP+1)) {
  425. $iCurEntry++;
  426. continue;
  427. }
  428. if ($iEntry>APP_BLOG_MAX_POSTS) {
  429. break;
  430. }
  431. $s=file_get_contents($filePath);
  432. if ($iEntry === count($aFilePaths) || $iEntry==APP_BLOG_MAX_POSTS) {
  433. $marginbottom = "0px";
  434. } else {
  435. $marginbottom = "5px";
  436. }
  437. ?>
  438. <div class="blog-content" style="margin-bottom:<?PHP echo($marginbottom);?>;">
  439. <div class="blog-entry" style="width:100%;margin-bottom:0px;">
  440. <?PHP echo(enableEmoticons(HTMLencode($s, true)));?>
  441. </div>
  442. </div>
  443. <?PHP
  444. $iEntry++;
  445. $iCurEntry++;
  446. }?>
  447. <?PHP endif; ?>
  448. <?PHP
  449. $totPages = (int)(count($aFilePaths)/APP_BLOG_MAX_POSTS);
  450. if ($totPages < (count($aFilePaths)/APP_BLOG_MAX_POSTS)) {
  451. $totPages++;
  452. }
  453. $firstPost = 0;
  454. $prevPost = $blogSP - APP_BLOG_MAX_POSTS;
  455. if ($prevPost < 0) {
  456. $prevPost = 0;
  457. }
  458. $nextPost = $blogSP + APP_BLOG_MAX_POSTS;
  459. if ($nextPost > (($totPages - 1) * APP_BLOG_MAX_POSTS)) {
  460. $nextPost = (($totPages - 1) * APP_BLOG_MAX_POSTS);
  461. }
  462. if ($nextPost < 0) {
  463. $nextPost = 0;
  464. }
  465. $lastPost = (($totPages - 1) * APP_BLOG_MAX_POSTS);
  466. if ($lastPost < 0) {
  467. $lastPost = 0;
  468. }
  469. ?>
  470. <?PHP if (defined("APP_PAGINATION") && APP_PAGINATION):?>
  471. <br><br>
  472. <div style="text-align:center;">
  473. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($firstPost);?>"><img src="/res/first.png" style="width:45px;"></a>
  474. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($prevPost);?>"><img src="/res/arrow-left2.png" style="width:45px;"></a>
  475. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($nextPost);?>"><img src="/res/arrow-right2.png" style="width:45px;"></a>
  476. <a href="/<?PHP echo(AVATAR_NAME); ?>/?blogSP=<?PHP echo($lastPost);?>"><img src="/res/last.png" style="width:45px;"></a>
  477. </div>
  478. <?PHP endif; ?>
  479. <br><br>
  480. </div>
  481. <div id="gallery">
  482. <div class="gallery-content">
  483. <?PHP
  484. $pattern = $GALLERY_PATH . DIRECTORY_SEPARATOR . "*";
  485. $aFilePaths = glob($pattern);
  486. if (empty($aFilePaths)): ?>
  487. <div class="image-entry">
  488. <div style="width:100%;border:0px solid black;"><img class="image-ico" src="/res/imgicon.png" align="center"></div>
  489. <div style="margin-top:10px;"><?PHP echo(getResource0("Sample", $lang));?></div>
  490. </div>
  491. <?PHP else: ?>
  492. <?PHP
  493. $CUDOZ++;
  494. $iEntry = 1;
  495. foreach ($aFilePaths as $filePath) {
  496. $orifilename = basename($filePath);
  497. $filename = explode("|",basename($filePath))[1];
  498. if ($iEntry === count($aFilePaths)) {
  499. $marginbottom = "0px";
  500. } else {
  501. $marginbottom = "5px";
  502. }
  503. ?>
  504. <div class="image-entry">
  505. <a href="/img?av=<?PHP echo(AVATAR_NAME);?>&pic=<?PHP echo($orifilename);?>">
  506. <div style="width:100%;border:0px solid black;"><img class="image-ico" src="/res/imgicon.png" align="center"></div>
  507. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  508. </a>
  509. </div>
  510. <?PHP
  511. $iEntry++;
  512. }?>
  513. <?PHP endif; ?>
  514. </div>
  515. </div>
  516. <?PHP
  517. $pattern = $MAGICJAR1_PATH . DIRECTORY_SEPARATOR . "*";
  518. $aFilePaths = glob($pattern);
  519. if (!empty($aFilePaths)): ?>
  520. <div id="magicjar1">
  521. <div class="magicjar1-content">
  522. <div class="magicjar-num">&nbsp;1&nbsp;</div>
  523. <?PHP
  524. $iEntry = 1;
  525. foreach ($aFilePaths as $filePath) {
  526. $orifilename = basename($filePath);
  527. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  528. $filename = explode("|",basename($filePath))[1];
  529. if ($iEntry === count($aFilePaths)) {
  530. $marginbottom = "0px";
  531. } else {
  532. $marginbottom = "5px";
  533. }
  534. ?>
  535. <div class="file-entry">
  536. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  537. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=1&fn=<?PHP echo($orifilename);?>">
  538. <?PHP else: ?>
  539. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=1&fn=<?PHP echo($orifilename);?>">
  540. <?PHP endif; ?>
  541. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  542. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  543. </a>
  544. </div>
  545. <?PHP
  546. $iEntry++;
  547. }?>
  548. </div>
  549. </div>
  550. <?PHP endif; ?>
  551. <?PHP
  552. $pattern = $MAGICJAR2_PATH . DIRECTORY_SEPARATOR . "*";
  553. $aFilePaths = glob($pattern);
  554. if (!empty($aFilePaths)): ?>
  555. <div id="magicjar2">
  556. <div class="magicjar2-content">
  557. <div class="magicjar-num">&nbsp;2&nbsp;</div>
  558. <?PHP
  559. $iEntry = 1;
  560. foreach ($aFilePaths as $filePath) {
  561. $orifilename = basename($filePath);
  562. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  563. $filename = explode("|",basename($filePath))[1];
  564. if ($iEntry === count($aFilePaths)) {
  565. $marginbottom = "0px";
  566. } else {
  567. $marginbottom = "5px";
  568. }
  569. ?>
  570. <div class="file-entry">
  571. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  572. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=2&fn=<?PHP echo($orifilename);?>">
  573. <?PHP else: ?>
  574. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=2&fn=<?PHP echo($orifilename);?>">
  575. <?PHP endif; ?>
  576. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  577. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  578. </a>
  579. </div>
  580. <?PHP
  581. $iEntry++;
  582. }?>
  583. </div>
  584. </div>
  585. <?PHP endif; ?>
  586. <?PHP
  587. $pattern = $MAGICJAR3_PATH . DIRECTORY_SEPARATOR . "*";
  588. $aFilePaths = glob($pattern);
  589. if (!empty($aFilePaths)): ?>
  590. <div id="magicjar3">
  591. <div class="magicjar3-content">
  592. <div class="magicjar-num">&nbsp;3&nbsp;</div>
  593. <?PHP
  594. $iEntry = 1;
  595. foreach ($aFilePaths as $filePath) {
  596. $orifilename = basename($filePath);
  597. $orifileExt = strtolower(pathinfo($orifilename, PATHINFO_EXTENSION));
  598. $filename = explode("|",basename($filePath))[1];
  599. if ($iEntry === count($aFilePaths)) {
  600. $marginbottom = "0px";
  601. } else {
  602. $marginbottom = "5px";
  603. }
  604. ?>
  605. <div class="file-entry">
  606. <?PHP if (in_array($orifileExt, ["png", "jpg", "jpeg", "gif", "webp"])):?>
  607. <a href="/imgj?av=<?PHP echo(AVATAR_NAME);?>&jar=3&fn=<?PHP echo($orifilename);?>">
  608. <?PHP else: ?>
  609. <a href="/file?av=<?PHP echo(AVATAR_NAME);?>&jar=3&fn=<?PHP echo($orifilename);?>">
  610. <?PHP endif; ?>
  611. <div style="width:100%;border:0px solid black;"><img class="file-ico" src="/res/fileicon.png" align="center"></div>
  612. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  613. </a>
  614. </div>
  615. <?PHP
  616. $iEntry++;
  617. }?>
  618. </div>
  619. </div>
  620. <?PHP endif; ?>
  621. <div id="friends">
  622. <div class="friends-content">
  623. <div id="mynetworkTitle"><?PHP echo(getResource0("My Network", $lang));?>:<br><br>
  624. <?PHP
  625. $pattern = $FRIENDS_PATH . DIRECTORY_SEPARATOR . "*.txt";
  626. $aFilePaths = glob($pattern);
  627. if (empty($aFilePaths)): ?>
  628. <div class="friend-entry">
  629. <a href="http://5mode.com">
  630. <div style="width:100%;border:0px solid black;"><img class="friend-ico" src="/res/pic1.png" align="center"></div>
  631. <div style="margin-top:10px;"><?PHP echo(getResource0("Sample", $lang));?></div>
  632. </a>
  633. </div>
  634. <?PHP else: ?>
  635. <?PHP
  636. $CUDOZ++;
  637. $iEntry = 1;
  638. foreach ($aFilePaths as $filePath) {
  639. $orifilename = basename($filePath);
  640. $link=file_get_contents($filePath);
  641. $filename = pathinfo($filePath, PATHINFO_FILENAME);
  642. if ($iEntry === count($aFilePaths)) {
  643. $marginbottom = "0px";
  644. } else {
  645. $marginbottom = "5px";
  646. }
  647. ?>
  648. <div class="friend-entry">
  649. <a href="<?PHP echo($link);?>">
  650. <div style="width:100%;border:0px solid black;"><img class="friend-ico" src="/res/pic1.png" align="center"></div>
  651. <div style="margin-top:10px;"><?PHP echo($filename);?> </div>
  652. </a>
  653. </div>
  654. <?PHP
  655. $iEntry++;
  656. }?>
  657. <?PHP endif; ?>
  658. </div>
  659. </div>
  660. </div>
  661. <div id="passworddisplay">
  662. <br>
  663. &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>
  664. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" autocomplete="off"><br>
  665. <div style="text-align:center;">
  666. <a id="hashMe" href="#" onclick="showEncodedPassword();"><?PHP echo(getResource0("Hash Me", $lang));?>!</a>
  667. </div>
  668. </div>
  669. </form>
  670. <div id="footerCont">&nbsp;</div>
  671. <div id="footer">
  672. <div style="float:left">
  673. <select id="cbLang" onchange="changeLang(this);">
  674. <option value="en-US" <?PHP echo($lang==PHP_EN?"selected":"");?>>en</option>
  675. <option value="it-IT" <?PHP echo($lang==PHP_IT?"selected":"");?>>it</option>
  676. <option value="zh-CN" <?PHP echo($lang==PHP_CN?"selected":"");?>>cn</option>
  677. </select>
  678. </div>
  679. <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>
  680. <?PHP endif; ?>
  681. <script src="/static/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>
  682. <?PHP if ($CURRENT_VIEW == PUBLIC_VIEW): ?>
  683. <!-- SKINNER CODE -->
  684. <?php if (is_readable($AVATAR_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  685. <?php include($AVATAR_PATH . DIRECTORY_SEPARATOR . "skinner.html"); ?>
  686. <?php else: ?>
  687. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  688. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html"); ?>
  689. <?php endif; ?>
  690. <?php endif; ?>
  691. <!-- METRICS CODE -->
  692. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  693. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  694. <?php endif; ?>
  695. <?php endif; ?>
  696. </body>
  697. </html>