欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

smartirc.php.svn-base

PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。
SVN-BASE
第 1 页 / 共 5 页
字号:
<?php/** * $Id$ * $Revision$ * $Author$ * $Date$ * * Net_SmartIRC * This is a PHP class for communication with IRC networks, * which conforms to the RFC 2812 (IRC protocol). * It's an API that handles all IRC protocol messages. * This class is designed for creating IRC bots, chats and show irc related info on webpages. * * Documenation, a HOWTO and examples are in SmartIRC included. * * Here you will find a service bot which I am also developing * <http://cvs.meebey.net/atbs> and <http://cvs.meebey.net/phpbitch> * Latest versions of Net_SmartIRC you will find on the project homepage * or get it through PEAR since SmartIRC is an official PEAR package. * See <http://pear.php.net/Net_SmartIRC>. * * Official Projet Homepage: <http://sf.net/projects/phpsmartirc> * * Net_SmartIRC conforms to RFC 2812 (Internet Relay Chat: Client Protocol) *  * Copyright (c) 2002-2003 Mirco 'meebey' Bauer <meebey@meebey.net> <http://www.meebey.net> *  * Full LGPL License: <http://www.gnu.org/licenses/lgpl.txt> *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */// ------- PHP code ----------include_once('SmartIRC/defines.php');include_once('SmartIRC/irccommands.php');include_once('SmartIRC/messagehandler.php');define('SMARTIRC_VERSION', '1.0.0 ($Revision$)');define('SMARTIRC_VERSIONSTRING', 'Net_SmartIRC '.SMARTIRC_VERSION);/** * main SmartIRC class * * @package Net_SmartIRC * @version 0.5.5 * @author Mirco 'meebey' Bauer <mail@meebey.net> * @access public */class Net_SmartIRC_base{    /**     * @var resource     * @access private     */    var $_socket;        /**     * @var string     * @access private     */    var $_address;        /**     * @var integer     * @access private     */    var $_port;        /**     * @var string     * @access private     */    var $_nick;        /**     * @var string     * @access private     */    var $_username;        /**     * @var string     * @access private     */    var $_realname;        /**     * @var string     * @access private     */    var $_usermode;        /**     * @var string     * @access private     */    var $_password;        /**     * @var boolean     * @access private     */    var $_state = false;        /**     * @var array     * @access private     */    var $_actionhandler = array();        /**     * @var array     * @access private     */    var $_timehandler = array();        /**     * @var integer     * @access private     */    var $_debug = SMARTIRC_DEBUG_NOTICE;        /**     * @var array     * @access private     */    var $_messagebuffer = array();        /**     * @var integer     * @access private     */    var $_messagebuffersize;        /**     * @var boolean     * @access private     */    var $_usesockets = false;        /**     * @var integer     * @access private     */    var $_receivedelay = 100;        /**     * @var integer     * @access private     */    var $_senddelay = 250;        /**     * @var integer     * @access private     */    var $_logdestination = SMARTIRC_STDOUT;        /**     * @var resource     * @access private     */    var $_logfilefp = 0;        /**     * @var string     * @access private     */    var $_logfile = 'Net_SmartIRC.log';        /**     * @var integer     * @access private     */    var $_disconnecttime = 1000;        /**     * @var boolean     * @access private     */    var $_loggedin = false;        /**     * @var boolean     * @access private     */    var $_benchmark = false;        /**     * @var integer     * @access private     */    var $_benchmark_starttime;        /**     * @var integer     * @access private     */    var $_benchmark_stoptime;        /**     * @var integer     * @access private     */    var $_actionhandlerid = 0;        /**     * @var integer     * @access private     */    var $_timehandlerid = 0;        /**     * @var array     * @access private     */    var $_motd = array();        /**     * @var array     * @access private     */    var $_channels = array();        /**     * @var boolean     * @access private     */    var $_channelsyncing = false;        /**     * @var string     * @access private     */    var $_ctcpversion;        /**     * @var mixed     * @access private     */    var $_mintimer = false;        /**     * @var integer     * @access private     */    var $_maxtimer = 300000;        /**     * @var integer     * @access private     */    var $_txtimeout = 300;        /**     * @var integer     * @access private     */    var $_rxtimeout = 300;        /**     * @var integer     * @access private     */    var $_selecttimeout;        /**     * @var integer     * @access private     */    var $_lastrx;        /**     * @var integer     * @access private     */    var $_lasttx;        /**     * @var boolean     * @access private     */    var $_autoreconnect = false;        /**     * @var boolean     * @access private     */    var $_autoretry = false;        /**     * All IRC replycodes, the index is the replycode name.     *     * @see $SMARTIRC_replycodes     * @var array     * @access public     */    var $replycodes;        /**     * All numeric IRC replycodes, the index is the numeric replycode.     *     * @see $SMARTIRC_nreplycodes     * @var array     * @access public     */    var $nreplycodes;        /**     * Stores all channels in this array where we are joined, works only if channelsyncing is activated.     * Eg. for accessing a user, use it like this: (in this example the SmartIRC object is stored in $irc)     * $irc->channel['#test']->users['meebey']->nick;     *     * @see setChannelSyncing()     * @see Net_SmartIRC_channel     * @see Net_SmartIRC_channeluser     * @var array     * @access public     */    var $channel;        /**     * Constructor. Initiales the messagebuffer and "links" the replycodes from     * global into properties. Also some PHP runtime settings are configured.     *     * @access public     * @return void     */    function Net_SmartIRC_base()    {        // precheck        $this->_checkPHPVersion();                ob_implicit_flush(true);        @set_time_limit(0);        ignore_user_abort(true);        $this->_messagebuffer[SMARTIRC_CRITICAL] = array();        $this->_messagebuffer[SMARTIRC_HIGH] = array();        $this->_messagebuffer[SMARTIRC_MEDIUM] = array();        $this->_messagebuffer[SMARTIRC_LOW] = array();        $this->replycodes = &$GLOBALS['SMARTIRC_replycodes'];        $this->nreplycodes = &$GLOBALS['SMARTIRC_nreplycodes'];                // hack till PHP allows (PHP5) $object->method($param)->$object        $this->channel = &$this->_channels;        // another hack        $this->user = &$this->_users;                if (isset($_SERVER['REQUEST_METHOD'])) {            // the script is called from a browser, lets set default log destination            // to SMARTIRC_BROWSEROUT (makes browser friendly output)            $this->setLogdestination(SMARTIRC_BROWSEROUT);        }    }        /**     * Enables/disables the usage of real sockets.     *     * Enables/disables the usage of real sockets instead of fsocks     * (works only if your PHP build has loaded the PHP socket extension)     * Default: false     *     * @param bool $boolean     * @return void     * @access public     */    function setUseSockets($boolean)    {        if ($boolean === true) {            if (@extension_loaded('sockets')) {                $this->_usesockets = true;            } else {                $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: socket extension not loaded, trying to load it...', __FILE__, __LINE__);                                if (strtoupper(substr(PHP_OS, 0,3) == 'WIN')) {                    $load_status = @dl('php_sockets.dll');                } else {                    $load_status = @dl('sockets.so');                }                 if ($load_status) {                    $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: socket extension succesfully loaded', __FILE__, __LINE__);                    $this->_usesockets = true;                } else {                    $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: couldn\'t load the socket extension', __FILE__, __LINE__);                    $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: your PHP build doesn\'t support real sockets, will use fsocks instead', __FILE__, __LINE__);                    $this->_usesockets = false;                }            }        } else {            $this->_usesockets = false;        }    }        /**     * Sets the level of debug messages.     *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -