sajax_remote_uri = $this->sajax_get_my_uri(); } /** * PHP 4 Constructor * * @param string $remoteURI */ function sajax($remoteURI = NULL) { $this->__construct($$remoteURI); } /** * * */ function sajax_get_my_uri() { global $REQUEST_URI; return $REQUEST_URI; } function sajax_handle_client_request() { $mode = ""; if (! empty($_GET["rs"])) $mode = "get"; if (!empty($_POST["rs"])) $mode = "post"; if (empty($mode)) return; if ($mode == "get") { // Bust cache in the head header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 $func_name = $_GET["rs"]; if (! empty($_GET["rsargs"])) $args = $_GET["rsargs"]; else $args = array(); } else { $func_name = $_POST["rs"]; if (! empty($_POST["rsargs"])) $args = $_POST["rsargs"]; else $args = array(); } if (! in_array($func_name, $this->sajax_export_list)) echo "-:$func_name not callable"; else { echo "+:"; $result = call_user_func_array($func_name, $args); echo $result; } exit; } // End sajax_handle_client_request() function ... function sajax_get_common_js() { $t = strtoupper($this->sajax_request_type); if ($t != "GET" && $t != "POST") return "// Invalid type: $t.. \n\n"; ob_start(); ?> sajax_get_common_js(); } function sajax_esc($val) { return str_replace('"', '\\\\"', $val); } /** * sajax_get_one_stub * * @param string $func_name */ function sajax_get_one_stub($func_name) { ob_start(); ?> // wrapper for function x_() { sajax_do_call("", x_.arguments); } sajax_export_list[] = func_get_arg($i); } } function sajax_get_javascript() { $html = ""; if (! $this->sajax_js_has_been_shown) { $html .= $this->sajax_get_common_js(); $this->sajax_js_has_been_shown = 1; } foreach ($this->sajax_export_list as $func) { $html .= $this->sajax_get_one_stub($func); } return $html; } function sajax_show_javascript() { echo $this->sajax_get_javascript(); } } // End sajax class ?>