display.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <html>
  2. <meta name="viewport" content="width=device-width, initial-scale=1">
  3. <head>
  4. <title>QuickSend</title>
  5. <link rel="stylesheet" href="tocas.css">
  6. </head>
  7. <body>
  8. <div class="ts inverted heading fluid slate" style="background-color:#2c2835;color:white;">
  9. <span class="large header">Quick Send System</span>
  10. <span class="description">Send data between mobile and laptops.<br> Powered by IMUS Laboratory</span>
  11. <div class="ts bottom attached tabbed menu" style="color:white;">
  12. <a class="item" href="index.php" style="color:#9d9ca3;">Send</a>
  13. <a class="item" href="file.php" style="color:#9d9ca3;">Files</a>
  14. <a class="item" href="rx.php" style="color:#9d9ca3;">Receive</a>
  15. <!-- <a class="item" href="img.php" style="color:#9d9ca3;">Image</a> -->
  16. <a class="active item">Display</a>
  17. </div>
  18. </div>
  19. <div class="ts container">
  20. <br><br>
  21. <div class="ts stackable grid">
  22. <div class="four wide column" align="center">
  23. <div id="output"></div>
  24. <div class="ts small statistic">
  25. <div class="label">QuickSend ID</div>
  26. <div class="value" id="sid"><?php
  27. if (isset($_GET['id']) !== False){
  28. echo '<script>var sid = parseInt("' . $_GET['id'] . '");</script>';
  29. echo $_GET['id'];
  30. $id = $_GET['id'];
  31. }else{
  32. //No input ids
  33. echo '<script>var sid = parseInt("0");</script>';
  34. echo 0;
  35. $id = 0;
  36. }
  37. ?></div>
  38. </div>
  39. </div>
  40. <div class="twelve wide column">
  41. <div class="ts fluid input" style="height:250px">
  42. <?php
  43. $memodir = "Memo/";
  44. $dataType = "TEXT";
  45. if (file_exists($memodir . $id.".txt")){
  46. $myfile = fopen($memodir . $id.".txt", "r") or die("Unable to open file!");
  47. $content = hex2bin(fread($myfile,filesize($memodir . $id.".txt")));
  48. fclose($myfile);
  49. $filetrue = true;
  50. //Process the different filetype
  51. if (strpos($content, "data:image/") !== False && strpos($content, ";base64,") !== False){
  52. //This is an image encoded in base64
  53. echo "<img class='ts centered image' src='" . $content . "'> ";
  54. echo '<a class="ts bottom right attached label" href="'.$content.'" target="_blank">View Raw</a>';
  55. echo '</img>';
  56. $dataType = "IMAGE";
  57. }else if (strpos($content, "data:file/") !== False){
  58. $filename = str_replace("data:file/","uploads/",$content);
  59. echo '<div class="ts fluid segment">';
  60. echo '<div class="ts fluid steps">
  61. <div class="step">
  62. <div class="content">
  63. <div class="title">Click the button below to download your file</div>
  64. <div class="description">Please beware that we have the permission to remove your file anytime.</div>
  65. </div>
  66. </div>
  67. </div><br>';
  68. echo '<a href="'.$filename.'" class="ts basic fluid button" download>Download</a>';
  69. echo '</div>';
  70. $dataType = "FILE";
  71. }else{
  72. echo '<textarea id="textholder" placeholder="Text to be sent via QRcode.">';
  73. echo $content;
  74. echo '</textarea>';
  75. $dataType = "TEXT";
  76. }
  77. }else{
  78. $filetrue = false;
  79. echo 'The specified Memo ID cannot be find in the database. Are you sure you entered the correct QuickSend id?';
  80. }
  81. ?>
  82. <?php
  83. if ($filetrue == true){
  84. echo '<script>var file_exists = true;</script>';
  85. }else{
  86. echo '<script>var file_exists = false;</script>';
  87. }
  88. ?>
  89. </div><br><br>
  90. <div class="ts container" align="right"><?php
  91. if($dataType == "TEXT"){
  92. echo '<button class="ts tiny basic button" onclick="action()">Open / Search</button>';
  93. echo '<button class="ts tiny basic button" onclick="copy()">Copy to Clipboard</button>';
  94. }
  95. ?>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <div style="position: fixed;
  101. z-index: 100;
  102. bottom: 0;
  103. left: 0;
  104. width: 100%;
  105. background-color:#2c2835;
  106. color:white;">
  107. <div class="ts container">
  108. <img class="ts tiny right floated image" src="img/cube.png"></img>
  109. </div>
  110. <div align="left" class="ts container">
  111. <br>
  112. CopyRight IMUS Laboratory 2021, All right reserved.
  113. </div>
  114. </div>
  115. <div id="notifybar" class="ts active bottom right snackbar" style="display:none;z-index: 101;">
  116. <div class="content" style="z-index: 102;">
  117. Your message has been copied into the clipboard.
  118. </div>
  119. </div>
  120. <br><br><br><br>
  121. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
  122. <script type="text/javascript" src="jquery.qrcode.min.js"></script>
  123. <script>
  124. jQuery(function(){
  125. if (file_exists == true){
  126. jQuery('#output').qrcode("http://imuslab.com/qs/display.php?id=" + sid);
  127. }else{
  128. jQuery('#output').qrcode("NOT FOUND");
  129. }
  130. })
  131. function copyToClipboard(elem) {
  132. // create hidden text element, if it doesn't already exist
  133. var targetId = "_hiddenCopyText_";
  134. var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
  135. var origSelectionStart, origSelectionEnd;
  136. if (isInput) {
  137. // can just use the original source element for the selection and copy
  138. target = elem;
  139. origSelectionStart = elem.selectionStart;
  140. origSelectionEnd = elem.selectionEnd;
  141. } else {
  142. // must use a temporary form element for the selection and copy
  143. target = document.getElementById(targetId);
  144. if (!target) {
  145. var target = document.createElement("textarea");
  146. target.style.position = "absolute";
  147. target.style.left = "-9999px";
  148. target.style.top = "0";
  149. target.id = targetId;
  150. document.body.appendChild(target);
  151. }
  152. target.textContent = elem.textContent;
  153. }
  154. // select the content
  155. var currentFocus = document.activeElement;
  156. target.focus();
  157. target.setSelectionRange(0, target.value.length);
  158. // copy the selection
  159. var succeed;
  160. try {
  161. succeed = document.execCommand("copy");
  162. } catch(e) {
  163. succeed = false;
  164. }
  165. // restore original focus
  166. if (currentFocus && typeof currentFocus.focus === "function") {
  167. currentFocus.focus();
  168. }
  169. if (isInput) {
  170. // restore prior selection
  171. elem.setSelectionRange(origSelectionStart, origSelectionEnd);
  172. } else {
  173. // clear temporary content
  174. target.textContent = "";
  175. }
  176. return succeed;
  177. }
  178. function copy(){
  179. copyToClipboard(document.getElementById("textholder"));
  180. $("#notifybar").fadeIn('slow').delay(3000).fadeOut('slow');
  181. }
  182. function action(){
  183. var content = $('#textholder').val();
  184. //alert(content);
  185. if (content.substr(0, 4).includes("http") || content.substr(0, 11).includes("data:image/")){
  186. //It is a url to be open
  187. window.open(content,"_blank");
  188. }else{
  189. //It is a normal text to be searched
  190. content = content.replace(" ","+");
  191. window.open("https://www.google.com.hk/?#safe=off&q=" + content,"_blank");
  192. }
  193. }
  194. </script>
  195. </body>
  196. </html>