All pastes #902668 Raw Edit

Ali Engin Musaolu

public text v1 · immutable
·published 2008-02-13 17:59 UTC
rendered paste body
<?


class attila {
    var $ch = "";
    var $userAgent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
    var $cookieF   = 'tmp/getcookies.txt'; # path tam girilmelidir. ( absolute )
    
    /* HTTP istegini baslat */
    function baslat($url) {
    	  $this->ch = curl_init($url);
    }
    
    /* HTTP isteginin detaylari - ana fonksiyon */
    function istekDetay($istek,$cookie="1",$HTTPS="0",$postVerisi="") {

        if($istek == 'POST' && $fields != "") {
            curl_setopt($this->ch,CURLOPT_POSTFIELDS,$fields);
        }
        
        if($istek == 'GET') {
            curl_setopt($this->ch,CURLOPT_HTTPGET,1);
        }

        if($istek == 'POST') {
            curl_setopt($this->ch,CURLOPT_POSTFIELDS,$postVerisi);
        }
        
        if($cookie == 1) {
            curl_setopt($this->ch,CURLOPT_COOKIEJAR, $this->cookieF);
            curl_setopt($this->ch,CURLOPT_COOKIEFILE,$this->cookieF);
        }
        
	  if($HTTPS == 1) {
            curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        }

	  curl_setopt($this->ch, CURLOPT_USERAGENT, $this->useragent);
        curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);

        return curl_exec($this->ch);
        $this->istekBitis();
              
    }
    

    /* HTTP istegi sonu */
    function istekBitis() {
        curl_close($this->ch);    
    }
    
    /* ara fonksiyonlar */
    function POST($url,$fields,$cookies,$https=0) {

    	  $this->baslat($url); 

        if($https == 1) $https = 1; else $https = 0;
        
        if($cookies == 0) {
            return $this->istekDetay('POST',0,$https,$fields);
        }
        
        if($cookies == 1) {
            return $this->istekDetay('POST',1,$https,$fields);
        }
    
    function GET($url,$cookies,$https=0) {

    	  $this->baslat($url); 

        if($https == 1) $https = 1; else $https = 0;
        
        if($cookies == 0) {
            return $this->istekDetay('GET',0,$https,0);
        }
        
        if($cookies == 1) {
            return $this->istekDetay('GET',1,$https,0);
        }

    }
}

$istek = new attila;
# $istek->istekDetay("http://localhost/test/curl.php");
# $istek->rDetails('POST',1,0,'post verisi');

/* 
GET istek tasi
echo $istek->doGET("http://localhost/test/curl.php?a=e",1);
GET normal
echo $istek->doGET("http://localhost/test/curl.php?a=e",0);
HTTPS GET
echo $istek->doGET("https://login.yahoo.com/config/login?",1,1);
HTTP POST
echo $istek->doPOST("http://localhost/csa/sample.php","emre=isim&yilmaz=soyad",1,0);
HTTPS POST
echo $istek->doPOST("http://localhost/csa/sample.php","emre=isim&yilmaz=soyad",1,0);
*/

/*
echo $istek->doPOST("http://localhost/csa/sample.php","emre=isim&yilmaz=soyad",1);
echo $istek->doPOST("http://localhost/csa/2.php","ehe=mehe",1);
//echo $istek->doGET("http://localhost/csa/curl2.php",1);

*/

/* 
echo $istek->GET("http://www.sosyomat.com/giris",1);
echo $istek->POST("http://www.sosyomat.com/uyelik/login","user[mail]=yilmazyemre@yahoo.com&user[password]=yemre&frame=true&x=1&y=5",1);
$kaynak = $istek->GET("http://www.sosyomat.com/arkadaslarim",1);

preg_match_all('|<div class="avatard"><a href="http://([^\.]*?)\.sosyomat.com/" class="nehir-link">|i',$kaynak,$sonuc);
echo"Yns adli uyenin arkadaslari: <br />";
foreach($sonuc[1] as $arkadas) {
    echo($arkadas) . "<br />";
}
 
*/

echo $istek->POST("http://localhost/csa/2.php",'asd=asd&asdasdasd=asdasd',1);

















?>