Exemplo n.º 1
0
//
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: *');
//Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-Http-Method-Override, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-control, X-Auth-Token, If-Match');
//header('Access-Control-Expose-Headers: Content-Type, X-Auth-Token, X-Request-ID, Location, Etag, ETag');
// handle som restrictions about kazoo
$headers = getallheaders();
if ($headers['Access-Control-Request-Headers']) {
    header('Content-Type: text/html; charset=UTF-8');
    header('Access-Control-Allow-Headers:accept, content-type, x-auth-token, x-kazoo-cluster-id');
    //    header('access-control-allow-headers: content-type,x-auth-token');
    header('Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD');
    header('Allow: GET');
} else {
    header('Content-Type: application/json');
    header('Access-Control-Allow-Headers: content-type,x-auth-token');
    header('Vary: Accept');
}
$path = explode("?", $_SERVER['REQUEST_URI']);
$paths = explode("/", $path[0]);
// disable debug if user_agent %=% snom
if (preg_match("/snom/i", $_SERVER["HTTP_USER_AGENT"])) {
    @define('DEBUG_FUNCTION', '');
}
require_once 'config.php';
$host = get_dbhost($hosts);
$sag = new Sag($host, $dbport);
$myip4 = get_ip(4);
//show_debug();
get_groundsettings($paths);
Exemplo n.º 2
0
header('Access-Control-Allow-Origin: *');
//Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-Http-Method-Override, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-control, X-Auth-Token, If-Match');
//header('Access-Control-Expose-Headers: Content-Type, X-Auth-Token, X-Request-ID, Location, Etag, ETag');
// handle som restrictions about kazoo
$headers = getallheaders();
if ($headers['Access-Control-Request-Headers']) {
    header('Content-Type: text/html; charset=UTF-8');
    header('access-control-allow-headers: content-type,x-auth-token');
    header('Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD');
    header('Allow: GET');
} else {
    header('Content-Type: application/json');
    header('Access-Control-Allow-Headers: content-type,x-auth-token');
    header('Vary: Accept');
}
$path = explode("?", $_SERVER['REQUEST_URI']);
$f_path = explode("/", $path[0]);
unset($f_path[0]);
unset($f_path[1]);
// unset / and /prov
// disable debug if user_agent %=% snom
if (preg_match("/snom/i", $_SERVER["HTTP_USER_AGENT"])) {
    @define('DEBUG_FUNCTION', '');
}
require_once 'config.php';
$host = get_dbhost($hosts);
$sag = new Sag($host);
$myip4 = get_ip(4);
//show_debug();
get_groundsettings($f_path);
Exemplo n.º 3
0
function get_phone_data($macaddress, $qpass = false, $nonepass = false)
{
    global $host, $sag, $tmp;
    //   if(filemtime($tmp.'provcache-!!') > time()-600) {
    //        $provdata = unserialize(file_get_contents($tmp.'provcache-!!'));
    //        if (! is_array($provdata)) {
    //            {global $debug; $debug[] = array(level=>false,status=>'problem',file=>__FILE__.":".__LINE__,log=>'('. __FUNCTION__ .') '." Loaderror: ".$tmp."provcache-!!");}
    //            return(false);
    //        }
    //    } else {
    $ret = get_all_dbs($host);
    foreach ($ret['res'] as $key => $value) {
        if (stristr($value, 'account/')) {
            $res = get_entry($value, '/_design/devices/_view/listing_by_macaddress');
            //print_r($res);
            if ($res['err']) {
                show_debug("Get macaddress_view Error:" . $res['err']);
                continue;
            } else {
                //                    if(! $ph_dat['devices']) $ph_dat['devices'] = json_decode(json_encode($res['res']->rows), true);
                foreach ($res['res']->rows as $mac) {
                    $mac->value->account = $value;
                    $mac->value->mac = $mac->key;
                    $provdata[$mac->id] = $mac->value;
                }
            }
        }
    }
    //        file_put_contents($tmp.'provcache-!!',serialize($provdata));
    //    }
    //print_r($provdata);
    foreach ($provdata as $v) {
        if (stristr(str_replace(":", "", $macaddress), str_replace(":", "", $v->mac))) {
            $prov[] = $v;
        }
        /* array all devices if owner too  */
        if ($v->owner) {
            $devices[$v->owner] = $v;
        }
    }
    foreach ($prov as $k => $val) {
        //echo $prov[$k]->account." , ".$prov[$k]->pvt_account_id."\n";
        $ph_account = get_entry($prov[$k]->account, $prov[$k]->pvt_account_id);
        $ph_dat['account'][$k] = json_decode(json_encode($ph_account['res']), true);
        //print_r($ph_account);
        $ph_users[$k] = get_entry($prov[$k]->account, '/_design/users/_view/crossbar_listing');
        /* OBJECT2ARRAY */
        $ph_user[$k] = json_decode(json_encode($ph_users[$k]['res']->rows), true);
        //print_r($ph_user[$k]);
    }
    $ph_dat['devices'] = json_decode(json_encode($devices), true);
    //print_r($ph_dat['devices']);
    //print_r($prov);
    // return fase if qpass enabled and wrong ['provision_enabled']
    //{global $debug; $debug[] = array(level=>'d',status=>'info',file=>__FILE__.":".__LINE__,log=>'('. __FUNCTION__ .') '." DEBUG: ".$ph_dat['account'][0]['provision']['provision_enabled']." == false || ".$ph_dat['account'][0]['provision']['urlpass']." == false || ".$ph_dat['account'][0]['provision']['urlpass']." != $qpass) && $nonepass");}
    if (($ph_dat['account'][0]['provision']['provision_enabled'] == false || $ph_dat['account'][0]['provision']['urlpass'] == false || $ph_dat['account'][0]['provision']['urlpass'] != $qpass) && $nonepass == false) {
        /* fraud? */
        sleep(20);
        return false;
    }
    $ph_dat['prov'] = json_decode(json_encode($prov), true);
    // take template of the first account ## get account and userdata (f_path = /ui/snom/3xx/300)
    $ph_dat['template'] = get_groundsettings(array('0' => 'ui', '1' => $prov[0]->provision->endpoint_brand, '2' => $prov[0]->provision->endpoint_family, '3' => $prov[0]->provision->endpoint_model), 'object');
    /* OBJECT2ARRAY */
    foreach ($ph_user as $account => $users) {
        foreach ($users as $k => $v) {
            $ph_dat['users'][$account][$v['id']] = $v;
        }
    }
    global $debug;
    $debug[] = array(level => 'd', status => 'info', file => __FILE__ . ":" . __LINE__, log => '(' . __FUNCTION__ . ') ' . " Get Phone & Userdata from bigCouch");
    //print_r($ph_dat);
    //exit;
    return $ph_dat;
}