0

hello all,
i am new here, i saw your community and i think to start here :)
i opend new site base on wordpress

i got this prob :

Warning: Cannot modify header information - headers already sent by (output started at /home/down/domains/4downyoutube.com/public_html/wp-content/plugins/youtubefreedown/stream.php:1) in /home/down/domains/4downyoutube.com/public_html/wp-content/plugins/youtubefreedown/curl.php on line 185

this is the curl file :

<?php

class Curl {
	var $callback = false;
	var $secure = false;
	var $conn = false;
	var $cookiefile =false;
	var $header = false;
	var $cookie = false;
	var $follow = true;
        var $dump   = false;
        var $range  = false;
        var $timeout = false;
	var $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

	function Curl($u = false) {
		$this->conn = curl_init();
		if (!$u) {
			$u = rand(0,100000);
		}

                $file = dirname(__FILE__).'/temp/'.md5($u);
                $file = str_replace('\\','/', $file);
		$this->cookiefile= $file;

	}

	function setCallback($func_name) {
		$this->callback = $func_name;
	}

	function close() {
		curl_close($this->conn);
		if (is_file($this->cookiefile)) {
			//unlink($this->cookiefile);
		}

	}

	function doRequest($method, $url, $vars) {

		$ch = $this->conn;

		curl_setopt($ch, CURLOPT_URL, $url);
		if ($this->header) {
			curl_setopt($ch, CURLOPT_HEADER, 1);
		} else {
		    curl_setopt($ch, CURLOPT_HEADER, 0);
		}
		curl_setopt($ch, CURLOPT_USERAGENT,$this->user_agent);
                curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: ".$_SERVER['REMOTE_ADDR'], "HTTP_X_FORWARDED_FOR: ".$_SERVER['REMOTE_ADDR'])); // send users ip ???


		if($this->secure) {
			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  0);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		}

		if ($this->cookie)
        {
        	curl_setopt($ch, CURLOPT_COOKIE,$this->cookie);
        }

        if ($this->follow) {
            @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        } else {
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
        }

        if($this->dump) {
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
        } else {
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        }

        if($this->range)
        {
            curl_setopt($ch, CURLOPT_RANGE,$this->range);
        } 

        if($this->timeout)
        {
            curl_setopt($ch, CURLOPT_TIMEOUT,$this->timeout);
        } else {
            curl_setopt($ch, CURLOPT_TIMEOUT,false);
        }

        curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiefile);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiefile);

        if ($method == 'POST') {
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: ')); // lighttpd fix
        }

        $data = curl_exec($ch);

        if ($data) {
                if ($this->callback)
                {
                        $callback = $this->callback;
                        $this->callback = false;
                        return call_user_func($callback, $data);
                } else {
                        return $data;
                }
        } else {
                return false;
        }
	}

	function get($url) {
		return $this->doRequest('GET', $url, 'NULL');
	}


        function processHeader($ch,$string)
        {
            if(preg_match('%Content-Range: bytes 0-1024/([0-9]+)%', $string,$match))
            {
                $this->size =  $match[1];
                return false;
            }

            if(preg_match('%Content-Length: ([0-9]+)%', $string,$match))
            {
                $this->size =  $match[1];
                return false;
            }

            return strlen($string);
        }

        function getSize($url) {

            $this->size = false;

            $this->header  =  true;
            $this->range   = "0-1024";
            $this->dump    =  true; // some sites dont echo in curl

            curl_setopt($this->conn,CURLOPT_HEADERFUNCTION,array($this,processHeader));
            ob_start();
            $this->doRequest('GET', $url,false);
            $result = ob_get_contents();
            ob_end_clean();

            $this->dump    = false;
            $this->header  = false;
            $this->range   = false;
          
            return $this->size;
	}


	function getError()
	{
		return curl_error($this->conn);
	}

	function post($url, $params = false) {

		$post_data = '';

		if (is_array($params)) {

			foreach($params as $var=>$val) {
				if(!empty($post_data))$post_data.='&';
				$post_data.= $var.'='.urlencode($val);
			}

		} else {
			$post_data = $params;
		}

		return $this->doRequest('POST', $url, $post_data);
	}
        
        function streamHeader($ch,$string)
        {
            if(empty ($string)) return;

            header($string);
            return strlen($string);
        }

        function stream($url) 
        {
            $this->dump = true;
            curl_setopt($this->conn,CURLOPT_HEADERFUNCTION,array($this,"streamHeader"));
            $this->doRequest('GET', $url,false);

        }

        function getRedirect($url)
	{
	    $this->follow = false;
	    $this->header = true;

	    $html =  $this->get($url);

	    if(preg_match('/Location: (.*?)[\r\n]+/',$html,$match) || preg_match('/http-equiv=\'Refresh\' content=\'[0-9]+;url=(.*?)\'/s',$html,$match))
	    {
	        return $match[1];
	    }

	    $this->follow = true;
	    $this->header = false;
	}
        
}

