Jump to content

Recommended Posts

Can anybody with some advanced PHP knowledge get this working? It should connect to my IRCD server, and display the currently open channels, which will then allow the user to click the channel, and join it.

 

<?php
error_reporting(E_ALL ^ E_NOTICE);
    $botnick = "Chatterup";
    $server = "chatterup.webhop.net";
    $port = "6667";
    $channel = "";
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Room List</title>
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" id="AutoNumber1" style="border-collapse: collapse">
  <tr>
    <td width="8%" height="20" align="center" valign="middle" bgcolor="#FFFFCC" style="border-left:1px solid #333333;border-bottom:1px solid;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Users</td>
    <td width="15%" height="20" align="left" valign="middle" bgcolor="#FFFFCC" style="border-bottom:1px solid;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Roomname:</td>
    <td width="77%" height="20" align="left" valign="middle" bgcolor="#FFFFCC" style="border-right:1px solid #333333;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Topic:</td>
  </tr>
<?php
    $fp = fsockopen($server, $port, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    }
    else
    {
        fputs($fp,"USER $botnick $botnick 127.0.0.1 :php\n");
        $nick = $botnick . rand(10000,99999);
        fputs($fp,"NICK $nick\n");
        while (!feof($fp))
        {
            usleep(50);
            $fget = @fgets($fp, 128);
            //echo "$fget <br>\n";
            $match = explode(" ", $fget);
            $fget = ereg_replace ("\n", "", $fget);
            $fget = ereg_replace ("\r", "", $fget);

            if (isset($match[0]) && $match[0] == "PING")
            {
                fputs($fp, "PONG :" . $match[1]);
            }
            elseif(isset($match[1]))
            {
                if ($match[1] == "001")
                {
                    fputs($fp,"LIST\n");
                }
                else if ($match[1] == "433")
                {
                    $nick = $botnick . rand(10000,99999);
                    fputs($fp,"NICK $nick\n");
                }
                else if ($match[1] == "323")
                {
                    fputs($fp, "QUIT :bye!\n");
                    break;
                }
                else if ($match[1] == "322")
                {
                    $match[3] = ereg_replace ("#", "", $match[3]);
                    if (eregi ("$channel(.*)", $match[3], $chan))
                    {
                        $topic = explode(":", $fget);
                        unset($topic[0]);
                        unset($topic[1]);
                        $topic = implode(":", $topic);
                        if ($color == "FBFBF7")
                        {
                            $color = "FFFFFF";
                        }
                        else {
                            $color = "FBFBF7";
                        }
                    ?>
  <tr>
    <td width="8%" align="center" valign="middle" bgcolor="#<?php echo $color; ?>" style="border-top:1px solid #333333;border-left:1px solid #333333;border-bottom:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"><?php echo $match[4]; ?></td>
    <td width="15%" style="border-bottom:1px solid #333333;bordertop:1px solid #333333;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;" bgcolor="#<?php echo $color; ?>"> <a href="http://webchat.chatcore.org/chat/channel.aspx?value=<?php echo $chan[1]; ?>&member=XS803m">
      <?php echo $chan[1]; ?>
      </a></td>
    <td width="77%" style="border-right:1px solid #333333;border-bottom:1px solid #333333;FONT-FAMILY:;border-top:1px solid #333333; verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"bgcolor="#<?php echo $color; ?>"> 
      <?php echo $topic; ?></td>
  </tr>
                      <?php
                    }
                }
            }
        }
        fclose($fp);
    }
?>
</table>
</body>
</html>

 

It seems to just time out.

 

If someone could fix this for me I'd be mighty great full.

 

Thanks!!

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/
Share on other sites

If this is urgent, then please pay someone to fix it. Everyone here contributes their time, effort and knowledge for free. Your problem is no more urgent than anyone else's is.

 

You've not even described your problem properly. What do you mean by 'times out'? What actually happens? Do you get a blank screen? An error message?

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/#findComment-688337
Share on other sites

Remove your error suppressing @'s on your functions i.e. fputs() fgets().

Add conditionals to error if the functions fail:

if(!fputs()) {

}

 

Can you connect to your server through port 6667?

Does your server name resolve correctly from the target chatterup.webhop.net?

Is there a firewall in the way, etc.

 

Some simple debugging, easy enough.

 

Dont post as URGENT it wont do you any favors! As GingerRobot stated, you can pay people to investigate.

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/#findComment-689226
Share on other sites

Remove your error suppressing @'s on your functions i.e. fputs() fgets().

Add conditionals to error if the functions fail:

if(!fputs()) {

}

 

Can you connect to your server through port 6667?

Does your server name resolve correctly from the target chatterup.webhop.net?

Is there a firewall in the way, etc.

 

Some simple debugging, easy enough.

 

