public function findPlayer($player)
 {
     $results = array();
     print_r($this->getSearchUrl($player));
     $curl = new CURL();
     $curl->addSession($this->getSearchUrl($player));
     $curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
     $curl->setOpt(CURLOPT_REFERER, 'http://lh.beta.smallballstats.info');
     $page = $curl->exec();
     $curl->clear();
     $page = json_decode($page);
     foreach ($page->responseData->results as $result) {
         array_push($results, array('url' => $result->unescapedUrl, 'title' => $result->titleNoFormatting, 'content' => $result->contentNoFormatting));
     }
     sleep(1);
     $curl = new CURL();
     $curl->addSession($this->getSearchUrl($player, 4));
     $curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
     $curl->setOpt(CURLOPT_REFERER, 'http://lh.beta.smallballstats.info');
     $page = $curl->exec();
     $curl->clear();
     $page = json_decode($page);
     foreach ($page->responseData->results as $result) {
         array_push($results, array('url' => $result->unescapedUrl, 'title' => $result->titleNoFormatting, 'content' => $result->contentNoFormatting));
     }
     print_r($results);
     die;
 }
 public function getPlayByPlay()
 {
     $url = $this->getPlayByPlayUrl($this->id);
     $curl = new CURL();
     $curl->addSession($url);
     $page = $curl->exec();
     $curl->clear();
     $this->playByPlay = new SimpleXMLElement($page);
     return $this->playByPlay;
 }
Beispiel #3
0
 /**
  * Login into pyLoad
  *
  * @param string $username Username
  * @param string $password Password
  * @return string Session ID
  * @throws \Exception
  */
 public function login($username, $password)
 {
     if (!is_null(PyLoad::getInstance()->getSession())) {
         return PyLoad::getInstance()->getSession();
     }
     $curl_opts[CURLOPT_POST] = true;
     $curl_opts[CURLOPT_POSTFIELDS] = array('username' => $username, 'password' => $password);
     $curl_opts[CURLOPT_HTTPHEADER] = array('Content-Type: multipart/form-data');
     $session = CURL::exec('login', $curl_opts);
     $session = str_replace('"', '', $session);
     PyLoad::getInstance()->setSession($session);
     return $session;
 }
Beispiel #4
0
 public function getAll()
 {
     $result = array();
     $html = file_get_html("http://www.eps.uam.es/esp/alumnos/lab_horario.php?horario_id=17&semestre=S2");
     $e = $html->find('select');
     $e = $e[0];
     $curl = new CURL();
     $opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true);
     foreach ($e->find('option') as $g) {
         $result[] = array("id" => $g->value, "name" => $g->innertext);
         $id = $g->value;
         $curl->addSession("http://www.eps.uam.es/esp/alumnos/lab_horario.php?local_id={$id}&horario_id=17&semestre=S2", $opts);
     }
     // Ejecuta todas las peticiones en paralelo
     $pages = $curl->exec();
     $curl->clear();
     for ($i = 0; $i < sizeof($pages); $i++) {
         $result[$i]["data"] = Laboratorio::get($result[$i]["id"], $page);
     }
     return $result;
 }
Beispiel #5
0
function grabproxy($header, $agentstr)
{
    // hidemyass.com got hax'd by hysterix!
    // these are the 'ghetto tables'; md5's
    // of an image we compare to when grabing proxies
    // so we can grab the port number with ease.
    // shit loads faster than scanning each pixel
    // in each image, and easier to implement.
    // pretty hax if you ask me, obviously they
    // don't want people doing this! The first rule of fight club....
    // Also, if you do the md5 locally to just the file it is different from these.
    // I believe this is the md5 of the header as well as the image together,
    // don't think they are wrong when they don't compare on your system
    $ghetto_tables = array('2741898dc5492442a60c48fd8af5f914' => '80', '27760f111201b87996e9d5f1f55e1e2b' => '81', '8c4d39d1386fdb4dc6312a00387ae8be' => '444', '38925677a3ab9071d81b50d0e4d14ce0' => '1080', '5969ad3f3cb42fc2cfc32e667b64db4d' => '1260', '37357c1363a6edac318a513c8a16733a' => '2301', '380ac73e41c1c9f4b460b6aa74fbaea5' => '3124', '70846fe60a6915b3979033fe53f46402' => '3128', '9407ba7a72999731d6cefdc41a7522b4' => '33655', '53fc62ce0db7912b5be729849ef11dff' => '34387', '9229f0e355a3311d1f6b196ffce7cb74' => '6588', 'c1865c575ac4645f47b603deaf98ca60' => '6654', 'a580f19646451c4d832303b596fe6248' => '6666', '2980cfed592e0e31f9b0f30e24e23bf2' => '8000', '9739217797951fd6525313a762007561' => '8080', '0b269894b8fc6b74adb92840528b4e33' => '8118', '14509909876456e7539e95a9a104fcdc' => '8888', '3afb17a502f997278ec096e3347edace' => '9090', '7109cafc0782511575f4dc40e932d2e7' => '9188', '963b608d579bd4a2110e41b11eb6a12a' => '51898', '703a56c126717b1e6791915eee0ed3d8' => '65208');
    // Gather an array of proxy lists (About 400 proxies in this list)
    $ass_hiders[0] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/1/";
    $ass_hiders[1] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/2/";
    $ass_hiders[2] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/3/";
    $ass_hiders[3] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/4/";
    $ass_hiders[4] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/5/";
    $ass_hiders[5] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/6/";
    $ass_hiders[6] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/7/";
    $ass_hiders[7] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/8/";
    $ass_hiders[8] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/9/";
    $ass_hiders[9] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/10/";
    $ass_hiders[10] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/11/";
    $ass_hiders[11] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/12/";
    $ass_hiders[12] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/13/";
    $ass_hiders[13] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/14/";
    $ass_hiders[14] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/15/";
    $randkey = array_rand($ass_hiders);
    // Select a random $ass_hiders page
    $failed = false;
    //$random_hole = rand(1, count($ass_hiders));
    //foreach ($ass_hiders as $ass_hider) {  // UR DOIN IT WRONG
    $curl = new CURL();
    // create the curl instance
    $opts = setBrowser(0, 0, $header, $agentstr);
    // do not set first variable to 1; we don't need infinite looping
    $curl->retry = MAX_RETRYS;
    $curl->addSession($ass_hiders[$randkey], $opts[0]);
    ob_start();
    // this is a hack if i've ever seen one
    $result = $curl->exec();
    // this is the site returned
    ob_end_clean();
    // without this, php likes to output a 1 to the screen (something to do with the header info probably)
    // unset curl
    $curl->clear();
    // remove the curl instance
    unset($curl);
    if (is_array($result)) {
        $result = $result[0] . $result[1];
    }
    $matches = array();
    $yanoob = array();
    $html = str_get_html($result);
    $arrInput = array();
    foreach ($html->find('table') as $t) {
        $x = 0;
        $matches = array();
        foreach ($t->find('tr') as $rows) {
            foreach ($rows->find('td') as $columns) {
                $str = $columns->outertext;
                // Strip out IP's and load into array $matches
                /* keep the wall of shame up */
                //$pattern = '|(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)|U';
                //$pattern = '/^(1\d{0,2}|2(\d|[0-5]\d)?)\.(1\d{0,2}|2(\d|[0-5]\d)?)
                //	   \.(1\d{0,2}|2(\d|[0-5]\d)?)\.(1\d{0,2}|2(\d|[0-5]\d)?)$/';
                //$pattern = '/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/';
                $pattern = '|(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)|U';
                if (preg_match($pattern, $str, $yatmparr)) {
                    // we found an ip
                    $yanoob[0] = $yatmparr[0];
                    // prepare the ip for the array
                    unset($yatmparr);
                }
                foreach ($columns->find('img') as $yaimg) {
                    $tehport = $yaimg->alt;
                    if (strcmp($tehport, "port") == 0) {
                        // grab the port url
                        $portsrc = $yaimg->src;
                        $assUrl = split_url($ass_hiders[$randkey]);
                        $portUrl = split_url($portsrc);
                        if (isset($portUrl['scheme'])) {
                            // path absolute, use as-is
                            $theport = $arrPost['url'];
                        } else {
                            // no host, path relative, slap this on the back of the original url; great success!
                            $newpath = str_replace_once("/", "", $portUrl['path']);
                            // remove the leading slash if it xists
                            $theport = $assUrl['scheme'] . "://" . $assUrl['host'] . "/" . $newpath . '?' . $portUrl['query'];
                        }
                        $curl = new CURL();
                        // create the curl instance
                        $opts = setBrowser(0, 0, $header, $agentstr);
                        // do not set first variable to 1
                        $curl->retry = MAX_RETRYS;
                        $curl->addSession($theport, $opts[0]);
                        ob_start();
                        // this is a hack if i've ever seen one
                        $result = $curl->exec();
                        // this is the png returned
                        ob_end_clean();
                        // without this, php likes to output a 1 to the screen (something to do with the header info probably)
                        // unset curl
                        $curl->clear();
                        // remove the curl instance
                        unset($curl);
                        if (is_array($result)) {
                            $result = $result[0] . $result[1];
                        }
                        //print_r($result);
                        // ingenuity wins out again; hysterix -1 ; hidemyass - 0
                        // they can slow us down but they cant stop us
                        $portnum = retPortNum($result, $ghetto_tables);
                        if (isset($portnum)) {
                            // everything worked; we only want ip's with ports
                            $yanoob[1] = $portnum;
                            array_push($matches, $yanoob);
                        }
                    }
                }
            }
        }
    }
    $html->clear();
    // if you dont include these two statements, the damn
    unset($html);
    // simple html dom becomes simple memory leaker 2.0 because
    unset($result);
    // of a f*****g "php5 circular references memory leak" - nigger t**s
    unset($agentstr);
    //Grab a random IP from array $matches
    $randkey = array_rand($matches, 1);
    $newprox = $matches[$randkey];
    return $newprox;
}
 protected function setPlayerNcaaIdsForTeam($team, $year)
 {
     $this->CI->load->library('Parse/NcaaParse');
     $cookie = $this->CI->ncaaparse->getCookie();
     $curl = new CURL();
     $curl->addSession(sprintf('http://web1.ncaa.org/stats/StatsSrv/careerteam?academicYear=%s&coachId=-100&division=1&doWhat=display&idx=&orgId=%s&playerId=-100&sortOn=0&sportCode=MBA', $year, $team->getNcaaId()));
     $curl->setOpt(CURLOPT_COOKIE, $cookie);
     $curl->setOpt(CURLOPT_REFERER, 'http://web1.ncaa.org/stats/StatsSrv/careersearch');
     $page = $curl->exec();
     $curl->clear();
     $this->CI->load->library('domparser');
     $html = $this->CI->domparser->str_get_html($page);
     $players = array('' => '');
     $playersArray = array();
     foreach ($html->find('table.statstable', 1)->find('tr') as $key => $row) {
         if ($key > 2) {
             $id = $row->find('td', 0)->find('a', 0)->getAttribute('href');
             preg_match('/[0-9]+/', $id, $match);
             $id = $match[0];
             $player = sprintf('%s (%s / %s)', trim($row->find('td', 0)->plaintext), trim($row->find('td', 1)->plaintext), trim($row->find('td', 3)->plaintext));
             $name = explode(',', trim($row->find('td', 0)->plaintext));
             $playerArray = array('ncaaId' => $id, 'firstName' => trim($name[1]), 'lastName' => trim($name[0]), 'class' => trim($row->find('td', 1)->plaintext), 'position' => trim($row->find('td', 3)->plaintext));
             $players[$id] = $player;
             $playersArray[$id] = $playerArray;
         }
     }
     $this->players = $players;
     $this->playersArray = $playersArray;
     return $players;
 }
 function getrank($url)
 {
     $url = 'info:' . $url;
     $ch = $this->GoogleCH($this->strord($url));
     $curl = new CURL('http://www.google.com/search?client=navclient-auto&ch=6' . $ch . '&features=Rank&q=' . urlencode($url));
     $response = trim($curl->exec(true, false));
     var_dump($response);
     $rank = (int) substr(strrchr($response, ':'), 1);
     return $rank;
 }
