TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-05-2008, 09:14 PM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default mirc php script

anyone know of a php script that is like mirc?
-that shows the users logged in

thanks
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 09-06-2008, 05:07 PM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Perhaps you mean a chat room, and that can't be done using php only.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 09-06-2008, 08:05 PM   #3 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Perhaps you mean a chat room, and that can't be done using php only.
do you know of a open source version i can use?
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 09-06-2008, 08:10 PM   #4 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

How about PHPOpenChat, PHP based free live Chat Server Software?
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 09-06-2008, 09:23 PM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
... that can't be done using php only.
Oh really?

To help guide the original question, in order to display the logged in users on an IRC server all that you need to do is connect to the server and send along a specially formatted command that the server understands, nothing complicated at all. There are various implementations in PHP which make talking to IRC servers easier, faster, object-oriented and so on (a Google search should suffice) or you can learn to use PHP's built-in code to do things in a more low-level way (through sockets and such like, which most of the abstractions do anyway).
Salathe is offline  
Reply With Quote
Old 09-07-2008, 10:21 AM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I've even made an IRC bot in the past with PHP, so PHP is more than capable of doing it. I'll see if I can dig up the code and show you the IRC commands you need to post through a socket to the IRC server.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 09-07-2008, 10:35 AM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Sorry guys, I didn't mean that it can't be done literally, what I meant is that nobody likes a chat room where the page need to be refreshed when posting a message or when a user logs in/out. That's why I said "php only". In order to do a decent chat room you also need to make use of some javascript (ajax) and SQL. Obviously, there's more than php there. I, personally, would also use a Java server to do all the server-side work and let PHP handle the client part. Simply because it's more efficient than PHP when talking about sockets and streaming (see threads and buffering).

But, I guess I missed the point a little bit, because now I see that he wants to send messages to an IRC server rather than create a chat server.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 09-07-2008, 01:12 PM   #8 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I have quickly knocked this together

PHP Code:
<?php
set_time_limit
(0);//so we dont timeout

class IRC
{
    const 
SERVER  'b0rk.uk.quakenet.org';
    const 
PORT    6667;
    const 
CHANNEL '#sketch';
    const 
NICK    'sketchmedia2';

    private static 
$pSocket;
    private static 
$szBuffer;

    public static function 
getUsers()
    {
        if(!
self::$pSocket fsockopen(self::SERVERself::PORT$iError$szError2))
        {
            die(
$iError ' - ' .$szError);
        }
        
$szUsers self::mainLoop();
        return 
explode(' 'trim(str_replace(':'''substr($szUsersstrpos($szUsersself::CHANNEL) + strlen(self::CHANNEL)))));
    }
    private static function 
mainLoop()
    {
        
self::sendCmd('PASS NOPASS');
        
self::sendCmd('NICK 'self::NICK);
        
self::sendCmd('USER 'self::NICK ' USING TALKPHP IRC');
         while(!
feof(self::$pSocket))
        {
            
self::$szBuffer fgets(self::$pSocket1024);
            if(
strpos(self::$szBuffer'376'))
            {
                
self::sendCmd('JOIN ' self::CHANNEL);
            }
            if(
substr(self::$szBuffer06) == 'PING :')
            {
                
self::sendCmd('PONG :'.substr(self::$szBuffer6));
            }
            if(
strpos(self::$szBuffer'353'))
            {
                
fclose(self::$pSocket);
                return 
self::$szBuffer;
            }
            
//echo self::$szBuffer , '<br />';
        
}
    }
    private static function 
sendCmd($szCmd)
    {
        
$szCmd .= "\n\r";
        
fwrite(self::$pSocket$szCmdstrlen($szCmd)) or die('Error'); //sends the command to the server
    
}
}
echo 
'<pre>'var_dump(IRC::getUsers()), '</pre>';
quite simple, a little explanation though:
PHP Code:
 if(strpos(self::$szBuffer'376'))
 {
      
self::sendCmd('JOIN ' self::CHANNEL);
  } 
this checks to see if the MOTD has finished, meaning we really are connected and we can send the JOIN command

PHP Code:
 if(substr(self::$szBuffer06) == 'PING :')
{
     
self::sendCmd('PONG :'.substr(self::$szBuffer6));

this line responds to PING requests sent by the IRC server, this allows each computer to know if the opposite end is still present and available, you will be disconnected if you don't respond to PING with the message sent, this line takes care of that.

PHP Code:
if(strpos(self::$szBuffer'353'))
{
    
fclose(self::$pSocket);

    return 
self::$szBuffer;

Reads the user list, and returns the line.

You may need to change the numbers or make a regex that does it, but i dont have the time currently, un-comment the echo in the main loop to see the server responses.

The script outputs :
Code:
array(3) {   [0]=>   string(12) "sketchmedia2"   [1]=>   string(5) "sam__"   [2]=>   string(10) "@GBH|Johno" }
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
The Following User Says Thank You to sketchMedia For This Useful Post:
Wildhoney (09-07-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design