mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-04-09 06:18:01 +02:00
add upload history and nginx accel download
This commit is contained in:
parent
cfba9975c5
commit
f3e9434793
@ -1,5 +0,0 @@
|
||||
{
|
||||
"require": {
|
||||
"php-ffmpeg/php-ffmpeg": "~0.5"
|
||||
}
|
||||
}
|
@ -8,5 +8,6 @@
|
||||
/* GENERAL SETTINGS */
|
||||
define('_DEFAULT_TYPE', 'application/octet-stream');
|
||||
define('_SITEURL', 'http://example.com/');
|
||||
define('_FILEPATH', dirname ( __FILE__ ) . '/out/');
|
||||
define('_UPLOADDIR', '/out/');
|
||||
define('_FILEPATH', dirname ( __FILE__ ) . _UPLOADDIR);
|
||||
?>
|
||||
|
25
download2.php
Normal file
25
download2.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
function XFastDownload($location, $filename, $mimeType = 'application/octet-stream')
|
||||
{
|
||||
$url = "https://www.google-analytics.com/collect";
|
||||
$payload = "v=1&tid=UA-73200448-1&cid=" . session_id() . "&t=pageview&dh=" . $_SERVER['HTTP_HOST'] . "&dp=" . urlencode($_SERVER['REQUEST_URI']) . "&uip=" . $_SERVER['REMOTE_ADDR'] . "&ua=" . urlencode($_SERVER["HTTP_USER_AGENT"]) . "&dr=" . urlencode($_SERVER["HTTP_REFERER"]);
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_exec($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
$expire = 604800;
|
||||
|
||||
header("X-Accel-Redirect: $location");
|
||||
header("Cache-Control: public, max-age=$expire");
|
||||
header("Content-type: $mimeType");
|
||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||
}
|
||||
?>
|
36
index.php
36
index.php
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
//check for view param otherwise return file
|
||||
$hash = isset($_GET["hash"]) ? substr($_GET["hash"], strrpos($_GET["hash"], '/') + 1) : null;
|
||||
if(!isset($_GET["v"]) && $hash != null)
|
||||
@ -8,20 +10,9 @@
|
||||
$db = new DB();
|
||||
$f = $db->GetFile($hash);
|
||||
if($f->id != 0){
|
||||
include_once('download.php');
|
||||
smartReadFile($f->path, $f->filename, $f->mime);
|
||||
}
|
||||
|
||||
exit;
|
||||
}else if(isset($_GET["thumb"]) && $hash != null)
|
||||
{
|
||||
include_once('db.php');
|
||||
|
||||
$db = new DB();
|
||||
$f = $db->GetFile($hash);
|
||||
if($f->id != 0){
|
||||
include_once('download.php');
|
||||
smartReadFile($f->path . '/thumb/', $f->filename, $f->mime);
|
||||
include_once('download2.php');
|
||||
|
||||
$db->AddView($f->hash160);
|
||||
}
|
||||
|
||||
exit;
|
||||
@ -113,6 +104,10 @@
|
||||
echo "<div id=\"uploads\" style=\"display: none\"></div><div id=\"upload\">Drop Files < " . $maxsizeM . "</div>";
|
||||
}
|
||||
?>
|
||||
<div id="history">
|
||||
<h3>Your Uploads</h3>
|
||||
<small>History is saved in <a style="display: initial; padding: initial; margin: initial;" href="https://www.w3schools.com/html/html5_webstorage.asp">localStorage</a> <b style="cursor: pointer; user-select: none;" onclick="localStorage.setItem('history', ''); window.location.reload();">(clear)</b></small>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<a href="https://github.com/v0l/void.cat">Github</a>
|
||||
| <a href="https://twitter.com/chkn10deez">Twitter</a>
|
||||
@ -129,5 +124,18 @@
|
||||
ga('create', 'UA-73200448-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
<script>
|
||||
var h = loadHistory();
|
||||
var hl = document.querySelector('#history');
|
||||
for(var x = h.length - 1; x >= 0; x--) {
|
||||
var hx = h[x];
|
||||
var nh = document.createElement('a');
|
||||
nh.href = hx.link + '&v';
|
||||
nh.target = '_blank'
|
||||
nh.text = (hx.filename === null ? 'clipboard' : hx.filename);
|
||||
|
||||
hl.appendChild(nh);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -140,6 +140,18 @@ video {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#history {
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 2px solid #eee;
|
||||
background-color: rgba(238, 238, 238, 0.18);
|
||||
}
|
||||
|
||||
#history a {
|
||||
display: block;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* MEDIA OVERWRITE QUERIES */
|
||||
@media (max-width: 720px) {
|
||||
#main {
|
||||
@ -173,4 +185,4 @@ video {
|
||||
video {
|
||||
max-height: 720px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,25 @@ function addPasteFunctions()
|
||||
document.addEventListener('paste', handleFilePaste, false);
|
||||
}
|
||||
|
||||
function loadHistory(){
|
||||
var hist = localStorage.getItem("history");
|
||||
if(hist.length > 0) {
|
||||
hist = JSON.parse(hist);
|
||||
} else {
|
||||
hist = [];
|
||||
}
|
||||
|
||||
return hist;
|
||||
}
|
||||
|
||||
function saveToHistory(r){
|
||||
var hist = loadHistory();
|
||||
|
||||
hist[hist.length] = r;
|
||||
|
||||
localStorage.setItem("history", JSON.stringify(hist));
|
||||
}
|
||||
|
||||
function uploadComplete(rsp, id, s)
|
||||
{
|
||||
var upl = $('#' + id);
|
||||
@ -99,6 +118,9 @@ function uploadComplete(rsp, id, s)
|
||||
+ '<br/><small><b>Hash256:</b> ' + rsp.hash
|
||||
+ '</small><br/><small><b>Hash160:</b> ' + rsp.publichash + '</small>'
|
||||
+ '<br/><small><a target=\"_blank\" href=\"//' + lk + '&v\">(link)</a></small>';
|
||||
|
||||
//save to history
|
||||
saveToHistory(rsp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@
|
||||
$response["hash"] = $fh;
|
||||
rewind($tmpf);
|
||||
|
||||
$response["filename"] = $fname;
|
||||
|
||||
//check for dupes
|
||||
$f_e = $db->Exists256($fh);
|
||||
if($f_e->id != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user