// Copyright: Copyright (C) 2002-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/cgiemu.inc.php"; // get_or_post: whether the form data came from $_GET or $_POST function &get_or_post() { if ($_SERVER["REQUEST_METHOD"] == "POST") { return $_POST; } else { return $_GET; } } // curform: Obtain the current form, either from the sent form or // from the suspended form function &curform() { $FORM =& get_or_post(); if ( defined("USE_SUSPEND_FORM") && USE_SUSPEND_FORM && array_key_exists("formid", $FORM)) { $FORM =& retrieve_form(); } return $FORM; } // is_form: If a form is requested function is_form($isform = null) { // Cache the result static $cache; // Use "isform" to alter the cache if (!is_null($isform)) { // A status is provided if (is_array($isform)) { if (array_key_exists("isform", $isform)) { $cache = $isform["isform"]; settype($cache, "boolean"); } // A scalar value } else { $cache = $isform; 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("form", $FORM)) { $cache = false; return $cache; } // "isform" was specified $status =& retrieve_status(); if (is_array($status) && array_key_exists("isform", $status)) { $cache = $status["isform"]; return $cache; } // Yes, we need a form here $cache = true; return $cache; } // form_type: Return the form name (new, cur, del, listpref... etc) function form_type($type = null) { // Cache the result static $cache; // Set the form type if (!is_null($type)) { $cache = $type; } // Return the cache if (isset($cache)) { return $cache; } // Obtain the current form $FORM =& curform(); // Form type specified in arguments if (array_key_exists("form", $FORM)) { $cache = $FORM["form"]; // No form source is found } else { $cache = null; } return $cache; } // form_step: Return the form step number function form_step($step = null) { // Cache the result static $cache; // Set the form step if (!is_null($step)) { $cache = $step; } // Return the cache if (isset($cache)) { return $cache; } // Obtain the current form $FORM =& curform(); // Form type specified in arguments if (array_key_exists("step", $FORM)) { $cache = $FORM["step"]; // No form source is found } else { $cache = 1; } // Steps that are not sane are considered as 1 if (!is_int($cache)) { // Text strings may be convertable if (is_string($cache)) { if (preg_match("/^\d+$/", $cache)) { // Convert its type to integer settype($cache, "integer"); } else { $cache = 1; } // Others are not convertable } else { $cache = 1; } } // "nextstep" specified $status =& retrieve_status(); if ( is_array($status) && array_key_exists("nextstep", $status) && $status["nextstep"]) { $cache++; } return $cache; } ?>