本文整理汇总了PHP中markup函数的典型用法代码示例。如果您正苦于以下问题:PHP markup函数的具体用法?PHP markup怎么用?PHP markup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了markup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ban
function ban($mask, $reason, $length, $board)
{
global $mod, $pdo;
$query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)");
$query->bindValue(':ip', $mask);
$query->bindValue(':mod', $mod['id']);
$query->bindValue(':time', time());
if ($reason !== '') {
markup($reason);
$query->bindValue(':reason', $reason);
} else {
$query->bindValue(':reason', null, PDO::PARAM_NULL);
}
if ($length > 0) {
$query->bindValue(':expires', $length);
} else {
$query->bindValue(':expires', null, PDO::PARAM_NULL);
}
if ($board) {
$query->bindValue(':board', $board);
} else {
$query->bindValue(':board', null, PDO::PARAM_NULL);
}
$query->execute() or error(db_error($query));
modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban (<small>#' . $pdo->lastInsertId() . '</small>) for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : utf8tohtml($mask)) . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
示例2: showHomePage
/**
* Show home page.
* If the user is already logged in, show categories, otherwise show README.
*
* @return Response
*/
public function showHomePage()
{
if (Auth::check()) {
return redirect(route('category.index'));
}
$readme = markup(\File::get(base_path('readme.md')));
return view('home')->withTitle(_('Home'))->withContent($readme);
}
示例3: boot
public static function boot()
{
// NOTE events cycle is as follows:
// saving -> creating -> created -> saved
// saving -> updating -> updated -> saved
// deleting -> deleted -> restoring -> restored
parent::boot();
static::saved(function ($page) {
// Build markup
$markup = markup($page->source);
self::where([$page->getKeyName() => $page->getKey()])->limit(1)->update(['markup' => $markup]);
// Backup version
return Version::createFromPage($page);
});
}
示例4: rebuildPost
function rebuildPost($id)
{
global $board, $mod;
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `id` = :id", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
if (!($post = $query->fetch(PDO::FETCH_ASSOC)) || !$post['body_nomarkup']) {
return false;
}
markup($post['body'] =& $post['body_nomarkup']);
$post = (object) $post;
event('rebuildpost', $post);
$post = (array) $post;
$query = prepare(sprintf("UPDATE ``posts_%s`` SET `body` = :body WHERE `id` = :id", $board['uri']));
$query->bindValue(':body', $post['body']);
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
buildThread($post['thread'] ? $post['thread'] : $id);
return true;
}
示例5: new_ban
public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
{
global $mod, $pdo, $board;
if ($mod_id === false) {
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
}
$range = self::parse_range($mask);
$mask = self::range_to_string($range);
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
$query->bindValue(':ipstart', $range[0]);
if ($range[1] !== false && $range[1] != $range[0]) {
$query->bindValue(':ipend', $range[1]);
} else {
$query->bindValue(':ipend', null, PDO::PARAM_NULL);
}
$query->bindValue(':mod', $mod_id);
$query->bindValue(':time', time());
if ($reason !== '') {
$reason = escape_markup_modifiers($reason);
markup($reason);
$query->bindValue(':reason', $reason);
} else {
$query->bindValue(':reason', null, PDO::PARAM_NULL);
}
if ($length) {
if (is_int($length) || ctype_digit($length)) {
$length = time() + $length;
} else {
$length = self::parse_time($length);
}
$query->bindValue(':expires', $length);
} else {
$query->bindValue(':expires', null, PDO::PARAM_NULL);
}
if ($ban_board) {
$query->bindValue(':board', $ban_board);
} else {
$query->bindValue(':board', null, PDO::PARAM_NULL);
}
if ($post) {
$post['board'] = $board['uri'];
$query->bindValue(':post', json_encode($post));
} else {
$query->bindValue(':post', null, PDO::PARAM_NULL);
}
$query->execute() or error(db_error($query));
if (isset($mod['id']) && $mod['id'] == $mod_id) {
modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
return $pdo->lastInsertId();
}
示例6: error
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
} elseif (preg_match('/^\\/IP\\/(\\d+\\.\\d+\\.\\d+\\.\\d+|' . $config['ipv6_regex'] . ')$/', $query, $matches)) {
// View information on an IP address
$ip = $matches[1];
$host = $config['mod']['dns_lookup'] ? rDNS($ip) : false;
if (hasPermission($config['mod']['unban']) && isset($_POST['unban']) && isset($_POST['ban_id'])) {
removeBan($_POST['ban_id']);
header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
} elseif (hasPermission($config['mod']['create_notes']) && isset($_POST['note'])) {
$query = prepare("INSERT INTO `ip_notes` VALUES(NULL, :ip, :mod, :time, :body)");
$query->bindValue(':ip', $ip);
$query->bindValue(':mod', $mod['id'], PDO::PARAM_INT);
$query->bindValue(':time', time(), PDO::PARAM_INT);
markup($_POST['note']);
$query->bindValue(':body', $_POST['note']);
$query->execute() or error(db_error($query));
header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
} else {
$body = '';
$boards = listBoards();
foreach ($boards as &$_board) {
openBoard($_board['uri']);
$temp = '';
$query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` DESC LIMIT :limit", $_board['uri']));
$query->bindValue(':ip', $ip);
$query->bindValue(':limit', $config['mod']['ip_recentposts'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
while ($post = $query->fetch()) {
if (!$post['thread']) {
示例7: preg_split
// Assume we're using the utf8mb4 charset
} else {
// MySQL's `utf8` charset only supports up to 3-byte symbols
// Remove anything >= 0x010000
$chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
$post['body_nomarkup'] = '';
foreach ($chars as $char) {
$o = 0;
$ord = ordutf8($char, $o);
if ($ord >= 0x10000) {
continue;
}
$post['body_nomarkup'] .= $char;
}
}
$post['tracked_cites'] = markup($post['body'], true, $post['op']);
if ($post['has_file']) {
$allhashes = '';
foreach ($post['files'] as $key => &$file) {
if ($post['op'] && $config['allowed_ext_op']) {
if (!in_array($file['extension'], $config['allowed_ext_op'])) {
error($config['error']['unknownext']);
}
} elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) {
error($config['error']['unknownext']);
}
$file['is_an_image'] = !in_array($file['extension'], $config['allowed_ext_files']);
// Truncate filename if it is too long
$file['filename'] = mb_substr($file['filename'], 0, $config['max_filename_len']);
$upload = $file['tmp_name'];
if (!is_readable($upload)) {
示例8: printContent
function printContent()
{
if (isset($_GET['version']) && $_GET['version'] == '2.0') {
$contents = file('inc/RELEASENOTES-2.0.txt');
} else {
if (isset($_GET['version']) && $_GET['version'] == '2.1') {
$contents = file('inc/RELEASENOTES-2.1.txt');
} else {
if (isset($_GET['version']) && $_GET['version'] == '2.2') {
$contents = file('inc/RELEASENOTES-2.2.txt');
} else {
if (isset($_GET['version']) && $_GET['version'] == '2.3') {
$contents = file('inc/RELEASENOTES-2.3.txt');
} else {
if (isset($_GET['version']) && $_GET['version'] == '2.4') {
$contents = file('inc/RELEASENOTES-2.4.txt');
} else {
$contents = file('inc/RELEASENOTES.txt');
}
}
}
}
}
for ($i = 0; $i < count($contents); $i++) {
if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '===') {
$id = trim(preg_replace('%Version (\\d+\\.\\d+\\.\\d+).*\\n?%', '$1', $contents[$i]));
print '<h2 id="' . $id . '"><a href="#' . $id . '" name="' . $id . '">#</a> ';
print $contents[$i];
print '</h2>';
} else {
if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '---') {
print '<h3>';
print $contents[$i];
print '</h3>';
} else {
if (substr($contents[$i], 0, 3) == '===') {
// Skip
} else {
if (substr($contents[$i], 0, 3) == '---') {
// Skip
} else {
if (trim($contents[$i]) == '' && substr($contents[$i + 1], 0, 1) != '-') {
print '<p>';
} else {
if (substr($contents[$i], 0, 1) == '-') {
print '<ul>';
while (trim($contents[$i]) != '') {
print '<li>';
print preg_replace('%-\\s+(.*)%', '$1', markup($contents[$i]));
while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '-') {
print markup(htmlentities($contents[$i]));
}
print '</li>';
}
print '</ul><p>';
} else {
if (substr($contents[$i], 0, 1) == '#') {
print '<table class="ticket-table">';
while (trim($contents[$i]) != '') {
$ticket = preg_replace('%#(\\d+).*%', '$1', $contents[$i]);
print '<tr>';
print '<td width="80">';
print '<a href="https://github.com/jOOQ/jOOQ/issues/' . $ticket . '">#';
print $ticket;
print '</a>';
print '</td>';
print '<td>';
print htmlentities(preg_replace('%#\\d+\\s+-\\s+(.*)%', '$1', $contents[$i]));
while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '#') {
print htmlentities($contents[$i]);
}
print '</td>';
print '</tr>';
}
print '</table>';
} else {
print markup($contents[$i]);
}
}
}
}
}
}
}
}
}
示例9: preg_split
// Assume we're using the utf8mb4 charset
} else {
// MySQL's `utf8` charset only supports up to 3-byte symbols
// Remove anything >= 0x010000
$chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
$post['body_nomarkup'] = '';
foreach ($chars as $char) {
$o = 0;
$ord = ordutf8($char, $o);
if ($ord >= 0x10000) {
continue;
}
$post['body_nomarkup'] .= $char;
}
}
$post['tracked_cites'] = markup($post['body'], true);
if ($post['has_file']) {
$fnarray = array();
foreach ($post['files'] as $key => &$file) {
if ($post['op'] && $config['allowed_ext_op']) {
if (!in_array($file['extension'], $config['allowed_ext_op'])) {
error($config['error']['unknownext']);
}
} elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) {
error($config['error']['unknownext']);
}
$file['is_an_image'] = !in_array($file['extension'], $config['allowed_ext_files']);
// Truncate filename if it is too long
$file['filename'] = mb_substr($file['filename'], 0, $config['max_filename_len']);
if (!isset($filenames)) {
$filenames = escapeshellarg($file['tmp_name']);
示例10: rebuildPost
function rebuildPost($id)
{
global $board;
$query = prepare(sprintf("SELECT `body_nomarkup`, `thread` FROM `posts_%s` WHERE `id` = :id", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
if (!($post = $query->fetch()) || !$post['body_nomarkup']) {
return false;
}
markup($body =& $post['body_nomarkup']);
$query = prepare(sprintf("UPDATE `posts_%s` SET `body` = :body WHERE `id` = :id", $board['uri']));
$query->bindValue(':body', $body);
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
buildThread($post['thread'] ? $post['thread'] : $id);
return true;
}
示例11: printContent
function printContent()
{
$contents = file('inc/RELEASENOTES.txt');
for ($i = 0; $i < count($contents); $i++) {
if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '===') {
print '<h2>';
print $contents[$i];
print '</h2>';
} else {
if ($i + 1 < count($contents) && substr($contents[$i + 1], 0, 3) == '---') {
print '<h3>';
print $contents[$i];
print '</h3>';
} else {
if (substr($contents[$i], 0, 3) == '===') {
// Skip
} else {
if (substr($contents[$i], 0, 3) == '---') {
// Skip
} else {
if (trim($contents[$i]) == '' && substr($contents[$i + 1], 0, 1) != '-') {
print '<p>';
} else {
if (substr($contents[$i], 0, 1) == '-') {
print '<ul>';
while (trim($contents[$i]) != '') {
print '<li>';
print preg_replace('%-\\s+(.*)%', '$1', $contents[$i]);
while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '-') {
print htmlentities($contents[$i]);
}
print '</li>';
}
print '</ul><p>';
} else {
if (substr($contents[$i], 0, 1) == '#') {
print '<table class="ticket-table">';
while (trim($contents[$i]) != '') {
$ticket = preg_replace('%#(\\d+).*%', '$1', $contents[$i]);
print '<tr>';
print '<td width="80">';
print '<a href="https://sourceforge.net/apps/trac/jooq/ticket/' . $ticket . '">#';
print $ticket;
print '</a>';
print '</td>';
print '<td>';
print htmlentities(preg_replace('%#\\d+\\s+-\\s+(.*)%', '$1', $contents[$i]));
while (trim($contents[++$i]) != '' && substr($contents[$i], 0, 1) != '#') {
print htmlentities($contents[$i]);
}
print '</td>';
print '</tr>';
}
print '</table>';
} else {
print markup($contents[$i]);
}
}
}
}
}
}
}
}
}
示例12: __construct
public function __construct($post, $root = null, $mod = false, $hr = true)
{
global $config;
if (!isset($root)) {
$root =& $config['root'];
}
foreach ($post as $key => $value) {
$this->{$key} = $value;
}
$this->subject = utf8tohtml($this->subject);
$this->name = utf8tohtml($this->name);
$this->mod = $mod;
$this->root = $root;
$this->hr = $hr;
$this->posts = array();
$this->omitted = 0;
$this->omitted_images = 0;
if ($this->embed) {
$this->embed = embed_html($this->embed);
}
$this->modifiers = extract_modifiers($this->body_nomarkup);
if ($config['always_regenerate_markup']) {
$this->body = $this->body_nomarkup;
markup($this->body);
}
if ($this->mod) {
// Fix internal links
// Very complicated regex
$this->body = preg_replace('/<a((([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\\s)*)href="' . preg_quote($config['root'], '/') . '(' . sprintf(preg_quote($config['board_path'], '/'), $config['board_regex']) . ')/u', '<a $1href="?/$4', $this->body);
}
}
示例13: mod_edit_page
function mod_edit_page($id)
{
global $config, $mod, $board;
$query = prepare('SELECT * FROM ``pages`` WHERE `id` = :id');
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
$page = $query->fetch();
if (!$page) {
error(_('Could not find the page you are trying to edit.'));
}
if (!$page['board'] && $mod['boards'][0] !== '*') {
error($config['error']['noaccess']);
}
if (!hasPermission($config['mod']['edit_pages'], $page['board'])) {
error($config['error']['noaccess']);
}
if ($page['board'] && !openBoard($page['board'])) {
error($config['error']['noboard']);
}
if (isset($_POST['method'], $_POST['content'])) {
$content = $_POST['content'];
$method = $_POST['method'];
$page['type'] = $method;
if (!in_array($method, array('markdown', 'html', 'infinity'))) {
error(_('Unrecognized page markup method.'));
}
switch ($method) {
case 'markdown':
$write = purify_html(markdown($content));
break;
case 'html':
if (hasPermission($config['mod']['rawhtml'])) {
$write = $content;
} else {
$write = purify_html($content);
}
break;
case 'infinity':
$c = $content;
markup($content);
$write = $content;
$content = $c;
}
if (!isset($write) or !$write) {
error(_('Failed to mark up your input for some reason...'));
}
$query = prepare('UPDATE ``pages`` SET `type` = :method, `content` = :content WHERE `id` = :id');
$query->bindValue(':method', $method);
$query->bindValue(':content', $content);
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
$fn = ($board['uri'] ? $board['uri'] . '/' : '') . $page['name'] . '.html';
$body = "<div class='ban'>{$write}</div>";
$html = Element('page.html', array('config' => $config, 'body' => $body, 'title' => utf8tohtml($page['title'])));
file_write($fn, $html);
modLog("Edited page {$page['name']} <span class='unimportant'>(#{$page['id']})</span>");
}
if (!isset($content)) {
$query = prepare('SELECT `content` FROM ``pages`` WHERE `id` = :id');
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
$content = $query->fetchColumn();
}
mod_page(sprintf(_('Editing static page: %s'), $page['name']), 'mod/edit_page.html', array('page' => $page, 'token' => make_secure_link_token("edit_page/{$id}"), 'content' => prettify_textarea($content), 'board' => $board));
}
示例14: new_ban
public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
{
global $config, $mod, $pdo, $board;
if ($mod_id === false) {
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
}
if (!in_array($ban_board, $mod['boards']) && $mod['boards'][0] != '*') {
error($config['error']['noaccess']);
}
$range = self::parse_range($mask);
$mask = self::range_to_string($range);
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
$query->bindValue(':ipstart', $range[0]);
if ($range[1] !== false && $range[1] != $range[0]) {
$query->bindValue(':ipend', $range[1]);
} else {
$query->bindValue(':ipend', null, PDO::PARAM_NULL);
}
$query->bindValue(':mod', $mod_id);
$query->bindValue(':time', time());
if ($reason !== '') {
$reason = escape_markup_modifiers($reason);
markup($reason);
$query->bindValue(':reason', $reason);
} else {
$query->bindValue(':reason', null, PDO::PARAM_NULL);
}
if ($length) {
if (is_int($length) || ctype_digit($length)) {
$length = time() + $length;
} else {
$length = self::parse_time($length);
}
$query->bindValue(':expires', $length);
} else {
$query->bindValue(':expires', null, PDO::PARAM_NULL);
}
if ($ban_board) {
$query->bindValue(':board', $ban_board);
} else {
$query->bindValue(':board', null, PDO::PARAM_NULL);
}
if ($post) {
$post['board'] = $board['uri'];
$match_urls = '(?xi)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))';
$matched = array();
preg_match_all("#{$match_urls}#im", $post['body_nomarkup'], $matched);
if (isset($matched[0]) && $matched[0]) {
$post['body'] = str_replace($matched[0], '###Link-Removed###', $post['body']);
$post['body_nomarkup'] = str_replace($matched[0], '###Link-Removed###', $post['body_nomarkup']);
}
$query->bindValue(':post', json_encode($post));
} else {
$query->bindValue(':post', null, PDO::PARAM_NULL);
}
$query->execute() or error(db_error($query));
if (isset($mod['id']) && $mod['id'] == $mod_id) {
modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
if (!$config['cron_bans']) {
rebuildThemes('bans');
}
return $pdo->lastInsertId();
}
示例15: foreach
<?
foreach($tabs as $t)
{
$title = "<a href='#{$t->element_id}' class='tab_clicker'>{$t->tab_title}</a>";
$img = trim($t->image);
if ($img !== false && strlen($img) && @file_exists($_SERVER['DOCUMENT_ROOT'].$img))
$title = "<img src='$img' alt='' title=''> $title";
echo "<div>$title</div>";
}
?>
</div>
<div class='tab_content' style='float:left;position:relative;width:75%; min-height:200px; margin-left:-1px;'>
<?
foreach($tabs as $t)
{
echo "<div id='{$t->element_id}' class='content'>";
echo markup($t->content);
echo "</div>";
}
?>
</div>
</div>
</div>
</body>
</html>