-
Notifications
You must be signed in to change notification settings - Fork 3
/
ajax_send.php
100 lines (97 loc) · 2.61 KB
/
ajax_send.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/*
* ajax_send.php
*
* Copyright 2021 Jim Richardson <jim@noideersoftware.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* send proxy requests to server
*/
require ('includes/master.inc.php');
include ('functions.php');
// map ajaxv21.php to somewhere else (so ajaxv21.php's actual file name & location is only known to this script )
//$cmds =convert_to_argv($argv,"",true);
$version = "1.012";
$build = "2519-2682779641";
if(is_cli()) {
$cmds = convert_to_argv($argv,"",true);
define('cr',PHP_EOL);
}
if(!defined('cr')){
define('cr','<br>');
}
if (!empty($_POST)) {
$cmds = convert_to_argv($_POST,"",true);
}
elseif (!empty($_GET)) {
if (isset($cmds)) {
$cmds = array_merge($cmds,convert_to_argv($_GET,"",true));
}
else {
$cmds = convert_to_argv($_GET,"",true);
}
}
if(isset($cmds['debug'])) {
echo '$cmds = '.print_r($cmds,true);
}
if (isset($cmds['query'])) {
$query = split_query($cmds['query']);
if (isset($cmds['debug'])){
print_r($query);
}
$cmd = $cmds['url'];
}
else {
$cmd = $cmds['url'];
}
if (isset($cmds['debug'])) {
echo "cmd = $cmd".cr;
}
$options['phpgsm-auth'] = "true";
if(isset($query['output'])) {
if ($query['output'] == 'xml'){header('Content-Type: text/xml');}
if ($query['output'] == 'json') {header('Content-Type: application/json');}
}
//echo $cmd.'<br>';
//print_r($options);
//echo '<br>';
//print_r($query);
//echo '<br>';
//echo print_r($cmds,true).'<br>';
//echo geturl($cmd,'','',$options,$query);
//die();
echo geturl($cmd,null,null,$options,$query); //password set file
function split_query($query) {
// split up query
$return='';
$items = preg_split('/:/', $query);
//print_r($items);
foreach ($items as $item) {
//build query string
if (empty($return)) {
$return = '?'.$item;
}
else {
$return .='&'.$item;
}
$split_item = preg_split('/=/',$item);
$return_array[$split_item[0]] = $split_item[1];
}
//die(print_r($return_array));
return $return_array;
}
?>