<?php

error_reporting(E_ALL);
$url = "https://github.com/joshdick/miniProxy";
$result = runCurl($url);
print_r($result);

function runCurl($url) {//get page by url
    $filePath = getcwd() . "/proxis.txt";
    $proxy = getProxy($filePath);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//Proxy!!
    curl_setopt($ch, CURLOPT_PROXY, trim($proxy['host']));
    curl_setopt($ch, CURLOPT_PROXYPORT, trim($proxy['port']));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result['response'] = curl_exec($ch);
    $result['status'] = curl_getinfo($ch);
    return $result;
}

function getProxy($filePath) {//generate proxies for curl
    $file = fopen($filePath, "r");
    $pArray = array();
    while (!feof($file)) {
        $pArray[] = fgets($file);
    }
    fclose($file);
    $pRArray = array_rand($pArray, 3);
    $proxy = explode(":", $pArray[$pRArray[0]]);
    $result['host'] = $proxy[0];
    $result['port'] = $proxy[1];
    return $result;
}
?>