topical media & game development
mashup-delicious-06-example6-10-Sajax.php / php
<?php
if (!isset(GLOBALS['sajax_version'] = '0.12';
GLOBALS['sajax_export_list'] = array();
GLOBALS['sajax_remote_uri'] = '';
_SERVER["REQUEST_URI"];
}
value) {
value);
if (value) ? "Boolean(true)" : "Boolean(false)";
}
elseif (value)";
}
elseif (value)";
}
elseif (type == "object" ) {
//
// XXX Arrays with non-numeric indices are not
// permitted according to ECMAScript, yet everyone
// uses them.. We'll use an object.
//
type == "object") {
value);
}
foreach (k=>esc_key = sajax_esc(k))
k: " . sajax_get_js_repr(s .= "\"v) . ", ";
}
if (count(s = substr(s . " }";
}
else {
value);
esc_val'";
return sajax_export_list;
_GET["rs"]))
_POST["rs"]))
mode))
return;
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
_GET["rs"];
if (! empty(args = args = array();
}
else {
_POST["rs"];
if (! empty(args = args = array();
}
if (! in_array(sajax_export_list))
echo "-:result = call_user_func_array(args);
echo "var res = " . trim(sajax_get_js_repr(sajax_debug_mode;
global sajax_remote_uri;
global t = strtoupper(t != "" && t != "POST")
return "// Invalid type: sajax_debug_mode ? "true" : "false"; ?>;
var sajax_request_type = "<?php echo sajax_failure_redirect; ?>";
function sajax_debug(text) {
if (sajax_debug_mode)
alert(text);
}
function sajax_init_object() {
sajax_debug("sajax_init_object() called..")
var A;
var msxmlhttp = new Array(
'Msxml2.XMLHTTP.5.0',
'Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0',
'Msxml2.XMLHTTP',
'Microsoft.XMLHTTP');
for (var i = 0; i < msxmlhttp.length; i++) {
try {
A = new ActiveXObject(msxmlhttp[i]);
} catch (e) {
A = null;
}
}
if(!A && typeof XMLHttpRequest != "undefined")
A = new XMLHttpRequest();
if (!A)
sajax_debug("Could not create connection object.");
return A;
}
var sajax_requests = new Array();
function sajax_cancel() {
for (var i = 0; i < sajax_requests.length; i++)
sajax_requests[i].abort();
}
function sajax_do_call(func_name, args) {
var i, x, n;
var uri;
var post_data;
var target_id;
sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
target_id = sajax_target_id;
if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "")
sajax_request_type = "GET";
uri = "<?php echo /g,"");
status = txt.charAt(0);
data = txt.substring(2);
if (status == "") {
// let's just assume this is a pre-response bailout and let it slide for now
} else if (status == "-")
alert("Error: " + data);
else {
if (target_id != "")
document.getElementById(target_id).innerHTML = eval(data);
else {
try {
var callback;
var extra_data = false;
if (typeof args[args.length-1] == "object") {
callback = args[args.length-1].callback;
extra_data = args[args.length-1].extra_data;
} else {
callback = args[args.length-1];
}
callback(eval(data), extra_data);
} catch (e) {
sajax_debug("Caught error " + e + ": Could not eval " + data );
}
}
}
}
}
sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
x.send(post_data);
sajax_debug(func_name + " waiting..");
delete x;
return true;
}
<?php
html;
}
function sajax_show_common_js() {
echo sajax_get_common_js();
}
// javascript escape a value
function sajax_esc(val = str_replace("\\", "\\\\", val = str_replace("\r", "\\r", val = str_replace("\n", "\\n", val = str_replace("'", "\\'", val);
}
function sajax_get_one_stub(func_name; ?>
function x_<?php echo func_name; ?>",
x_<?php echo html = ob_get_contents();
ob_end_clean();
return func_name) {
echo sajax_get_one_stub(sajax_export_list;
i = 0; n; sajax_export_list[] = func_get_arg(sajax_js_has_been_shown = 0;
function sajax_get_javascript()
{
global sajax_export_list;
sajax_js_has_been_shown) {
sajax_js_has_been_shown = 1;
}
foreach (func) {
func);
}
return SAJAX_INCLUDED = 1;
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.