function getPage($url,$post = false,$cookie = false)
{
    $pURL = parse_url($url);

    $curl = new Curl($pURL['host']);

    if (strstr($url,'https://'))
    {
        $curl->secure = true;
    }

    if ($post) {
    	return $curl->post($url,$post);
    } else {
        return $curl->get($url);
    }

}
?>

thanks for your help.

3
Contributors
12
Replies
17
Views
6 Years
Discussion Span
Last Post by Matthew N.
0

This is a very common problem that has been raised (and solved) many times before. I suggest that you use the search capability on this site to look for similar problems that have already been solved before posting it as a new problem. In this case a search will provide you with these search results. Have a look at some of them and you'll probably be able to figure out what you did wrong.

0

i do it already,
i try many things that offer there but its still show up, so i write this new post.

maybe i am doing something not right.

thanks

0

some sites PHP.ini files have all error reporting on.
add

ob_start();

to the start of the file, evem before comments.
Please say if this works

Edited by Matthew N.: n/a

0

no put it after the PHP tags like this :

<?php
ob_start();

Sorry, my fault for not being clear.

0

ok thanks.
when i put this in the curl.php
i get this error

Warning: Cannot modify header information - headers already sent by (output started at /home/down/domains/4downyoutube.com/public_html/wp-content/plugins/youtubefreedown/stream.php:1) in /home/down/domains/4downyoutube.com/public_html/wp-content/plugins/youtubefreedown/curl.php on line 185

this is the stream.php code
i tried to put the code ob_start(); in this file 2.

<?php

if(!isset($_GET['url']) && empty ($_GET['url'])){
    die('No url found');
}

include('curl.php');

$curl = new Curl(time());

$curl->stream(base64_decode($_GET['url']));

?>
0

this 2 error come togther??

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /home/down/domains/4downyoutube.com/public_html/wp-content/plugins/youtubefreedown/curl.php on line 65
0

Does your web host allow you to change php.ini?
This error is suggesting that it cant run cURL with safe_mode on or an open_basedir.
I'm sorry I cannot help with the open_basedir, as I don't know anything about it.

0

ok. make a file in public_html or htdocs folder (depending on which you have) called php.ini.set.php and add this code to it:
(It will turn safe_mode off it is not already off).

<?php
if(ini_get('safe_mode') != "On")) {
    echo 'safe_mode is already off. The error is caused by an open_basedir';
} else {
    ini_set('safe_mode','Off');
    echo 'safe_mode is now turned off';
}
?>

Now open it (In a webbrowser)
this will fix the safe_mode error.
I will try and find out how to fix the open_basedir error.

Edited by Matthew N.: n/a

0

I'll describe my code :

if(ini_get('safe_mode') != "On") {

}
/*
This piece of code checks with the PHP config to check whether safe_mode is on or not.
*/
ini_set('safe_mode','Off');
/*
This turns safe_mode off in the PHP config
*/
0

Here is something I found in Godaddy Help Center :
What is open_basedir?
Print this Article
Comment on this Article
Last Updated: December 10, 2007 11:52 AM

The open_basedir function defines the locations or paths from which PHP is allowed to access files using functions like fopen() and gzopen(). If a file is outside of the paths defined by open_basdir, PHP will refuse to open it. You cannot use a symbolic link as a workaround, because the path that the symbolic link resolves to falls under the restrictions of the open_basedir function.

Note: The open_basedir restrictions can be turned off in the Apache configuration file, httpd.conf, with the following line: php_admin_value open_basedir none

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.