scratch
/file.php |
@@ -86,6 +86,27 @@ |
#### Store the file. |
$timestamp = atomized_put_contents($userPath.'.'.$fileExtension, $data); |
|
### Log IP address. |
$db = new PDO('sqlite:db/scratch.sqlite3'); |
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
try { |
$db->beginTransaction(); |
|
## Create tags table if it does not exist. |
$db->query('CREATE TABLE IF NOT EXISTS "uploaders" ("hash" text NOT NULL COLLATE NOCASE, "ip" text COLLATE NOCASE, UNIQUE("hash") ON CONFLICT REPLACE)'); |
|
$q = $db->prepare('REPLACE INTO "uploaders" ("hash", "ip") VALUES(:hash, :ip)'); |
$q->bindParam(':hash', $file); |
$q->bindParam(':ip', $_SERVER['REMOTE_ADDR']); |
$q->execute(); |
|
$db->commit(); |
} catch (Exception $e) { |
error_log($e); |
## Rollback. |
$db->rollback(); |
} |
|
### Process any sent tags. |
if(isset($_POST['tags'])) { |
$tags = json_decode( |