added copy url button closes #112

This commit is contained in:
Christian Haschek
2022-03-08 22:23:57 +01:00
parent ef1a1ecaff
commit 6f540ad27e
3 changed files with 9 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
<?php
// basic path definitions
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).'/..');
define('ROOT', dirname(__FILE__).DS.'..');
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))

View File

@@ -346,13 +346,13 @@ function getTypeOfFile($url)
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
{
$content_type = exec("file -bi " . escapeshellarg($url));
if($content_type && $content_type!=$type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
if($content_type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
$type = $content_type;
}
else
{
$fi = new finfo(FILEINFO_MIME);
$type = $fi->buffer(file_get_contents($url, false, null, -1, 1024));
//for windows we'll use mime_content_type. Make sure you have enabled the "exif" extension in php.ini
$type = mime_content_type($url);
}
if(!$type) return false;
if(startsWith($type,'text')) return 'text';
@@ -431,7 +431,10 @@ function getUserIP()
// checks the list of uploaded files for this hash
function sha1Exists($sha1)
{
$handle = fopen(ROOT.DS.'data'.DS.'sha1.csv', "r");
$shafile = ROOT.DS.'data'.DS.'sha1.csv';
if(!file_exists($shafile)) touch($shafile);
$handle = fopen($shafile, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if(substr($line,0,40)===$sha1) return trim(substr($line,41));

View File

@@ -14,7 +14,7 @@ $(function() {
{
var o = JSON.parse(response);
if(o.status=='ok')
$("#uploadinfo").append("<div class='alert alert-success' role='alert'><strong>"+file.name+"</strong> uploaded as <a target='_blank' href='/"+o.hash+"'>"+o.hash+"</a><br/>URL: <a target='_blank' href='"+o.url+"'>"+o.url+"</a></div>")
$("#uploadinfo").append("<div class='alert alert-success' role='alert'><strong>"+file.name+"</strong> uploaded as <a target='_blank' href='/"+o.hash+"'>"+o.hash+"</a><br/>URL: <a target='_blank' href='"+o.url+"'>"+o.url+"</a> <button class='btn btn-xs' onClick='navigator.clipboard.writeText(\""+o.url+"\");'>Copy URL</button></div>")
else if(o.status=='err')
$("#uploadinfo").append("<div class='alert alert-danger' role='alert'><strong>Error uploading "+file.name+"</strong><br/>Reason: "+o.reason+"</div>")
console.log(o)