PHPOpenChat PHP Cross Reference Customer Relationship Management

Source: /include/class.Line.inc - 969 lines - 24056 bytes - Summary - Text - Print

Description: Get default values

   1  <?php //-*-php-*-
   2  /*   ********************************************************************   **
   3  **   Copyright notice                                                       **
   4  **                                                                          **
   5  **   (c) 1995-2004 PHPOpenChat Development Team                             **
   6  **   http://phpopenchat.sourceforge.net/                                    **
   7  **                                                                          **
   8  **   All rights reserved                                                    **
   9  **                                                                          **
  10  **   This script is part of the PHPOpenChat project. The PHPOpenChat        **
  11  **   project is free software; you can redistribute it and/or modify        **
  12  **   it under the terms of the GNU General Public License as published by   **
  13  **   the Free Software Foundation; either version 2 of the License, or      **
  14  **   (at your option) any later version.                                    **
  15  **                                                                          **
  16  **   The GNU General Public License can be found at                         **
  17  **   http://www.gnu.org/copyleft/gpl.html.                                  **
  18  **   A copy is found in the textfile GPL and important notices to the       **
  19  **   license from the team is found in the textfile LICENSE distributed     **
  20  **   with these scripts.                                                    **
  21  **                                                                          **
  22  **   This script is distributed in the hope that it will be useful,         **
  23  **   but WITHOUT ANY WARRANTY; without even the implied warranty of         **
  24  **   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          **
  25  **   GNU General Public License for more details.                           **
  26  **                                                                          **
  27  **   This copyright notice MUST APPEAR in all copies of the script!         **
  28  **   ********************************************************************   */
  29  
  30  /**
  31  * Get default values
  32  */
  33  require_once (POC_BASE.'/config.inc.php');
  34  require_once (POC_INCLUDE_PATH.'/class.Template.inc');
  35  require_once (POC_INCLUDE_PATH.'/class.Logger.inc');
  36  
  37  /**
  38   * Class Line holds lines written by chatters
  39   *
  40   * @todo rewrite of method filter_input_buffer() based on preg_replace()
  41   * @author Frerk Meyer <frerk@meychern.de>
  42   * @author Michael Oertel <michael@ortelius.de>
  43   * @access  public
  44   * @version $Id: class.Line.inc,v 1.42.2.12 2004/03/04 12:50:58 letreo Exp $
  45   */
  46  class POC_Line {
  47  
  48    /**
  49    * chatter object represents a person taking part in a chat session
  50    *
  51    * @var object
  52    */
  53    var $chatter = null;
  54  
  55    /**
  56    * recipient object represents a person receiving a chat message
  57    *
  58    * @var object
  59    */
  60    var $recipient = null;
  61  
  62    /**
  63    * string said by chatter
  64    *
  65    * @var string
  66    */
  67    var $said = '';
  68  
  69    /**
  70    * true if line is whispered
  71    *
  72    * @var boolean
  73    */
  74    var $whispered = false;
  75    
  76    /**
  77    * true if line is approved by a moderator
  78    *
  79    * @var boolean
  80    */
  81    var $approved = false;
  82    
  83    /**
  84    * contains an irc-command found in the line
  85    *
  86    * @var array
  87    */
  88    var $irc_command = array();
  89    
  90    /**
  91    * contains accepted mime types for private images
  92    *
  93    * @var array
  94    */
  95    var $mime_types = array();
  96    
  97    /**
  98    * counts smileys within a line
  99    *
 100    * @var integer
 101    */
 102    var $smiley_count = 0;
 103  
 104    /**
 105    * marks a line as invitation message
 106    *
 107    * @var boolean
 108    */
 109    var $invitationMsg = false;
 110  
 111    /**
 112    * private window flag
 113    *
 114    * @var boolean
 115    */
 116    var $in_private_window = false;
 117  
 118    /**
 119    * sender busy flag
 120    *
 121    * @var boolean
 122    */
 123    var $sender_busy = false;
 124  
 125    /**
 126    * @var string
 127    */
 128    var $join = '';
 129  
 130    /**
 131    * @var string
 132    */
 133    var $leave = '';
 134  
 135    /**
 136    * @var boolean
 137    */
 138    var $info = false;
 139  
 140    /**
 141    * @var integer
 142    */
 143    var $time;
 144  
 145    /**
 146     * Constructor for class Line
 147     *
 148     * @param object $chatter chatter object represents a person taking part in a chat session
 149     * @param string $said string said by chatter
 150     * @param object recipient of the text line
 151     */
 152    function POC_Line($chatter, $said)
 153    {
 154      // check $chatter - should be of class Chatter
 155      // check $said - should be of type string
 156      $this->chatter   = $chatter;
 157      $this->said      = $said;
 158      $this->time      = time();
 159    }
 160    
 161    /**
 162    * provides the HTML code for a chosen smiley
 163    * @access private
 164    * @param string smiley code
 165    * @param object template
 166    * @return string HTML image tag
 167    */
 168    function _mk_smiley_img_tag($smiley, $templ = null)
 169    {
 170      if(is_null($templ)){
 171        $templ = &$_SESSION['template'];
 172      }
 173      return '<img src="'.$templ->get_tmpl_web_path().'/images/icons/smileys/'.$smiley.'.gif" align="middle" border="0" />';
 174    }
 175  
 176    /**
 177     * Provides send time of line
 178     *
 179     * @return string
 180     */
 181    function get_time( $format = 'Y-m-d H:i:s')
 182    {
 183      return (!empty($this->time))? date($format, $this->time):'';
 184    }
 185  
 186    /**
 187     * Getter for chatter object
 188     *
 189     * @return object
 190     */
 191    function get_chatter()
 192    {
 193      return $this->chatter;
 194    }
 195    
 196    /**
 197     * alias for get chatter
 198     * @see get_chatter()
 199     */
 200    function get_sender()
 201    {
 202      return $this->get_chatter();
 203    }
 204    
 205    /**
 206     * Getter for recipient object
 207     *
 208     * @return object
 209     */
 210    function get_recipient()
 211    {
 212      return $this->recipient;
 213    }
 214  
 215    /**
 216     * Setter for recipient object
 217     *
 218     * @param object
 219     */
 220    function set_recipient( $recipient )
 221    {
 222      if(!is_object( $recipient) ) die('Recipient MUST be an object!');
 223      $this->recipient = $recipient;
 224    }
 225  
 226    /**
 227     * Setter for invitationMsg
 228     *
 229     * @param boolean
 230     */
 231    function set_invitationMsg( $bool = true )
 232    {
 233        $this->invitationMsg = $bool;
 234    }
 235  
 236    /**
 237     * Provides the invitationMsg flag
 238     *
 239     * @return boolean
 240     */
 241    function get_invitationMsg()
 242    {
 243        return $this->invitationMsg;
 244    }
 245    
 246    /**
 247    * alias for get_invitationMsg
 248    * @see get_invitationMsg()
 249    */
 250    function is_invitationMsg()
 251    {
 252        return $this->get_invitationMsg();
 253    }
 254  
 255    /**
 256     * Setter for sender object
 257     *
 258     * @param object
 259     */
 260    function set_sender( $sender )
 261    {
 262        $this->chatter = $sender;
 263        return true;
 264    }
 265  
 266    /**
 267     * Setter for sender busy flag
 268     *
 269     * @param boolean
 270     */
 271    function set_sender_busy( $bool = true )
 272    {
 273        $this->sender_busy = $bool;
 274    }
 275  
 276    /**
 277     * Setter for info flag
 278     *
 279     * @param boolean
 280     */
 281    function set_info( $bool = true )
 282    {
 283        $this->info = $bool;
 284    }
 285  
 286    /**
 287     * Getter for info flag
 288     *
 289     * @return boolean
 290     */
 291    function is_info()
 292    {
 293        return $this->info;
 294    }
 295  
 296    /**
 297     * Getter for sender busy flag
 298     * 
 299     * if is set, the chatter is using the private chat window 
 300     * and so hi is bussy to chat private with another one
 301     * 
 302     * @return boolean
 303     */
 304    function get_sender_busy()
 305    {
 306        return $this->sender_busy;
 307    }
 308    
 309    /** 
 310    * alias for get_sender_busy()
 311    * @see get_sender_busy()
 312    * @return boolean
 313    */
 314    function is_sender_busy(){return $this->get_sender_busy();}
 315    
 316    /**
 317     * alias
 318     * @ignore
 319     */
 320    function set_chatter( $sender )
 321    {
 322        return set_sender($sender);
 323    }
 324  
 325    /**
 326     * Getter for said string
 327     *
 328     * @return string
 329     */
 330    function get_said()
 331    {
 332      return $this->said;
 333    }
 334    
 335    /**
 336     * Setter for said string
 337     *
 338     * @param string
 339     */
 340    function set_said( $said )
 341    {
 342      $this->said = $said;
 343    }
 344  
 345    /**
 346    * Getter for chatter object
 347    *
 348    * @return object
 349    */
 350    function get_whispered()
 351    {
 352      return $this->whispered;
 353    }
 354    function is_whispered(){return $this->get_whispered();}//alias
 355    
 356    /**
 357     * Setter for var $whispered
 358     *
 359     * @param boolean
 360     * @return boolean
 361     */
 362    function set_whispered( $bool = true )
 363    {
 364      $this->whispered = $bool;
 365    }
 366    
 367    /**
 368     * Sets approved flag
 369     *
 370     * @param boolean
 371     */
 372    function set_approved( $bool = true )
 373    {
 374      $this->approved = $bool;
 375    }
 376    
 377    /**
 378     * Gets approved flag
 379     *
 380     * @return boolean
 381     */
 382    function get_approved()
 383    {
 384      return $this->approved;
 385    }
 386    
 387    /**
 388     * Gets the irc-command of line
 389     *
 390     * @return string
 391     */
 392    function get_irc_command()
 393    {
 394      return $this->irc_command;
 395    }
 396    
 397    /**
 398     * Provides the nickname of the chatter who is logging in.
 399     *
 400     * @return string
 401     */
 402    function get_login()
 403    {
 404      return $this->login;
 405    }
 406    
 407    /**
 408     * Provides the nickname of the chatter who is leaving the chat.
 409     *
 410     * @return string
 411     */
 412    function get_leave()
 413    {
 414      return $this->leave;
 415    }
 416    
 417    /**
 418     * Sets the nickname of the chatter who is logging in.
 419     *
 420     * @return string
 421     */
 422    function set_login($login)
 423    {
 424      $this->login = $login;
 425    }
 426    
 427    /**
 428     * Sets the nickname of the chatter who is leaving the chat.
 429     *
 430     * @return string
 431     */
 432    function set_leave($leave)
 433    {
 434      $this->leave = $leave;
 435    }
 436  
 437    function is_loginMsg()
 438    {
 439      return ( $this->login != '' );
 440    }
 441  
 442    function is_leavingMsg()
 443    {
 444      return ( $this->leave != '' );
 445    }
 446    
 447    /**
 448     * Sets accepted mime types for private images
 449     *
 450     * @param array
 451     */
 452    function set_accepted_mime_types($types)
 453    {
 454      $this->mime_types = $types;
 455    }
 456    
 457    /**
 458     * Returns a file name for the given smiley
 459     *
 460     * @access private
 461     * @param string
 462     * @return string
 463     */
 464    function _smiley_mapping($code)
 465    {
 466      if( $this->smiley_count >= MAX_SMILEYS_PER_LINE )
 467        return $code;
 468      else 
 469        $this->smiley_count++;
 470      
 471      if( $code == ':me' )
 472      {
 473        $sender = $this->get_sender();
 474        $smiley_dir  = '/images/icons/chatter';
 475        for ($i=0;$i<count($this->mime_types);$i++)
 476        {
 477          preg_match('#image/[x\-]?(.*)#',$this->mime_types[$i], $parts);
 478          $file_extension = $parts[1];
 479          $smiley_path = $smiley_dir.'/'.strtolower($sender->get_nick()).'.'.$file_extension;
 480          if( file_exists($_SESSION['template']->get_tmpl_sys_path().$smiley_path) )
 481            return '<img src="'.$_SESSION['template']->get_tmpl_web_path().$smiley_path.'" align="middle" alt="'.$_SESSION['translator']->out('PRIVATE_IMAGE').'" width="'.PRIVATE_IMG_SIZE_X.'" height="'.PRIVATE_IMG_SIZE_Y.'" />';
 482        }
 483        
 484        return $code;
 485      }
 486  
 487      if( $code == ':you' )
 488      {
 489        $recipient = $this->get_recipient();
 490        $smiley_dir  = '/images/icons/chatter';
 491        for ($i=0;$i<count($this->mime_types);$i++)
 492        {
 493          preg_match('#image/[x\-]?(.*)#',$this->mime_types[$i], $parts);
 494          $file_extension = $parts[1];
 495          $smiley_path = $smiley_dir.'/'.strtolower($recipient->get_nick()).'.'.$file_extension;
 496          if( file_exists($_SESSION['template']->get_tmpl_sys_path().$smiley_path) )
 497            return '<img src="'.$_SESSION['template']->get_tmpl_web_path().$smiley_path.'" align="middle" alt="'.$_SESSION['translator']->out('PRIVATE_IMAGE').'" width="'.PRIVATE_IMG_SIZE_X.'" height="'.PRIVATE_IMG_SIZE_Y.'" />';
 498        }
 499  
 500        return $code;
 501      }
 502  
 503      //if the current theme comes with new smileys than
 504      //check for that new smileys
 505      if( isset($_SESSION['template']) 
 506      &&  $_SESSION['template']->has_extra_smileys()
 507      &&  in_array($code, $_SESSION['template']->get_extra_smileys()) ){
 508        return $this->_mk_smiley_img_tag( preg_replace('/:/','',$code) );
 509      }
 510  
 511      if( defined('OFFER_MORE_ICONS') && OFFER_MORE_ICONS ){
 512        $parts  = split('@', preg_replace('/:/','',$code));
 513        $theme  = $parts[1];
 514        $_code  = $parts[0];
 515        unset($parts);
 516        if( in_array( $theme, $_SESSION['template']->get_theme_list() )){
 517          $templ = &new POC_Template();
 518          $templ->set_theme($theme);
 519          return $this->_mk_smiley_img_tag($_code, $templ);
 520        }
 521        unset($theme);
 522      }
 523      
 524      
 525      switch ($code)
 526      {
 527        case ':-)': return $this->_mk_smiley_img_tag('smile');
 528        case ':)' : return $this->_mk_smiley_img_tag('smile');
 529        case ':-(': return $this->_mk_smiley_img_tag('frown');
 530        case ':(':  return $this->_mk_smiley_img_tag('frown');
 531        case ':,-(':return $this->_mk_smiley_img_tag('crying');
 532        case ':,(': return $this->_mk_smiley_img_tag('crying');
 533        case ':-p': return $this->_mk_smiley_img_tag('tongue');
 534        case ':p':  return $this->_mk_smiley_img_tag('tongue');
 535        case ':-x': return $this->_mk_smiley_img_tag('kiss');
 536        case ':-D': return $this->_mk_smiley_img_tag('biggrin');
 537        case ':D':  return $this->_mk_smiley_img_tag('biggrin');
 538        case ':-]': return $this->_mk_smiley_img_tag('evillaugh');
 539        case ':]':  return $this->_mk_smiley_img_tag('evillaugh');
 540        case '=:-)':return $this->_mk_smiley_img_tag('punk');
 541        case ':-)=':return $this->_mk_smiley_img_tag('beard');
 542        case 'B-))':return $this->_mk_smiley_img_tag('poc');
 543        case 'B-)': return $this->_mk_smiley_img_tag('poc');
 544        case '(/)': return $this->_mk_smiley_img_tag('denied');
 545        case '(:(=':return $this->_mk_smiley_img_tag('ghost');
 546        case '~==': return $this->_mk_smiley_img_tag('candle');
 547        case '~o':  return $this->_mk_smiley_img_tag('bomb');
 548        case '~--': return $this->_mk_smiley_img_tag('dynamite');
 549        case ':#D': return $this->_mk_smiley_img_tag('sail');
 550        case ':-Q': return $this->_mk_smiley_img_tag('smoke');
 551        case ':[=]':return $this->_mk_smiley_img_tag('trash');
 552        case '8)':  return $this->_mk_smiley_img_tag('frog');
 553  
 554        case ':alarm:':
 555        case ':angel:':
 556        case ':angry:':
 557        case ':angryfire:':
 558        case ':apresent:':
 559        case ':asskick:':
 560        case ':at:':
 561        case ':beard:':
 562        case ':biggrin:':
 563        case ':birthday:':
 564        case ':blank:':
 565        case ':bomb:':
 566        case ':borg:':
 567        case ':candle:':
 568        case ':cheesy:':
 569        case ':cloud:':
 570        case ':confused:':
 571        case ':cool:':
 572        case ':cry:':
 573        case ':crying:':
 574        case ':dazzler:':
 575        case ':denied:':
 576        case ':director:':
 577        case ':dynamite:':
 578        case ':eating:':
 579        case ':evillaugh:':
 580        case ':eviltongue:':
 581        case ':fairy:':
 582        case ':female:':
 583        case ':finger:':
 584        case ':flower:':
 585        case ':frog:':
 586        case ':frown:':
 587        case ':ghost:':
 588        case ':grin:':
 589        case ':hehe:':
 590        case ':help:':
 591        case ':hi:':
 592        case ':huh:':
 593        case ':kidding:':
 594        case ':kiss:':
 595        case ':kisslipps:':
 596        case ':icon_aetsch:':
 597        case ':icon_beten:':
 598        case ':icon_bussi:':
 599        case ':icon_knabber:':
 600        case ':icon_megaphon:':
 601        case ':icon_nurse:':
 602        case ':icon_redface:':
 603        case ':icon_rolleyes:':
 604        case ':icon_rolleyes2:':
 605        case ':icon_thumb:':
 606        case ':icon_verwirrt:':
 607        case ':icon_wut:':
 608        case ':lol:':
 609        case ':love:':
 610        case ':lovestory:':
 611        case ':mail:':
 612        case ':male:':
 613        case ':massa:':
 614        case ':msg:':
 615        case ':none:':
 616        case ':nono:':
 617        case ':pa:':
 618        case ':phoneme:':
 619        case ':phone:':
 620        case ':poc:':
 621        case ':punk:':
 622        case ':question:':
 623        case ':rain:':
 624        case ':rambo:':
 625        case ':repuke:':
 626        case ':rettass:':
 627        case ':rolleyes:':
 628        case ':rose:':
 629        case ':sad:':
 630        case ':sail:':
 631        case ':scream:':
 632        case ':shocked:':
 633        case ':sleep:':
 634        case ':smile:':
 635        case ':smoke:':
 636        case ':smoky:':
 637        case ':stoned:':
 638        case ':sun:':
 639        case ':thumbsup:':
 640        case ':toffline:':
 641        case ':toilet:':
 642        case ':tombstone:':
 643        case ':tongue:':
 644        case ':trash:':
 645        case ':verysad:':
 646        case ':wow:':
 647        case ':yawn:':
 648  
 649        case ':SM001:':
 650        case ':SM002:':
 651        case ':SM003:':
 652        case ':SM004:':
 653        case ':SM005:':
 654        case ':SM006:':
 655        case ':SM007:':
 656        case ':SM008:':
 657        case ':SM009:':
 658        case ':SM010:':
 659        case ':SM011:':
 660        case ':SM012:':
 661        case ':SM013:':
 662        case ':SM014:':
 663        case ':SM015:':
 664        case ':SM016:':
 665        case ':SM017:':
 666        case ':SM018:':
 667        case ':SM019:':
 668        case ':SM020:':
 669        case ':SM021:':
 670        case ':SM022:':
 671        case ':SM023:':
 672        case ':SM024:':
 673        case ':SM025:':
 674        case ':SM026:':
 675        case ':SM027:':
 676        case ':SM028:':
 677        case ':SM029:':
 678        case ':SM030:':
 679        case ':SM031:':
 680        case ':SM032:':
 681        case ':SM033:':
 682        case ':SM034:':
 683        case ':SM035:':
 684        case ':SM036:':
 685        case ':SM037:':
 686        case ':SM038:':
 687        case ':SM039:':
 688        case ':SM040:':
 689        case ':SM041:':
 690        case ':SM042:':
 691        case ':SM043:':
 692        case ':SM044:':
 693        case ':SM045:':
 694        case ':SM046:':
 695        case ':SM047:':
 696        case ':SM048:':
 697        case ':SM049:':
 698        case ':SM050:':
 699        case ':SM051:':
 700        case ':SM052:':
 701        case ':SM053:':
 702        case ':SM054:':
 703        case ':SM055:':
 704        case ':SM056:':
 705        case ':SM057:':
 706        case ':SM058:':
 707        case ':SM059:':
 708        case ':SM060:':
 709        case ':SM061:':
 710        case ':SM062:':
 711        case ':SM063:':
 712        case ':SM064:':
 713        case ':SM065:':
 714        case ':SM066:':
 715        case ':SM067:':
 716        case ':SM068:':
 717        case ':SM069:':
 718        case ':SM070:':
 719        case ':SM071:':
 720        case ':SM072:':
 721        case ':SM073:':
 722        case ':SM074:':
 723        case ':SM075:':
 724        case ':SM076:':
 725        case ':SM077:':
 726        case ':SM078:':
 727        case ':SM079:':
 728        case ':SM080:':
 729        case ':SM081:':
 730        case ':SM082:':
 731        case ':SM083:':
 732        case ':SM084:':
 733        case ':SM085:':
 734        case ':SM086:':
 735        case ':SM087:':
 736        case ':SM088:':
 737        case ':SM089:':
 738        case ':SM090:':
 739        case ':SM091:':
 740        case ':SM092:':
 741        case ':SM093:':
 742        case ':SM094:':
 743        case ':SM095:':
 744        case ':SM096:':
 745        case ':SM097:':
 746        case ':SM098:':
 747        case ':SM099:':
 748        case ':SM100:':
 749        case ':SM101:':
 750        case ':SM102:':
 751        case ':SM103:':
 752        case ':SM104:':
 753        case ':SM105:':
 754        case ':SM106:':
 755        case ':SM107:':
 756        case ':SM108:':
 757        case ':SM109:':
 758        case ':SM110:':
 759        case ':SM111:':
 760        case ':SM112:':
 761        case ':SM113:':
 762        case ':SM114:':
 763        case ':SM115:':
 764        case ':SM116:':
 765        case ':SM117:':
 766        case ':SM118:':
 767        case ':SM119:':
 768        case ':SM120:':
 769        case ':SM121:':
 770        case ':SM122:':
 771        case ':SM123:':
 772        case ':SM124:':
 773        case ':SM125:':
 774        case ':SM126:':
 775        case ':SM127:':
 776        case ':SM128:':
 777        case ':SM129:':
 778        case ':SM130:':
 779        case ':SM131:':
 780        case ':SM132:':
 781        case ':SM133:':
 782        case ':SM134:':
 783        case ':SM135:':
 784        case ':SM136:':
 785        case ':SM137:':
 786        case ':SM138:':
 787        case ':SM139:':
 788        case ':SM140:':
 789        case ':SM141:':
 790        case ':SM142:':
 791        case ':SM143:':
 792        case ':SM144:':
 793        case ':SM145:':
 794        case ':SM155:':
 795        case ':smiley:':
 796        case ':smiley1:':
 797        case ':smiley10:':
 798        case ':smiley11:':
 799        case ':smiley2:':
 800        case ':smiley21:':
 801        case ':smiley3:':
 802        case ':smiley4:':
 803        case ':smiley5:':
 804        case ':smiley6:':
 805        case ':smiley7:':
 806        case ':smiley8:':
 807        case ':smiley9:':
 808          return $this->_mk_smiley_img_tag( preg_replace('/:/','',$code) );
 809        default: return $code;
 810      }
 811    }
 812  
 813    /**
 814     * Filters irc-commands in $said
 815     *
 816     * @return void
 817     */
 818    function filter_irc()
 819    {
 820      //filter IRC like commands
 821      if( preg_match ( '#^/([a-z]+) ?([^ ]*) ?([0-9]*).*$#i', $this->said, $irc_command ) && $irc_command[1] != '')
 822      {
 823        $this->irc_command[] = $irc_command[1];
 824        $this->irc_command[] = preg_replace('/\+/', ' ', $irc_command[2]);
 825        $this->irc_command[] = $irc_command[3];
 826      }
 827    }
 828    
 829    /**
 830     * Filters icons, links, etc. in $said
 831     *
 832     * @todo replace eregi_replace with preg_replace.
 833     * @return null
 834     */
 835    function filter_buffer_input()
 836    {
 837      if( count($this->irc_command) > 0 )
 838        return null;
 839      //filter urls
 840      elseif ( preg_match ( '#www\.|https?://|ftp://|.+@.+\..+#', $this->said) )
 841      {
 842        $pieces = explode(' ',$this->said);
 843        reset($pieces);
 844        do{
 845          if( preg_match ('#www\.|https?://|ftp://#',current($pieces)) )
 846          {
 847            $pieces[key($pieces)] = eregi_replace("((((https?://([^ :@]*(:[^ :@]*)?@)?)|(ftp://([^ :@]*(:[^ :@]*)?@)?))?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]{1,5})?(/[^][ <>@()]*)?)|(((https?://([^ :@]*(:[^ :@]*)?@)?)|(ftp://([^ :@]*(:[^ :@]*)?@)?)|(www\.))[^] <>/@()]+\.[a-z]{2,}(:[0-9]{1,5})?(/[^][ <>@()]*)?))",
 848              "<a class=\"linkWithinOutputFrame\" href=\"jump.php?url=\\0\" target=\"_blank\">\\0</a>",current($pieces));
 849          }
 850          elseif( preg_match('/.*@.*\..*/',current($pieces)) )
 851          {
 852            $pieces[key($pieces)] = eregi_replace("[^][ <>@():]+@[^][ <>@():]+\.[a-z]{2,}","<a class=\"linkWithinOutputFrame\" href=\"mailto:\\0\">\\0</a>",current($pieces));
 853          }
 854        }while(next($pieces));
 855        $this->said = implode($pieces,' ');
 856        
 857        return null;
 858      }
 859      
 860      //insert smiley-images if configured
 861      if( SMILEYS_AS_IMAGES )
 862        $this->said = preg_replace('/(=?[:|B|\(|~|8]\w*[@\w]*:?[^ |\<|\w]*[D|x|Q]?)/e', '\$this->_smiley_mapping("\1")' ,$this->said );
 863  
 864      //insert private-images if configured
 865      if( ALLOW_PRIVATE_IMAGES )
 866        $this->said = preg_replace('/(:[me|you]*)/e', '\$this->_smiley_mapping("\1")' ,$this->said );
 867      
 868      $this->said = preg_replace( "/\#{3}([^#]*)\#{3}/e", '\1', $this->said );
 869  
 870      return null;
 871    }
 872  
 873    /**
 874     * Filters 'says to', 'leaves us', ... messages within output frame
 875     *
 876     * used in getlines.php only
 877     *
 878     * @param object Translator
 879     * @return null
 880     */
 881    function filter_buffer_output()
 882    {
 883      $this->said = preg_replace( "/\#{3}([^#]*)\#{3}/e", "\$_SESSION['translator']->out('\\1')", $this->said );
 884  
 885      return null;
 886    }
 887  
 888    /**
 889    * @desc
 890    * Returns a formatted line, 
 891    * but at this time only used to format the locally displayed lines! 
 892    * 
 893    * @todo use this function in getlines also
 894    * @see getlines.php
 895    * @return string
 896    */
 897    function out()
 898    {
 899      $sender = $this->chatter;
 900      $recipient = $this->recipient;
 901      
 902      //whispering to somebody?!
 903      if( $this->get_whispered()
 904      && is_object($recipient)
 905      && $recipient->get_nick() == $_SESSION['translator']->out('EVERYBODY')
 906      )
 907        $this->set_whispered(false);
 908      $italic = ( $this->is_whispered() )? ';font-style:italic':'';
 909      $line  = '<div style="color: #'.$sender->get_color().$italic.'">'.HTML_BEFORE_LINE;
 910      unset($italic);
 911      $line .= $_SESSION['chat']->get_grade_icon( $sender );
 912      $gender  = '';
 913      if( SHOW_GENDER_ICON )
 914        $gender = ($sender->get_gender())?'<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/icons/'.$sender->get_gender().'.gif" width="8" height="8" alt="'.$_SESSION['translator']->out('GENDER').'" /> ':'<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/dot_clear.gif" width="8" height="8" alt="" /> ';
 915      $line .= $gender.'<span>'.$sender->get_nick().'</span>&nbsp;';
 916      if( $this->get_whispered() )
 917        $line .= $_SESSION['translator']->out('WHISPERS_TO');
 918      else
 919        $line .= $_SESSION['translator']->out('SAYS_TO');
 920      
 921      if( is_object($recipient) )
 922        $line .= '&nbsp;<span>'.$recipient->get_nick().'</span>:&nbsp;';
 923      
 924      $this->filter_buffer_output();
 925      $line .= $this->get_said().HTML_AFTER_LINE.'</div>';
 926  
 927      unset($sender);
 928      unset($recipient);
 929      
 930      return preg_replace('#</#', '<\\/', $line);
 931    }
 932    
 933    /**
 934    * Provides the private window flag
 935    * 
 936    * if is set, the line will be displayed in the private chat window only 
 937    *
 938    * @return boolean
 939    */
 940    function in_private_window()
 941    {
 942      return $this->in_private_window;
 943    }
 944    
 945    /**
 946    * Sets the private window flag 
 947    *
 948    * @param boolean
 949    */
 950    function set_in_private_window( $bool = true )
 951    {
 952      $this->in_private_window = $bool;
 953    }
 954    
 955    /**
 956    * Test class Line
 957    * 
 958    * Call like this: POC_Line::test();
 959    */
 960    function test() {
 961      $line = new POC_Line("Fritz","Hello World!");
 962      print "Line test, ";
 963      print $line->get_chatter();
 964      print " said: ";
 965      print $line->get_said();
 966      print "<br>\n";
 967    }
 968  }
 969  ?>

title

Description

title

Description

title

Description

title

title

Body