-
Notifications
You must be signed in to change notification settings - Fork 0
/
librap.php
108 lines (95 loc) · 2.32 KB
/
librap.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
<?php
/**
* RAP protocol related functions
*
* @author Andreas Thienemann
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
include "group_manager.cfg.php";
/**
* Authenticate clients
*
* @todo Actually implement authentication, now it's just a stub
* @return void
*/
function rap_authenticate() {
global $ws_address;
// For now just do a simple client_ip check
if (in_array($_SERVER["REMOTE_ADDR"], $ws_address)) {
return true;
}
echo <<< EOF
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//OMA//DTD XHTML Mobile 1.2//EN"
"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Permission denied for ${_SERVER['REMOTE_ADDR']}</title>
</head>
<body>
<p>Authentication needed</p>
</body>
</html>
EOF;
exit();
}
/**
* Parse the GET string and extract mobile handset information
*
* @return array The handset information available.
*/
function parse_rap_get() {
$rap_languages = array(
0 => "Undefined",
1 => "US",
2 => "German",
3 => "English International",
);
$lang = $rap_languages[$_GET["lang"]] ?? "Undefined";
$base_mac = $_GET["mac"] ?? "";
$ipui = $_GET["handsetid"] ?? "";
$sip_id = $_GET["sipid"] ?? "";
return array(
"language" => $lang,
"basestation_mac" => $base_mac,
"ipui" => $ipui,
"number" => $sip_id,
);
}
/**
* Simple localization support for strings.
*
* @param string index The string identifier to localize
* @return string The localized string.
*/
function lang($index) {
$lang = parse_rap_get();
$lang = $lang["language"];
// Default is US
if ($lang != "US" && $lang != "German") {
$lang = "US";
}
$words = array(
"US" => array(
"__gm_title" => "Groups",
"__gm_nogroup" => "No Group",
"__gm_available" => "Groups available",
"__gm_incoming" => "Incoming groups",
"__gm_outgoing" => "Outgoing group",
"__gm_extension" => "ext.",
"__gm_send_form" => "Send",
),
"German" => array(
"__gm_title" => "Gruppen",
"__gm_nogroup" => "Keine Gruppe",
"__gm_available" => "Verfügbare Gruppen",
"__gm_incoming" => "Kommende Gruppen",
"__gm_outgoing" => "Gehende Gruppe",
"__gm_extension" => "Tn.",
"__gm_send_form" => "Senden",
),
);
return isset($words[$lang][$index]) ?
$words[$lang][$index] :
"unknown";
}