Beispiel #8
0
 function grab_rosinst($yaheader, $agentstr)
 {
     $proxyUrl = "http://rosinstrument.com/proxy/plab100.xml";
     $curl = new CURL();
     // create the curl instance
     $opts = $this->setBrowser(0, 0, $yaheader, $agentstr);
     // do not set first variable to 1; we don't need infinite looping
     $curl->retry = MAX_RETRYS;
     $curl->addSession($proxyUrl, $opts[0]);
     $result = $curl->exec();
     // this is the site returned
     $curl->clear();
     // remove the curl instance
     unset($curl);
     // unset curl
     if (is_array($result)) {
         $result = $result[0];
         if (isset($result[1])) {
             $result .= $result[1];
         }
     }
     $goodmatches = array();
     $matches = array();
     $yacntr = 0;
     $pattern = '/<title>(.*?)<\\/title>/';
     // grabs netblk-41-215-180-130.iconnect.zm:8080 or 66.190.144.90:27445
     preg_match_all($pattern, $result, $matches);
     for ($i = 0; $i < count($matches[1]); $i++) {
         $arrtmp = explode(":", $matches[1][$yacntr]);
         $goodmatches[$yacntr][0] = $arrtmp[0];
         $goodmatches[$yacntr][1] = $arrtmp[1];
         $yacntr++;
     }
     unset($goodmatches[0]);
     unset($goodmatches[1]);
     unset($result);
     unset($agentstr);
     if (empty($goodmatches)) {
         // bark at them
         return 0;
     } else {
         return $goodmatches;
         // return something
     }
 }
 public function getCookie()
 {
     $curl = new CURL();
     $curl->addSession('http://web1.ncaa.org/stats/StatsSrv/careersearch');
     $curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
     $curl->setOpt(CURLOPT_HEADER, 1);
     $page = $curl->exec();
     $curl->clear();
     preg_match('|Set-Cookie: (.*);|U', $page, $cookies);
     return $cookies[1];
 }
 public function getPlayer($player)
 {
     if (is_numeric($player)) {
         $player = $this->CI->_player->findOneByNcaaId($player);
     }
     if (!$player->getName() || !($player->getAtBats() || $player->getInningsPitched())) {
         return false;
     }
     print_r($player);
     print_r("\n\n");
     $teams = $player->getTeams();
     $searchType = $player->getInningsPitched() ? 'pitchers' : 'hitters';
     $url = sprintf('http://www.boydsworld.com/cgi/%s.pl?player=%s&style=Contains&submit=Search&team=%s', $searchType, $player->getName(), $teams[0]->getName());
     $curl = new CURL();
     $curl->addSession($url);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, false);
     $curl->setOpt(CURLOPT_HEADER, false);
     $curl->setOpt(CURLOPT_REFERER, 'http://www.boydsworld.com/data/hitters.html');
     $curl->setOpt(CURLOPT_VERBOSE, true);
     $page = $curl->exec();
     $curl->clear();
     print_r($page);
     print_r("\n\n");
 }
