Пример #1
0
    die("<strong><font color=red>Not Support Folder</font></strong>");
}
if (!preg_match('@!([^!]{8})!([\\w\\-\\,]{43})@i', $url, $fid)) {
    die("<strong><font color=red>FileID or Key not found at link.</font></strong>");
} else {
    $sid = '';
    $seqno = rand(0, 0xffffffff);
    $post = array(array('a' => 'g', 'g' => 1, 'p' => $fid[1]));
    $json = json_encode($post);
    $data = $this->curl('https://g.api.mega.co.nz/cs?id=' . $seqno++ . ($sid ? '&sid=' . $sid : ''), "", $json, 0, 1);
    $res = json_decode($data, true);
    if (isset($res[0]['e'])) {
        $code = $res[0]['e'];
        if (is_numeric($code)) {
            die("<strong><font color=red>File temporarily not available.</font></strong>");
        }
    }
    if (!isset($res[0]['s']) || !isset($res[0]['at'])) {
        die(Tools_get::report($Original, "dead"));
    }
    $key = base64_to_a32($fid[2]);
    $k = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]);
    $iv = array_merge(array_slice($key, 4, 2), array(0, 0));
    $meta_mac = array_slice($key, 6, 2);
    $enc_attributes = base64urldecode($res[0]['at']);
    $attributes = dec_attr($enc_attributes, $k);
    $infolink = array('url' => $res[0]['g'], 'size' => $res[0]['s'], 'name' => $attributes->n, 'key' => $key, 'iv' => $iv, 'mac' => $meta_mac);
    $link = trim($infolink['url']);
    $filename = $infolink['name'];
    $filesize = $infolink['size'];
}
Пример #2
0
function getfiles()
{
    global $master_key, $root_id, $inbox_id, $trashbin_id;
    $files = api_req(array('a' => 'f', 'c' => 1));
    foreach ($files->f as $file) {
        if ($file->t == 0 || $file->t == 1) {
            $key = substr($file->k, strpos($file->k, ':') + 1);
            $key = decrypt_key(base64_to_a32($key), $master_key);
            if ($file->t == 0) {
                $k = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]);
                $iv = array_merge(array_slice($key, 4, 2), array(0, 0));
                $meta_mac = array_slice($key, 6, 2);
            } else {
                $k = $key;
            }
            $attributes = base64urldecode($file->a);
            $attributes = dec_attr($attributes, $k);
            if ($file->h == 'gldU3Tab') {
                downloadfile($file, $attributes, $k, $iv, $meta_mac);
            }
        } else {
            if ($file->t == 2) {
                $root_id = $file->k;
            } else {
                if ($file->t == 3) {
                    $inbox_id = $file->k;
                } else {
                    if ($file->t == 4) {
                        $trashbin_id = $file->k;
                    }
                }
            }
        }
    }
}