forked from hogsim/PMB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.inc.php
executable file
·59 lines (54 loc) · 1.7 KB
/
ajax.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net [email protected] et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: ajax.inc.php,v 1.7 2012-09-06 09:29:46 ngantier Exp $
/***********************************************
*function ajax_http_send_response
* Send the response at the http_send_request (in http_request.js) without error
*input :
* - $ack : text to be send
* - $type : type of header: 'text/html' by default
*Output:
* send an header and $ack to the client
*/
function ajax_http_send_response($ack='',$type='text/html'){
global $charset;
if(is_array($ack) || is_object($ack)){
header("Content-Type: application/json; charset=$charset");
print json_encode($ack);
}else{
header("Content-Type: $type; charset=$charset");
print $ack;
}
}
/***********************************************
*function ajax_http_send_error
* Send the response at the http_send_request (in http_request.js) with an error
*input :
* - $error : Error code
* - $ack : text to be send
*Output:
* send the header error and $ack to the client
*/
function ajax_http_send_error($error='404 Not Found',$ack=''){
header("HTTP/1.0 $error");
print $ack;
}
function array2xml($buffer) {
global $charset;
$xml = "<?xml version='1.0' encoding='iso-8859-1'?>";
$xml.= "<pmb_services version=\"1.0\">\n";
foreach($buffer as $val) {
$xml .= "<param>\n";
foreach ($val as $key => $value) {
if(!is_array($value)) {
$value=htmlspecialchars($value,ENT_QUOTES,$charset);
$xml .= "<$key>".$value."</$key>\n";
}
}
$xml .= "</param>\n";
}
$xml .= "</pmb_services>";
return $xml;
}