Pisałem bibliotekę, i lipnie, bo coś nie działa post(logowanie)

Biblioteka:
<?php
class curl {
public $curl = NULL;
public $settings = array( CURLOPT_COOKIEFILE => "cookies.txt",
CURLOPT_COOKIEJAR => "cookies.txt",
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_AUTOREFERER => TRUE,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30",
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => NULL,
CURLOPT_HEADER => FALSE,
CURLOPT_TIMEOUT => "10",
CURLOPT_CONNECTTIMEOUT => "5"
);
function polacz($web) {
return $this->curl = curl_init($web);
}
function wejdz($web, $values_post = NULL) {
curl_setopt($this->curl, CURLOPT_URL, $web);
foreach($this->settings as $opt => $value) {
curl_setopt($this->curl, $opt, $value);
}
if($values_post) { curl_setopt($this->curl, CURLOPT_POSTFIELDS, $values_post); }
return $this->curl;
}
function setopt($options) {
foreach($options as $opt => $value) {
$this->settings[$opt] = $value;
}
}
return curl_exec($this->curl);
}
function err() {
return curl_error($this->curl);
}
function rozlacz() {
return curl_close($this->curl);
}
}
?>
Plik:
$curl = new curl;
$url = "http://agirls.pl";
$curl->polacz($url);
$curl->wejdz($url."/login.php", "login=login&password=haslo&submit");
$curl->rozlacz();
To nie nadpisuje też pliku cookies.txt
Ten post edytował rivos 4.07.2012, 19:07:19