本文整理汇总了PHP中un_preparsecode函数的典型用法代码示例。如果您正苦于以下问题:PHP un_preparsecode函数的具体用法?PHP un_preparsecode怎么用?PHP un_preparsecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了un_preparsecode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNews
/**
* Prepares an array of the forum news items
*
* @package News
* @return array
*/
function getNews()
{
global $modSettings;
$admin_current_news = array();
// Ready the current news.
foreach (explode("\n", $modSettings['news']) as $id => $line) {
$admin_current_news[$id] = array('id' => $id, 'unparsed' => un_preparsecode($line), 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)));
}
$admin_current_news['last'] = array('id' => 'last', 'unparsed' => '', 'parsed' => '<div id="moreNewsItems_preview"></div>');
return $admin_current_news;
}
示例2: shd_save_reply
//.........这里部分代码省略.........
if (!empty($context['can_solve']) && !empty($_POST['resolve_ticket'])) {
$string = shd_check_dependencies();
if (!empty($string)) {
$context['shd_errors'][] = $string;
}
}
// Custom fields?
shd_load_custom_fields(false, $context['ticket_form']['msg'], $context['ticket_form']['dept']);
list($missing_fields, $invalid_fields) = shd_validate_custom_fields($context['ticket_form']['msg'], $context['ticket_form']['dept']);
$context['can_override_fields'] = shd_allowed_to('shd_override_cf', $context['ticket_form']['dept']);
$context['overriding_fields'] = $context['can_override_fields'] && isset($_POST['override_cf']);
// Did any custom fields fail validation?
if (!empty($invalid_fields)) {
$context['shd_errors'][] = 'invalid_fields';
$txt['error_invalid_fields'] = sprintf($txt['error_invalid_fields'], implode(', ', $invalid_fields));
}
// Any flat-out missing?
if (!empty($missing_fields) && !$context['overriding_fields']) {
$context['shd_errors'][] = 'missing_fields';
$txt['error_missing_fields'] = sprintf($txt['error_missing_fields'], implode(', ', $missing_fields));
}
if ($context['can_override_fields'] && !empty($missing_fields)) {
$context['ticket_form']['additional_opts']['override_cf'] = array('show' => true, 'checked' => false, 'text' => $txt['shd_override_cf']);
}
if (!empty($context['shd_errors']) || !empty($context['ticket_form']['preview'])) {
checkSubmitOnce('free');
// Anything else for redisplaying the form
$context['page_title'] = $txt['shd_helpdesk'];
$context['sub_template'] = 'reply_post';
// Oh, yeah, we need to look at the existing notifications pinging stuff, if appropriate, and reset that.
if ($context['can_ping'] && !empty($_POST['notify']) && is_array($_POST['notify'])) {
$items = array();
foreach ($_POST['notify'] as $item) {
if (!empty($item) && is_numeric($item)) {
$items[] = $item;
}
}
if (!empty($items)) {
$context['notification_ping_list'] = implode(',', $items);
}
}
shd_check_attachments();
// Set up the fancy editor
shd_postbox('shd_message', un_preparsecode($_POST['shd_message']), array('post_button' => $new_reply ? $txt['shd_reply_ticket'] : $txt['shd_ticket_edit_reply']));
// Build the link tree and navigation
$context['linktree'][] = array('name' => $txt['shd_reply_ticket']);
checkSubmitOnce('register');
} else {
// It all worked, w00t, so let's get ready to rumble
$attachIDs = shd_handle_attachments();
if ($new_reply) {
// So... what is the new status?
$new_status = shd_determine_status('reply', $ticketinfo['starter_id'], $user_info['id'], -1, $context['ticket_form']['dept']);
// We explicitly don't care about how many replies - but it must be non-zero. Default in function spec is -1.
// Now to add the ticket details
$posterOptions = array('id' => $user_info['id']);
$msgOptions = array('body' => $_POST['shd_message'], 'id' => $context['ticket_form']['msg'], 'smileys_enabled' => empty($context['ticket_form']['disable_smileys']), 'attachments' => $attachIDs, 'custom_fields' => !empty($context['ticket_form']['custom_fields'][$context['ticket_form']['msg']]) ? $context['ticket_form']['custom_fields'][$context['ticket_form']['msg']] : array());
$ticketOptions = array('id' => $context['ticket_form']['ticket'], 'mark_as_read' => true, 'status' => $new_status);
if (!empty($context['can_solve']) && !empty($_POST['resolve_ticket'])) {
$ticketOptions['status'] = TICKET_STATUS_CLOSED;
shd_log_action('resolve', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
}
shd_create_ticket_post($msgOptions, $ticketOptions, $posterOptions);
// Handle notifications
require_once $sourcedir . '/sd_source/SimpleDesk-Notifications.php';
shd_notifications_notify_newreply($msgOptions, $ticketOptions, $posterOptions);
} else {
// Only add what has actually changed
// Now to add the ticket details
$posterOptions = array();
$msgOptions = array('id' => $context['ticket_form']['msg'], 'attachments' => $attachIDs, 'custom_fields' => !empty($context['ticket_form']['custom_fields'][$context['ticket_form']['msg']]) ? $context['ticket_form']['custom_fields'][$context['ticket_form']['msg']] : array());
$ticketOptions = array('id' => $context['ticket_form']['ticket']);
if ((bool) $ticketinfo['smileys_enabled'] == $context['ticket_form']['disable_smileys']) {
// since one is enabled, one is 'now disable'...
$msgOptions['smileys_enabled'] = !$context['ticket_form']['disable_smileys'];
}
if ($reply['body'] != $context['ticket_form']['reply']) {
$msgOptions['body'] = $context['ticket_form']['reply'];
}
if (isset($msgOptions['body'])) {
$msgOptions['modified'] = array('id' => $user_info['id'], 'name' => $user_info['name'], 'time' => time());
}
if (!empty($context['can_solve']) && !empty($_POST['resolve_ticket'])) {
$ticketOptions['status'] = TICKET_STATUS_CLOSED;
shd_log_action('resolve', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
}
// DOOOOOOOO EEEEEEEEEEET NAO!
shd_modify_ticket_post($msgOptions, $ticketOptions, $posterOptions);
// OK, did we get any custom fields back?
foreach ($context['custom_fields_updated'] as $field) {
$action = 'cf_' . ($field['scope'] == CFIELD_TICKET ? 'tkt' : 'rpl') . (empty($field['default']) ? 'change_' : 'chgdef_') . ($field['visible'][0] ? 'user' : '') . ($field['visible'][1] ? 'staff' : '') . 'admin';
unset($field['default'], $field['scope'], $field['visible']);
$field['subject'] = $ticketinfo['subject'];
shd_log_action($action, $field);
}
}
$context['ticket_form']['msg'] = $msgOptions['id'];
shd_done_posting();
}
}
示例3: action_edit
public function action_edit()
{
global $context;
$context['sub_template'] = 'dismissnotice_ajax_edit';
$id_notice = isset($_GET['idnotice']) ? (int) $_GET['idnotice'] : 0;
if (empty($id_notice)) {
return $this->action_new();
}
require_once SUBSDIR . '/Post.subs.php';
require_once SUBSDIR . '/DismissibleNotices.class.php';
$notice = new Dismissible_Notices();
$dismissnotice_data = $notice->getNoticeById($id_notice, false);
$selected_groups = (array) json_decode($dismissnotice_data['show_to']);
$context['default_groups_list'] = $this->populateGroupList($selected_groups);
$context['dismissnotice_data'] = array('added' => standardTime($dismissnotice_data['added']), 'expire' => $dismissnotice_data['expire'], 'body' => un_preparsecode($dismissnotice_data['body']), 'class' => $dismissnotice_data['class'], 'element' => $this->positionChecked('element', $dismissnotice_data['positioning']['element']), 'position' => $dismissnotice_data['positioning']['position'], 'element_name' => $dismissnotice_data['positioning']['element_name'], 'global' => $this->positionChecked('global', $dismissnotice_data['positioning']['element']), 'groups' => $selected_groups);
}
示例4: char_template_edit
function char_template_edit()
{
global $context, $txt, $sourcedir, $smcFunc;
require_once $sourcedir . '/Subs-Post.php';
require_once $sourcedir . '/Subs-Editor.php';
$template_id = isset($_GET['template_id']) ? (int) $_GET['template_id'] : 0;
$request = $smcFunc['db_query']('', '
SELECT id_template, template_name, template
FROM {db_prefix}character_sheet_templates
WHERE id_template = {int:template}', ['template' => $template_id]);
$row = $smcFunc['db_fetch_assoc']($request);
if (empty($row)) {
redirectexit('action=admin;area=templates');
}
$context['template_id'] = $template_id;
$context['template_name'] = $row['template_name'];
// Now create the editor.
$editorOptions = ['id' => 'message', 'value' => un_preparsecode($row['template']), 'labels' => ['post_button' => $txt['save']], 'height' => '500px', 'width' => '100%', 'preview_type' => 0, 'required' => true];
create_control_richedit($editorOptions);
$context['page_title'] = $txt['char_templates_edit'];
$context['sub_template'] = 'char_template_edit';
loadTemplate('Admin-Chars');
}
示例5: load_char_sheet_templates
function load_char_sheet_templates()
{
global $context, $smcFunc, $sourcedir;
require_once $sourcedir . '/Subs-Post.php';
$context['sheet_templates'] = [];
// Go fetch the possible templates.
$request = $smcFunc['db_query']('', '
SELECT id_template, template_name, template
FROM {db_prefix}character_sheet_templates
ORDER BY position ASC');
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$context['sheet_templates'][$row['id_template']] = array('name' => $row['template_name'], 'body' => un_preparsecode($row['template']));
}
$smcFunc['db_free_result']($request);
}
示例6: list_getNews
function list_getNews()
{
global $modSettings;
$admin_current_news = array();
// Ready the current news.
foreach (explode("\n", $modSettings['news']) as $id => $line) {
$admin_current_news[$id] = array('id' => $id, 'unparsed' => un_preparsecode($line), 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)));
}
$admin_current_news['last'] = array('id' => 'last', 'unparsed' => '<div id="moreNewsItems"></div>
<noscript><textarea rows="3" cols="65" name="news[]" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 85%; min-width: 85%' : 'width: 85%') . ';"></textarea></noscript>', 'parsed' => '<div id="moreNewsItems_preview"></div>');
return $admin_current_news;
}
示例7: getFormMsgSubject
/**
* Prepares a post subject for the post form
*
* - Will add the approriate Re: to the post subject if its a reply to an existing post
* - If quoting a post, or editing a post, this function also prepares the message body
* - if editing is true, returns $message|$message[errors], else returns array($subject, $message)
*
* @package Posts
* @param boolean $editing
* @param int|null|false $topic
* @param string $first_subject
*/
function getFormMsgSubject($editing, $topic, $first_subject = '')
{
global $modSettings, $context;
$db = database();
if ($editing) {
require_once SUBSDIR . '/Messages.subs.php';
// Get the existing message.
$message = messageDetails((int) $_REQUEST['msg'], $topic);
// The message they were trying to edit was most likely deleted.
if ($message === false) {
fatal_lang_error('no_message', false);
}
$errors = checkMessagePermissions($message['message']);
prepareMessageContext($message);
if (!empty($errors)) {
$message['errors'] = $errors;
}
return $message;
} else {
// Posting a quoted reply?
if (!empty($topic) && !empty($_REQUEST['quote']) || !empty($modSettings['enableFollowup']) && !empty($_REQUEST['followup'])) {
$msg_id = !empty($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : (int) $_REQUEST['followup'];
// Make sure they _can_ quote this post, and if so get it.
$request = $db->query('', '
SELECT m.subject, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.body
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg = {int:id_msg}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND m.approved = {int:is_approved}') . '
LIMIT 1', array('id_msg' => $msg_id, 'is_approved' => 1));
if ($db->num_rows($request) == 0) {
fatal_lang_error('quoted_post_deleted', false);
}
list($form_subject, $mname, $mdate, $form_message) = $db->fetch_row($request);
$db->free_result($request);
// Add 'Re: ' to the front of the quoted subject.
if (trim($context['response_prefix']) != '' && Util::strpos($form_subject, trim($context['response_prefix'])) !== 0) {
$form_subject = $context['response_prefix'] . $form_subject;
}
// Censor the message and subject.
censorText($form_message);
censorText($form_subject);
$form_message = un_preparsecode($form_message);
// Remove any nested quotes, if necessary.
if (!empty($modSettings['removeNestedQuotes'])) {
$form_message = preg_replace(array('~\\n?\\[quote.*?\\].+?\\[/quote\\]\\n?~is', '~^\\n~', '~\\[/quote\\]~'), '', $form_message);
}
// Add a quote string on the front and end.
$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $msg_id . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
} elseif (!empty($topic) && empty($_REQUEST['quote'])) {
// Get the first message's subject.
$form_subject = $first_subject;
// Add 'Re: ' to the front of the subject.
if (trim($context['response_prefix']) != '' && $form_subject != '' && Util::strpos($form_subject, trim($context['response_prefix'])) !== 0) {
$form_subject = $context['response_prefix'] . $form_subject;
}
// Censor the subject.
censorText($form_subject);
$form_message = '';
} else {
$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
$form_message = '';
}
return array($form_subject, $form_message);
}
}
示例8: QuoteFast
function QuoteFast()
{
global $modSettings, $user_info, $txt, $settings, $context;
global $sourcedir, $smcFunc;
loadLanguage('Post');
if (!isset($_REQUEST['xml'])) {
loadTemplate('Post');
}
include_once $sourcedir . '/Subs-Post.php';
$moderate_boards = boardsAllowedTo('moderate_board');
// Where we going if we need to?
$context['post_box_name'] = isset($_GET['pb']) ? $_GET['pb'] : '';
$request = $smcFunc['db_query']('', '
SELECT IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.body, m.id_topic, m.subject,
m.id_board, m.id_member, m.approved
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg = {int:id_msg}' . (isset($_REQUEST['modify']) || !empty($moderate_boards) && $moderate_boards[0] == 0 ? '' : '
AND (t.locked = {int:not_locked}' . (empty($moderate_boards) ? '' : ' OR b.id_board IN ({array_int:moderation_board_list})') . ')') . '
LIMIT 1', array('current_member' => $user_info['id'], 'moderation_board_list' => $moderate_boards, 'id_msg' => (int) $_REQUEST['quote'], 'not_locked' => 0));
$context['close_window'] = $smcFunc['db_num_rows']($request) == 0;
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
$context['sub_template'] = 'quotefast';
if (!empty($row)) {
$can_view_post = $row['approved'] || $row['id_member'] != 0 && $row['id_member'] == $user_info['id'] || allowedTo('approve_posts', $row['id_board']);
}
if (!empty($can_view_post)) {
// Remove special formatting we don't want anymore.
$row['body'] = un_preparsecode($row['body']);
// Censor the message!
censorText($row['body']);
$row['body'] = preg_replace('~<br ?/?' . '>~i', "\n", $row['body']);
// Want to modify a single message by double clicking it?
if (isset($_REQUEST['modify'])) {
censorText($row['subject']);
$context['sub_template'] = 'modifyfast';
$context['message'] = array('id' => $_REQUEST['quote'], 'body' => $row['body'], 'subject' => addcslashes($row['subject'], '"'));
return;
}
// Remove any nested quotes.
if (!empty($modSettings['removeNestedQuotes'])) {
$row['body'] = preg_replace(array('~\\n?\\[quote.*?\\].+?\\[/quote\\]\\n?~is', '~^\\n~', '~\\[/quote\\]~'), '', $row['body']);
}
// Make the body HTML if need be.
if (!empty($_REQUEST['mode'])) {
require_once $sourcedir . '/Subs-Editor.php';
$row['body'] = strtr($row['body'], array('<' => '#smlt#', '>' => '#smgt#', '&' => '#smamp#'));
$row['body'] = bbc_to_html($row['body']);
$lb = '<br />';
} else {
$lb = "\n";
}
// Add a quote string on the front and end.
$context['quote']['xml'] = '[quote author=' . $row['poster_name'] . ' link=topic=' . $row['id_topic'] . '.msg' . (int) $_REQUEST['quote'] . '#msg' . (int) $_REQUEST['quote'] . ' date=' . $row['poster_time'] . ']' . $lb . $row['body'] . $lb . '[/quote]';
$context['quote']['text'] = strtr(un_htmlspecialchars($context['quote']['xml']), array('\'' => '\\\'', '\\' => '\\\\', "\n" => '\\n', '</script>' => '</\' + \'script>'));
$context['quote']['xml'] = strtr($context['quote']['xml'], array(' ' => ' ', '<' => '<', '>' => '>'));
$context['quote']['mozilla'] = strtr($smcFunc['htmlspecialchars']($context['quote']['text']), array('"' => '"'));
} elseif (isset($_REQUEST['modify'])) {
$context['sub_template'] = 'modifyfast';
$context['message'] = array('id' => 0, 'body' => '', 'subject' => '');
} else {
$context['quote'] = array('xml' => '', 'mozilla' => '', 'text' => '');
}
}
示例9: action_sportal_admin_article_edit
/**
* Edits an existing or adds a new article to the system
* Handles the previewing of an article
*/
public function action_sportal_admin_article_edit()
{
global $context, $options, $txt;
$this->_is_new = empty($_REQUEST['article_id']);
$article_errors = Error_Context::context('article', 0);
// Going to use editor and post functions
require_once SUBSDIR . '/Post.subs.php';
require_once SUBSDIR . '/Editor.subs.php';
// Convert this to BBC?
if (!empty($_REQUEST['content_mode']) && $_POST['type'] == 'bbc') {
$convert = $_REQUEST['content'];
require_once SUBSDIR . '/Html2BBC.class.php';
$bbc_converter = new Convert_BBC($convert);
$convert = $bbc_converter->get_bbc();
$convert = un_htmlspecialchars($convert);
$_POST['content'] = $convert;
}
// Saving the work?
if (!empty($_POST['submit']) && !$article_errors->hasErrors()) {
checkSession();
$this->_sportal_admin_article_edit_save();
}
// Just taking a look before you save?
if (!empty($_POST['preview']) || $article_errors->hasErrors()) {
$context['article'] = $this->_sportal_admin_article_preview();
// Fix any bbc errors they have created
if ($context['article']['type'] == 'bbc') {
preparsecode($context['article']['body']);
}
loadTemplate('PortalArticles');
// Showing errors or a preview?
if ($article_errors->hasErrors()) {
$context['article_errors'] = array('errors' => $article_errors->prepareErrors(), 'type' => $article_errors->getErrorType() == 0 ? 'minor' : 'serious', 'title' => $txt['sp_form_errors_detected']);
} else {
$context['preview'] = true;
}
} elseif ($this->_is_new) {
$context['article'] = array('id' => 0, 'article_id' => 'article' . mt_rand(1, 5000), 'category' => array('id' => 0), 'title' => $txt['sp_articles_default_title'], 'body' => '', 'type' => 'bbc', 'permissions' => 3, 'status' => 1);
} else {
$_REQUEST['article_id'] = (int) $_REQUEST['article_id'];
$context['article'] = sportal_get_articles($_REQUEST['article_id']);
}
if ($context['article']['type'] === 'bbc') {
$context['article']['body'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), un_preparsecode($context['article']['body']));
}
// On to the editor
if ($context['article']['type'] !== 'bbc') {
// Override user prefs for wizzy mode if they don't need it
$temp_editor = !empty($options['wysiwyg_default']);
$options['wysiwyg_default'] = false;
}
// Fire up the editor with the values
$editor_options = array('id' => 'content', 'value' => $context['article']['body'], 'width' => '100%', 'height' => '225px', 'preview_type' => 2);
create_control_richedit($editor_options);
$context['post_box_name'] = $editor_options['id'];
// Restore their settings
if (isset($temp_editor)) {
$options['wysiwyg_default'] = $temp_editor;
}
// Set the editor box to the right mode based on type (bbc, html, php)
addInlineJavascript('
$(window).load(function() {
diewithfire = window.setTimeout(function() {sp_update_editor("' . $context['article']['type'] . '", "");}, 200);
});
');
// Final bits for the template, category's and permission settings
$context['article']['permission_profiles'] = sportal_get_profiles(null, 1, 'name');
if (empty($context['article']['permission_profiles'])) {
fatal_lang_error('error_sp_no_permission_profiles', false);
}
$context['article']['categories'] = sportal_get_categories();
if (empty($context['article']['categories'])) {
fatal_lang_error('error_sp_no_category', false);
}
// Page out values
$context['is_new'] = $this->_is_new;
$context['article']['body'] = sportal_parse_content($context['article']['body'], $context['article']['type'], 'return');
$context['page_title'] = $this->_is_new ? $txt['sp_admin_articles_add'] : $txt['sp_admin_articles_edit'];
$context['sub_template'] = 'articles_edit';
}
示例10: getDraft
/**
* Get a draft contents, other draft details.
*
* @param int $id_member
* @param int $id_board
* @param int $id_topic
* @param int $id_msg = 0
*/
function getDraft($id_member, $id_board, $id_topic, $id_msg = 0)
{
global $context;
$id_cond = empty($_REQUEST['draft_id']) ? '1=1' : ' id_draft = {int:draft} ';
$id_sel = $id_msg ? ' AND id_msg = {int:message} ' : ' AND id_board = {int:board} AND id_topic = {int:topic} ';
$query = smf_db_query('
SELECT id_draft, id_board, id_topic, subject, body, icon, smileys, is_locked, is_sticky
FROM {db_prefix}drafts WHERE ' . $id_cond . '
AND id_member = {int:member}
' . $id_sel . '
LIMIT 1', array('draft' => isset($_REQUEST['draft_id']) ? $_REQUEST['draft_id'] : 0, 'member' => $id_member, 'board' => $id_board, 'topic' => $id_topic, 'message' => $id_msg));
if ($row = mysql_fetch_assoc($query)) {
$context['subject'] = $row['subject'];
$context['message'] = un_preparsecode($row['body']);
$context['use_smileys'] = !empty($row['smileys']);
$context['icon'] = $row['icon'];
$context['draft_locked'] = $context['locked'];
$context['locked'] = !empty($row['is_locked']);
$context['sticky'] = !empty($row['is_sticky']);
if ($id_msg) {
$context['draft_id'] = $row['id_draft'];
}
} else {
$context['draft_locked'] = $context['locked'];
}
mysql_free_result($query);
}
示例11: action_sportal_admin_page_edit
/**
* Interface for adding/editing a page
*/
public function action_sportal_admin_page_edit()
{
global $txt, $context, $options;
$context['SPortal']['is_new'] = empty($_REQUEST['page_id']);
$pages_errors = Error_Context::context('pages', 0);
// Some help will be needed
require_once SUBSDIR . '/Editor.subs.php';
require_once SUBSDIR . '/Post.subs.php';
// Convert this to BBC?
if (!empty($_REQUEST['content_mode']) && $_POST['type'] === 'bbc') {
require_once SUBSDIR . 'Html2BBC.class.php';
$bbc_converter = new Convert_BBC($_REQUEST['content']);
$_REQUEST['content'] = $bbc_converter->get_bbc();
$_REQUEST['content'] = un_htmlspecialchars($_REQUEST['content']);
$_POST['content'] = $_REQUEST['content'];
}
// Load in the blocks that can be used on a page
$this->blocks = getBlockInfo();
$context['page_blocks'] = $this->_sportal_admin_page_load_blocks();
// Saving the work?
if (!empty($_POST['submit']) && !$pages_errors->hasErrors()) {
checkSession();
$this->_sportal_admin_page_edit_save();
}
// Doing a quick look before you save or you messed up?
if (!empty($_POST['preview']) || $pages_errors->hasErrors()) {
$context['SPortal']['page'] = array('id' => $_POST['page_id'], 'page_id' => $_POST['namespace'], 'title' => Util::htmlspecialchars($_POST['title'], ENT_QUOTES), 'body' => Util::htmlspecialchars($_POST['content'], ENT_QUOTES), 'type' => $_POST['type'], 'permissions' => $_POST['permissions'], 'style' => sportal_parse_style('implode'), 'status' => !empty($_POST['status']));
// Fix up bbc errors before we go to the preview
if ($context['SPortal']['page']['type'] == 'bbc') {
preparsecode($context['SPortal']['page']['body']);
}
loadTemplate('PortalPages');
// Showing errors or a preview?
if ($pages_errors->hasErrors()) {
$context['pages_errors'] = array('errors' => $pages_errors->prepareErrors(), 'type' => $pages_errors->getErrorType() == 0 ? 'minor' : 'serious', 'title' => $txt['sp_form_errors_detected']);
} else {
$context['SPortal']['preview'] = true;
}
} elseif ($context['SPortal']['is_new']) {
$context['SPortal']['page'] = array('id' => 0, 'page_id' => 'page' . mt_rand(1, 5000), 'title' => $txt['sp_pages_default_title'], 'body' => '', 'type' => 'bbc', 'permissions' => 3, 'style' => '', 'status' => 1);
} else {
$_REQUEST['page_id'] = (int) $_REQUEST['page_id'];
$context['SPortal']['page'] = sportal_get_pages($_REQUEST['page_id']);
}
if ($context['SPortal']['page']['type'] === 'bbc') {
$context['SPortal']['page']['body'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), un_preparsecode($context['SPortal']['page']['body']));
}
// Set up the editor, values, initial state, etc
if ($context['SPortal']['page']['type'] !== 'bbc') {
// No wizzy mode if they don't need it
$temp_editor = !empty($options['wysiwyg_default']);
$options['wysiwyg_default'] = false;
}
$editorOptions = array('id' => 'content', 'value' => $context['SPortal']['page']['body'], 'width' => '100%', 'height' => '225px', 'preview_type' => 2);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];
if (isset($temp_editor)) {
$options['wysiwyg_default'] = $temp_editor;
}
// Set the editor box as needed (editor or textbox, etc)
addInlineJavascript('
$(window).load(function() {
diewithfire = window.setTimeout(function() {sp_update_editor("' . $context['SPortal']['page']['type'] . '", "");}, 200);
});
');
// Permissions
$context['SPortal']['page']['permission_profiles'] = sportal_get_profiles(null, 1, 'name');
if (empty($context['SPortal']['page']['permission_profiles'])) {
fatal_lang_error('error_sp_no_permission_profiles', false);
}
// And for the template
$context['SPortal']['page']['style'] = sportal_parse_style('explode', $context['SPortal']['page']['style'], !empty($context['SPortal']['preview']));
$context['SPortal']['page']['body'] = sportal_parse_content($context['SPortal']['page']['body'], $context['SPortal']['page']['type'], 'return');
$context['page_title'] = $context['SPortal']['is_new'] ? $txt['sp_admin_pages_add'] : $txt['sp_admin_pages_edit'];
$context['sub_template'] = 'pages_edit';
}
示例12: action_quotefast
/**
* Loads a post an inserts it into the current editing text box.
* Used to quick edit a post as well as to quote a post and place it in the quick reply box
* Can be used to quick edit just the subject from the topic listing
*
* uses the Post language file.
* uses special (sadly browser dependent) javascript to parse entities for internationalization reasons.
* accessed with ?action=quotefast and ?action=quotefast;modify
*/
public function action_quotefast()
{
global $modSettings, $user_info, $context;
$db = database();
loadLanguage('Post');
require_once SUBSDIR . '/Post.subs.php';
$moderate_boards = boardsAllowedTo('moderate_board');
// Where we going if we need to?
$context['post_box_name'] = isset($_GET['pb']) ? $_GET['pb'] : '';
$request = $db->query('', '
SELECT IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.body, m.id_topic, m.subject,
m.id_board, m.id_member, m.approved
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg = {int:id_msg}' . (isset($_REQUEST['modify']) || !empty($moderate_boards) && $moderate_boards[0] == 0 ? '' : '
AND (t.locked = {int:not_locked}' . (empty($moderate_boards) ? '' : ' OR b.id_board IN ({array_int:moderation_board_list})') . ')') . '
LIMIT 1', array('current_member' => $user_info['id'], 'moderation_board_list' => $moderate_boards, 'id_msg' => (int) $_REQUEST['quote'], 'not_locked' => 0));
$row = $db->fetch_assoc($request);
$db->free_result($request);
$context['sub_template'] = 'quotefast';
if (!empty($row)) {
$can_view_post = $row['approved'] || $row['id_member'] != 0 && $row['id_member'] == $user_info['id'] || allowedTo('approve_posts', $row['id_board']);
}
if (!empty($can_view_post)) {
// Remove special formatting we don't want anymore.
$row['body'] = un_preparsecode($row['body']);
// Censor the message!
censorText($row['body']);
$row['body'] = preg_replace('~<br ?/?' . '>~i', "\n", $row['body']);
// Want to modify a single message by double clicking it?
if (isset($_REQUEST['modify'])) {
censorText($row['subject']);
$context['sub_template'] = 'modifyfast';
$context['message'] = array('id' => $_REQUEST['quote'], 'body' => $row['body'], 'subject' => addcslashes($row['subject'], '"'));
return;
}
// Remove any nested quotes.
if (!empty($modSettings['removeNestedQuotes'])) {
$row['body'] = preg_replace(array('~\\n?\\[quote.*?\\].+?\\[/quote\\]\\n?~is', '~^\\n~', '~\\[/quote\\]~'), '', $row['body']);
}
// Add a quote string on the front and end.
$context['quote']['xml'] = '[quote author=' . $row['poster_name'] . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $row['poster_time'] . "]\n" . $row['body'] . "\n[/quote]";
$context['quote']['text'] = strtr(un_htmlspecialchars($context['quote']['xml']), array('\'' => '\\\'', '\\' => '\\\\', "\n" => '\\n', '</script>' => '</\' + \'script>'));
$context['quote']['xml'] = strtr($context['quote']['xml'], array(' ' => ' ', '<' => '<', '>' => '>'));
$context['quote']['mozilla'] = strtr(Util::htmlspecialchars($context['quote']['text']), array('"' => '"'));
} elseif (isset($_REQUEST['modify'])) {
$context['sub_template'] = 'modifyfast';
$context['message'] = array('id' => 0, 'body' => '', 'subject' => '');
} else {
$context['quote'] = array('xml' => '', 'mozilla' => '', 'text' => '');
}
}
示例13: shd_frontpage_options
function shd_frontpage_options($return_config)
{
global $context, $modSettings, $txt, $sourcedir, $smcFunc;
// Since this is potentially dangerous, real admins only, thanks.
isAllowedTo('admin_forum');
$config_vars = array(array('select', 'shdp_frontpage_appear', array('always' => $txt['shdp_frontpage_appear_always'], 'firstload' => $txt['shdp_frontpage_appear_firstload'], 'firstdefault' => $txt['shdp_frontpage_appear_firstdefault'])), '', array('select', 'shdp_frontpage_type', array('php' => $txt['shdp_frontpage_type_php'], 'bbcode' => $txt['shdp_frontpage_type_bbcode'])), array('large_text', 'shdp_frontpage_content', 'size' => 30));
$context['settings_title'] = $txt['shdp_frontpage'];
$context['settings_icon'] = 'frontpage.png';
// Are we actually going to display this, or bouncing it back just for admin search?
if (!$return_config) {
require_once $sourcedir . '/Subs-Post.php';
require_once $sourcedir . '/Subs-Editor.php';
loadTemplate('sd_plugins_template/SDPluginFrontPage');
$context['sub_template'] = 'shd_frontpage_admin';
$context['shdp_frontpage_content'] = !empty($modSettings['shdp_frontpage_content']) ? un_preparsecode($modSettings['shdp_frontpage_content']) : '';
if (isset($_GET['save'])) {
$_POST['shdp_frontpage_content'] = isset($_POST['shdp_frontpage_content']) ? $_POST['shdp_frontpage_content'] : '';
if (!empty($_POST['shdp_frontpage_type']) && $_POST['shdp_frontpage_type'] == 'php') {
$context['shdp_frontpage_content'] = $smcFunc['htmlspecialchars']($_POST['shdp_frontpage_content'], ENT_QUOTES);
} else {
$_POST['shdp_frontpage_content'] = $smcFunc['htmlspecialchars']($_POST['shdp_frontpage_content'], ENT_QUOTES);
preparsecode($_POST['shdp_frontpage_content']);
$context['shdp_frontpage_content'] = un_preparsecode($_POST['shdp_frontpage_content']);
// So it's a known safe version.
}
}
$modSettings['disable_wysiwyg'] = true;
$editorOptions = array('id' => 'shdp_frontpage_content', 'value' => $context['shdp_frontpage_content'], 'labels' => array('post_button' => $txt['save']), 'preview_type' => 0, 'width' => '70%', 'disable_smiley_box' => false);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];
}
return $config_vars;
}
示例14: method_save_raw_post
function method_save_raw_post()
{
global $mobdb, $mobsettings, $user_info, $context, $sourcedir, $func, $smcFunc;
if ($user_info['is_guest']) {
createErrorResponse(8);
}
require_once $sourcedir . '/Subs-Post.php';
// What is this post?
$id_msg = (int) $context['mob_request']['params'][0][0];
if (empty($id_msg)) {
createErrorResponse(6);
}
$subject = utf8ToAscii(trim(base64_decode($context['mob_request']['params'][1][0])));
$body = utf8ToAscii(trim(base64_decode($context['mob_request']['params'][2][0])));
######## Added by Sean##############
$subject = addslashes__recursive($subject);
$body = addslashes__recursive($body);
// Set up the inputs for the form.
$body = $func['htmlspecialchars']($body, ENT_QUOTES);
preparsecode($body);
$subject = strtr($func['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
##################################################################
if (empty($body)) {
createErrorResponse('incorrect_params', '', 'xmlrpc');
}
// Get the board and body
$mobdb->query('
SELECT b.ID_BOARD AS id_board, m.ID_MEMBER AS id_member, t.isSticky, t.locked, t.ID_TOPIC, m.posterTime AS poster_time, t.ID_MEMBER_STARTED
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (m.ID_TOPIC = t.ID_TOPIC)
INNER JOIN {db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD)
WHERE m.ID_MSG = {int:msg}', array('msg' => $id_msg));
if ($mobdb->num_rows() == 0) {
createErrorResponse(6);
}
list($id_board, $id_member_posted, $sticky, $locked, $id_topic, $post_time, $id_member_start) = $mobdb->fetch_row();
$mobdb->free_result();
$is_started = $user_info['id'] == $id_member_start && !$user_info['is_guest'];
$can_edit = (!$locked || allowedTo('moderate_board', $id_board)) && (allowedTo('modify_any', $id_board) || allowedTo('modify_replies', $id_board) && $is_started || allowedTo('modify_own', $id_board) && $id_member_posted == $user_info['id'] && (empty($modSettings['edit_disable_time']) || $post_time + $modSettings['edit_disable_time'] * 60 > time()));
if (!$can_edit) {
createErrorResponse(6);
}
//$subject = strtr(htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));
//$body = htmlspecialchars($body);
$body = un_preparsecode($body);
censorText($subject);
censorText($body);
// Save it!
$msgOptions = array('body' => $body, 'id' => $id_msg);
if ($subject) {
$msgOptions['subject'] = $subject;
}
$topicOptions = array('id' => $id_topic, 'sticky_mode' => $sticky, 'locked_mode' => $locked);
$posterOptions = array();
modifyPost($msgOptions, $topicOptions, $posterOptions);
outputRPCResult(true);
}
示例15: EditNews
function EditNews()
{
global $txt, $modSettings, $context, $sourcedir, $user_info;
global $smcFunc;
require_once $sourcedir . '/Subs-Post.php';
// The 'remove selected' button was pressed.
if (!empty($_POST['delete_selection']) && !empty($_POST['remove'])) {
checkSession();
// Store the news temporarily in this array.
$temp_news = explode("\n", $modSettings['news']);
// Remove the items that were selected.
foreach ($temp_news as $i => $news) {
if (in_array($i, $_POST['remove'])) {
unset($temp_news[$i]);
}
}
// Update the database.
updateSettings(array('news' => implode("\n", $temp_news)));
logAction('news');
} elseif (!empty($_POST['save_items'])) {
checkSession();
foreach ($_POST['news'] as $i => $news) {
if (trim($news) == '') {
unset($_POST['news'][$i]);
} else {
$_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES);
preparsecode($_POST['news'][$i]);
}
}
// Send the new news to the database.
updateSettings(array('news' => implode("\n", $_POST['news'])));
// Log this into the moderation log.
logAction('news');
}
// Ready the current news.
foreach (explode("\n", $modSettings['news']) as $id => $line) {
$context['admin_current_news'][$id] = array('id' => $id, 'unparsed' => un_preparsecode($line), 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)));
}
$context['sub_template'] = 'edit_news';
$context['page_title'] = $txt['admin_edit_news'];
}