-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovision.html
More file actions
327 lines (289 loc) · 13.8 KB
/
provision.html
File metadata and controls
327 lines (289 loc) · 13.8 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flex PBX - Auto-Provision SIP Account</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.provision-card {
background: white;
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 600px;
text-align: center;
}
.qr-container {
background: #f8f9fa;
padding: 30px;
border-radius: 15px;
margin: 30px 0;
}
#qrcode {
display: inline-block;
}
.manual-settings {
text-align: left;
background: #f8f9fa;
padding: 20px;
border-radius: 10px;
margin-top: 20px;
}
.setting-row {
margin: 10px 0;
display: flex;
justify-content: space-between;
border-bottom: 1px solid #dee2e6;
padding-bottom: 8px;
}
.setting-label {
font-weight: 600;
color: #6c757d;
}
.setting-value {
font-family: monospace;
color: #212529;
}
.copy-btn {
cursor: pointer;
margin-left: 10px;
color: #667eea;
}
</style>
</head>
<body>
<div class="provision-card">
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h1 class="mb-2">Flex PBX</h1>
<p class="text-muted mb-0">Choose your provisioning method</p>
</div>
<div class="text-end">
<a href="/user-portal/" class="btn btn-sm btn-outline-primary me-2">
<i class="fas fa-user me-1"></i>User Login
</a>
<a href="/admin/" class="btn btn-sm btn-outline-secondary me-2">
<i class="fas fa-user-shield me-1"></i>Admin
</a>
<a href="/" class="btn btn-sm btn-outline-info">
<i class="fas fa-home me-1"></i>Home
</a>
</div>
</div>
<!-- Tabs for different auth methods -->
<ul class="nav nav-pills mb-4 justify-content-center" id="authTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="password-tab" data-bs-toggle="pill" data-bs-target="#password-method" type="button">Password</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pin-tab" data-bs-toggle="pill" data-bs-target="#pin-method" type="button">PIN Code</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="api-tab" data-bs-toggle="pill" data-bs-target="#api-method" type="button">API</button>
</li>
</ul>
<div class="tab-content" id="authTabContent">
<!-- Password Method -->
<div class="tab-pane fade show active" id="password-method" role="tabpanel">
<div class="form-group mb-3">
<label>Extension Number:</label>
<input type="number" id="extension" class="form-control text-center" placeholder="Enter your extension (e.g., 2000)" min="2000" max="2999">
</div>
<div class="form-group mb-3">
<label>Password:</label>
<input type="password" id="password" class="form-control text-center" placeholder="Enter your password">
</div>
<button class="btn btn-primary btn-lg" onclick="generateQR()">
<i class="fas fa-qrcode me-2"></i> Generate QR Code
</button>
</div>
<!-- PIN Method -->
<div class="tab-pane fade" id="pin-method" role="tabpanel">
<div class="form-group mb-3">
<label>Extension Number:</label>
<input type="number" id="pinExtension" class="form-control text-center" placeholder="Enter your extension" min="2000" max="2999">
</div>
<div class="form-group mb-3">
<label>PIN Code:</label>
<input type="text" id="pinCode" class="form-control text-center" placeholder="6-digit PIN from admin" maxlength="6">
</div>
<button class="btn btn-success btn-lg" onclick="verifyPin()">
<i class="fas fa-key me-2"></i> Verify PIN
</button>
<p class="mt-3 text-muted small">Request a PIN code from your administrator for headless devices</p>
</div>
<!-- API Method -->
<div class="tab-pane fade" id="api-method" role="tabpanel">
<div class="alert alert-info text-start">
<h6>API Provisioning Endpoints</h6>
<p class="small mb-2"><strong>Authenticate with password:</strong></p>
<code class="d-block mb-2">POST /api/provision.php?path=authenticate</code>
<pre class="small mb-3">{"extension": "2000", "password": "yourpass"}</pre>
<p class="small mb-2"><strong>Verify PIN code:</strong></p>
<code class="d-block mb-2">POST /api/provision.php?path=verify_pin</code>
<pre class="small mb-3">{"extension": "2000", "pin": "123456"}</pre>
<p class="small mb-0"><strong>Response contains SIP configuration:</strong></p>
<pre class="small">{"success": true, "config": {...}}</pre>
</div>
</div>
</div>
<div class="qr-container" id="qrContainer" style="display: none;">
<div id="qrcode"></div>
<p class="mt-3 mb-0 text-muted">Scan with any compatible SIP application</p>
</div>
<!-- One-Click Config Links -->
<div class="manual-settings" id="oneClickLinks" style="display: none;">
<h6 class="mb-3">One-Click Configuration Links</h6>
<p class="small text-muted mb-3">Click a link to automatically configure your SIP client:</p>
<div class="d-grid gap-2">
<a href="#" id="sipLink" class="btn btn-outline-primary btn-sm">
<i class="fas fa-phone me-2"></i> Generic SIP URI
</a>
<a href="#" id="linphoneLink" class="btn btn-outline-success btn-sm">
<i class="fas fa-mobile me-2"></i> Linphone
</a>
<a href="#" id="zoiperLink" class="btn btn-outline-info btn-sm">
<i class="fas fa-headset me-2"></i> Zoiper
</a>
<a href="#" id="groundwireLink" class="btn btn-outline-warning btn-sm">
<i class="fas fa-broadcast-tower me-2"></i> Groundwire
</a>
</div>
<p class="mt-3 mb-0 text-muted small">Note: Some browsers may require permission to open SIP apps</p>
</div>
<div class="manual-settings" id="manualSettings" style="display: none;">
<h6 class="mb-3">Manual Configuration</h6>
<div class="setting-row">
<span class="setting-label">Server:</span>
<span class="setting-value">flexpbx.devinecreations.net</span>
</div>
<div class="setting-row">
<span class="setting-label">Username:</span>
<span class="setting-value" id="dispUsername">-</span>
</div>
<div class="setting-row">
<span class="setting-label">Password:</span>
<span class="setting-value" id="dispPassword">-</span>
</div>
<div class="setting-row">
<span class="setting-label">Port:</span>
<span class="setting-value">5060</span>
</div>
<div class="setting-row">
<span class="setting-label">Transport:</span>
<span class="setting-value">UDP</span>
</div>
<div class="setting-row">
<span class="setting-label">Dial Plan:</span>
<span class="setting-value" style="font-size: 0.85em;">(2xxx|*xx|1[2-9]xxxxxxxxx)</span>
</div>
</div>
<div class="mt-4">
<small class="text-muted">Compatible with all SIP clients that support QR provisioning:<br>
Groundwire • Linphone • Zoiper • Bria • Telephone • MicroSIP • and more</small>
</div>
<div class="mt-3 text-center">
<hr class="my-3">
<small class="text-muted">
Need help? <a href="/user-portal/" class="text-decoration-none">Login to User Portal</a> or
<a href="mailto:support@devine-creations.com" class="text-decoration-none">Contact Support</a>
</small>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
function generateQR() {
const extension = document.getElementById('extension').value;
const password = document.getElementById('password').value;
// Validate inputs
if (!extension || !password) {
alert('Please enter both extension number and password');
return;
}
// Update manual settings display
document.getElementById('dispUsername').textContent = extension;
document.getElementById('dispPassword').textContent = password;
// Clear previous QR code
const qrContainer = document.getElementById('qrcode');
qrContainer.innerHTML = '';
// Generate SIP URI for QR code
// Format: sip:username@server;password=pass;transport=udp
const sipUri = `sip:${extension}@flexpbx.devinecreations.net:5060;password=${password};transport=udp;dialplan=(2xxx|*xx|1[2-9]xxxxxxxxx)`;
// Generate QR code
new QRCode(qrContainer, {
text: sipUri,
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.M
});
// Show QR and manual settings
document.getElementById('qrContainer').style.display = 'block';
document.getElementById('manualSettings').style.display = 'block';
document.getElementById('oneClickLinks').style.display = 'block';
// Generate one-click configuration links
generateConfigLinks(extension, password);
}
// Generate clickable configuration links
function generateConfigLinks(extension, password) {
const server = 'flexpbx.devinecreations.net';
const dialplan = '(2xxx|*xx|1[2-9]xxxxxxxxx)';
// Generic SIP URI (RFC 3261)
const sipUri = `sip:${extension}:${password}@${server}:5060`;
document.getElementById('sipLink').href = sipUri;
// Linphone config URL
const linphoneUri = `linphone-config:provisioning?url=${encodeURIComponent('https://flexpbx.devinecreations.net/api/provision.php?path=get_config&extension=' + extension + '&password=' + password)}`;
document.getElementById('linphoneLink').href = linphoneUri;
// Zoiper config URL
const zoiperUri = `zoiper://config?username=${extension}&password=${password}&server=${server}&port=5060&transport=udp`;
document.getElementById('zoiperLink').href = zoiperUri;
// Groundwire SIP URI
const groundwireUri = `sip:${extension}@${server}:5060;transport=udp;password=${password}`;
document.getElementById('groundwireLink').href = groundwireUri;
}
// Don't auto-generate - wait for user input
// PIN verification
async function verifyPin() {
const extension = document.getElementById('pinExtension').value;
const pin = document.getElementById('pinCode').value;
if (!extension || !pin) {
alert('Please enter both extension number and PIN code');
return;
}
try {
const response = await fetch('/api/provision.php?path=verify_pin', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ extension, pin })
});
const data = await response.json();
if (data.success) {
// Display credentials
const config = data.config;
document.getElementById('extension').value = extension;
document.getElementById('password').value = config.password;
// Switch to password tab and generate QR
document.getElementById('password-tab').click();
setTimeout(() => generateQR(), 100);
alert('PIN verified! QR code generated successfully.');
} else {
alert('PIN verification failed: ' + data.message);
}
} catch (error) {
alert('Error: ' + error.message);
}
}
</script>
</body>
</html>