//var_dump($data);
$sslContext = stream_context_create($contextOpts);
$result = file_get_contents($url, null, $sslContext);
//var_dump($result);
$headers = $http_response_header;
//var_dump($headers);
//        $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//        curl_close($ch);
if (strpos($headers[0], '200 OK') !== false && strpos($result, 'SUCCESSFUL') !== false) {
    $resultParams = json_decode($result, true);
    if (isset($resultParams['uuid'])) {
        $uuid = base64_encode(urldecode($resultParams['uuid']));
        //save uuid
        //set beacon activation to true
    }
    saveBeaconData($uuid);
}
function saveBeaconData($uuid = null)
{
    $conf = new Conf();
    global $dbConnection;
    //db credentials
    $dbInfo['host'] = $conf->dbhost;
    $dbInfo['username'] = $conf->dbuser;
    $dbInfo['password'] = $conf->dbpass;
    $dbInfo['database'] = $conf->dbname;
    $dbInfo['port'] = $conf->dbport;
    $dbConnection = createDbConnection($dbInfo['host'], $dbInfo['username'], $dbInfo['password'], $dbInfo['database'], $dbInfo['port']);
    executeSql("UPDATE `hs_hr_config` SET `value` = '{$uuid}' WHERE `key` = 'beacon.uuid'");
    executeSql("UPDATE `hs_hr_config` SET `value` = 'on' WHERE `key` = 'beacon.activiation_status'");
    mysqli_close($dbConnection);
Exemple #2
0
        case 'CANCEL':
            session_destroy();
            header("Location: ./install.php");
            exit(0);
            break;
        case 'BACK':
            back($_POST['txtScreen']);
            break;
        case 'CONFIRMED':
            $_SESSION['INSTALLING'] = 0;
            break;
        case 'REGISTER':
            $_SESSION['CONFDONE'] = 'OK';
            break;
        case 'REGINFO':
            $reqAccept = saveBeaconData();
            //            break;
            //
            //        case 'NOREG' : $reqAccept = TRUE;
        //            break;
        //
        //        case 'NOREG' : $reqAccept = TRUE;
        case 'LOGIN':
            session_destroy();
            setcookie('PHPSESSID', '', time() - 3600, '/');
            header("Location: ./");
            exit(0);
            break;
    }
}
if (isset($error)) {