Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Goku klausimai

Parašė And2s· 2009 Rugp. 27 22:08:06
#10

// This function sanitises news & article submissions
function descript($text, $striptags = true) {
   // Convert problematic ascii characters to their true values
   $search = array("40","41","58","65","66","67","68","69","70",
      "71","72","73","74","75","76","77","78","79","80","81",
      "82","83","84","85","86","87","88","89","90","97","98",
      "99","100","101","102","103","104","105","106","107",
      "108","109","110","111","112","113","114","115","116",
      "117","118","119","120","121","122"
      );
   $replace = array("(",")",":","a","b","c","d","e","f","g","h",
      "i","j","k","l","m","n","o","p","q","r","s","t","u",
      "v","w","x","y","z","a","b","c","d","e","f","g","h",
      "i","j","k","l","m","n","o","p","q","r","s","t","u",
      "v","w","x","y","z"
      );
   $entities = count($search);
   for ($i=0; $i < $entities; $i++) {
      $text = preg_replace("#(&\#)(0*".$search[$i]."+);*#si", $replace[$i], $text);
   }
   $text = preg_replace('#(&\#x)([0-9A-F]+);*#si', "", $text);
   $text = preg_replace('#(<[^>]+[/\"\'\s])(onmouseover|onmousedown|onmouseup|onmouseout|onmousemove|onclick|ondblclick|onfocus|onload|xmlns)[^>]*>#iU', ">", $text);
   $text = preg_replace('#([a-z]*)=([\`\'\"]*)script:#iU', '$1=$2nojscript...', $text);
   $text = preg_replace('#([a-z]*)=([\`\'\"]*)javascript:#iU', '$1=$2nojavascript...', $text);
   $text = preg_replace('#([a-z]*)=([\'\"]*)vbscript:#iU', '$1=$2novbscript...', $text);
   $text = preg_replace('#(<[^>]+)style=([\`\'\"]*).*expression\([^>]*>#iU', "$1>", $text);
   $text = preg_replace('#(<[^>]+)style=([\`\'\"]*).*behaviour\([^>]*>#iU', "$1>", $text);
   if ($striptags) {
      do {
         $thistext = $text;
         $text = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $text);
      } while ($thistext != $text);
   }
   return $text;
}



Redagavo And2s· 2009 Rugp. 27 22:08:21