"I have given the world for the sake of your eyes"

tşk ederim şimdi oldu =)

saintx adlı üyeden alıntı: mesajı görüntüle
@buddy; şu haliyle deneyebilir misin?

<?php
    
    header("Content-Type: text/plain; charset=UTF-8");
    
    function curl_get_contents($url, $timeout = 20, $connect_timeout = 5)
    {
        if(extension_loaded("curl"))
        {
            $handle = curl_init();
            
            curl_setopt($handle, CURLOPT_URL, $url);
            
            curl_setopt($handle, CURLOPT_HEADER, false);
            curl_setopt($handle, CURLOPT_NOBODY, false);
            
            curl_setopt($handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0");
            
            curl_setopt($handle, CURLOPT_BINARYTRANSFER, true);
            curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
            
            curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
            
            curl_setopt($handle, CURLOPT_TIMEOUT, $timeout);
            curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, $connect_timeout);
            
            $response = (object) array(
                "url" => $url,
                "body" => curl_exec($handle),
                "info" => curl_getinfo($handle),
                "error" => (object) array(
                    "ID" => curl_errno($handle),
                    "message" => curl_error($handle)
                )
            );
            
            curl_close($handle);
            
            unset($handle, $url, $timeout, $connect_timeout);
            
            return $response;
        }
        else
        {
            return false;
        }
    }
    
    function translate($string, $from = "en", $to = "tr")
    {
        $string = urlencode($string);
        
        $url = "http://translate.google.com/translate_a/t?client=t&text={$string}&hl=en&sl={$from}&tl={$to}&multires=1&oc=0&prev=btn&sc=1";
        
        $request = curl_get_contents($url);
        
        if($request->error->ID !== 0)
        {
            return false;
        }
        
        $response = $request->body;
        
        $json = preg_match("#\[(.*?)\]#si", $response, $matches) ? json_decode("[".ltrim($matches[0], "[")) : null;
        
        return isset($json[0]) ? $json[0] : false;
    }
    
    echo translate("Hello World", "en", "tr");
    
    echo "\n";
    
    echo translate("Merhaba Dünya", "tr", "en");