// Copyright: Copyright (C) 2006-2007 Pristine Communications // Set the include path if (!defined("INCPATH_SET")) { require_once dirname(__FILE__) . "/incpath.inc.php"; } // Referenced subroutines require_once "monica/callform.inc.php"; require_once "monica/chkfunc.inc.php"; require_once "monica/formfunc.inc.php"; require_once "monica/gettext.inc.php"; require_once "monica/guest.inc.php"; require_once "monica/sql.inc.php"; // Settings if (!defined("USER_REQ_EXPIRE")) { define("USER_REQ_EXPIRE", 72); } // fetch_curreq: Fetch the current request function fetch_curreq() { // The error status static $error = null; // Fetched before if (array_key_exists("REQUEST", $GLOBALS)) { return $error; } // Obtain the current form $FORM =& curform(); // No item specified if (!array_key_exists("req", $FORM)) { $error = array("msg"=>NC_("Please specify the request."), "isform"=>false); return $error; } $sn =& $FORM["req"]; // Find the record if (!check_sn($sn)) { $error = array("msg"=>NC_("Invalid request S/N: %s."), "margs"=>array($FORM["req"]), "isform"=>false); return $error; } $cols = array(); $select = "SELECT * FROM userreq WHERE sn=$sn;\n"; $result = sql_query($select); if (sql_num_rows($result) != 1) { $error = array("msg"=>NC_("Invalid request S/N: %s."), "margs"=>array($FORM["req"]), "isform"=>false); return $error; } $row = sql_fetch_assoc($result); // Obtain the request arguments $row["_args"] = $row["args"]; parse_str($row["_args"], $row["args"]); // Obtain the user information if (!is_null($row["usr"])) { $row["_usr"] = $row["usr"]; $select = "SELECT * FROM users WHERE sn=" . $row["_usr"] . ";\n"; $result = sql_query($select); $row["usr"] = sql_fetch_assoc($result); } // Local extension if (function_exists("fetch_curreq_script")) { $row = fetch_curreq_script($row); } $GLOBALS["REQUEST"] = $row; is_form(true); if ( !array_key_exists("step", curform()) && array_key_exists("step", $row["args"])) { form_step($row["args"]["step"]); } // OK return null; } // is_userreq: If a request is requested function is_userreq($isreq = null) { // Cache the result static $cache; // Use "isreq" to alter the cache if (!is_null($isreq)) { // A status is provided if (is_array($isreq)) { if (array_key_exists("isreq", $isreq)) { $cache = $isreq["isreq"]; settype($cache, "boolean"); } // A scalar value } else { $cache = $isreq; settype($cache, "boolean"); } } // Return the cache if (isset($cache)) { return $cache; } // Obtain the current form $FORM =& curform(); // No valid form infomation if (!array_key_exists("req", $FORM)) { $cache = false; return $cache; } // "isreq" was specified $status =& retrieve_status(); if (is_array($status) && array_key_exists("isreq", $status)) { $cache = $status["isreq"]; return $cache; } // Yes, we have a request here $cache = true; return $cache; } // expire_userreq: Expire user requests function expire_userreq() { $delete = "DELETE FROM userreq" . " WHERE expire IS NOT NULL" . " AND expire