-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfunctions.php
72 lines (62 loc) · 1.43 KB
/
functions.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
<?php
/* List of all codecs and their ids*/
$codec_ids = array(
'uLaw' => 0,
'GSM' => 1,
'aLaw' => 6,
'g722' => 7,
'g729' => 16,
'Speex narrow' => 24,
'Speex wide' => 25,
'Speex ultra' => 26,
'iLBC30' => 27,
'iLBC20' => 28,
'g726' => 29,
'VP8' => 31,
'H.264' => 32,
'Opus narrow' => 34,
'Opus wide' => 35,
'Opus super' => 36,
'Opus full' => 37
);
function ver_to_int($ver) {
$arr = explode('.', $ver);
$f = (int) $arr[0];
$s = (int) $arr[1];
return $f * 10000 + $s;
}
function error($err) {
echo "<error>$err</error>";
die();
}
/* THIS IS JUST AN EXAMPLE, you'll need your own way to authenticate users */
/*
This function returns some parameters which are put in the provisioning.
The only parameters it passes right now are the username and password for
the SIP/IAX2 account.
*/
function validate_user($username, $password) {
$secretuser = "secretuser";
$secretpass = "verysecret";
if ($username != $secretuser || $password != $secretpass)
return false;
$tmp = array();
$tmp['username'] = $username;
$tmp['password'] = $password;
return $tmp;
}
/*
This function returns string with escaped special XML symbols.
It is mainly used for the properly passing of the URL for balance,
rate and call quality rating.
*/
function xml_url ($string) {
$sym = array(
"<" => "<",
">" => ">",
'"' => """,
"'" => "'",
"&" => "&",
);
return strtr($string, $sym);
}