Skip to content

Commit

Permalink
Track originating ID when uploading a grant (see #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
wavexx committed Jan 6, 2017
1 parent 45cf838 commit 4056242
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion htdocs/include/grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function useGrant($upload, $GRANT)
$db->beginTransaction();

$sql = "INSERT INTO ticket (id, user_id, name, path, size, cmt, pass_ph"
. ", time, last_time, expire, expire_dln, locale) VALUES (";
. ", time, last_time, expire, expire_dln, locale, from_grant) VALUES (";
$sql .= $db->quote($upload['id']);
$sql .= ", " . $GRANT['user_id'];
$sql .= ", " . $db->quote($upload["name"]);
Expand All @@ -65,6 +65,7 @@ function useGrant($upload, $GRANT)
$sql .= ", " . (empty($GRANT["expire"])? 'NULL': $GRANT['expire']);
$sql .= ", " . (empty($GRANT["expire_dln"])? 'NULL': $GRANT['expire_dln']);
$sql .= ", " . (empty($GRANT["locale"])? 'NULL': $db->quote($GRANT['locale']));
$sql .= ", " . $db->quote($GRANT['id']);
$sql .= ")";
$db->exec($sql);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/include/scripts/db/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE TABLE role (id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) UNIQ
INSERT INTO role (name, admin) VALUES('admin',1);
INSERT INTO role (name, admin) VALUES('user',0);
CREATE TABLE "user" (id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) UNIQUE NOT NULL, pass_md5 CHAR(0), pass_ph VARCHAR(60), role_id INTEGER not null REFERENCES role (id), email VARCHAR(255));
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255));
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255), from_grant CHAR(32));
CREATE TABLE "grant" (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), grant_expire INTEGER, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255));
CREATE INDEX i_ticket on ticket ( expire, expire_dln, downloads );
CREATE INDEX i_grant on "grant" ( grant_expire );
2 changes: 1 addition & 1 deletion htdocs/include/scripts/db/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CREATE TABLE role (id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, adm
INSERT INTO role (name, admin) VALUES('admin',TRUE);
INSERT INTO role (name, admin) VALUES('user',FALSE);
CREATE TABLE "user" (id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, pass_md5 VARCHAR(1), pass_ph VARCHAR(60), role_id INTEGER not null REFERENCES role (id), email VARCHAR(255)) WITHOUT OIDS;
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 VARCHAR(1), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255)) WITHOUT OIDS;
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 VARCHAR(1), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255), from_grant CHAR(32)) WITHOUT OIDS;
CREATE TABLE "grant" (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), grant_expire INTEGER, cmt VARCHAR(1023), pass_md5 VARCHAR(1), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255)) WITHOUT OIDS;
CREATE INDEX i_ticket on ticket ( expire, expire_dln, downloads );
CREATE INDEX i_grant on "grant" ( grant_expire );
2 changes: 1 addition & 1 deletion htdocs/include/scripts/db/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CREATE TABLE role (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) UNIQU
INSERT INTO role (name, admin) VALUES('admin',1);
INSERT INTO role (name, admin) VALUES('user',0);
CREATE TABLE "user" (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) UNIQUE NOT NULL, pass_md5 CHAR(0), pass_ph VARCHAR(60), role_id INTEGER not null REFERENCES role (id), email VARCHAR(255));
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255));
CREATE TABLE ticket (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), name VARCHAR(1023) NOT NULL, path VARCHAR(1023) NOT NULL, size INTEGER NOT NULL, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_stamp INTEGER, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255), from_grant CHAR(32));
CREATE TABLE "grant" (id CHAR(32) PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES "user" (id), grant_expire INTEGER, cmt VARCHAR(1023), pass_md5 CHAR(0), pass_ph VARCHAR(60), time INTEGER NOT NULL, downloads INTEGER NOT NULL DEFAULT 0, last_time INTEGER, expire INTEGER, expire_dln INTEGER, notify_email VARCHAR(1023), sent_email VARCHAR(1023), locale VARCHAR(255));
CREATE INDEX i_ticket on ticket ( expire, expire_dln, downloads );
CREATE INDEX i_grant on "grant" ( grant_expire );
1 change: 1 addition & 0 deletions htdocs/include/scripts/dbupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
$db->exec("UPDATE ticket SET expire = expire - time");
$db->exec("UPDATE grant SET expire = expire - time");
$db->exec("UPDATE grant SET grant_expire = grant_expire - time");
$db->exec("ALTER TABLE ticket ADD from_grant CHAR(32)");
$db->exec("UPDATE config SET value = '0.18' WHERE name = 'version'");

$version = "0.18";
Expand Down

0 comments on commit 4056242

Please sign in to comment.