Files
OpenLog/distfiles-old/settings.php

64 lines
2.0 KiB
PHP

<?php
/*
settings.php
OpenLog Online Logbook
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
// determine today's date and time and assign them to variables
$today = date("Y-m-d");
$now = date("H:i:s");
$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0];
$ostype = strtoupper(substr(php_uname('s'), 0, 3));
if ($ostype == 'WIN') {
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0];
} else {
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
}
$lifetime = 60 * 60 * 24 * $sttl;
if (!is_dir($sdir)) mkdir($sdir, 0700, true);
ini_set('session.cookie_lifetime', $lifetime);
ini_set('session.gc_maxlifetime', $lifetime);
ini_set('session.save_path', $sdir);
$ss = session_status();
if ($ss == PHP_SESSION_NONE) session_start();
// get config options from database and assign them to constants
unset($techid);
if (isset($_SESSION['login']) && $_SESSION['login'] != '') {
$techid = $_SESSION['login'];
}
$configqry = mysqli_query($db, "select confname,confvalue,confid from configs");
while ($configrow = mysqli_fetch_assoc($configqry)) {
$constname = strtoupper($configrow["confname"]);
if (isset($techid)) {
$confid = $configrow["confid"];
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
if (mysqli_num_rows($custqry)) {
$custrow = mysqli_fetch_row($custqry);
$custval = $custrow[0];
} else {
unset($custval);
}
}
if (isset($custval)) {
$constvalue = $custval;
} else {
$constvalue = $configrow["confvalue"];
}
define("$constname", "$constvalue");
}
// error reporting
$logerrors = LOG_ERRORS;
if ($logerrors == 1) {
error_reporting(E_ALL);
} else {
error_reporting(0);
}