function vk_doApiReq($data) { global $app; $data['api_id'] = $app['id']; $data['format'] = 'json'; $data['v'] = '3.0'; $sig = ''; ksort($data); foreach ($data as $k => $v) { $sig .= "{$k}={$v}"; } $sig = md5($sig . $app['secret']); $baseLink = 'https://api.vk.com/method/' . $data['method'] . '?'; unset($k, $v, $data['method']); return Get_Reply(vk_GetPage($baseLink . http_build_query($data) . "&sig={$sig}&access_token=" . $GLOBALS['json']['access_token'])); }
function Login($user, $pass) { global $default_acc, $cookie, $domain, $referer, $pauth; $errors = array('CaptchaInvalid' => 'Wrong CAPTCHA entered.', 'InvalidLogIn' => 'Invalid Login/Pass.', 'CaptchaRequired' => 'Captcha Required.'); if (!empty($_POST['step']) && $_POST['step'] == '1') { if (empty($_POST['recaptcha_response_field'])) { html_error('You didn\'t enter the image verification code.'); } $post = array('recaptcha_challenge_field' => $_POST['recaptcha_challenge_field'], 'recaptcha_response_field' => $_POST['recaptcha_response_field']); $post['login'] = urlencode($user); $post['password'] = urlencode($pass); $page = geturl($domain, 80, '/api/user/login', $referer . 'login.php?return=%2F', $cookie, $post, 0, $_GET['proxy'], $pauth); is_page($page); $json = Get_Reply($page); if (!empty($json['error'])) { html_error('Login Error' . (!empty($errors[$json['error']]) ? ': ' . $errors[$json['error']] : '..')); } elseif ($json['status'] != 'OK') { html_error('Login Failed'); } $cookie = GetCookiesArr($page, $cookie); if (empty($cookie['autologin'])) { html_error('Login Error: Cannot find "autologin" cookie'); } SaveCookies($user, $pass); // Update cookies file return true; } else { $post = array(); $post['login'] = urlencode($user); $post['password'] = urlencode($pass); $page = geturl($domain, 80, '/api/user/login', $referer . 'login.php?return=%2F', $cookie, $post, 0, $_GET['proxy'], $pauth); is_page($page); $json = Get_Reply($page); if (!empty($json['error']) && $json['error'] != 'CaptchaRequired') { html_error('Login Error' . (!empty($errors[$json['error']]) ? ': ' . $errors[$json['error']] : '.')); } elseif ($json['status'] == 'OK') { $cookie = GetCookiesArr($page, $cookie); if (empty($cookie['autologin'])) { html_error('Login Error: Cannot find "autologin" cookie.'); } SaveCookies($user, $pass); // Update cookies file return true; } elseif (empty($json['error']) || $json['error'] != 'CaptchaRequired') { html_error('Login Failed.'); } // Captcha Required $page = geturl($domain, 80, '/login.php?return=%2F', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth); is_page($page); $cookie = GetCookiesArr($page, $cookie); if (!preg_match('@(https?://([^/\\r\\n\\t\\s\'\\"<>]+\\.)?(?:depositfiles|dfiles)\\.[^/:\\r\\n\\t\\"\'<>]+(?:\\:\\d+)?)/js/base2\\.js@i', $page, $jsurl)) { html_error('Cannot find captcha.'); } $jsurl = empty($jsurl[1]) ? 'http://' . $domain . $jsurl[0] : $jsurl[0]; $jsurl = parse_url($jsurl); $page = geturl($jsurl['host'], defport($jsurl), $jsurl['path'] . (!empty($jsurl['query']) ? '?' . $jsurl['query'] : ''), $referer . 'login.php?return=%2F', $cookie, 0, 0, $_GET['proxy'], $pauth); is_page($page); if (!preg_match('@recaptcha_public_key\\s*=\\s*[\'\\"]([\\w\\-]+)@i', $page, $cpid)) { html_error('reCAPTCHA Not Found.'); } $post = array('action' => 'FORM'); $post['step'] = '1'; if (!$default_acc) { $post['up_encrypted'] = 'true'; $post['up_login'] = urlencode(encrypt($user)); $post['up_pass'] = urlencode(encrypt($pass)); } Show_reCaptcha($cpid[1], $post, 'Login'); } }
} $i = 1; foreach (array_keys($sites) as $site) { if (!empty($_POST['UpT8']) && !empty($_POST['UpT8'][$site]) || empty($_POST['UpT8']) && empty($DontUlTo[$site])) { $post['host' . $i++] = $site; } } $up_url = $json['server']; // Uploading echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n"; $url = parse_url($up_url); $upfiles = upfile($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), 0, 0, $post, $lfile, $lname, 'files[]', '', $_GET['proxy'], $pauth); // Upload Finished echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>\n"; is_page($upfiles); $json = Get_Reply($upfiles); if (empty($json['url'])) { if (empty($json['error']) || strtolower($json['error']) == 'success') { html_error('Upload error.'); } html_error('Upload error: ' . htmlentities($json['error']) . '.'); } $download_link = $json['url']; } function Get_Reply($page) { if (!function_exists('json_decode')) { html_error('Error: Please enable JSON in php.'); } $body = substr($page, strpos($page, "\r\n\r\n") + 4); if (empty($body)) {
if (!empty($upres['error'])) { html_error("Upload Error: [{$upres['error']['error_code']}] {$upres['error']['error_msg']}"); } if (!$video) { sleep(1); // Let's wait another second :D $data = array('api_id' => $app['id'], 'method' => 'audio.save', 'audio' => $upres['audio'], 'hash' => $upres['hash'], 'server' => $upres['server']); $req = SigAndReq($data, '/method/' . $data['method'] . '?'); if ($usecurl) { $page = cURL('https://api.vk.com' . $req); } else { $page = geturl('api.vk.com', 0, $req, 0, 0, array('hash' => $upres['hash']), 0, $_GET['proxy'], $pauth, 0, 'https'); // Port is overridden to 443 is_page($page); } $rply = Get_Reply($page); } if (!empty($rply['error'])) { if (is_array($rply['error'])) { html_error("audio.save Error: [{$rply['error']['error_code']}] {$rply['error']['error_msg']}"); } else { html_error('Save Error: ' . $rply['error']); } } if ($video && !empty($upsrv['response']['vid'])) { $download_link = 'http://vk.com/video' . $json['user_id'] . '_' . $upsrv['response']['vid']; } elseif ($video) { html_error('Your video will appear in your VK account after a while.', 0); } elseif (!$video && !empty($rply['response']['url'])) { $download_link = $rply['response']['url']; } else {
function k2s_apireq($actionPath, $post = array()) { if (!function_exists('json_encode')) { html_error('Error: Please enable JSON in PHP.'); } if (!is_array($post)) { html_error('k2s_apireq: Parameter 2 must be passed as an array.'); } $post['auth_token'] = !empty($post['auth_token']) ? $post['auth_token'] : (!empty($GLOBALS['cookie']['sessid']) ? urldecode($GLOBALS['cookie']['sessid']) : false); $page = geturl($GLOBALS['domain'], 80, '/api/v1/' . $actionPath, $GLOBALS['referer'], 0, json_encode($post), 0, $_GET['proxy'], $GLOBALS['pauth']); is_page($page); $status = (int) substr($page, 9, 3); if ($status >= 500) { return array('status' => 'fail', 'code' => $status, 'message' => "k2s_apireq: HTTP Error {$status}."); } return Get_Reply($page); }
// Uploading echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n"; $url = parse_url($up_url); $upfiles = upfile($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), 0, 0, $post, $lfile, $lname, 'Filedata', '', $_GET['proxy'], $pauth, 'Shockwave Flash'); // Upload Finished echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>\n"; is_page($upfiles); $json = Get_Reply($upfiles); if (empty($json['result']) || $json['result'] != 'true' || empty($json['id'])) { html_error('Upload error: "' . htmlentities($json['message']) . '"'); } $id = $json['id']; //geturl($domain, 80, '/newfile/edit/'.$id, $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);is_page($page); $page = geturl($domain, 80, '/newfile/gridFile/' . $id, $referer . "newfile/edit/\r\nX-Requested-With: XMLHttpRequest", $cookie, 0, 0, $_GET['proxy'], $pauth); is_page($page); $json = Get_Reply($page); $info = reset($json['rows']); $download_link = "{$referer}{$id}.html"; if (!empty($info['cell'][7])) { $delete_link = $referer . "delete/file/{$id}/" . $info['cell'][7]; } } function FormToArr($content, $v1 = '&', $v2 = '=') { $rply = array(); if (strpos($content, $v1) === false || strpos($content, $v2) === false) { return $rply; } foreach (array_filter(array_map('trim', explode($v1, $content))) as $v) { $v = array_map('trim', explode($v2, $v, 2)); if ($v[0] != '') {
function mf_apireq($action, $post = array()) { if (!function_exists('json_encode')) { html_error('Error: Please enable JSON in PHP.'); } if (!is_array($post)) { html_error('mf_apireq: Parameter 2 must be passed as an array.'); } $post['response_format'] = 'json'; // Get API replies in json if (in_array($action, array('user/get_session_token', 'upload/poll_upload'))) { unset($post['session_token']); } else { if (empty($post['session_token']) && !empty($GLOBALS['app']['session_token'])) { $post['session_token'] = $GLOBALS['app']['session_token']; } } $post = array_map('urlencode', array_filter($post)); $path = "api/{$GLOBALS['app']['api_version']}/{$action}.php"; if ($GLOBALS['cURL']) { $page = cURL($GLOBALS['referer'] . $path, 0, $post, $GLOBALS['referer']); } else { $page = geturl($GLOBALS['domain'], 443, "/{$path}", $GLOBALS['referer'], 0, $post, 0, 0, 0, 0, 'https'); // geturl doesn't support https proxy is_page($page); } $status = (int) substr($page, 9, 3); if ($status >= 500) { return array('result' => 'Error', 'error' => $status, 'message' => "mf_apireq: HTTP Error {$status}."); } $json = Get_Reply($page); if (count($json) == 1 && !empty($json['response'])) { $json = $json['response']; } return $json; }
function doApiReq($atrr) { global $options, $T8; $domain = 'g.api.mega.co.nz'; //$domain = 'eu.api.mega.co.nz'; if (!function_exists('json_encode')) { html_error('Error: Please enable JSON in php.'); } $cURL = $options['use_curl'] && extension_loaded('curl') && function_exists('curl_init') && function_exists('curl_exec') ? true : false; $chttps = false; if ($cURL) { $cV = curl_version(); if (in_array('https', $cV['protocols'], true)) { $chttps = true; } } if (!extension_loaded('openssl') && !$chttps) { html_error('You need to install/enable PHP\'s OpenSSL extension to support HTTPS connections.'); } elseif (!$chttps) { $cURL = false; } $sid = !empty($T8['sid']) ? '&sid=' . $T8['sid'] : ''; $post = json_encode($atrr); $referer = "https://mega.co.nz/\r\nContent-Type: application/json"; if ($cURL) { $page = cURL("https://{$domain}/cs?id=" . $T8['seqno']++ . $sid, 0, "[{$post}]", $referer); } else { global $pauth; $page = geturl($domain, 443, '/cs?id=' . $T8['seqno']++ . $sid, $referer, 0, "[{$post}]", 0, 0, 0, 0, 'https'); is_page($page); } list($header, $page) = array_map('trim', explode("\r\n\r\n", $page, 2)); if (is_numeric($page)) { return array((int) $page); } if (in_array((int) substr($header, 9, 3), array(500, 503))) { return array(-3); } // 500 Server Too Busy return Get_Reply($page); }