$flash = array();
 $imported_version = (string) trim($_POST['import_version']);
 # On recupere les infos
 if (!is_uploaded_file($_FILES['imported_file']['tmp_name'])) {
     $flash['error'][] = T_('Your file could not be downloaded');
 } elseif ($_FILES["imported_file"]["error"] > 0) {
     $flash['error'][] = T_('Your file could not be imported') . '<br />' . $_FILES["imported_file"]["error"];
 } elseif (strpos($_FILES["imported_file"]["type"], "gzip") === false) {
     $flash['error'][] = T_("Your file doesn't have the right format : ") . '<br />' . $_FILES["imported_file"]["type"];
 } else {
     $response = T_('Congratulations! You imported an old data configuration successfully') . "<br/>";
     $response .= T_("File name: ") . $_FILES["imported_file"]["name"] . "<br />";
     $response .= T_("Size: ") . $_FILES["imported_file"]["size"] / 1024 . " " . T_("Kb") . "<br />";
     $flash['notice'][] = $response;
     $gzfile = file_get_contents($_FILES['imported_file']['tmp_name'], FILE_USE_INCLUDE_PATH);
     $content = my_gzdecode($gzfile);
     $tables = json_decode($content, true);
     $author_id = $blog_settings->get('author_id');
     foreach ($tables as $table) {
         if ($imported_version == '1.1' && in_array($table['name'], $possible_tables["1.1"]) || $imported_version == '1.0' && in_array($table['name'], $possible_tables["1.0"])) {
             // on vide le contenu de la table
             if ($table['name'] == 'user') {
                 $core->con->execute("DELETE FROM " . $core->prefix . "user WHERE user_id != '" . $author_id . "'");
             } elseif ($table['name'] == "permissions") {
                 $core->con->execute("DELETE FROM " . $core->prefix . "permissions WHERE user_id != '" . $author_id . "'");
             } elseif ($table['name'] == "settings") {
                 $core->con->execute("DELETE FROM " . $core->prefix . "setting WHERE\n\t\t\t\t\t\t\t\tsetting_value != 'author_id' AND\n\t\t\t\t\t\t\t\tsetting_value != 'planet_url' AND\n\t\t\t\t\t\t\t\tsetting_value != 'planet_version'");
             } else {
                 $core->con->execute("TRUNCATE TABLE `" . $core->prefix . $table['name'] . "`");
             }
             $cols = $table['head'];
Exemplo n.º 2
0
function GetFromMicrosoft($bssid)
{
    $headers = array('Accept: */*', 'Accept-Language: en-us', 'Content-Type: text/xml', 'Accept-Encoding: gzip, deflate', 'User-Agent: PHP/' . phpversion() . ' 3WiFi/2.0', 'Cache-Control: no-cache');
    $tries = 2;
    $bssid = strtolower(str_replace("-", ":", $bssid));
    $data = null;
    while (!$data && $tries > 0) {
        $time = date('Y-m-d\\TH:i:s.uP');
        $xmlRequest = '<GetLocationUsingFingerprint xmlns="http://inference.location.live.com"><RequestHeader><Timestamp>' . $time . '</Timestamp><ApplicationId>e1e71f6b-2149-45f3-a298-a20682ab5017</ApplicationId><TrackingId>21BF9AD6-CFD3-46B3-B041-EE90BD34FDBC</TrackingId><DeviceProfile ClientGuid="0fc571be-4624-4ce0-b04e-911bdeb1a222" Platform="Windows7" DeviceType="PC" OSVersion="7600.16695.amd64fre.win7_gdr.101026-1503" LFVersion="9.0.8080.16413" ExtendedDeviceInfo="" /><Authorization /></RequestHeader><BeaconFingerprint><Detections><Wifi7 BssId="' . $bssid . '" rssi="-1" /></Detections></BeaconFingerprint></GetLocationUsingFingerprint>';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://inference.location.live.net/inferenceservice/v21/Pox/GetLocationUsingFingerprint');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $data = function_exists('gzdecode') ? gzdecode(curl_exec($ch)) : my_gzdecode(curl_exec($ch));
        curl_close($ch);
        $tries--;
        sleep(2);
    }
    $result = '';
    if (!$data) {
        return $result;
    }
    $xml = simplexml_load_string($data);
    if (!$xml) {
        return $result;
    }
    if ($xml->GetLocationUsingFingerprintResult->ResponseStatus == 'Success' && $xml->GetLocationUsingFingerprintResult->LocationResult->ResolverStatus->attributes()->Status == 'Success' && $xml->GetLocationUsingFingerprintResult->LocationResult->ResolverStatus->attributes()->Source == 'Internal' && $xml->GetLocationUsingFingerprintResult->LocationResult->RadialUncertainty < 500) {
        $geo = $xml->GetLocationUsingFingerprintResult->LocationResult->ResolvedPosition->attributes();
        $result = $geo->Latitude . ';' . $geo->Longitude . ';microsoft';
        if ($geo->Latitude == 12.3456 && $geo->Longitude == -7.891) {
            $result = '';
        }
    }
    return $result;
}