<?php
$cookieFile = "cookies.txt";
if(!file_exists($cookieFile)) {
$fh = fopen($cookieFile, "w");
fwrite($fh, "");
fclose($fh);
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.sunnyportal.com/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_COOKIEJAR => 'cookies.txt',
CURLOPT_COOKIEFILE => 'cookies.txt',
CURLOPT_CUSTOMREQUEST => "GET"
));
$response = curl_exec($curl);
preg_match('@<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value=\"(.*)\" />@', $response, $sonuc1);
$viewstate = $sonuc1[1];
preg_match('@<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value=\"(.*)\" />@', $response, $sonuc);
$viewgenerator = $sonuc[1];
$ch = curl_init();
$params = [
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'__VIEWSTATE' => $viewstate,
'__VIEWSTATEGENERATOR' => $viewgenerator,
'ctl00$ContentPlaceHolder1$LoginControl1$txtUserName' => 'asfasfaf@sdafasdf.com',
'ctl00$ContentPlaceHolder1$LoginControl1$txtPassword' => 'asfasfs',
'ctl00$ContentPlaceHolder1$LoginControl1$LoginBtn' => 'Oturum aç',
'ctl00$ContentPlaceHolder1$LoginControl1$RedirectURL' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$RedirectPlant' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$RedirectPage' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$RedirectDevice' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$RedirectOther' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$PlantIdentifier' => '',
'ctl00$ContentPlaceHolder1$LoginControl1$ServiceAccess' => 'true',
'ClientScreenWidth' => '1366',
'ClientScreenHeight' => '768',
'ClientScreenAvailWidth' => '1366',
'ClientScreenAvailHeight' => '728',
'ClientWindowInnerWidth' => '1365',
'ClientWindowInnerHeight' => '367',
'ClientBrowserVersion' => '64',
'ClientAppVersion' => '5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
'ClientAppName' => 'Netscape',
'ClientLanguage' => 'tr',
'ClientPlatform' => 'Win32',
'ClientUserAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
];
curl_setopt($ch, CURLOPT_URL,'https://www.sunnyportal.com/Templates/Login.aspx');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, "https://www.sunnyportal.com/Templates/Login.aspx");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_COOKIE, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
$source = curl_exec($ch);
curl_close($ch);
echo $source;
?>al bakalım