-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandexport.php
More file actions
66 lines (47 loc) · 1.3 KB
/
Copy pathcommandexport.php
File metadata and controls
66 lines (47 loc) · 1.3 KB
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
<?php
include "inc/main.php";
$release=@addslashes($_REQUEST['release']);
$format=@addslashes($_REQUEST['format']);
$command=@addslashes($_REQUEST['command']);
$sql="select c.id, r.`release`, name, commands, info from commands c
left join releases r on c.release=r.id
where r.`release`=\"$release\" and c.name=\"$command\"";
//var_dump($sql);
$db->execute($sql);
$x=$db->dataset;
$pkgs=array();
foreach ($x as $k=>$v){
if($format=="json"){
$arr=array(
'name'=>$command,
'release'=>$release,
'commands'=>base64_encode($v['commands']),
'info'=>base64_encode($v['info'])
);
$result=json_encode($arr);
}
if($format=="xml"){
//header("Content-type: text/xml");
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput=true;
$root = $dom->createElement('command');
$release = $dom->createElement('release',$release);
$name= $dom->createElement('name',$command);
$info = $dom->createElement('info',base64_encode($v['info']));
$commands = $dom->createElement('commands',base64_encode($v['commands']));
$root->appendChild($release);
$root->appendChild($name);
$root->appendChild($info);
$root->appendChild($commands);
$dom->appendChild($root);
$result=$dom->saveXML();
}
}
if($format=="xml"){
header("Content-type: text/xml");
echo $result;
}
if($format=="json"){
header("Content-type: text/plain");
echo $result;
}