fsockopen setup

Started on the old forum in May 2010 · view the original in the archive · old links redirect here

3 replies · 705 views · started 16 years ago · 1 min read

4 participants
sanju Developer · 59 posts #1

friends, is it possible to enable the service by .htacess/php ini/ or any php file? how to know that my server Support this service or not? Plz post some details about it ...Thank u

GiLL Senior · 356 posts #3

you can check like

<?php
If(function_exists("fsockopen")){
        echo 'Function Exists';
}
Else{
        echo 'function does not exist';
}
?> 

or

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Language" content="en-gb" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Function Test</title>

</head>

<body>

PHP mail() and fsockopen function test.
<p >
Send Mail check follows.. no error indicates it's working.</p>

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// Send
mail('mailcheck@somecrappyfakedomainname.whatver.com', 'test subject', $message);
?> 

<p>
FSOCKOPEN test follows: </p>
<p>
<b>
<?
echo get_url_title("http://news.bbc.co.uk");

function get_url_title($url, $timeout = 2)
{
    $url = parse_url($url);

    if(!in_array($url['scheme'],array('','http')))
        return;

    $fp = fsockopen ($url['host'], ($url['port'] > 0 ? $url['port'] : 80), $errno, $errstr, $timeout);
    if (!$fp)
    {
        return;
        // echo "$errstr ($errno)<br>\n";
    }
    else
    {
        fputs ($fp, "GET /".$url['path'].($url['query'] ? '?'.$url['query'] : '')." HTTP/1.0\r\nHost: ".$url['host']."\r\n\r\n");
        $d = '';
       
        while (!feof($fp))
        {
            $d .= fgets ($fp,2048);

            if(preg_match('~(</head>|<body>|(<title>\s*(.*?)\s*</title>))~i', $d, $m))
                break;
        }
        fclose ($fp);

        return $m[3];
    }
}

?>
</b>
</p>
<p></p>
<p></p>
FSOCKOPEN test ends. </p>
<p></p>

<p>PHP Info Follows:</p>
<p></p>
<p ><? phpinfo(); ?></p>

</body>

</html>

left wap stuff

leonine Developer · 130 posts #4

Get info easily

<? phpinfo(); ?>

This is my new community for wap coding. Come and join and experience real wap coding http://leonine.6te.net

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close