index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <?php
  2. include '../auth.php';
  3. if (!defined('PHP_VERSION_ID')) {
  4. $version = explode('.', PHP_VERSION);
  5. define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <meta name="apple-mobile-web-app-capable" content="yes" />
  10. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=0.6, maximum-scale=0.6"/>
  11. <html>
  12. <head>
  13. <link rel="manifest" href="manifest.json">
  14. <script type='text/javascript' charset='utf-8'>
  15. // Hides mobile browser's address bar when page is done loading.
  16. window.addEventListener('load', function(e) {
  17. setTimeout(function() { window.scrollTo(0, 1); }, 1);
  18. }, false);
  19. </script>
  20. <meta charset="UTF-8">
  21. <script src="../script/jquery.min.js"></script>
  22. <link rel="stylesheet" href="../script/tocas/tocas.css">
  23. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  24. <script type='text/javascript' src="../script/ao_module.js"></script>
  25. <title>ArOZ Onlineβ</title>
  26. <style>
  27. body{
  28. background-color: #f7f7f7;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <nav id="topMenu" class="ts attached inverted borderless normal menu">
  34. <div class="ts narrow container">
  35. <a href="../" class="item">ArOZ Onlineβ</a>
  36. </div>
  37. </nav>
  38. <!-- Main Header-->
  39. <?php
  40. //random image selector
  41. if (isset($_GET['folder']) && $_GET['folder'] != ""){
  42. $folder = $_GET['folder'];
  43. $imagesDir = 'storage/' . $folder ."/";
  44. }else{
  45. $imagesDir = 'uploads/';
  46. }
  47. if (isset($_GET['filepath']) && $_GET['filename']){
  48. header("Location: embedded.php?filename=" . $_GET['filename'] . "&filepath=" . $_GET['filepath']);
  49. }
  50. $images = glob($imagesDir . '*.{jpg,jpeg,png}', GLOB_BRACE);
  51. if (sizeof($images) == 0){
  52. array_push($images,'img/std_background.png');
  53. }
  54. $randomImage = $images[array_rand($images)];
  55. //Handle pwa request
  56. $pwa = "false";
  57. if (isset($_GET['pwa']) && $_GET['pwa'] == "enabled"){
  58. $pwa = "true";
  59. }
  60. ?>
  61. <div class="ts center aligned borderless attached very padded segment" style="background-image:url(<?php echo $randomImage;?>);background-size: cover; background-position: center; ">
  62. <div class="ts narrow container">
  63. <br>
  64. <div style="background:rgba(0,0,0,0.5);border-radius: 25px;">
  65. <div class="ts massive header" style="color:white">
  66. Photo Station
  67. <div class="sub header" style="color:white">
  68. Share your photo with your friends and family
  69. </div>
  70. </div>
  71. </div>
  72. <br>
  73. <a onClick="uploadImage();" class="ts labeled icon button">
  74. <i class="upload icon"></i>
  75. Upload
  76. </a>
  77. <a onClick="openImageManager();" class="ts right labeled icon button">
  78. Manage
  79. <i class="folder open icon"></i>
  80. </a>
  81. <br>
  82. <br>
  83. </div>
  84. </div>
  85. <div class="ts attached pointing secondary menu">
  86. <!-- Dropdown Menu -->
  87. <div class="ts dropdown labeled icon button" style="width:200px">
  88. <i class="folder icon"></i>
  89. <span id="folderdir" class="text">Loading...</span>
  90. <div class="menu">
  91. <div class="header">
  92. <i class="folder open icon"></i> uploads/
  93. </div>
  94. <?php
  95. $dirs = array_filter(glob('storage/*'), 'is_dir');
  96. //check if defined folder path
  97. if (isset($_GET['folder']) && $_GET['folder'] != ""){
  98. $folderpath = $_GET['folder'];
  99. }else{
  100. $folderpath = "";
  101. }
  102. //Check if defined search keyword
  103. if (isset($_GET['search']) && $_GET['search'] != ""){
  104. $keyword = $_GET['search'];
  105. }else{
  106. $keyword = "";
  107. }
  108. if ($folderpath == ""){
  109. echo '<a class="active item" Onclick="changeFolderView(0)">Unsorted</a>';
  110. }else{
  111. echo '<a class="item" Onclick="changeFolderView(0)">Unsorted</a>';
  112. }
  113. echo '<div class="divider"></div>';
  114. echo '<div class="header">
  115. <i class="folder open icon"></i> storage/
  116. </div>';
  117. foreach ($dirs as $folder){
  118. $folder = str_replace("storage/","",$folder);
  119. if ($folderpath == $folder){
  120. if(ctype_xdigit($folder)){
  121. echo "<a class='active item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".hex2bin($folder).'</a>';
  122. }else{
  123. echo "<a class='active item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".$folder.'</a>';
  124. }
  125. }else{
  126. if(ctype_xdigit($folder)){
  127. echo "<a class='item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".hex2bin($folder).'</a>';
  128. }else{
  129. echo "<a class='item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".$folder.'</a>';
  130. }
  131. }
  132. }
  133. ?>
  134. </div>
  135. </div>
  136. <div class="ts icon buttons">
  137. <button id="sort1" class="ts button active" Onclick="changeSortMethod(1);"><i class="sort alphabet ascending icon"></i></button>
  138. <button id="sort2" class="ts button" Onclick="changeSortMethod(2);"><i class="sort alphabet descending icon"></i></button>
  139. <button id="dlbtn" class="ts button" onClick="downloadmode();"><i class="download icon"></i></button>
  140. <?php
  141. if (file_exists("../QuickSend/")){
  142. echo '<button class="ts button" onClick="shareThis();"><i class="share alternate icon"></i></button>';
  143. }else{
  144. echo '<button class="ts disabled button"><i class="share alternate icon"></i></button>';
  145. }
  146. ?>
  147. <!-- <button class="ts button" onClick="shareThis();"><i class="share alternate icon"></i></button> -->
  148. </div>
  149. <div class="right fitted item">
  150. <div class="ts borderless right icon input">
  151. <input id="searchbar" type="text" placeholder="Search...">
  152. <i class="search icon"></i>
  153. </div>
  154. </div>
  155. </div>
  156. <div id="contentFrame" class="ts center aligned attached vertically very padded secondary segment">
  157. <div class="ts narrow container">
  158. <div class="ts stackable five flatted cards">
  159. <?php
  160. $template = '<div class="ts card">
  161. <div class="image">
  162. <img src="genthumb.php?src=%FILE_PATH%&size=%3C480" OnClick="TogglePreview('."'".'%IMGAGE_PATH%'."'".')">
  163. </div>
  164. <div class="left aligned content">
  165. <div class="description">%UPLOAD_DATA%</div>
  166. </div>
  167. </div>';
  168. //Scan all image within dir
  169. if (isset($_GET['folder']) && $_GET['folder'] != ""){
  170. $files = glob("storage/".$_GET['folder'].'/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
  171. }else{
  172. $files = glob('uploads/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
  173. }
  174. //Sort the file accordingly
  175. if (isset($_GET['sort']) && $_GET['sort'] != ""){
  176. $sortmode = $_GET['sort'];
  177. if ($_GET['sort'] = 'reverse'){
  178. rsort($files);
  179. }
  180. }else{
  181. $sortmode = "";
  182. sort($files);
  183. }
  184. $count = 0;
  185. $path2name = [];
  186. foreach($files as $file) {
  187. if ($keyword != ""){
  188. //There are set keyword for search
  189. $ext = pathinfo($file, PATHINFO_EXTENSION);
  190. if(substr(basename($file),0,6) === "inith"){
  191. $filename = str_replace("." . $inith,"",str_replace("inith","",basename($file)));
  192. $filename = hex2bin($filename);
  193. }else{
  194. $filename = basename($file);
  195. }
  196. if (strpos(strtolower($filename),strtolower($keyword)) !== False){
  197. //echo $file . "<br>";
  198. $box = str_replace("%FILE_PATH%",$file,$template);
  199. $box = str_replace("%UPLOAD_DATA%",$filename,$box);
  200. $box = str_replace("%IMGAGE_PATH%",$file,$box);
  201. echo $box;
  202. $count += 1;
  203. array_push($path2name,[$file,$filename . "." .$ext]);
  204. }
  205. }else{
  206. $ext = pathinfo($file, PATHINFO_EXTENSION);
  207. if(substr(basename($file),0,6) === "inith"){
  208. $filename = str_replace("." . $inith,"",str_replace("inith","",basename($file)));
  209. $filename = hex2bin($filename);
  210. }else{
  211. $filename = basename($file);
  212. }
  213. //echo $file . "<br>";
  214. $box = str_replace("%FILE_PATH%",$file,$template);
  215. $box = str_replace("%UPLOAD_DATA%",$filename,$box);
  216. $box = str_replace("%IMGAGE_PATH%",$file,$box);
  217. echo $box;
  218. $count += 1;
  219. array_push($path2name,[$file,$filename. "." .$ext]);
  220. }
  221. }
  222. if ($count == 0){
  223. //No result found.
  224. $box = str_replace("%FILE_PATH%","img/no_img_found.png",$template);
  225. $uploadmsg = "<div align='center'><a class='ts button' onClick='uploadImage();'>Upload</a></div>";
  226. $box = str_replace("%IMGAGE_PATH%","img/no_img_found.png",$box);
  227. $box = str_replace("%UPLOAD_DATA%",$uploadmsg,$box);
  228. echo $box;
  229. }
  230. ?>
  231. </div>
  232. </div>
  233. </div>
  234. <!--Notification Bar -->
  235. <div id="nbar" class="ts bottom right active snackbar" style="display:none;">
  236. <div id="nbartxt" class="content">
  237. Download Mode Enabled.
  238. </div>
  239. <a class="primary action" Onclick="downloadmode()">Toggle</a>
  240. </div>
  241. <!-- Image Preview Window -->
  242. <div id="imagePreview" align="center" style="z-index: 99; display:none;">
  243. <div style="position:fixed;
  244. top:0;
  245. left:0 !important;;
  246. height:100%;
  247. width:100%;
  248. z-index: 100;
  249. background:rgba(0,0,0,0.3);
  250. boarder:0px;" OnClick="TogglePreview()">
  251. <div class="ts active dimmer"></div>
  252. </div>
  253. <!-- Close Button -->
  254. <div style="position:fixed;
  255. z-index: 101;
  256. top:100px;
  257. background-color:#383838;
  258. top:0;left:0;
  259. ">
  260. <button OnClick="TogglePreview(0);" class="ts big close button"></button>
  261. </div>
  262. <!-- Preview Image -->
  263. <div id="previewImageDiv" align="center" style="position:fixed;
  264. z-index: 101;
  265. top:70px;
  266. left:0;
  267. color:white;
  268. max-height:100%;
  269. //background:rgba(0,0,0,0.5);
  270. ">
  271. <img id="previewingImage" class="ts massive image" src="img/std_background.png"><br>
  272. <div id="previewImagetxt" align="center"><i class="image icon"></i>Loading...</div>
  273. </div>
  274. </div>
  275. <!-- Bottom Bar -->
  276. <div class="ts bottom attached segment">
  277. <div class="ts narrow container">
  278. <br>
  279. <div class="ts large header">
  280. ArOZ Online Beta Photo Station
  281. <div class="smaller sub header">
  282. CopyRight IMUS Laboratory, 2016-2020<br>
  283. You are using PHP <?php echo PHP_VERSION_ID; ?>, Recommmend version was >=70404
  284. </div>
  285. </div>
  286. <br>
  287. </div>
  288. </div>
  289. <div id="DATA_PIPELINE_pwa" style="display:none;"><?php echo $pwa;?></div>
  290. <div id="DATA_PIPELINE_folder_path" style="display:none;"><?php echo $folderpath;?></div>
  291. <div id="DATA_PIPELINE_search_keyword" style="display:none;"><?php echo $keyword;?></div>
  292. <div id="DATA_PIPELINE_sort_mode" style="display:none;"><?php echo $sortmode;?></div>
  293. <div id="DATA_PIPELINE_path2name" style="display:none;"><?php echo json_encode($path2name); ?></div>
  294. <script>
  295. </script>
  296. <script>
  297. </script>
  298. <script src="index.js"></script>
  299. </body>
  300. </html>