Source for file StaticMethods.class.php

Documentation is available at StaticMethods.class.php

  1. <?php
  2. /**
  3.  * Class StaticMethods, contans only the simple methond for static use
  4.  *
  5.  * LICENSE: CREATIVE COMMONS PUBLIC LICENSE  "Namensnennung — Nicht-kommerziell 2.0"
  6.  *
  7.  * @copyright  2010 <SEDesign />
  8.  * @license    http://creativecommons.org/licenses/by-nc/2.0/de/
  9.  * @version    $3.0.7$
  10.  * @link       http://www.sedesign.de/de_produkte_chat-v3.html
  11.  * @since      File available since Alpha 2.0
  12.  */
  13.  
  14.  
  15.     /**
  16.     * Message filter, replaces smileys with images and "bad words"
  17.     *
  18.     * @param string $str, message text
  19.     * @param Array  $sml, Smileys dataset
  20.     * @return String 
  21.     */
  22.     static function filtering($str$sml$_prefix){
  23.         
  24.         //replace smileys
  25.         for ($a=0$a<count($sml)$a++){
  26.                  $img getimagesize("./".$sml[$a][1]);
  27.                  $str str_replace($sml[$a][0]"<img src=\"".$sml[$a][1]."\" ".$img[3].">"$str$count);
  28.                  if ($count>0$count_all+=$count;
  29.         }
  30.         
  31.         if ($count_all > 8$str strip_tags($str);
  32.         
  33.         // create links from URIs
  34.         if (stripos($str']http://')===false
  35.             $str preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$str);
  36.         else 
  37.             $str str_replace("http://www.youtube.com/watch?v="""$str);
  38.  
  39.             
  40.         // Bad Word Filter
  41.         
  42.         if (!isset($_SESSION['etchat_'.$_prefix.'_badwords']&& file_exists("./lang/bad_words.xml")){
  43.             $xml @file_get_contents("./lang/bad_words.xml");
  44.             $parser = new XMLParser($xml);
  45.             $parser->Parse();
  46.  
  47.             foreach($parser->document->word as $bword){
  48.                 
  49.                 $exceptions = array();
  50.                 
  51.                 if (is_array($bword->except))
  52.                     foreach ($bword->except as $except)
  53.                         $exceptions[$except->tagData;
  54.                 
  55.                 $_SESSION['etchat_'.$_prefix.'_badwords'][= array(
  56.                     'in' => chop(trim($bword->tagAttrs['in'])),
  57.                     'out' => chop(trim($bword->tagAttrs['out'])),
  58.                     'except' => $exceptions
  59.                 );
  60.             }
  61.         }
  62.         
  63.         if (isset($_SESSION['etchat_'.$_prefix.'_badwords'])){
  64.             
  65.             foreach($_SESSION['etchat_'.$_prefix.'_badwords'as $key =>$bword){
  66.                 if (count($bword['except'])>0)
  67.                     foreach($bword['except'as $key_ex => $ex){
  68.                         $str str_replace($ex"<norepl>".$ex."</norepl>" $str);
  69.                     }
  70.             }
  71.             
  72.             foreach($_SESSION['etchat_'.$_prefix.'_badwords'as $bword){
  73.                 $bad_word $bword['in'];
  74.                 $good_word $bword['out'];
  75.                 
  76.                 $pattern '/(?<!\<norepl\>)'.$bad_word.'(?!\<\/norepl\>)/ui'
  77.                 $str preg_replace($pattern$good_word$str)
  78.             }
  79.             
  80.             $str str_ireplace("<norepl>"""$str);
  81.             $str str_ireplace("</norepl>"""$str);
  82.         }
  83.         
  84.         
  85.         $video '<object width="425" height="344"><param name="wmode" value="transparent" name="movie" value="http://www.youtube.com/v/$1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed wmode="transparent" src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object>';
  86.         
  87.         if (substr($str08)!="/window:"){
  88.             if (stripos($str'[img]')!==false && stripos($str'[/img]')!==false){
  89.                 $image_path preg_replace('/\[img\](.*?)\[\/img\]/''$1'$str)
  90.                     if (!empty($image_path))
  91.                         $str="<img src=\"$image_path\" style=\"max-width:500px;max-height:300px;\">";
  92.             }
  93.             $str preg_replace('/\[video\](.*?)\[\/video\]/'$video$str);  
  94.         }
  95.         
  96.         return $str;
  97.     }
  98. }

Documentation generated on Thu, 05 May 2011 14:05:59 +0000 by phpDocumentor 1.4.3