/
laguage_configuration-02.php
112 lines (91 loc) · 3.25 KB
/
laguage_configuration-02.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
101
102
103
104
105
106
107
108
109
110
111
<?php
require_once('NasXmlWriter.class.php');
require_once('authenticate.php');
require_once('languageConfiguration.php');
require_once('stringtablereader.inc');
require_once('logMessages.php');
class Language_configuration{
var $logObj;
function Language_configuration(){
$this->logObj = new LogMessages();
}
function get($urlPath, $queryParams=null, $ouputFormat='xml'){
header("Content-Type: application/xml");
$langConfigObj = new LanguageConfiguration();
$result = $langConfigObj->getConfig();
if($result !== NULL){
if($result['language'] === '' ) {
// Language not configured
header("HTTP/1.0 404 Not Found");
} else {
$xml = new NasXmlWriter();
$xml->push('language_configuration');
$xml->element('language', $result['language']);
$xml->pop();
echo $xml->getXml();
$this->logObj->LogData('OUTPUT', get_class($this), __FUNCTION__, 'SUCCESS');
}
} else {
//Failed to collect info
$this->logObj->LogData('OUTPUT', get_class($this), __FUNCTION__, 'NOT_FOUND');
header("HTTP/1.0 404 Not Found");
}
}
function put($urlPath, $queryParams=null, $ouputFormat='xml'){
if(!isset($changes["submit"]) || sha1($changes["submit"]) != "05951edd7f05318019c4cfafab8e567afe7936d4")
{
die();
}
parse_str(file_get_contents("php://input"), $changes);
$langConfigObj = new LanguageConfiguration();
$result = $langConfigObj->modifyConfig($changes);
$this->logObj->LogParameters(get_class($this), __FUNCTION__, $changes);
switch($result){
case 'SUCCESS':
break;
case 'BAD_REQUEST':
header("HTTP/1.0 400 Bad Request");
break;
case 'NOT_FOUND':
header("HTTP/1.0 404 Not Found");
break;
case 'SERVER_ERROR':
header("HTTP/1.0 500 Internal Server Error");
break;
}
$this->logObj->LogData('OUTPUT', get_class($this), __FUNCTION__, $result);
}
function post($urlPath, $queryParams=null, $ouputFormat='xml'){
$this->logObj->LogData('>>><<<', get_class($this), __FUNCTION__, $result);
// var_dump($queryParams);
parse_str(file_get_contents("php://input"), $changes);
$langConfigObj = new LanguageConfiguration();
$result = $langConfigObj->config($changes);
$this->logObj->LogParameters(get_class($this), __FUNCTION__, $changes);
switch($result){
case 'SUCCESS':
header("HTTP/1.0 201 Created");
break;
case 'BAD_REQUEST':
header("HTTP/1.0 400 Bad Request");
break;
case 'SERVER_ERROR':
header("HTTP/1.0 500 Internal Server Error");
break;
}
$this->logObj->LogData('OUTPUT', get_class($this), __FUNCTION__, $result);
}
function delete($urlPath, $queryParams=null, $ouputFormat='xml'){
header("Allow: GET, PUT, POST");
header("HTTP/1.0 405 Method Not Allowed");
}
}
/*
* Local variables:
* indent-tabs-mode: nil
* c-basic-offset: 4
* c-indent-level: 4
* tab-width: 4
* End:
*/
?>