include 'simple_html_dom.php';
$html = str_get_html('https://cloud.su-19.com/index.php/login');
$token = $html->find('head', 0)->{'data-requesttoken'};
function isAuth( $data ){
return preg_match('#<form[^>]+id="logout"#Usi',$data);
}
$ch = curl_init();
$url = 'https://cloud.su-19.com/index.php/login';
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'user'=>'dm_gusev',
'password'=>'B2ttera4nat',
'timezone'=>'Europe/Moscow',
'timezone_offset'=>3,
'requesttoken'=>$token,
'direct'=>1
));
echo isAuth($data = curl_exec($ch))?'Success':'Failed';
curl_close($ch);