-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprovisioning.phtml
159 lines (134 loc) · 4.7 KB
/
provisioning.phtml
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Copyright (c) 2007-2022 AG Projects
* https://ag-projects.com
*
* This page provides the functions for managing SIP accounts,
* ENUM ranges, ENUM numbers, Trusted Peers, LCR, Rating plans
* on a remote NGNPro server
*
*/
require '/etc/cdrtool/global.inc';
require 'ngnpro_client.php';
set_time_limit(600);
page_open(
array(
"sess" => "CDRTool_Session",
"auth" => "CDRTool_Auth",
"perm" => "CDRTool_Perm"
)
);
$title = "Provisioning";
if (is_readable("/etc/cdrtool/local/header.phtml")) {
include '/etc/cdrtool/local/header.phtml';
} else {
include 'header.phtml';
}
$perm->check("provisioning");
if ($_REQUEST['action'] == 'PerformActions' && $_REQUEST['sub_action'] == 'export') {
$export = true;
}
if ($export) {
Header("Content-type: application/json");
Header("Content-Disposition: attachment; filename=ngnpro_export.json");
} else {
$layout = new pageLayoutLocal();
$layout->showTopMenu($title);
}
global $CDRTool;
$login_credentials = array();
$login_credentials['username'] = $auth->auth["uname"];
if ($CDRTool['impersonate']) {
if (preg_match("/^([0-9]*)\.([0-9]*)$/", $CDRTool['impersonate'], $m)) {
$_customer = $m[1];
$_reseller = $m[2];
} else {
page_close();
printf("Error: Invalid impersonate value %s", $CDRTool['impersonate']);
exit;
}
if ($_customer == "0" && $_reseller == "0") {
$login_credentials['login_type'] = 'admin';
$login_credentials['reseller'] = '0';
} else if ($_customer == $_reseller) {
$login_credentials = array(
'soap_username' => $CDRTool['soap_username'],
'soap_password' => $CDRTool['soap_password'],
'customer' => $_customer,
'reseller' => $_reseller,
'login_type' => 'reseller'
);
} else {
$login_credentials = array(
'soap_username' => $CDRTool['soap_username'],
'soap_password' => $CDRTool['soap_password'],
'customer' => $_customer,
'reseller' => $_reseller,
'login_type' => 'customer'
);
}
$login_credentials['username'] = $auth->auth["uname"];
} else {
page_close();
printf("Please define impersonate field for login account <b>%s</b>", $auth->auth["uname"]);
exit;
}
if (file_exists("/etc/cdrtool/ngnpro_engines.inc")) {
require '/etc/cdrtool/ngnpro_engines.inc';
} else {
page_close();
printf("Error: you must copy setup/ngnpro_engines.inc.sample to /etc/cdrtool/ngnpro_engines.inc and edit it before trying again");
exit;
}
if (array_key_exists($login_credentials['reseller'], $resellerFilters)) {
$login_credentials['soap_filter'] = $resellerFilters[$login_credentials['reseller']]['soap_filter'];
$login_credentials['record_generator'] = $resellerFilters[$login_credentials['reseller']]['record_generator'];
$login_credentials['name_servers'] = $resellerFilters[$login_credentials['reseller']]['name_servers'];
} else if ($resellerFilters['default']) {
$login_credentials['soap_filter'] = $resellerFilters['default']['soap_filter'];
$login_credentials['record_generator'] = isset($resellerFilters['default']['record_generator']) ? $resellerFilters['default']['record_generator'] : '';
$login_credentials['name_servers'] = isset($resellerFilters['default']['name_servers']) ? $resellerFilters['default']['name_servers'] : '' ;
}
$login_credentials['reseller_filters'] = $resellerFilters;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if (isset($_REQUEST['generatorId'])) {
$generator = new recordGenerator($_REQUEST['generatorId'], $recordGenerators, $soapEngines, $login_credentials);
if ($action == 'Generate') {
$generator->generateRecords();
$generator->showGeneratorForm();
} else {
$generator->showGeneratorForm();
}
} else {
$service = isset($_REQUEST['service']) ? $_REQUEST['service'] : '' ;
$SoapEngine = new SoapEngine($service, $soapEngines, $login_credentials);
$_class = $SoapEngine->records_class;
$RECORDS = new $_class($SoapEngine);
$RECORDS->showWelcomeMessage();
if ($action =='Add') {
$RECORDS->addRecord();
}
if ($action =='Copy') {
$RECORDS->copyRecord();
}
if ($action =='Delete') {
$RECORDS->deleteRecord();
}
if ($action =='Update') {
$RECORDS->updateRecord();
}
if ($action == 'PerformActions') {
$RECORDS->executeActions();
} else {
$RECORDS->listRecords();
}
}
if (!$export) {
$layout->showFooter();
echo "
</body>
</html>
";
}
page_close();
?>