-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecorder.php
More file actions
70 lines (58 loc) · 1.57 KB
/
recorder.php
File metadata and controls
70 lines (58 loc) · 1.57 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
66
67
68
69
70
<?php
function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs<br />\n";
if ($numargs >= 2) {
echo "Second argument is: " . func_get_arg(1) . "<br />\n";
}
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
echo "Argument $i is: " . $arg_list[$i] . "<br />\n";
}
}
function loadDatabase()
{
$databaseFileName = 'data.xml';
if (file_exists ($databaseFileName)){
return simplexml_load_file($databaseFileName);
}
//create or load
return new SimpleXMLElement("<data></data>");
}
function getToday()
{
date_default_timezone_set("America/Chicago");
//return date('Y-m-d H:i:s');
return date('Y-m-d H:i:s');
}
function printDatabase(){
$newsXML = loadDatabase();
Header('Content-type: text/xml');
echo $newsXML->asXML();
}
//Only continue if it's not a specialCommand
function validateRequest(){
if (count($_GET)==0){
echo "ping<br>";
$url = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST'] . htmlspecialchars($_SERVER['REQUEST_URI']);
echo '<a href="'.$url.'?_viewOnly=true">View Database</a>';
exit;
}
if (isset($_GET["_viewOnly"]) && strcmp($_GET["_viewOnly"],"true")==0){
printDatabase();
exit;
}
}
validateRequest();
$newsXML = loadDatabase();
$newsIntro = $newsXML->addChild('record');
foreach ($_GET as $param_name => $param_val) {
$newsIntro->addAttribute($param_name, $param_val);
//echo "Param: $param_name; Value: $param_val<br />\n";
}
$newsIntro->addAttribute('Date', getToday());
$newsXML->asXml('data.xml');
echo "Added Record<br>";
?>