From f9d6eb33122fe779af90bbba038e741e4b4fe823 Mon Sep 17 00:00:00 2001 From: nokonoko Date: Thu, 31 Oct 2013 01:33:32 +0100 Subject: gyazo uploader --- blackniggers/kittens.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 blackniggers/kittens.php (limited to 'blackniggers') diff --git a/blackniggers/kittens.php b/blackniggers/kittens.php new file mode 100644 index 0000000..e9b81e6 --- /dev/null +++ b/blackniggers/kittens.php @@ -0,0 +1,52 @@ +prepare("SELECT hash, filename FROM files WHERE hash = (:hash)"); + $do->bindParam(':hash', $filehash); + $do->execute(); + $result = $do->fetch(); + $con = null; + if($result[0]==$filehash){ + echo 'http://a.pomf.se/' . $result[1]; + }else{ + $catshit = hash_file('crc32b', $_FILES['imagedata']['tmp_name']); + $newName = generate_name($_FILES['imagedata']['name'], $catshit); + $delid = sha1($_FILES['imagedata']['tmp_name']); + //Insert info into DB + $con = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=XXX', 'XXX', 'XXX'); + $do = $con->prepare("INSERT INTO files (hash, orginalname, filename, size, date, expire, delid) VALUES (:hash, :orginname, :filename, :size, :date, :expire, :delid)"); + $do->bindParam(':hash', $filehash); + $do->bindParam(':orginname', $_FILES['imagedata']['name']); + $do->bindParam(':filename', $newName); + $do->bindParam(':size', $_FILES['imagedata']['size']); + $do->bindParam(':date', date('Y-m-d')); + $do->bindParam(':expire', $expire); + $do->bindParam(':delid', $delid); + $do->execute(); + $con = null; +$hurr = '/mnt/disk1/pomf/files/' . $newName; +move_uploaded_file($_FILES['imagedata']['tmp_name'], $hurr); +echo 'http://a.pomf.se/' . $newName; +} +} +?> -- cgit v1.2.3