123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <html>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <head>
- <title>QuickSend</title>
- <link rel="stylesheet" href="tocas.css">
- </head>
- <body>
- <div class="ts inverted heading fluid slate" style="background-color:#2c2835;color:white;">
- <span class="large header">Quick Send System</span>
- <span class="description">Send data between mobile and laptops.<br> Powered by IMUS Laboratory</span>
- <div class="ts bottom attached tabbed menu" style="color:white;">
- <a class="item" href="index.php" style="color:#9d9ca3;">Send</a>
- <a class="item" href="file.php" style="color:#9d9ca3;">Files</a>
- <a class="item" href="rx.php" style="color:#9d9ca3;">Receive</a>
- <!-- <a class="item" href="img.php" style="color:#9d9ca3;">Image</a> -->
- <a class="active item">Display</a>
- </div>
- </div>
- <div class="ts container">
- <br><br>
- <div class="ts stackable grid">
- <div class="four wide column" align="center">
- <div id="output"></div>
- <div class="ts small statistic">
- <div class="label">QuickSend ID</div>
- <div class="value" id="sid"><?php
- if (isset($_GET['id']) !== False){
- echo '<script>var sid = parseInt("' . $_GET['id'] . '");</script>';
- echo $_GET['id'];
- $id = $_GET['id'];
- }else{
- //No input ids
- echo '<script>var sid = parseInt("0");</script>';
- echo 0;
- $id = 0;
- }
- ?></div>
- </div>
- </div>
- <div class="twelve wide column">
- <div class="ts fluid input" style="height:250px">
- <?php
- $memodir = "Memo/";
- $dataType = "TEXT";
- if (file_exists($memodir . $id.".txt")){
- $myfile = fopen($memodir . $id.".txt", "r") or die("Unable to open file!");
- $content = hex2bin(fread($myfile,filesize($memodir . $id.".txt")));
- fclose($myfile);
- $filetrue = true;
- //Process the different filetype
- if (strpos($content, "data:image/") !== False && strpos($content, ";base64,") !== False){
- //This is an image encoded in base64
- echo "<img class='ts centered image' src='" . $content . "'> ";
- echo '<a class="ts bottom right attached label" href="'.$content.'" target="_blank">View Raw</a>';
- echo '</img>';
- $dataType = "IMAGE";
- }else if (strpos($content, "data:file/") !== False){
- $filename = str_replace("data:file/","uploads/",$content);
- echo '<div class="ts fluid segment">';
- echo '<div class="ts fluid steps">
- <div class="step">
- <div class="content">
- <div class="title">Click the button below to download your file</div>
- <div class="description">Please beware that we have the permission to remove your file anytime.</div>
- </div>
- </div>
- </div><br>';
- echo '<a href="'.$filename.'" class="ts basic fluid button" download>Download</a>';
- echo '</div>';
- $dataType = "FILE";
-
- }else{
- echo '<textarea id="textholder" placeholder="Text to be sent via QRcode.">';
- echo $content;
- echo '</textarea>';
- $dataType = "TEXT";
- }
- }else{
- $filetrue = false;
- echo 'The specified Memo ID cannot be find in the database. Are you sure you entered the correct QuickSend id?';
-
- }
- ?>
- <?php
- if ($filetrue == true){
- echo '<script>var file_exists = true;</script>';
- }else{
- echo '<script>var file_exists = false;</script>';
- }
- ?>
- </div><br><br>
- <div class="ts container" align="right"><?php
- if($dataType == "TEXT"){
- echo '<button class="ts tiny basic button" onclick="action()">Open / Search</button>';
- echo '<button class="ts tiny basic button" onclick="copy()">Copy to Clipboard</button>';
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <div style="position: fixed;
- z-index: 100;
- bottom: 0;
- left: 0;
- width: 100%;
- background-color:#2c2835;
- color:white;">
- <div class="ts container">
- <img class="ts tiny right floated image" src="img/cube.png"></img>
- </div>
- <div align="left" class="ts container">
- <br>
- CopyRight IMUS Laboratory 2021, All right reserved.
- </div>
- </div>
- <div id="notifybar" class="ts active bottom right snackbar" style="display:none;z-index: 101;">
- <div class="content" style="z-index: 102;">
- Your message has been copied into the clipboard.
- </div>
- </div>
- <br><br><br><br>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
- <script type="text/javascript" src="jquery.qrcode.min.js"></script>
- <script>
- jQuery(function(){
- if (file_exists == true){
- jQuery('#output').qrcode("http://imuslab.com/qs/display.php?id=" + sid);
- }else{
- jQuery('#output').qrcode("NOT FOUND");
- }
- })
- function copyToClipboard(elem) {
- // create hidden text element, if it doesn't already exist
- var targetId = "_hiddenCopyText_";
- var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
- var origSelectionStart, origSelectionEnd;
- if (isInput) {
- // can just use the original source element for the selection and copy
- target = elem;
- origSelectionStart = elem.selectionStart;
- origSelectionEnd = elem.selectionEnd;
- } else {
- // must use a temporary form element for the selection and copy
- target = document.getElementById(targetId);
- if (!target) {
- var target = document.createElement("textarea");
- target.style.position = "absolute";
- target.style.left = "-9999px";
- target.style.top = "0";
- target.id = targetId;
- document.body.appendChild(target);
- }
- target.textContent = elem.textContent;
- }
- // select the content
- var currentFocus = document.activeElement;
- target.focus();
- target.setSelectionRange(0, target.value.length);
-
- // copy the selection
- var succeed;
- try {
- succeed = document.execCommand("copy");
- } catch(e) {
- succeed = false;
- }
- // restore original focus
- if (currentFocus && typeof currentFocus.focus === "function") {
- currentFocus.focus();
- }
-
- if (isInput) {
- // restore prior selection
- elem.setSelectionRange(origSelectionStart, origSelectionEnd);
- } else {
- // clear temporary content
- target.textContent = "";
- }
- return succeed;
- }
- function copy(){
- copyToClipboard(document.getElementById("textholder"));
- $("#notifybar").fadeIn('slow').delay(3000).fadeOut('slow');
- }
- function action(){
- var content = $('#textholder').val();
- //alert(content);
- if (content.substr(0, 4).includes("http") || content.substr(0, 11).includes("data:image/")){
- //It is a url to be open
- window.open(content,"_blank");
- }else{
- //It is a normal text to be searched
- content = content.replace(" ","+");
- window.open("https://www.google.com.hk/?#safe=off&q=" + content,"_blank");
- }
- }
- </script>
- </body>
- </html>
|