private function get_current_user($sessID) { $sess = new session($sessID); if ($sess->Started()) { $person = new person(); $person->load_current_user($sess->Get("personID")); // update session_started, which affects session lifetime $sess->Save(); return $person; } }
function get_url() { global $sess; $sess or $sess = new session(); $url = "project/project.php?projectID=" . $this->get_id(); if ($sess->Started()) { $url = $sess->url(SCRIPT_PATH . $url); // This for urls that are emailed } else { static $prefix; $prefix or $prefix = config::get_config_item("allocURL"); $url = $prefix . $url; } return $url; }
function get_url($absolute = false, $id = false) { global $sess; $sess or $sess = new session(); $id or $id = $this->get_id(); $url = "task/task.php?taskID=" . $id; if ($sess->Started() && !$absolute) { $url = $sess->url(SCRIPT_PATH . $url); // This for urls that are emailed } else { static $prefix; $prefix or $prefix = config::get_config_item("allocURL"); $url = $prefix . $url; } return $url; }
$TPL["current_date"] = date("Y-m-d H:i:s"); $TPL["today"] = date("Y-m-d"); // The default From: email address if (config::get_config_item("AllocFromEmailAddress")) { define("ALLOC_DEFAULT_FROM_ADDRESS", add_brackets(config::get_config_item("AllocFromEmailAddress"))); } // The default email bounce address define("ALLOC_DEFAULT_RETURN_PATH_ADDRESS", config::get_config_item("allocEmailAdmin")); // If a script has NO_AUTH enabled, then it will perform its own // authentication. And will be responsible for setting up any of: // $current_user and $sess. if (!defined("NO_AUTH")) { $current_user =& singleton("current_user", new person()); $sess = new session(); // If session hasn't been started re-direct to login page if (!$sess->Started()) { defined("NO_REDIRECT") && exit("Session expired. Please <a href='" . $TPL["url_alloc_login"] . "'>log in</a> again."); alloc_redirect($TPL["url_alloc_login"] . ($_SERVER['REQUEST_URI'] != '/' ? '?forward=' . urlencode($_SERVER['REQUEST_URI']) : '')); // Else load up the current_user and continue } else { if ($sess->Get("personID")) { $current_user->load_current_user($sess->Get("personID")); } } } // Setup all the urls require_once ALLOC_MOD_DIR . "shared" . DIRECTORY_SEPARATOR . "global_tpl_values.inc.php"; $TPL = get_alloc_urls($TPL, $sess); // Add user's navigation to quick list dropdown if (is_object($current_user) && $current_user->get_id()) { $history = new history();
* along with allocPSA. If not, see <http://www.gnu.org/licenses/>. */ define("NO_AUTH", 1); require_once "../alloc.php"; $sess = new session(); if (isset($_POST["forwardUrl"])) { $url = $_POST["forwardUrl"]; } else { if (isset($_GET["forward"])) { $url = $_GET["forward"]; } else { $url = $sess->GetUrl($TPL["url_alloc_home"]); } } // If we already have a session if ($sess->Started()) { alloc_redirect($url); exit; // Else log the user in } else { if ($_POST["login"]) { $person = new person(); $row = $person->get_valid_login_row($_POST["username"], $_POST["password"]); if ($row) { $sess->Start($row); $q = prepare("UPDATE person SET lastLoginDate = '%s' WHERE personID = %d", date("Y-m-d H:i:s"), $row["personID"]); $db = new db_alloc(); $db->query($q); if ($sess->TestCookie()) { $sess->UseCookie(); $sess->SetTestCookie($_POST["username"]);