Dont post as URGENT it wont do you any favors! As GingerRobot stated, you can pay people to investigate.

 

Sorry, I don't really understand exactly what you are wanting me to do.

 

As for can my server be accessed, yes, We were running an IRCX server, and had a roomlist php file working fine, we moved on to a more reliable IRCD server, and are in the need of a fix for it. We are able to connect to the chat just fine through 6667.

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/#findComment-689235
Share on other sites

http://chatterup.webhop.net/site/pages/list.php

 

Notice: Undefined offset: 1 in C:\wamp\www\site\pages\list.php on line 45

 

Notice: Undefined offset: 1 in C:\wamp\www\site\pages\list.php on line 50

 

Notice: Undefined offset: 1 in C:\wamp\www\site\pages\list.php on line 53

 

Notice: Undefined offset: 1 in C:\wamp\www\site\pages\list.php on line 56

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/#findComment-689837
Share on other sites

Sorry, I just don't know enough about IRC protocol to really help you here.

 

Well, I changed a few things, and have gotten further.

 

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
    $botnick = "Chatterup";
    $server = "chatterup.webhop.net";
    $port = "6667";
    $channel = "";
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Room List</title>
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" id="AutoNumber1" style="border-collapse: collapse">
  <tr>
    <td width="8%" height="20" align="center" valign="middle" bgcolor="#FFFFCC" style="border-left:1px solid #333333;border-bottom:1px solid;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Users</td>
    <td width="15%" height="20" align="left" valign="middle" bgcolor="#FFFFCC" style="border-bottom:1px solid;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Roomname:</td>
    <td width="77%" height="20" align="left" valign="middle" bgcolor="#FFFFCC" style="border-right:1px solid #333333;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"> Topic:</td>
  </tr>
<?php
    $fp = fsockopen($server, $port, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    }
    else {
        fputs($fp,"USER $botnick $botnick 127.0.0.1 :php\n");
        $nick = $botnick . rand(10000,99999);
        fputs($fp,"NICK $nick\n");
        while (!feof($fp)) {
            usleep(50);
            $fget = @fgets($fp, 128);
            echo "$fget <br>\n";
            $match = explode(" ", $fget);
            $fget = ereg_replace ("\n", "", $fget);
            $fget = ereg_replace ("\r", "", $fget);
            if ($match[1] == "001") {
                fputs($fp,"LIST\n");
            }
            else if ($match[0] == "PING") {
                fputs($fp, "PONG :" . $match[1]);
            }
            else if ($match[1] == "433") {
                $nick = $botnick . rand(10000,99999);
                fputs($fp,"NICK $nick\n");
            }
            else if ($match[1] == "323") {
                fputs($fp, "QUIT :bye!\n");
                break;
            }
            else if ($match[1] == "322") {
                $match[3] = ereg_replace ("#", "", $match[3]);
                if (eregi ("$channel(.*)", $match[3], $chan)) {
                    $topic = explode(":", $fget);
                    unset($topic[0]);
                    unset($topic[1]);
                    $topic = implode(":", $topic);
                    if ($color == "FBFBF7") {
                        $color = "FFFFFF";
                    }
                    else {
                        $color = "FBFBF7";
                    }
                    ?>
  <tr>
    <td width="8%" align="center" valign="middle" bgcolor="#<?php echo $color; ?>" style="border-top:1px solid #333333;border-left:1px solid #333333;border-bottom:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"><?php echo $match[4]; ?></td>
    <td width="15%" style="border-bottom:1px solid #333333;bordertop:1px solid #333333;border-top:1px solid #333333;FONT-FAMILY: verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;" bgcolor="#<?php echo $color; ?>"> <a href="./chat.php?action=Chat&rmname=[EN]<?php echo $chan[1]; ?>">
      <?php echo $chan[1]; ?>
      </a></td>
    <td width="77%" style="border-right:1px solid #333333;border-bottom:1px solid #333333;FONT-FAMILY:;border-top:1px solid #333333; verdana;FONT-SIZE: 8pt;TEXT-DECORATION: none;"bgcolor="#<?php echo $color; ?>"> 
      <?php echo $topic; ?></td>
  </tr>
                      <?php
                }
            }
        }
        fclose($fp);
    }
?>
</table>
</body>
</html>

 

Now I get this - :chatterup.webhop.net NOTICE AUTH :*** Looking up your hostname...

:chatterup.webhop.net NOTICE AUTH :*** Found your hostname (cached)

PING :2C109BD4

:2C109BD4!nospoof@chatterup.webhop.net PRIVMSG Chatterup36427 :VERSION

ERROR :Closing Link: Chatterup36427[127.0.0.1] (Ping timeout)

Link to comment
https://forums.phpfreaks.com/topic/132393-urgent/#findComment-689846
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.