Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 05:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



PHP - cURL Cookie Problem

Discussion on PHP - cURL Cookie Problem within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 112
Join Date: Jan 2010
Posts: 1,531
Received Thanks: 414
PHP - cURL Cookie Problem

Hallo,
ich möchte eine Chinesische Seite sogesagt übersetzen. Dazu habe ich mir gedacht das ich ein Formular auf Deutsch mache und den Post an die chinesische Seite schicke.
Leider bekomme ich eine Fehlermeldung von der Seite aus das die Cookies deaktiviert sind oder so.
Nun weiß ich nicht weiter. Cookies sind laut Script an und sollten eig. weitergegebene werden.
Könnt ihr mir helfen?
PHP Code:
<?PHP
session_start
();

if (isset(
$_POST['submit']) && ($_POST['submit'] == "Registrieren")){
_99nos_register($_POST['account'],$_POST['passwort'],$_POST['key'],$_POST['email'],$_POST['captcha']);
}

$iGetPage curl_get('http://99nos.com/member/reg.aspx',1,0);
$_SESSION["cookie"] = 'ASP.NET_SessionId='.middlestring ($iGetPage,'ASP.NET_SessionId=',' path=/');
$_SESSION['Key1'] = middlestring($iGetPage,'ctl00_ContentPlaceHolder_main_ScriptManager1_HiddenField&_TSM_CombinedScripts_=','"');
$_SESSION['Key2'] = middlestring($iGetPage,'__VIEWSTATE" value="','"');
$_SESSION['Key3'] = middlestring($iGetPage,'__EVENTVALIDATION" value="','"');
$_SESSION['Key4'] = middlestring($iGetPage,'ctl00$ContentPlaceHolder_main$HyperLink2" value="','"');
?>

<form method="POST">
Account: <input name="account" /> <br/>
Passwort: <input name="passwort" /> <br/>
Sicherheitskey: <input name="key" /> <br/>
E-Mail: <input name="email" /> <br/>
Captcha: <?PHP echo "<img src='data:image/jpg;base64,".base64_encode(curl_get('http://99nos.com/VerifyCode.aspx'01))."' />"?> <input name="captcha" /><br/>
<input type="submit" name="submit" value="Registrieren" />
</form>

<?PHP
function _99nos_register($iAccount,$iPasswort,$iKey,$iEMail,$iCaptcha){
$iSendPaket 'ctl00_ContentPlaceHolder_main_ScriptManager1_HiddenField='.urlencode($_SESSION['Key1']).'&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE='.urlencode($_SESSION['Key2']).'&__EVENTVALIDATION='.urlencode($_SESSION['Key3']).'&ctl00%24ContentPlaceHolder_main%24UserID='.urlencode($iAccount).'&ctl00%24ContentPlaceHolder_main%24UserPWD='.urlencode($iPasswort).'&ctl00%24ContentPlaceHolder_main%24Re_UserPWD='.urlencode($iPasswort).'&ctl00%24ContentPlaceHolder_main%24SafePWD='.urlencode($iKey).'&ctl00%24ContentPlaceHolder_main%24Re_SafePWD='.urlencode($iKey).'&ctl00%24ContentPlaceHolder_main%24Email='.urlencode($iEMail).'&ctl00%24ContentPlaceHolder_main%24ValidateCode='.urlencode($iCaptcha).'&ctl00%24ContentPlaceHolder_main%24HyperLink2='.urlencode($_SESSION['Key4']);
$iPostPaket curl_post('http://99nos.com/member/reg.aspx',$iSendPaket,0,1);
echo 
$iPostPaket;
exit;
}

function 
curl_get($url$head$cook 0){
$ch curl_init($url);
curl_setopt($chCURLOPT_SSL_VERIFYPEER,0);
curl_setopt($chCURLOPT_SSL_VERIFYHOST,0);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($chCURLOPT_HEADER$head);
if(
$cook == 1){
curl_setopt($chCURLOPT_COOKIE$_SESSION["cookie"]);
echo 
"<!--".$_SESSION['cookie']."-->";
}
return 
curl_exec($ch);
}

function 
curl_post($url$datas,$head$cook 0){
$ch curl_init($url);
curl_setopt($chCURLOPT_POST,1);
curl_setopt($chCURLOPT_POSTFIELDS$datas);
curl_setopt($chCURLOPT_HEADER$head);
curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
if(
$cook == 1){
$ioption curl_setopt($chCURLOPT_COOKIE$_SESSION["cookie"]);
echo 
"<!--".$_SESSION['cookie']."-->";
}
curl_setopt($chCURLOPT_SSL_VERIFYPEER,0);
curl_setopt($chCURLOPT_SSL_VERIFYHOST,0);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
curl_setopt($chCURLOPT_HEADER1);
return 
curl_exec($ch);
}

function 
middlestring($string,$start,$stop){
$pos strpos($string,$start)+strlen($start);
$retstr substr($string,$pos);
$pos strpos($retstr,$stop);
$retstr substr($retstr,0,$pos);
return 
$retstr;
}
?>
Ich würde mich sehr freuen wenn ihr mir helfen könntet, 2 PHP Foren konnten dies leider nicht
mfg Freaky
¿Freaky¿ is offline  
Old 08/18/2011, 10:51   #2


 
Menan's Avatar
 
