Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- header('Content-Type: text/html; charset=utf-8');
- /*
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Requested-With: XMLHttpRequest'));
- curl_setopt($ch, CURLOPT_USERAGENT, $ua);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- //curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_PROXY, $proxy);
- curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
- curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($cookiesFile));
- curl_setopt($ch, CURLOPT_COOKIEFILE, realpath($cookiesFile));
- curl_setopt($ch, CURLOPT_REFERER, 'http://google.com');
- $result = curl_exec($ch);
- curl_close($ch);
- */
- /*
- * Создание нового файла
- create ('test.txt');
- */
- function create ($file) {
- $create = fopen(realpath($file), "w");
- fclose($create);
- }
- /*
- * Сохранение в файл
- save ('test.txt', "Hello World");
- */
- function save (
- $file,
- $data
- ) {
- $file = realpath($file);
- $current = file_get_contents($file);
- $current .= $data . "\r\n";
- file_put_contents($file, $current);
- }
- /*
- * System Result
- saveSys ($result);
- */
- function saveSys (
- $data
- ) {
- $file = realpath('saveSys.txt');
- $create = fopen($file, "w");
- fclose($create);
- $current = file_get_contents($file);
- $current .= $data . "\r\n";
- file_put_contents($file, $current);
- }
- /*
- * Save Page
- savePage ($result);
- */
- function savePage (
- $data
- ) {
- $file = realpath('page.html');
- $create = fopen($file, "w");
- fclose($create);
- $current = file_get_contents($file);
- $current .= $data . "\r\n";
- file_put_contents($file, $current);
- }
- /*
- * Удаление первой строки из файла
- delStr ('test.txt');
- */
- function delStr (
- $file
- ) {
- $lines = file(realpath($file));
- unset($lines[0]);
- file_put_contents($file, implode('', $lines));
- }
- /*
- * Рандомизатор
- $text = '{Hello|Hi|Yo}';
- echo rnd ($text);
- */
- function rnd($text) {
- while (preg_match('#\{([^\{\}]+)\}#i', $text, $m)) {
- $v = explode('|', $m[1]);
- $i = rand(0, count($v) - 1);
- $text = preg_replace('#'.preg_quote($m[0]).'#i', $v[$i], $text, 1);
- }
- return $text;
- }
- /*
- * Генерация
- echo gen();
- */
- function gen($length = 10) {
- $chars = 'qwertyuiopasdfghjklzxcvbnm0123456789';
- $numChars = strlen($chars);
- $string = '';
- for ($i = 0; $i < $length; $i++) {
- $string .= substr($chars, rand(1, $numChars) - 1, 1);
- }
- return $string;
- }
- /*
- * ruCaptcha
- $recognize = recognize();
- */
- function recognize(
- $filename = 'captcha.png',
- $apikey = '***',
- $is_verbose = true,
- $domain = 'rucaptcha.com',
- $rtimeout = 5,
- $mtimeout = 120,
- $is_phrase = 0,
- $is_regsense = 0,
- $is_numeric = 1,
- $min_len = 4,
- $max_len = 7,
- $language = 0
- ) {
- if (!file_exists($filename))
- {
- if ($is_verbose) echo "file $filename not found\n";
- return false;
- }
- $postdata = array(
- 'method' => 'post',
- 'key' => $apikey,
- 'file' => new CurlFile($filename),
- 'phrase' => $is_phrase,
- 'regsense' => $is_regsense,
- 'numeric' => $is_numeric,
- 'min_len' => $min_len,
- 'max_len' => $max_len,
- 'language' => $language
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://$domain/in.php");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
- $result = curl_exec($ch);
- if (curl_errno($ch))
- {
- if ($is_verbose) echo "CURL returned error: ".curl_error($ch)."\n";
- return false;
- }
- curl_close($ch);
- if (strpos($result, "ERROR")!==false)
- {
- if ($is_verbose) echo "server returned error: $result\n";
- return false;
- }
- else
- {
- $ex = explode("|", $result);
- $captcha_id = $ex[1];
- if ($is_verbose) echo "captcha sent, got captcha ID $captcha_id\n";
- $waittime = 0;
- if ($is_verbose) echo "waiting for $rtimeout seconds\n";
- sleep($rtimeout);
- while(true)
- {
- $result = file_get_contents("http://$domain/res.php?key=".$apikey.'&action=get&id='.$captcha_id);
- if (strpos($result, 'ERROR')!==false)
- {
- if ($is_verbose) echo "server returned error: $result\n";
- return false;
- }
- if ($result=="CAPCHA_NOT_READY")
- {
- if ($is_verbose) echo "captcha is not ready yet\n";
- $waittime += $rtimeout;
- if ($waittime>$mtimeout)
- {
- if ($is_verbose) echo "timelimit ($mtimeout) hit\n";
- break;
- }
- if ($is_verbose) echo "waiting for $rtimeout seconds\n";
- sleep($rtimeout);
- }
- else
- {
- $ex = explode('|', $result);
- if (trim($ex[0])=='OK') return trim($ex[1]);
- }
- }
- return false;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement