summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-10-24 08:31:47 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-10-24 10:03:54 +0200
commit76343fb91511b9f53e58b6c01b258bfe00ddb4c6 (patch)
tree60eb4d3727bae159a1807915a58348b210ead206 /web/lib/aur.inc.php
parenta0a523070847230565c2ad5993ee058ff475a8e1 (diff)
downloadaur-76343fb91511b9f53e58b6c01b258bfe00ddb4c6.tar.gz
aur-76343fb91511b9f53e58b6c01b258bfe00ddb4c6.tar.xz
Use an INI-style configuration file
Replace web/lib/config.inc.php with an INI-style configuration file. This allows us to get rid of several globals and makes it easier to use the same configuration file in external scripts. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 81cbf694..c4a1705a 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -10,12 +10,12 @@ date_default_timezone_set('UTC');
include_once('translator.inc.php');
set_lang();
-include_once("config.inc.php");
include_once("DB.class.php");
include_once("routing.inc.php");
include_once("version.inc.php");
include_once("acctfuncs.inc.php");
include_once("cachefuncs.inc.php");
+include_once("confparser.inc.php");
include_once("credentials.inc.php");
/**
@@ -26,16 +26,15 @@ include_once("credentials.inc.php");
* session timeout if it is still valid.
*
* @global array $_COOKIE User cookie values
- * @global string $LOGIN_TIMEOUT Time until session times out
*
* @return void
*/
function check_sid() {
global $_COOKIE;
- global $LOGIN_TIMEOUT;
if (isset($_COOKIE["AURSID"])) {
$failed = 0;
+ $timeout = config_get_int('options', 'login_timeout');
# the visitor is logged in, try and update the session
#
$dbh = DB::connect();
@@ -50,7 +49,7 @@ function check_sid() {
$failed = 1;
} else {
$last_update = $row[0];
- if ($last_update + $LOGIN_TIMEOUT <= $row[1]) {
+ if ($last_update + $timeout <= $row[1]) {
$failed = 2;
}
}
@@ -73,11 +72,11 @@ function check_sid() {
# and update the idle timestamp
# Only update the timestamp if it is less than the
- # current time plus $LOGIN_TIMEOUT.
+ # current time plus $timeout.
#
# This keeps 'remembered' sessions from being
# overwritten.
- if ($last_update < time() + $LOGIN_TIMEOUT) {
+ if ($last_update < time() + $timeout) {
$q = "UPDATE Sessions SET LastUpdateTS = UNIX_TIMESTAMP() ";
$q.= "WHERE SessionID = " . $dbh->quote($_COOKIE["AURSID"]);
$dbh->exec($q);
@@ -274,8 +273,6 @@ function uid_from_sid($sid="") {
* @return void
*/
function html_header($title="", $details=array()) {
- global $AUR_LOCATION;
- global $DISABLE_HTTP_LOGIN;
global $LANG;
global $SUPPORTED_LANGS;
@@ -588,3 +585,16 @@ function array_pkgbuild_merge($pkgbase_info, $section_info) {
function bound($n, $min, $max) {
return min(max($n, $min), $max);
}
+
+/**
+ * Return the URL of the AUR root
+ *
+ * @return string The URL of the AUR root
+ */
+function aur_location() {
+ $location = config_get('options', 'aur_location');
+ if (substr($location, -1) != '/') {
+ $location .= '/';
+ }
+ return $location;
+}