elite*gold: 0
The Black Market: 169/0/0
Join Date: Sep 2008
Posts: 9,484
Received Thanks: 3,109
Ich frag mich, wieso du hier:

PHP Code:
function curl_get($url$head$cook 0
$cook = 0 setzt, da sie ja beim aufruf der Funktion so oder so auf 1 oder 0 gesetzt wird...
Menan is offline  
Old 08/18/2011, 14:00   #3
 
elite*gold: 112
Join Date: Jan 2010
Posts: 1,531
Received Thanks: 414
Naja, es waren fertige Funktionen die ich von einem Kumpel bekommen habe.
Dort wurde $cook auf 0 gesetzt weil z.B. ich manchmal Faul bin und den Cookie nicht angebe. Und deswegen soll keine Fehlermeldung kommen etc.
Aber das hilft mir jetzt bei meinem Problem nicht gerade weiter
¿Freaky¿ is offline  
Old 08/18/2011, 14:48   #4


 
Menan's Avatar
 
elite*gold: 0
The Black Market: 169/0/0
Join Date: Sep 2008
Posts: 9,484
Received Thanks: 3,109
Eventuell musst du noch mehr cookies übergeben als die Session Id...

Edit ich glaube ich hab da was gefunden...

Du hast ja am Anfang des Scripts eine Abfrage, ob "abgesendet" wurde.

Allerdings holst du dir beim ersten Aufrufen des Scripts die Cookies etc. dann kommt der submit und er holt sich erneut die Cookies...

eventuell liegt es daran, dass du dann 2 verschiedene Cookies bzw. die Cookies dann falsch / ungültig sind..

Ich könnte mir vorstellen, dass es eventuell daran liegt...
Menan is offline  
Old 08/18/2011, 15:22   #5
 
elite*gold: 112
Join Date: Jan 2010
Posts: 1,531
Received Thanks: 414
Ja er holt sich erneut die Cookies aber nachdem er den Post abgegeben hat...
Ich setze ja nicht einfach so den die Abfrage über das erneute Cookie setzen :P

Aber wenn du das Script ausprobiert hättest, dann würdest du sehen was man zurück bekommt. Die Seite sagt irgend wie das die Cookies deaktiviert sind oder so (ist auf Chinesisch >.>).
¿Freaky¿ is offline  
Old 08/18/2011, 15:39   #6


 
Menan's Avatar
 
elite*gold: 0
The Black Market: 169/0/0
Join Date: Sep 2008
Posts: 9,484
Received Thanks: 3,109
Ich hab das Script ausprobiert, eventuell werden auch nach der Registrierung neue Cookies gesetzt, die du erneut abfragen musst und weil es eben die neuen Cookies nicht setzen kann meint es, dass Cookies deaktiviert sind.
Menan is offline  
Old 08/19/2011, 03:03   #7
 
elite*gold: 112
Join Date: Jan 2010
Posts: 1,531
Received Thanks: 414
Naja, beim Sniffen waren bei mir die Cookies von Anfang bis Ende gleich
¿Freaky¿ is offline  
Reply


Similar Threads Similar Threads
help with curl
05/20/2011 - CO2 Programming - 0 Replies
im trying to log in to a page using curl to modify one of my post like updating that specific post with new information over the time i dont understand very much curl and most of the examples i search are in php and i need it to use with autoit or the cmd directly right now im trying from the start, to get logged in the webpage i have found that i need the names of the inputs user and password and that i need a cookie to receive and to send, but when i check the curl.txt in a browser it...
Cookie.Atdmt
07/02/2010 - WarRock - 5 Replies
mein antivir programm hat den virus gefunden Cookie.Atdmt ist das ein schlimmmer virus?
[PHP] cUrl Login
04/19/2010 - Web Development - 0 Replies
So ich hab ein kleines Problem. Und zwar versuche ich für das Browsergame Space Pioneers einen Bot mit PHP zu schreiben was generell auch kein Problem wäre, allerdings habe ich ein kleines Problem. Und zwar gibt es zwei möglichkeiten sich einzuloggen, das wäre einmal auf Looki und einmal der Notfall Login Login. Nun zu meinem Problem. Das Einloggen im ersten Link klappt soweit ganz gut, ich habe meines errachtens auch alle Inputs mit übergeben, hat mir allerdings keinen Acceskey...
Auto-Account Creator - Problem: Cookie
01/13/2008 - General Coding - 2 Replies
Heyho! Ich will einen auto account creator erstellen. Habe die Http-Packets analysiert und die server responses ebenso. Jetzt wüsste ich gerne: in einem HTTP-Request wird eine Cookie ID abgefragt... Wie soll ich die in mein Programm einbinden? bzw: wie kann ich die Cookie erstellung einbinden? Habe ich nicht genau genug nachgesehen und es gab eine "CREATE Cookie" anweisung? bitte um Hilfe/Ratschläge :) //edit// hab mich kurz mit rEdoX unterhalten... vllt hab ich doch kein problem ;D



All times are GMT +1. The time now is 05:01.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.