mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-04-09 07:38:01 +02:00
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)
|
||||
{
|
||||
$this->mysqli->close();
|
||||
$this->mysqli->close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +25,12 @@
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$stmt->bind_param("s", $hash);
|
||||
$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->close();
|
||||
}
|
||||
@ -42,12 +42,12 @@
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$stmt->bind_param("s", $hash);
|
||||
$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->close();
|
||||
}
|
||||
@ -55,16 +55,16 @@
|
||||
return $res;
|
||||
}
|
||||
|
||||
function GetFiles()
|
||||
{
|
||||
$res = array();
|
||||
function GetFiles()
|
||||
{
|
||||
$res = array();
|
||||
|
||||
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created from files");
|
||||
if($stmt)
|
||||
{
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $hash160, $hash256, $mime, $path, $filename, $views, $created);
|
||||
while($stmt->fetch()){
|
||||
$stmt = $this->mysqli->prepare("select id, hash160, hash256, mime, path, filename, views, created, expire from files");
|
||||
if($stmt)
|
||||
{
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $hash160, $hash256, $mime, $path, $filename, $views, $created, $expire);
|
||||
while($stmt->fetch()){
|
||||
$nf = new FileUpload();
|
||||
$nf->id = $id;
|
||||
$nf->hash160 = $hash160;
|
||||
@ -74,14 +74,15 @@
|
||||
$nf->filename = $filename;
|
||||
$nf->views = $views;
|
||||
$nf->created = $created;
|
||||
|
||||
$nf->expire = $expire;
|
||||
|
||||
array_push($res, $nf);
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function InsertFile($f)
|
||||
{
|
||||
@ -96,7 +97,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
$stmt->bind_param("s", $hash160);
|
||||
|
1
file.php
1
file.php
@ -8,6 +8,7 @@
|
||||
public $filename;
|
||||
public $views;
|
||||
public $created;
|
||||
public $expire;
|
||||
}
|
||||
|
||||
class FileUploadStats {
|
||||
|
13
index.php
13
index.php
@ -13,8 +13,7 @@
|
||||
include_once('download2.php');
|
||||
XFastDownload(_UPLOADDIR . $f->hash160, $f->filename, $f->mime);
|
||||
|
||||
if(!isset($_SERVER["HTTP_RANGE"]))
|
||||
{
|
||||
if(!isset($_SERVER['HTTP_RANGE'])){
|
||||
$db->AddView($f->hash160);
|
||||
}
|
||||
}
|
||||
@ -116,18 +115,10 @@
|
||||
<a href="https://github.com/v0l/void.cat">Github</a>
|
||||
| <a href="https://twitter.com/chkn10deez">Twitter</a>
|
||||
| Hosting: <?php echo explode("\t", exec("du -sh " . _FILEPATH))[0]; ?>
|
||||
<br/><small>Files expire in 30 days if not viewed</small>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
var h = loadHistory();
|
||||
var hl = document.querySelector('#history');
|
||||
|
Loading…
x
Reference in New Issue
Block a user