[Phpfreechat-svn] SF.net SVN: phpfreechat: [698] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-08-23 16:37:09
|
Revision: 698 Author: kerphi Date: 2006-08-23 09:36:49 -0700 (Wed, 23 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=698&view=rev Log Message: ----------- Add a basic log proxy which store all chat messages into a simple file (chat.log) Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/log.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-08-23 09:44:16 UTC (rev 697) +++ trunk/src/pfcglobalconfig.class.php 2006-08-23 16:36:49 UTC (rev 698) @@ -41,10 +41,11 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "auth", "noflood", "censor"); + var $proxys = array("lock", "auth", "noflood", "censor", "log"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), - "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*")); + "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), + "log" => array("path"=>"")); var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // by default allow users to create there own channels Added: trunk/src/proxys/log.class.php =================================================================== --- trunk/src/proxys/log.class.php (rev 0) +++ trunk/src/proxys/log.class.php 2006-08-23 16:36:49 UTC (rev 698) @@ -0,0 +1,66 @@ +<?php +/** + * log.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * 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, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_log + * this proxy will log "everything" from the chat + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_log extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $cmdtocheck = array("send", "me", "notice"); + if ( in_array($this->name, $cmdtocheck) ) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; + $u =& $this->u; + + $logpath = ($c->proxys_cfg[$this->proxyname]["path"] == "" ? $c->data_public_path : + $c->proxys_cfg[$this->proxyname]["path"]); + $logfile = $logpath."/".$c->getId()."/chat.log"; + + if (!is_writable($logpath)) + { + if ((file_exists($logfile) && is_writable($logpath)) || + (!file_exists($logfile))) + { + $fp = fopen($logfile, 'a'); + fwrite($fp, $recipient." -> ".$param."\n"); + } + } + } + + // forward the command to the next proxy or to the final command + $this->next->run($xml_reponse, $p); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |