htmlspecialchars() public static method

See http://php.net/manual/en/function.htmlspecialchars.php for details on the parameters and purpose of the function.
public static htmlspecialchars ( string | array $string, integer $quote_flag = null, string $encoding = 'UTF-8', boolean $decode = true, boolean $double_encode = true ) : string
$string string | array The string or array of strings to escape
$quote_flag integer Sets what quotes and doublequotes are escaped
$encoding string The encoding of the passed string
$decode boolean Whether or not to unescape any html entities first
$double_encode boolean Whether or not to double escape any html entities
return string The escaped string
Beispiel #1
0
 /**
  * Output the Atom entry for a specific slug
  *
  * @param string $slug The slug to get the entry for
  */
 public function get_entry($slug)
 {
     $params['slug'] = $slug;
     $params['status'] = $this->is_auth() ? 'any' : Post::status('published');
     if ($post = Post::get($params)) {
         // Assign alternate link.
         $alternate = URL::get('display_entry', $post, false);
         $self = URL::get('atom_entry', $post, false);
         $id = isset($params['slug']) ? $params['slug'] : 'atom_entry';
         $user = User::get_by_id($post->user_id);
         $title = $this->is_auth() ? $post->title : $post->title_atom;
         $content = $this->is_auth() ? Utils::htmlspecialchars($post->content, ENT_COMPAT, 'UTF-8', false) : Utils::htmlspecialchars($post->content_atom, ENT_COMPAT, 'UTF-8', false);
         // Build the namespaces, plugins can alter it to override or insert their own.
         $namespaces = array('default' => 'http://www.w3.org/2005/Atom');
         $namespaces = Plugins::filter('atom_get_entry_namespaces', $namespaces);
         $namespaces = array_map(function ($value, $key) {
             return ($key == "default" ? "xmlns" : "xmlns:" . $key) . "=\"" . $value . "\"";
         }, $namespaces, array_keys($namespaces));
         $namespaces = implode(' ', $namespaces);
         $xml = new SimpleXMLElement('<entry ' . $namespaces . '></entry>');
         $entry = $xml;
         $entry_title = $entry->title = $title;
         $entry_author = $entry->addChild('author');
         $author_name = $entry_author->addChild('name', $user->displayname);
         $entry_link = $xml->addChild('link');
         $entry_link->addAttribute('rel', 'alternate');
         $entry_link->addAttribute('href', $post->permalink);
         $entry_link = $entry->addChild('link');
         $entry_link->addAttribute('rel', 'edit');
         $entry_link->addAttribute('href', URL::get('atom_entry', "slug={$post->slug}"));
         $entry_id = $entry->addChild('id', $post->guid);
         $entry_updated = $entry->addChild('updated', $post->updated->get('c'));
         $entry_edited = $entry->addChild('app:edited', $post->modified->get('c'), 'http://www.w3.org/2007/app');
         $entry_published = $entry->addChild('published', $post->pubdate->get('c'));
         foreach ($post->tags as $tag) {
             $entry_category = $entry->addChild('category');
             $entry_category->addAttribute('term', $tag->term);
         }
         $entry_content = $entry->addChild('content', $content);
         $entry_content->addAttribute('type', 'html');
         Plugins::act('atom_get_entry', $xml, $post, $this->handler_vars);
         $xml = $xml->asXML();
         ob_clean();
         header('Content-Type: application/atom+xml');
         print $this->tidy_xml($xml);
     }
 }
Beispiel #2
0
"<?php 
            echo in_array($opt_key, (array) $value) ? ' selected' : '';
            ?>
><?php 
            echo \Habari\Utils::htmlspecialchars($opt_val);
            ?>
</option>
				<?php 
        }
        ?>
			</optgroup>
		<?php 
    } else {
        ?>
			<option value="<?php 
        echo $opts_key;
        ?>
"<?php 
        echo in_array($opts_key, (array) $value) ? ' selected' : '';
        ?>
><?php 
        echo \Habari\Utils::htmlspecialchars($opts_val);
        ?>
</option>
		<?php 
    }
    ?>
	<?php 
}
?>
</select>