SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what do i need to use IRC with php?

    hello everybody.

    what kind of addition do i need to be able to use IRC with PHP on my server?

    in my contineues effort to learn PHP on all its flavours.
    i found some scripts using functions interactivly with an IRC server.

    i would like to learn more about this stuff. but what do i need inorder to be able to use IRC with php?

    my sever currently is set up as follows:

    Apache/2.0.48 (Win32)
    PHP/4.3.4 (clean install. no additional models)
    MySql/4.0.17

    what else do i need to start?

    thanks in advance

  2. #2
    SitePoint Enthusiast dodga's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made some good experiences with Pear's SmartIRC.
    If you have some specific questions, feel free to ask.
    The examples are pretty good, too
    remember my name - you'll scream it later

  3. #3
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are feeling adventurous, all you need (as long as you read it properly) is the RFQ on IRC. Then you can connect to the server and send/receive data using sockets.

  4. #4
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx for the responce guys.

    dodga:
    i already downloaded this. but it does not work (the examples that is) so i figuered something is missing in my PHP instaltion. or that i need to install another module. am i missing smething?
    if u got some tips on how to work this i would be greatfull.

    Dangermouse:
    maybe im lame asking this. but what's "RFQ" ?
    i dont even know what that is. or where to find it


    thanx everybody for ur help

  5. #5
    SitePoint Addict loadx's Avatar
    Join Date
    Jul 2004
    Location
    Melbourne, VIC, Australia
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From my experience in making my php IRC bot all you will need in order to connect to irc is a socket.

    im not exactly sure what you want to do but if you are looking at making a bot your going to have to identify yourself to the server which you can find in the IRC RFC...there was a tutorial on building an IRC bot here:
    http://www.codedemons.net/tutorials/...ur-Own-IRC-Bot

    hope that was what your after

  6. #6
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    acteualy im tihnking of building some kind of basic webchat irce, i know its not easy. but pretty much thats the only way i can learn anything

    im having a problem with my PEAR in php.
    i tried runing it inorder to install the go-pear
    but every time i run the pear.bat its telling me something is wrong with my path.

    Code:
    WARNING!  The include_path defined in the currently used php.ini does not
    contain the PEAR PHP directory you just specified:
    <E:\PHP\pear>
    If the specified directory is also not in the include_path used by
    your scripts, you will have problems getting any PEAR packages working.
    
    Current include path           : .;c:\php4\pear
    Configured directory           : E:\PHP\pear
    Currently used php.ini (guess) :
    i mostly dont understand whats going on here :
    Code:
    Current include path           : .;c:\php4\pear
    Configured directory           : E:\PHP\pear
    im runing a windows system.

    i guess i got something wrong with my php installtion. but i cannot underestand this msg

  7. #7
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dodga
    I made some good experiences with Pear's SmartIRC.
    If you have some specific questions, feel free to ask.
    The examples are pretty good, too
    im gonna take you on this offer

    the thing is i want to learn how this stuff works. so im writing my own version.

    the raw data prossecing and the connection is not a problem. ive been over that.

    but what i can figuer out is how to do the following.

    - the user loades the page. the connect script openes a socket to the IRC server. get the neccesery stuff. sends idnt registers joins the right channel and gets the topic and the user lists.

    i can do only one of those things at a atime. if i try more i get a timout.
    wich leads me to my primary concern.
    i can use the socket as long as the script is running.
    but how do i keep the socket opened and listning for update once the initial loading is done?

    cant seem to find any refrence on such a thing anywhere.
    every tutorial or guide i found talks about oppening a socket. getting some data and thats it.

    i want it to keep litning. how can that be done?

  8. #8
    SitePoint Enthusiast dodga's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but how do i keep the socket opened and listning for update once the initial loading is done?
    Actually, there is no "initial loading" in the web.
    After the webserver sent the HTML to be displayed, PHP stopped already executing the script

    Actually, I don't really know, if you can do something like an web (HTTP) IRC client in PHP. As Java-Applet it would not be a problem, because it would run on the clients computer.

    But as always, I'll give you some hints, how I would try to approach this.
    First I'd figure out, if it is possible to send a continuous data stream to the browser, e.g.
    PHP Code:
    set_time_limit(0); // disable script timeout
    while (true) { // do not stop
      
    echo 'test';
      
    ob_flush();

    If that works, everything else is done in a jiffy (and you probably got that already worked out), otherwise I'd abandon PHP in this particular case to seek a more suitable language (e.g. Java) (don't stone me )

    EDIT: Out of curiosity I tried the above code which actually DID work (at least on Linux, Apache 1.3.31, PHP 5.0.1 and Galeon )
    But you need some way of cleaning the screen (e.g. via JavaScript?) because the data gets appended and the browser does not scroll automatically.
    Well then, happy coding

    EDIT2: If you run into crashes, you probably need to do some memory profiling. I wrote an IRC bot once, that I ran continuously but it did segfault something after 12 hours. Did not investigate that further (could have been a memory leak in PHP4 that already has been fixed), but just wanted to tell you
    remember my name - you'll scream it later

  9. #9
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well acteually im starting to blive that yes. php is defnetly not the way to go here.

    ive been doing some testing (that aprently i should have done b4 this stage of coding)
    and what apears is this:
    inorder to keep the user connected via the PHP client. the script sohould run indefnetly. untill the user ends it.
    wich presented me with 2 problems i somhow managed to ignore.
    1)the server this was supposed to go will not allow a PHP script to be excuted for such a long time and will time out (with a nice big scary error for the user).
    2)running 8 clients on a test server upped the memory and CPU usage segnificantly. wich means that when the script would go up evernteualy, its 3000 users comunity. say 10% of them decides to try the new chat.
    im ot verry good in math. but i dont think the server would like that verry much (and so the hosting company i blive:P)

    i got myself in a tight spot here. i spent so much time on this that im left with only 2 weeks to comeup with an alternate plan.

    i guess i should learn for the next time to research and make sure everything is posible B4 i write most of the less critical code

    but for the time bein. if anyone got anny sujestions. im open wide.

    thanks

  10. #10
    SitePoint Enthusiast dodga's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if such a script would consume to much resources on the server, than I'd shift the load to the client.
    IMHO you're better off with a Java-Applet. There are already some IRC-Applets out there, but if you really want to learn that kinda stuff (IRC, client-server-communication, etc) , go for it and try to implement it yourself.
    More software experience =
    More coding practice =
    But don't reinvent the wheel and try to have an eye on how other people solve their problems
    remember my name - you'll scream it later

  11. #11
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that exactly my problem. ive been wondering wround every forum tutorial and refrence site i could find. nothing is directed towards what i ment to do.
    Java i dont know much about. and some tutorials that would even send me to the right direction cannot be found.
    and if an applet IS found, no source code, wich cant help me much since i need the source to see how things tick inorder to try and implement myself.
    even with php almost no relevent info can be found.
    infact 99.99% of the code i wrote myself.
    verry little of that is based on some bits and peaces i found on the internet. it took some seriouce amounts of cafain and about 2 bottles of taylanol to get where im at.
    and so it seems all for nothing.
    i guess my next step is to learn ASP and JAVA as it seems they can solv much of the problems i face in php.

    but for the more imidiate needs, i thaghut of something. and would like to know if its posible b4 spending anymore time.

    i got most of the parsing and raw data processing code done and ready to use in php.
    the only problem is to keep the connection live with the irc server without killing my server.
    is it posible to come up with a java app that would act as a pipe line for the raw data, and when it gets it hands it over to php?
    i mean like a java app would connect with the desired irc server.
    and whenever it recives some data it calles the php script to handle it, and whenever a user inputs something, it calles the PHP script. to handle the parsing and then send the final input that should be sent to the irc to the javapp. and that sends it to the server.

    in short the java would act just as a pipe line between php the user and the irc server.

    am i dreaming here? or could it be a good solution for my imidiate means?

  12. #12
    SitePoint Enthusiast dodga's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Nusa
    i mean like a java app would connect with the desired irc server.
    and whenever it recives some data it calles the php script to handle it, and whenever a user inputs something, it calles the PHP script. to handle the parsing and then send the final input that should be sent to the irc to the javapp. and that sends it to the server.
    There are several problems with that idea IMHO...

    First you need to be aware, that you probably need 1 connection to IRC per user, otherwise it would seem, as if all messages originated from the same user (that is, if you want your users to be able to send message to IRC).
    Possible solution to this: Prefixing sent messages; e.g. you have users on your webpage (identified by username) which can chat with users on IRC (identified by IRC nickname). Messages from IRC users are handled normally, but messages from web users should be sent as e.g. "<IRC nick of Java-Applet> [<Username of web user>] <message>" to IRC.

    Next (even bigger) problem: you have no way of "pushing" the data to the client. In the web you are in a "pull environment"; you put information somewhere and everyone who wants it can fetch the information when needed (given the privileges one may need). (Applies to server-side technologies like PHP or Servlets; as far as I can tell, of course)
    Some kind of auto-reload could do the trick here (no realtime then, could get confusing for users).
    There are ceratin ways to circumvent that (maybe XML-RPC or iframes, etc.) but I don't know much about "pushing" data over HTTP to users.

    And last but not least: I see no advantage in doing IRC communication in Java and still invoke PHP to prepare the information and deliver it (probably not possible).

    I'd say: do it completely client-side as Java-Applet (only if it needs to be in a web-environment, of course) or tell your users to use a real IRC client.

    HTH
    remember my name - you'll scream it later

  13. #13
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dodga
    There are several problems with that idea IMHO...

    First you need to be aware, that you probably need 1 connection to IRC per user, otherwise it would seem, as if all messages originated from the same user (that is, if you want your users to be able to send message to IRC).
    ok. i dont know anything about java so maybe i didnt understand what can be dine really.

    but to explain what i ment a bit more..
    the JAVA app would be on the user side. it loads with the pags.
    the page itself contains one frame for user to type.
    another frame for user list
    another one to display the output from the irc chat.

    now. the feed to those fram comes from a hidden frame that handles the raw data.

    what the java applet should do is just stream the data from the irc server. puts it in a Var, then reloads the PHP hiden frame with this var.
    the php parse the data into understandable text or comands. and displays it to the user.

    and when a user inputs somthin, it calles the hidden fram that parse this input into the apropriate IRC data. and then sends it through the Java Pipeline to the IRC server.

    now, why would that requier the java app to be on the server side? i dont think i understood you on this one, i cant see why the app cant be on the user side,

    the only thing that is not clear to me. is if the comunication with the java app is posible,

    anyways, i cant read or do anything else anymore...
    so im going to sleep now, Gnight.

    just one last thing, would the PHP_JAVA extention offer anything useable?
    or i shouldnt waist my time on it now?
    Last edited by Nusa; Sep 6, 2004 at 02:15.

  14. #14
    SitePoint Enthusiast dodga's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Nusa
    the JAVA app would be on the user side. it loads with the pags.
    So we're talking about a Java-Applet here.

    Quote Originally Posted by Nusa
    what the java applet should do is just stream the data from the irc server. puts it in a Var, then reloads the PHP hiden frame with this var.
    Sorry, but that makes no sense to me
    The only way to get the data from the Java applet to PHP is making a HTTP request (either GET or POST).
    So basically you have something like this

    Java-Applet (user) connected to IRC -> HTTP request to server -> PHP (server) displaying the data

    Quote Originally Posted by Nusa
    the php parse the data into understandable text or comands. and displays it to the user.
    Why send the data to the server at all?
    You could parse and display it via the Java-Applet. Saves you time, bandwidth and the hassle of maintaining the PHP script.

    Quote Originally Posted by Nusa
    now, why would that requier the java app to be on the server side? i dont think i understood you on this one, i cant see why the app cant be on the user side,
    I misunderstood you there, sorry

    Quote Originally Posted by Nusa
    the only thing that is not clear to me. is if the comunication with the java app is posible,
    It is, through various methods (HTTP, XML-RPC?, SOAP?, direct socket connection, etc..) but IMHO it makes no sense.
    You only shifted the IRC connection to the client, yet you want to send all IRC data to your server for processing, gaining nothing in my eyes

    Quote Originally Posted by Nusa
    just one last thing, would the PHP_JAVA extention offer anything useable?
    or i shouldnt waist my time on it now?
    Never used that, but that would run server-side (because it is called from PHP) and again does not make anything better
    remember my name - you'll scream it later

  15. #15
    Web Design Ireland cianuro's Avatar
    Join Date
    Jun 2004
    Location
    Dublin Ireland
    Posts
    914
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could your PHP socket code and implement it into a flash SWF file. Share the load between your server and the client.

  16. #16
    SitePoint Member
    Join Date
    Aug 2004
    Location
    sc
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dodga
    The only way to get the data from the Java applet to PHP is making a HTTP request (either GET or POST).
    So basically you have something like this

    Java-Applet (user) connected to IRC -> HTTP request to server -> PHP (server) displaying the data
    yes that what i ment. since i already wrote most of thePHP script, wich now seems as a mistake todo so befor figuering out the server comunication issue, i would hate to see all this work goto waist.
    so the purose of asking this is because i want something to shift the load of keeping the IRC-CLIENT connection off the site hosting server.

    Quote Originally Posted by dodga
    Why send the data to the server at all?
    You could parse and display it via the Java-Applet. Saves you time, bandwidth and the hassle of maintaining the PHP script.
    seems like the logical thing todo. and i will do it eventeualy sinceit looks like an intresting chalenge pluse the learning of a new scripting languge, but for the time i nt think it would be posible for me to get t this level of scipting in java in a time limit of 2 -- weeks




    Quote Originally Posted by dodga
    It is, through various methods (HTTP, XML-RPC?, SOAP?, direct socket connection, etc..) but IMHO it makes no sense.
    You only shifted the IRC connection to the client, yet you want to send all IRC data to your server for processing, gaining nothing in my eyes
    thats because im not looking for an alternative to my script.
    the java applet i need is just so the connecion with the irc server wont be lost, because doing his in a PHP script would load the server too much and as it seems time out mos tof the useres when there are too many connections
    ----------

    Quote Originally Posted by cianuro
    You could your PHP socket code and implement it into a flash SWF file. Share the load between your server and the client.
    i did not fully understand what you ment. and i dont know anything about flash (probably thats why i didnt understand).

    i need some seriouce guiding here
    i feel like a little boy in grownups game, and i forgot my sportsshoos


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •