Ejemplo n.º 1
0
function proxy_api($cmd)
{
    $pwd = "insert your seo-proxies pwd here!!";
    $uid = 6990;
    global $PROXY;
    global $NL;
    $fp = fsockopen("www.seo-proxies.com", 80);
    if (!$fp) {
        echo "Unable to connect to proxy API {$NL}";
        return -1;
        // connection not possible
    } else {
        if ($cmd == "rotate") {
            $PROXY['ready'] = 0;
            fwrite($fp, "GET /api.php?api=1&uid={$uid}&pwd={$pwd}&cmd=rotate&randomness=1 HTTP/1.0\r\nHost: www.seo-proxies.com\r\nAccept: text/html, text/plain, text/*, */*;q=0.01\r\nAccept-Encoding: plain\r\nAccept-Language: en\r\n\r\n");
            stream_set_timeout($fp, 8);
            $res = "";
            $n = 0;
            while (!feof($fp)) {
                if ($n++ > 4) {
                    break;
                }
                $res .= fread($fp, 8192);
            }
            $info = stream_get_meta_data($fp);
            fclose($fp);
            if ($info['timed_out']) {
                echo 'API: Connection timed out! $NL';
                return -2;
                // api timeout
            } else {
                if (strlen($res) > 1000) {
                    return -3;
                }
                // invalid api response (check the API website for possible problems)
                $data = extractBody($res);
                $ar = explode(":", $data);
                if (count($ar) < 4) {
                    return -100;
                }
                // invalid api response
                switch ($ar[0]) {
                    case "ERROR":
                        echo "API Error: {$res} {$NL}";
                        return 0;
                        // Error received
                        break;
                    case "ROTATE":
                        $PROXY['address'] = $ar[1];
                        $PROXY['port'] = $ar[2];
                        $PROXY['external_ip'] = $ar[3];
                        $PROXY['ready'] = 1;
                        return 1;
                        break;
                    default:
                        echo "API Error: Received answer {$ar['0']}, expected \"ROTATE\"";
                        return -101;
                        // unknown API response
                }
            }
        }
        // cmd==rotate
    }
}
Ejemplo n.º 2
0
function get_google_cc($cc, $lc)
{
    global $pwd;
    global $uid;
    global $PROXY;
    global $LICENSE;
    global $NL;
    global $portal;
    $fp = fsockopen("{$portal}.seo-proxies.com", 80);
    if (!$fp) {
        echo "Unable to connect to google_cc API {$NL}";
        return NULL;
        // connection not possible
    } else {
        fwrite($fp, "GET /g_api.php?api=1&uid={$uid}&pwd={$pwd}&cmd=google_cc&cc={$cc}&lc={$lc} HTTP/1.0\r\nHost: {$portal}.seo-proxies.com\r\nAccept: text/html, text/plain, text/*, */*;q=0.01\r\nAccept-Encoding: plain\r\nAccept-Language: en\r\n\r\n");
        stream_set_timeout($fp, 8);
        $res = "";
        $n = 0;
        while (!feof($fp)) {
            if ($n++ > 4) {
                break;
            }
            $res .= fread($fp, 8192);
        }
        $info = stream_get_meta_data($fp);
        fclose($fp);
        if ($info['timed_out']) {
            echo 'API: Connection timed out! $NL';
            return NULL;
            // api timeout
        } else {
            $data = extractBody($res);
            $obj = unserialize($data);
            if (isset($obj['error'])) {
                echo $obj['error'] . "{$NL}";
            }
            if (isset($obj['info'])) {
                echo $obj['info'] . "{$NL}";
            }
            return $obj['data'];
            if (strlen($data) < 4) {
                return NULL;
            }
            // invalid api response
        }
    }
}