scratch – Diff between revs 128 and 140
?pathlinks?
Rev 128 | Rev 140 | |||
---|---|---|---|---|
Line 84... | Line 84... | |||
84 | } |
84 | } |
|
Line 85... | Line 85... | |||
85 | |
85 | |
|
86 | #### Store the file. |
86 | #### Store the file. |
|
Line -... | Line 87... | |||
- | 87 | $timestamp = atomized_put_contents($userPath.'.'.$fileExtension, $data); |
||
- | 88 | |
||
- | 89 | ### Log IP address. |
||
- | 90 | $db = new PDO('sqlite:db/scratch.sqlite3'); |
||
- | 91 | $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
- | 92 | try { |
||
- | 93 | $db->beginTransaction(); |
||
- | 94 | |
||
- | 95 | ## Create tags table if it does not exist. |
||
- | 96 | $db->query('CREATE TABLE IF NOT EXISTS "uploaders" ("hash" text NOT NULL COLLATE NOCASE, "ip" text COLLATE NOCASE, UNIQUE("hash") ON CONFLICT REPLACE)'); |
||
- | 97 | |
||
- | 98 | $q = $db->prepare('REPLACE INTO "uploaders" ("hash", "ip") VALUES(:hash, :ip)'); |
||
- | 99 | $q->bindParam(':hash', $file); |
||
- | 100 | $q->bindParam(':ip', $_SERVER['REMOTE_ADDR']); |
||
- | 101 | $q->execute(); |
||
- | 102 | |
||
- | 103 | $db->commit(); |
||
- | 104 | } catch (Exception $e) { |
||
- | 105 | error_log($e); |
||
- | 106 | ## Rollback. |
||
- | 107 | $db->rollback(); |
||
87 | $timestamp = atomized_put_contents($userPath.'.'.$fileExtension, $data); |
108 | } |
|
88 | |
109 | |
|
89 | ### Process any sent tags. |
110 | ### Process any sent tags. |
|
90 | if(isset($_POST['tags'])) { |
111 | if(isset($_POST['tags'])) { |
|
91 | $tags = json_decode( |
112 | $tags = json_decode( |