forked from Kieran/void.cat
add expire
This commit is contained in:
parent
4432e840d1
commit
0c725bb02e
41
db.php
41
db.php
@ -17,7 +17,7 @@
|
|||||||
{
|
{
|
||||||
if($this->error == null)
|
if($this->error == null)
|
||||||
{
|
{
|
||||||
$this->mysqli->close();
|
$this->mysqli->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,12 +25,12 @@
|
|||||||
{
|
{
|
||||||
$res = new FileUpload();
|
$res = new FileUpload();
|
||||||
|
|
||||||
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created from files where hash256 = ? limit 1");
|
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created, expire from files where hash256 = ? limit 1");
|
||||||
if($stmt)
|
if($stmt)
|
||||||
{
|
{
|
||||||
$stmt->bind_param("s", $hash);
|
$stmt->bind_param("s", $hash);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($res->id, $res->hash160, $res->hash256, $res->mime, $res->path, $res->filename, $res->views, $res->created);
|
$stmt->bind_result($res->id, $res->hash160, $res->hash256, $res->mime, $res->path, $res->filename, $res->views, $res->created, $res->expire);
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
@ -42,12 +42,12 @@
|
|||||||
{
|
{
|
||||||
$res = new FileUpload();
|
$res = new FileUpload();
|
||||||
|
|
||||||
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created from files where hash160 = ? limit 1");
|
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created, expire from files where hash160 = ? limit 1");
|
||||||
if($stmt)
|
if($stmt)
|
||||||
{
|
{
|
||||||
$stmt->bind_param("s", $hash);
|
$stmt->bind_param("s", $hash);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($res->id, $res->hash160, $res->hash256, $res->mime, $res->path, $res->filename, $res->views, $res->created);
|
$stmt->bind_result($res->id, $res->hash160, $res->hash256, $res->mime, $res->path, $res->filename, $res->views, $res->created, $res->expire);
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
@ -55,16 +55,16 @@
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetFiles()
|
function GetFiles()
|
||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
|
|
||||||
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created from files");
|
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created, expire from files");
|
||||||
if($stmt)
|
if($stmt)
|
||||||
{
|
{
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($id, $hash160, $hash256, $mime, $path, $filename, $views, $created);
|
$stmt->bind_result($id, $hash160, $hash256, $mime, $path, $filename, $views, $created, $expire);
|
||||||
while($stmt->fetch()){
|
while($stmt->fetch()){
|
||||||
$nf = new FileUpload();
|
$nf = new FileUpload();
|
||||||
$nf->id = $id;
|
$nf->id = $id;
|
||||||
$nf->hash160 = $hash160;
|
$nf->hash160 = $hash160;
|
||||||
@ -74,14 +74,15 @@
|
|||||||
$nf->filename = $filename;
|
$nf->filename = $filename;
|
||||||
$nf->views = $views;
|
$nf->views = $views;
|
||||||
$nf->created = $created;
|
$nf->created = $created;
|
||||||
|
$nf->expire = $expire;
|
||||||
|
|
||||||
array_push($res, $nf);
|
array_push($res, $nf);
|
||||||
}
|
}
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function InsertFile($f)
|
function InsertFile($f)
|
||||||
{
|
{
|
||||||
@ -96,7 +97,7 @@
|
|||||||
|
|
||||||
function AddView($hash160)
|
function AddView($hash160)
|
||||||
{
|
{
|
||||||
$stmt = $this->mysqli->prepare("update files set views = views + 1 where hash160 = ?");
|
$stmt = $this->mysqli->prepare("update files set views = views + 1, expire = DATE_ADD(NOW(), INTERVAL 30 DAY) where hash160 = ?");
|
||||||
if($stmt)
|
if($stmt)
|
||||||
{
|
{
|
||||||
$stmt->bind_param("s", $hash160);
|
$stmt->bind_param("s", $hash160);
|
||||||
|
1
file.php
1
file.php
@ -8,6 +8,7 @@
|
|||||||
public $filename;
|
public $filename;
|
||||||
public $views;
|
public $views;
|
||||||
public $created;
|
public $created;
|
||||||
|
public $expire;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileUploadStats {
|
class FileUploadStats {
|
||||||
|
13
index.php
13
index.php
@ -13,8 +13,7 @@
|
|||||||
include_once('download2.php');
|
include_once('download2.php');
|
||||||
XFastDownload(_UPLOADDIR . $f->hash160, $f->filename, $f->mime);
|
XFastDownload(_UPLOADDIR . $f->hash160, $f->filename, $f->mime);
|
||||||
|
|
||||||
if(!isset($_SERVER["HTTP_RANGE"]))
|
if(!isset($_SERVER['HTTP_RANGE'])){
|
||||||
{
|
|
||||||
$db->AddView($f->hash160);
|
$db->AddView($f->hash160);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,18 +115,10 @@
|
|||||||
<a href="https://github.com/v0l/void.cat">Github</a>
|
<a href="https://github.com/v0l/void.cat">Github</a>
|
||||||
| <a href="https://twitter.com/chkn10deez">Twitter</a>
|
| <a href="https://twitter.com/chkn10deez">Twitter</a>
|
||||||
| Hosting: <?php echo explode("\t", exec("du -sh " . _FILEPATH))[0]; ?>
|
| Hosting: <?php echo explode("\t", exec("du -sh " . _FILEPATH))[0]; ?>
|
||||||
|
<br/><small>Files expire in 30 days if not viewed</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="public/main.js"></script>
|
<script src="public/main.js"></script>
|
||||||
<script>
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
||||||
|
|
||||||
ga('create', 'UA-73200448-1', 'auto');
|
|
||||||
ga('send', 'pageview');
|
|
||||||
</script>
|
|
||||||
<script>
|
<script>
|
||||||
var h = loadHistory();
|
var h = loadHistory();
|
||||||
var hl = document.querySelector('#history');
|
var hl = document.querySelector('#history');
|
||||||
|
Loading…
Reference in New Issue
Block a user