Jump to content

Seeking some help (php fsockopen to curl conversion)


setheroth69

Recommended Posts

now I'm new to php, and been teaching myself.

I found online a class to use with php that allows me to pull information from the XML file on our shoutcast server. The problem I ran into is when I uploaded it to my host, I found out they block the use of fsockopen. I've read up on cURL but still can't wrap my head around it...

 

I have some of the class converted to use cURL but I'm running into a problem around this part:

 

        //$fp = fsockopen($this->host, $this->port, $errno, $errstr, 10);
        $fp = $data;
        If (!$fp) {
            $this->_error = "$errstr ($errno)";
            return(0);
        } else {
            fputs($fp, "GET /admin.cgi?pass=".$this->passwd."&mode=viewxml HTTP/1.0\r\n");
            fputs($fp, "User-Agent: Mozilla\r\n\r\n");
            while (!feof($data)) {
                    $this->_xml .= fgets($data, 512);
            }
            fclose($fp);

            if (stristr($this->_xml, "HTTP/1.0 200 OK") == true) {
                // <-H> Thanks to Blaster for this fix.. trim();
                $this->_xml = trim(substr($this->_xml, 42));
            } else {
                $this->_error = "Bad login";
                return(0);
            }

now I had a small workaround that ended up not working.

I kept getting the Bad Login error message.

 

I've searched online for a remedy and well all I could find were posts saying dump the host and find one that allows fsockopen....

 

If anyone can help me I'd greatly appreciate it, this problem is keeping me from finishing off an integration between the database, the webpage, and the dj's.

 

**I have attached the file (both the pure file and the edited file minus passwords and other sensitive information) for you all to look at.

 

***Oops forgot, using PHP5

 

[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.