Beispiel #11
0
 protected function exec($url, array $opts = array())
 {
     $this->checkBaseURL();
     $this->checkAuthentication();
     return CURL::exec($url, $opts);
 }
Beispiel #12
0
function get_url($link, $config)
{
    $url[0] = $link;
    if ($config['pars'] == 'curl') {
        $curl = new CURL();
        $curl->retry = 4;
        $opts = array(CURLOPT_RETURNTRANSFER => true);
        $curl->addSession($url[0], 0, $opts);
        $result = $curl->exec();
        $curl->clear();
    } elseif ($config['pars'] == 'mcurl') {
        $curl = new MCurl();
        $curl->threads = 100;
        $curl->timeout = 15;
        $curl->sec_multiget($url, $result);
    } else {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $link);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-Requested-With: XMLHttpRequest', 'Connection: Keep-Alive'));
        $data = curl_exec($ch);
        if ($data === false) {
            $err = curl_errno($ch);
            $errmsg = curl_error($ch);
            $result[0] = '';
        } else {
            $result[0] = $data;
        }
        curl_close($ch);
    }
    return $result[0];
}
Beispiel #13
0
     // set browser information
     $cntSuccess++;
 } elseif (strcasecmp($arrPost['method'], "get") == 0) {
     // need to get to site
     $opts2 = setBrowser($proxyvar, 1, $header, $agent);
     // set browser information
     $urlToPost = $urlToPost . "?" . $arrPost['post'];
     $cntSuccess++;
 }
 $curl2 = new CURL();
 $curl2->retry = MAX_RETRYS;
 $curl2->addSession($urlToPost, $opts2[0]);
 //grab the site
 ob_start();
 // this is a hack if i've ever seen one
 $result2 = $curl2->exec();
 ob_end_clean();
 // without this, php likes to output a 1 to the screen (something to do with the header info probably
 $time = date("c");
 $curl2->clear();
 unset($curl2);
 //echo "<br />result:<br />";
 //print_r($result2);  // server response
 // do they want logging?
 if (ENABLE_LOG == true) {
     if (DEBUG_LEVEL == 0 || DEBUG_LEVEL == 1) {
         // begin logging
         $log_data = " - Connection Attempt -\n  Time:       {$time}:\n";
         $log_data .= "  Url:        " . $connectlist[$b][0] . "\n";
         $log_data .= "  Action:     " . $arrPost['url'] . "\n";
         $log_data .= "  Sent to:    " . $urlToPost . "\n";
Beispiel #14
0
function multiget($inurls, &$res, $config, $transit, $roster, $lang, $multi = 0)
{
    global $db, $cache;
    $timeout = 10;
    $tcurl = $config['pars'];
    $num = $config['multiget'];
    $urlss = array_chunk($inurls, $num, TRUE);
    foreach ($urlss as $id => $urls) {
        if ($tcurl == 'curl') {
            $curl = new CURL();
            $curl->retry = 2;
            $opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => $timeout);
            foreach ($urls as $key => $link) {
                $curl->addSession($link, $key, $opts);
            }
            $result = $curl->exec();
            $curl->clear();
        } elseif ($tcurl == 'mcurl') {
            $curl = new MCurl();
            $curl->threads = 100;
            $curl->timeout = 15;
            $curl->sec_multiget($urls, $result);
        } else {
            foreach ($urls as $id => $link) {
                $ch[$id] = curl_init();
                curl_setopt($ch[$id], CURLOPT_URL, $link);
                curl_setopt($ch[$id], CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch[$id], CURLOPT_FAILONERROR, true);
                curl_setopt($ch[$id], CURLOPT_CONNECTTIMEOUT, $timeout);
                curl_setopt($ch[$id], CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Accept: text/html, */*", "User-Agent: Mozilla/3.0 (compatible; easyhttp)", "Connection: Keep-Alive"));
            }
            $mh = curl_multi_init();
            foreach ($ch as $id => $h) {
                curl_multi_add_handle($mh, $h);
            }
            $running = null;
            do {
                curl_multi_exec($mh, $running);
            } while ($running > 0);
            foreach ($ch as $id => $h) {
                $result[$id] = curl_multi_getcontent($h);
            }
            foreach ($ch as $id => $h) {
                curl_multi_remove_handle($mh, $h);
            }
            curl_multi_close($mh);
            unset($ch);
        }
        if ($multi != 0) {
            foreach ($result as $name => $val) {
                $res[$name] = $val;
            }
        } else {
            foreach ($result as $name => $val) {
                $json = json_decode($val, TRUE);
                if ($json['status'] == 'ok' && $json['status_code'] == 'NO_ERROR') {
                    $transit = insert_stat($json, $roster[$name], $config, $transit);
                    $res[$name] = pars_data2($json, $name, $config, $lang, $roster[$name]);
                    $cache->set($name, $res[$name], ROOT_DIR . '/cache/players/');
                }
            }
        }
        unset($result, $json);
    }
}
Beispiel #15
0
function multiget($urls, &$result, $tcurl = 'curl')
{
    if ($tcurl == 'curl') {
        $curl = new CURL();
        $opts = array(CURLOPT_RETURNTRANSFER => true);
        foreach ($urls as $key => $link) {
            $curl->addSession($link, $key, $opts);
        }
        $result = $curl->exec();
        $curl->clear();
    } else {
        $curl = new MCurl();
        $curl->threads = 100;
        $curl->timeout = 15;
        unset($results);
        $curl->sec_multiget($urls, $result);
    }
}