-
Notifications
You must be signed in to change notification settings - Fork 1
/
generic.php
41 lines (30 loc) · 1.21 KB
/
generic.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
<?php
require_once("db_auth.php");
function checkRestAuth($username, $server, $auth) {
$restServer = str_replace("uc.", "rest.", $server);
$url = "https://".$restServer."/company";
$authHeader = "Authorization: Basic " . $auth;
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array($authHeader, "X-No-Redirect: true"));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);
return $result;
}
function checkUser($login, $pass) {
$loginsplit = explode("@", $login);
$username = $loginsplit[0];
$server = null;
if ($loginsplit[1] == null) {
$server = "uc.pbx.speakup-telecom.com";
} else {
$server = $loginsplit[1];
}
$auth = base64_encode($username.":".$pass);
return checkRestAuth($username, $server, $auth);
}
$db = new mysqli("localhost", $SQLUSER, $SQLPASS, "bedien01_main");
header('Access-Control-Allow-Origin: *');
?>