\nReply-To: Spider PHP "; var $mail_to = false; var $mail_html = false; var $timeout = 60; // var $temp_folder = ''; function get_xpath($page, $post = null){ $doc = new DOMDocument(); if($this->debug) $doc->loadHTML($this->get_html($page, $post)); else @$doc->loadHTML($this->get_html($page, $post)); return new DOMXPath($doc); } function svuotaCookie(){ file_put_contents($this->cookie, ''); } function segnalaSeVuoto($var, $cos_e){ if(!$var) return mail($this->debug_email, '"'.$cos_e.'" vuoto!!!', $this->from_header); } function svuotaLog(){ file_put_contents($this->log_file, ''); } function log($mess, $tag = null){ if(is_null($tag)) $tag = get_class($this); $log = strftime("%c")."\t$tag\t$mess\n"; file_put_contents($this->log_file, $log, FILE_APPEND ); // $fp = fopen($this->log_file, "a+"); // fwrite($fp, $log, strlen($log)); // fclose($fp); } function mail($oggetto, $corpo_o_dati){ if($this->mail_to){ $header_html = ''; if($this->mail_html) $header_html = 'MIME-Version: 1.0' . "\n". 'Content-type: text/html; charset=iso-8859-1' . "\n"; $result = mail($this->mail_to, $oggetto, $corpo_o_dati, $header_html.$this->from_header); if($this->debug){ echo $result ? 'INVIATA EMAIL' : 'ERRORE DURANTE L\'INVIO DELLA MAIL'; } return $result; } else{ echo "

$oggetto

$corpo_o_dati
"; } } function get_html($page, $post = null){ return $this->request($page, $post); } function request($page, $post = null){ if($this->cache_data){ $key = md5($page.print_r($post, true)); session_start(); if($_SESSION[$key]) return $_SESSION[$key]; } $return = $this->curl($page, $post); if($this->cache_data) $_SESSION[$key] = $return; return $return; } function curl($page, $post = null){ $ch = curl_init(); // if(($cache_data||($cookie===true)) && !$temp_folder) die('devi impostare la $this->temp_folder e renderla scrivibile'); // if($cookie===true) $cookie if($this->debug){ $this->logfile = "php://output"; curl_setopt($ch, CURLOPT_VERBOSE, true); } if($this->cookie){ touch($this->cookie); } if($this->user_agent) curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); if($this->insecure_ssl){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // curl_setopt($ch, CURLOPT_SSL_VERIYHOST, 2); } if($this->referer){ if($this->debug) echo "Referer: ".$this->referer.'
'; curl_setopt($ch, CURLOPT_REFERER, $this->referer); $this->referer = $page;//per il prossimo passaggio? } if($this->logfile){ curl_setopt($ch, CURLOPT_VERBOSE, 1); $r = fopen($this->logfile, 'w+'); curl_setopt($ch, CURLOPT_STDERR, $r); } if(!is_null($this->timeout)){ curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); } if($this->cookie){ curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); } if($this->extra_header){ curl_setopt($ch, CURLOPT_HTTPHEADER, $this->extra_header); } if($post){ $poststring = $post; if(is_array($poststring)) $poststring = http_build_query($poststring); //la funzione accetta anche un array ma setta degli header in più: //Content-Type: multipart/form-data; boundary=----------------------------aee1864775a1 //siti TIM/ALICE si incazzano! curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring); } // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); // curl_setopt($ch, CURLOPT_HEADER, 1); // if($GLOBALS['aethaethp']) curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); // $GLOBALS['aethaethp'] = true; curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_URL, $page); $buf = curl_exec ($ch); // execute the curl command $e = curl_errno($ch); //lo controllo perchè "SSL: certificate subject name 'pbx.kalliopepbx.com' does not match target host name '213.243.203.46'" da' errno=0 //e questo è un warning che da' sempre quando si forza una connessione senza verifica di certificato if($e) $this->request_error = curl_error($ch); // if($error = curl_error($ch)){ // die($error); // } curl_close ($ch); unset($ch); if($this->debug){ echo "$page"; if($post) echo "
(".htmlentities(print_r($post, true)).")
"; if($this->logfile){ echo '
LOG:
'; fclose($r); echo '
'; } } if($this->debug_html){ $func = $this->debug_html_function; echo "
";
			echo $func(trim($buf));
			echo '
'; } if($this->debug_html || $this->debug){ echo '


'; flush(); } return $buf; } function parseAction($html){ preg_match('/action="([^"]*)"/ims', $html, $action); return $action[1]; } function parseInputs($html){ preg_match_all('//im', $html, $inputs); foreach($inputs[1] as $k=>$name) $posts[] = $name . "=" . $inputs[2][$k]; return implode("&", $posts); } } ?>