Since I am a fucking noob at PHP I have spent tons of hours at this and I will honestly say that I am fucking pissed and tired, but I wanna fix this shit, so I am starting to use last things I can imagine, like asking help on otland
The task I want to do is to create script that would log my user in a site - draugiem.lv As I understand this can be done by using curl. The major problem for me is that, I can't understand how to create the a proper path for POST_FIELDS. It seems for me that it is a bit different for this site than in others. Here is the dmn login form:
This is how curl looks like:
THe POST_FIELDS should be simular to this, but the link has to be much longer I think, since there is such shit as declaring languages or smth, I can't really understand a lot in that form:
The task I want to do is to create script that would log my user in a site - draugiem.lv As I understand this can be done by using curl. The major problem for me is that, I can't understand how to create the a proper path for POST_FIELDS. It seems for me that it is a bit different for this site than in others. Here is the dmn login form:
PHP:
<form action="/index.php" class="lgnfrm" method="POST" name="login" onSubmit="document.login.login.value='Uzgaidiet...'" >
<input type="hidden" name="redir" value="%2Findex.php" />
<input type="hidden" name="loginaction" value="1" />
<input type="hidden" name="lng" value="lv" />
<input type="hidden" name="t" value="x" />
<div class="tplLoginformContent">
Tavs e-pasts<br/><input type="text" class="inp" name="eml" size="23" value="" /><br />
Tava parole<br/><input type="password" onKeyPress="return capsLock(event)" class="inp" name="_21701351" size="23" autocomplete="off" /><br />
<div id="caps_lock" style="display:none; color:red; font-weight:bold">
Caps Lock taustiņš ir ieslēgts.<br />
Pārliecinies, ka raksti paroli pareizi! </div>
<table class="newButton newButtonLink " cellspacing="0" id="" style="">
<tr class=" small">
<td width="7"><div class="el l"></div></td>
<td class="el m"><input id="" class="" type="submit" name="login" value="Ienākt" onclick="" /></td>
<td width="7"><div class="el r"></div></td>
</tr>
</table>
<br />
<a href="/forgot/" class="foot">Aizmirsi paroli?</a>
</div>
<input type="hidden" id="feat1" name="feat1" value="" />
<input type="hidden" id="feat2" name="feat2" value="" />
<input type="hidden" id="feat3" name="feat3" value="" />
<input type="hidden" id="res" name="res" value="" />
</form>
This is how curl looks like:
PHP:
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://draugiem.lv/index.php');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldname2=fieldvalue2');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Downloads/AnnualReport.pdf');
// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);
// CLOSE CURL
curl_close ($ch);
THe POST_FIELDS should be simular to this, but the link has to be much longer I think, since there is such shit as declaring languages or smth, I can't really understand a lot in that form:
PHP:
curl_setopt ($ch, CURLOPT_POSTFIELDS, '[email protected]&_21701351=modafakingpw');