curlgiris.php
$uname = "murat_asl38";
$pass = "******";
$ch = curl_init();
$cookie_new = fopen ("cookie.txt", "w");
curl_setopt($ch, CURLOPT_URL, "http://www.****.com/login.php");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"www.***.com&login=".$uname."&pass=".$pass);
curl_setopt ($ch, CURLOPT_WRITEHEADER, $cookie_new);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$icerik = curl_exec($ch);
echo $icerik;
fclose ($cookie_new);
curl_close($ch);index.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<?php
echo '<meta http-equiv="refresh" content="0; url=curlson.php?session='.$_GET['session'].'"/>';
?>
</head>
<body>
</body>
</html>
<font color="#000000">
curlson.php
$session =$_GET['session'];
$dosya = fopen('cookie.txt','r');
$icerik = fread($dosya, filesize('cookie.txt'));
$dizi = (explode("Set-Cookie: ",$icerik));
$session1=(explode(";",$dizi[1]));
$session1['0'] = trim($session1['0']);
$session2=(explode(";",$dizi[2]));
$session2['0'] = trim($session2['0']);
$session3=(explode(";",$dizi[3]));
$session3['0'] = trim($session3['0']);
$cookie = $session2['0']."; ".$session3['0']."; ".$session1['0'];
$evrendizi = explode(":",$session3['0']);
$evren = str_replace("U_tr","",$evrendizi['0']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.****.com/index.php?page=overview&session=".$session);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_COOKIE,$cookie);
$sayfaicerik= curl_exec($ch);
$satirlar = explode ("toplam",$sayfaicerik);
$sayi = explode ("oyuncu",$satirlar['1']);
$final = trim($sayi['0']);
curl_close($ch);bu kullandığım phpbb bi forum sitesi yapılanlar bunlardır yardımların için tekrar teşekkürler
curlgiris te
CURLOPT_POSTFIELDS,"www.***.com&login=".$uname."&p ass=".$pass);
satırı şöyle olmalı;
CURLOPT_POSTFIELDS,"login=".$uname."&pass=".$pass) ;
tabii form daki kutucukların adı login ve pass ise.
ayrıca adres olarak sadece bu mu kullanılıyor. curl_setopt($ch, CURLOPT_URL, "http://www.****.com/login.php");
adresin sonunda ?do=login gibi birşey olabilir.
benim yazdığım projede login.php sayfası otomatik olarak index.php ye yönlendiriyordu. senin denediğin sitede de öyle mi? buna artı olarak yönlendirilen adresin son kısmı ?session= şeklinde mi? öyle değilse index.php de sorun oluşur.
son olarak curlson.php dosyasını hiç değiştirmemişsin. o script ogame e göre yazılmıştı. sana gönderilen header bilgisine göre düzenlemen gerekir.
cookie.txt
HTTP/1.1 302 Object moved
Date: Sun, 17 Feb 2008 08:42:55 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Location: ../index.asp
Content-Length: 133
Content-Type: text/html
Expires: Sun, 17 Feb 2008 08:42:55 GMT
Set-Cookie: Driveruser=nick=MaXCiLoPeZ&handle=Osman&lock=MaXCiLoPeZ&door=maxcilopez%2D%40hotmail%2Ecom; expires=Tue, 19-Feb-2008 08:42:54 GMT; path=/
Set-Cookie: ASPSESSIONIDSCSDBQCT=IDAJBHJDIOGLFFPOMGCLFHCD; path=/
Cache-control: private
HTTP/1.1 200 OK
Date: Sun, 17 Feb 2008 08:42:55 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Content-Length: 39349
Content-Type: text/html
Set-Cookie: ASPSESSIONIDSCSDBQCT=JDAJBHJDCFNCHPFCNFIOHMKP; path=/
Cache-control: private
benim yapmak istediğim
üyelik isteyen safyası bu
http://www.driverara.org/download/dr...l.asp?id=20544
Bu safyafa girip bir şeyler çekmek istiyorum ama o sayfaya giriş yaptıramadım :S
burdaki sorun ASPSESSIONIDSCSDBQCT
adlı cookie değişkeninden kaynaklanıyor gibi. sen muhtemelen en son da verilen değeri kullanmalısın.
bunu deneyip sonucu yazarsan yardımcı olmaya çalışırız.
Bilgiler harika ve örnek de tam istediğim gibi.Teşekkür ederim.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Peki bu ne işe yarıyor?
nihayet biri çıkıp beklediğim soruyu sordu? çünkü kodu hazır almıştım, bu yazıyı yazdığım zaman bilmiyordum. biraz araştırıp öğrendim. o parametrenin amacı curl_exec ile oluşan çıktının direk olarak ekrana basılması yerine string e dönüştürülmesi ve kaydedilmeye veya işlem yapılmaya hazır hale getirilmesidir.