mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Remove all usage of UNIX_TIMESTAMP in web interface
UNIX_TIMESTAMP is not part of the SQL standard. Instead, all usage in the web interface is changed to use PHP's time() function. Signed-off-by: Mark Weiman <mark.weiman@markzz.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
c3f464f50f
commit
3e442a0f7d
4 changed files with 16 additions and 16 deletions
|
@ -543,7 +543,7 @@ function try_login() {
|
||||||
|
|
||||||
$new_sid = new_sid();
|
$new_sid = new_sid();
|
||||||
$q = "INSERT INTO Sessions (UsersID, SessionID, LastUpdateTS)"
|
$q = "INSERT INTO Sessions (UsersID, SessionID, LastUpdateTS)"
|
||||||
." VALUES (" . $userID . ", '" . $new_sid . "', UNIX_TIMESTAMP())";
|
." VALUES (" . $userID . ", '" . $new_sid . "', " . strval(time()) . ")";
|
||||||
$result = $dbh->exec($q);
|
$result = $dbh->exec($q);
|
||||||
|
|
||||||
/* Query will fail if $new_sid is not unique. */
|
/* Query will fail if $new_sid is not unique. */
|
||||||
|
@ -560,7 +560,7 @@ function try_login() {
|
||||||
return array('SID' => $new_sid, 'error' => $login_error);
|
return array('SID' => $new_sid, 'error' => $login_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = "UPDATE Users SET LastLogin = UNIX_TIMESTAMP(), ";
|
$q = "UPDATE Users SET LastLogin = " . strval(time()) . ", ";
|
||||||
$q.= "LastLoginIPAddress = " . $dbh->quote($_SERVER['REMOTE_ADDR']) . " ";
|
$q.= "LastLoginIPAddress = " . $dbh->quote($_SERVER['REMOTE_ADDR']) . " ";
|
||||||
$q.= "WHERE ID = $userID";
|
$q.= "WHERE ID = $userID";
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
|
@ -638,7 +638,7 @@ function valid_username($user) {
|
||||||
function open_user_proposals($user) {
|
function open_user_proposals($user) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = "SELECT * FROM TU_VoteInfo WHERE User = " . $dbh->quote($user) . " ";
|
$q = "SELECT * FROM TU_VoteInfo WHERE User = " . $dbh->quote($user) . " ";
|
||||||
$q.= "AND End > UNIX_TIMESTAMP()";
|
$q.= "AND End > " . strval(time());
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
|
|
||||||
return ($result->fetchColumn() ? true : false);
|
return ($result->fetchColumn() ? true : false);
|
||||||
|
@ -665,7 +665,7 @@ function add_tu_proposal($agenda, $user, $votelength, $quorum, $submitteruid) {
|
||||||
$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, Quorum, ";
|
$q = "INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End, Quorum, ";
|
||||||
$q.= "SubmitterID, ActiveTUs) VALUES ";
|
$q.= "SubmitterID, ActiveTUs) VALUES ";
|
||||||
$q.= "(" . $dbh->quote($agenda) . ", " . $dbh->quote($user) . ", ";
|
$q.= "(" . $dbh->quote($agenda) . ", " . $dbh->quote($user) . ", ";
|
||||||
$q.= "UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + " . $dbh->quote($votelength);
|
$q.= strval(time()) . ", " . strval(time()) . " + " . $dbh->quote($votelength);
|
||||||
$q.= ", " . $dbh->quote($quorum) . ", " . $submitteruid . ", ";
|
$q.= ", " . $dbh->quote($quorum) . ", " . $submitteruid . ", ";
|
||||||
$q.= $active_tus . ")";
|
$q.= $active_tus . ")";
|
||||||
$result = $dbh->exec($q);
|
$result = $dbh->exec($q);
|
||||||
|
@ -978,7 +978,7 @@ function clear_expired_sessions() {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
$timeout = config_get_int('options', 'login_timeout');
|
$timeout = config_get_int('options', 'login_timeout');
|
||||||
$q = "DELETE FROM Sessions WHERE LastUpdateTS < (UNIX_TIMESTAMP() - " . $timeout . ")";
|
$q = "DELETE FROM Sessions WHERE LastUpdateTS < (" . strval(time()) . " - " . $timeout . ")";
|
||||||
$dbh->query($q);
|
$dbh->query($q);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1086,7 +1086,7 @@ function last_votes_list() {
|
||||||
|
|
||||||
$q = "SELECT UserID, MAX(VoteID) AS LastVote FROM TU_Votes, ";
|
$q = "SELECT UserID, MAX(VoteID) AS LastVote FROM TU_Votes, ";
|
||||||
$q .= "TU_VoteInfo, Users WHERE TU_VoteInfo.ID = TU_Votes.VoteID AND ";
|
$q .= "TU_VoteInfo, Users WHERE TU_VoteInfo.ID = TU_Votes.VoteID AND ";
|
||||||
$q .= "TU_VoteInfo.End < UNIX_TIMESTAMP() AND ";
|
$q .= "TU_VoteInfo.End < " . strval(time()) . " AND ";
|
||||||
$q .= "Users.ID = TU_Votes.UserID AND (Users.AccountTypeID = 2 OR Users.AccountTypeID = 4) ";
|
$q .= "Users.ID = TU_Votes.UserID AND (Users.AccountTypeID = 2 OR Users.AccountTypeID = 4) ";
|
||||||
$q .= "GROUP BY UserID ORDER BY LastVote DESC, UserName ASC";
|
$q .= "GROUP BY UserID ORDER BY LastVote DESC, UserName ASC";
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
|
|
|
@ -38,7 +38,7 @@ function check_sid() {
|
||||||
# the visitor is logged in, try and update the session
|
# the visitor is logged in, try and update the session
|
||||||
#
|
#
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = "SELECT LastUpdateTS, UNIX_TIMESTAMP() FROM Sessions ";
|
$q = "SELECT LastUpdateTS, " . strval(time()) . " FROM Sessions ";
|
||||||
$q.= "WHERE SessionID = " . $dbh->quote($_COOKIE["AURSID"]);
|
$q.= "WHERE SessionID = " . $dbh->quote($_COOKIE["AURSID"]);
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
$row = $result->fetch(PDO::FETCH_NUM);
|
$row = $result->fetch(PDO::FETCH_NUM);
|
||||||
|
@ -77,7 +77,7 @@ function check_sid() {
|
||||||
# This keeps 'remembered' sessions from being
|
# This keeps 'remembered' sessions from being
|
||||||
# overwritten.
|
# overwritten.
|
||||||
if ($last_update < time() + $timeout) {
|
if ($last_update < time() + $timeout) {
|
||||||
$q = "UPDATE Sessions SET LastUpdateTS = UNIX_TIMESTAMP() ";
|
$q = "UPDATE Sessions SET LastUpdateTS = " . strval(time()) . " ";
|
||||||
$q.= "WHERE SessionID = " . $dbh->quote($_COOKIE["AURSID"]);
|
$q.= "WHERE SessionID = " . $dbh->quote($_COOKIE["AURSID"]);
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ function pkgbase_add_comment($base_id, $uid, $comment) {
|
||||||
$q = "INSERT INTO PackageComments ";
|
$q = "INSERT INTO PackageComments ";
|
||||||
$q.= "(PackageBaseID, UsersID, Comments, CommentTS) VALUES (";
|
$q.= "(PackageBaseID, UsersID, Comments, CommentTS) VALUES (";
|
||||||
$q.= intval($base_id) . ", " . $uid . ", ";
|
$q.= intval($base_id) . ", " . $uid . ", ";
|
||||||
$q.= $dbh->quote($comment) . ", UNIX_TIMESTAMP())";
|
$q.= $dbh->quote($comment) . ", " . strval(time()) . ")";
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
$comment_id = $dbh->lastInsertId();
|
$comment_id = $dbh->lastInsertId();
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ function pkgbase_pin_comment($unpin=false) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = "UPDATE PackageComments ";
|
$q = "UPDATE PackageComments ";
|
||||||
if (!$unpin) {
|
if (!$unpin) {
|
||||||
$q.= "SET PinnedTS = UNIX_TIMESTAMP() ";
|
$q.= "SET PinnedTS = " . strval(time()) . " ";
|
||||||
} else {
|
} else {
|
||||||
$q.= "SET PinnedTS = 0 ";
|
$q.= "SET PinnedTS = 0 ";
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ function pkgbase_flag($base_ids, $comment) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
$q = "UPDATE PackageBases SET ";
|
$q = "UPDATE PackageBases SET ";
|
||||||
$q.= "OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid . ", ";
|
$q.= "OutOfDateTS = " . strval(time()) . ", FlaggerUID = " . $uid . ", ";
|
||||||
$q.= "FlaggerComment = " . $dbh->quote($comment) . " ";
|
$q.= "FlaggerComment = " . $dbh->quote($comment) . " ";
|
||||||
$q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
|
$q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
|
||||||
$q.= "AND OutOfDateTS IS NULL";
|
$q.= "AND OutOfDateTS IS NULL";
|
||||||
|
@ -749,12 +749,12 @@ function pkgbase_vote ($base_ids, $action=true) {
|
||||||
$first = 0;
|
$first = 0;
|
||||||
$vote_ids = $pid;
|
$vote_ids = $pid;
|
||||||
if ($action) {
|
if ($action) {
|
||||||
$vote_clauses = "($uid, $pid, UNIX_TIMESTAMP())";
|
$vote_clauses = "($uid, $pid, " . strval(time()) . ")";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$vote_ids .= ", $pid";
|
$vote_ids .= ", $pid";
|
||||||
if ($action) {
|
if ($action) {
|
||||||
$vote_clauses .= ", ($uid, $pid, UNIX_TIMESTAMP())";
|
$vote_clauses .= ", ($uid, $pid, " . strval(time()) . ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -972,7 +972,7 @@ function pkgbase_delete_comment($undelete=false) {
|
||||||
|
|
||||||
$q = "UPDATE PackageComments ";
|
$q = "UPDATE PackageComments ";
|
||||||
$q.= "SET DelUsersID = ".$uid.", ";
|
$q.= "SET DelUsersID = ".$uid.", ";
|
||||||
$q.= "DelTS = UNIX_TIMESTAMP() ";
|
$q.= "DelTS = " . strval(time()) . " ";
|
||||||
$q.= "WHERE ID = ".intval($comment_id);
|
$q.= "WHERE ID = ".intval($comment_id);
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
return array(true, __("Comment has been deleted."));
|
return array(true, __("Comment has been deleted."));
|
||||||
|
@ -1005,7 +1005,7 @@ function pkgbase_edit_comment($comment) {
|
||||||
$q = "UPDATE PackageComments ";
|
$q = "UPDATE PackageComments ";
|
||||||
$q.= "SET EditedUsersID = ".$uid.", ";
|
$q.= "SET EditedUsersID = ".$uid.", ";
|
||||||
$q.= "Comments = ".$dbh->quote($comment).", ";
|
$q.= "Comments = ".$dbh->quote($comment).", ";
|
||||||
$q.= "EditedTS = UNIX_TIMESTAMP() ";
|
$q.= "EditedTS = " . strval(time()) . " ";
|
||||||
$q.= "WHERE ID = ".intval($comment_id);
|
$q.= "WHERE ID = ".intval($comment_id);
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
return array(true, __("Comment has been edited."));
|
return array(true, __("Comment has been edited."));
|
||||||
|
|
|
@ -149,7 +149,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
|
||||||
$q.= "UsersID, Comments, RequestTS) VALUES (" . $type_id . ", ";
|
$q.= "UsersID, Comments, RequestTS) VALUES (" . $type_id . ", ";
|
||||||
$q.= $base_id . ", " . $dbh->quote($pkgbase_name) . ", ";
|
$q.= $base_id . ", " . $dbh->quote($pkgbase_name) . ", ";
|
||||||
$q.= $dbh->quote($merge_into) . ", " . $uid . ", ";
|
$q.= $dbh->quote($merge_into) . ", " . $uid . ", ";
|
||||||
$q.= $dbh->quote($comments) . ", UNIX_TIMESTAMP())";
|
$q.= $dbh->quote($comments) . ", " . strval(time()) . ")";
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
$request_id = $dbh->lastInsertId();
|
$request_id = $dbh->lastInsertId();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue