function auth nick by_kevin свой Логин pass admin свой Пароль curl cur

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function auth(){
$nick = 'by_kevin';/*свой Логин*/
$pass = 'admin';/*свой Пароль*/
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://spaces.ru/registration/?r=reg/loginform");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
//curl_setopt($curl, CURLOPT_TIMEOUT, 3);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5");
$outlogin = curl_exec($curl);
preg_match("/sid=(\d+)/",$outlogin, $SID);/// sid
preg_match("/<input type=\"hidden\" name=\"CK\" value=\"(.*?)\"\/>/",$outlogin, $CK_D);/// CK
$SID_A=$SID[1];
$CK_D_A=$CK_D[1];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://spaces.ru/registration/?r=reg/loginform&sid=::sid::$SID_A");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "name=$nick&password=$pass&cfms=%D0%92%D0%BE%D0%B9%D1%82%D0%B8&sid=&CK=$CK_D_A&link_id=0");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, "spaces.txt");
$outvhod = curl_exec($curl);
}