Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $FindIndexPage = "http://www.someaddress.com/search.aspx?path=1547";
- $FindSearchPage = "http://www.someaddress.com/search.aspx?path=1547%3b1631%3b1678&lang=1";
- $cookieFile = 'cookie.txt';
- $regexViewstate = '/__VIEWSTATE\" value=\"(.*)\"/i';
- $regexEventVal = '/__EVENTVALIDATION\" value=\"(.*)\"/i';
- function regexExtract($text, $regex, $regs, $nthValue)
- {
- if (preg_match($regex, $text, $regs)) {
- $result = $regs[$nthValue];
- }
- else {
- $result = "";
- }
- return $result;
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- $data=curl_exec($ch);
- $viewstate = regexExtract($data,$regexViewstate,$regs,1);
- $eventval = regexExtract($data, $regexEventVal,$regs,1);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
- curl_setopt($ch, CURLOPT_POST, FALSE);
- curl_setopt($ch, CURLOPT_URL, $urlSecuredPage);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
- $data = curl_exec($ch);
- curl_close($ch);
- $id = "2453618-4";
- $postData = '__VIEWSTATE='.urlencode($viewstate)
- .'&__EVENTVALIDATION='.urlencode($eventval)
- .'&_ctl0:ContentPlaceHolder:ytunnus='.urlencode($id)
- ;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_URL, $urlFindPage);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
- //curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
- $data2 = curl_exec($ch);
- $data2 = str_replace("http://www.someaddress.com/search.aspx?path=1547%3b1631%3b1678&lang=1", "http://www.someaddress.com/search.aspx?path=1547%3b1631%3b1678&lang=1", $data2);
- echo $data2;
- curl_close($ch);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment