Example #1
0
 /**
  * Clean a slug posted by the user
  * @param string $slug The slug provided by the user
  * @return string
  * @since 2.4b5
  */
 static function PostedSlug($string, $from_label = false)
 {
     includeFile('tool/strings.php');
     // Remove control characters
     $string = preg_replace('#[[:cntrl:]]#u', '', $string);
     // 	[\x00-\x1F\x7F]
     //illegal characters
     $string = str_replace(array('?', '*', ':', '|'), array('', '', '', ''), $string);
     //change known entities to their character equivalent
     $string = gp_strings::entity_unescape($string);
     //if it's from a label, remove any html
     if ($from_label) {
         $string = admin_tools::LabelHtml($string);
         $string = strip_tags($string);
         //after removing tags, unescape special characters
         $string = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $string);
     }
     // # character after unescape for entities and unescape of special chacters when $from_label is true
     $string = str_replace('#', '', $string);
     //slashes
     $string = admin_tools::SlugSlashes($string);
     return str_replace(' ', '_', $string);
 }
Example #2
0
 /**
  * Convert characters to their entity equivalent
  * @since 2.5b1
  */
 static function entity_escape($string)
 {
     $all_entities = gp_strings::all_entities();
     return str_replace(array_keys($all_entities), array_values($all_entities), $string);
 }