cookies, "w") or die("Unable to open cookie file for write!"); fclose($fp); $this->user = $user; $this->pw = $pw; $this->viewstate = $this->login(); echo $this->viewstate; //$this->viewstate = $this->getViewstate(); //echo $this->viewstate; } function getValue($token, $doc) { return $doc->getElementById($token)->getAttribute('value'); } function login() { $post = 'Button1=Login'; $post .= '&__VIEWSTATE=' . urlencode($this->viewstate); $post .= '&myUsername=' . $this->user; $post .= '&myPassword=' . $this->pw; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->login_url); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERAGENT, $this->agent); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookies); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookies); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->request_header); $result = curl_exec($ch); $doc = new DOMDocument(); $doc->loadHTML($result); curl_close($ch); return $this->getValue('__VIEWSTATE', $doc); } function getViewstate() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_USERAGENT, $this->agent); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookies); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookies); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->request_header); $result = curl_exec($ch); $doc = new DOMDocument(); $doc->loadHTML($result); curl_close($ch); return $this->getValue('__VIEWSTATE', $doc); } function getData($bbox) { $post = 'eo_cb_id=ctl00_ContentBody_cbAjax'; $post .= '&eo_cb_param=' . rawurlencode('{"c": 1, "m": "", "d": "' . $bbox[3] . '|' . $bbox[1] . '|' . $bbox[2] . '|' . $bbox[0] . '"}'); $post .= '&__eo_obj_states='; $post .= '&__VIEWSTATE=' . urlencode($this->viewstate); $post .= '&eo_version=5.0.51.2'; $post .= '&=&=&=2&=3&=4&=5&=1858&=6&=8&=11&=137&=13&=453'; $post .= '&__EVENTTARGET='; $post .= '&__EVENTARGUMENT='; $post .= '&__EVENTVALIDATION='; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_USERAGENT, $this->agent); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookies); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookies); curl_setopt($ch, CURLOPT_REFERER, $this->reffer); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->request_header); $result = curl_exec($ch); curl_close($ch); // sample data //$result = ']]>'; $xml = new SimpleXMLElement($result); $json = $xml->ExtraData; if(function_exists('json_decode')) return json_decode($json, true); else return NULL; } } ?>