mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-11 18:56:21 +00:00
added copy url button closes #112
This commit is contained in:
@@ -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'))
|
||||
|
||||
11
inc/core.php
11
inc/core.php
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user