当前位置: 首页>>代码示例>>PHP>>正文


PHP preparsecode函数代码示例

本文整理汇总了PHP中preparsecode函数的典型用法代码示例。如果您正苦于以下问题:PHP preparsecode函数的具体用法?PHP preparsecode怎么用?PHP preparsecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了preparsecode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_sportal_index

 /**
  * Loads article previews for display with the portal index template
  */
 public function action_sportal_index()
 {
     global $context, $modSettings;
     // Showing articles on the index page?
     if (!empty($modSettings['sp_articles_index'])) {
         require_once SUBSDIR . '/PortalArticle.subs.php';
         $context['sub_template'] = 'portal_index';
         // Set up the pages
         $total_articles = sportal_get_articles_count();
         $total = min($total_articles, !empty($modSettings['sp_articles_index_total']) ? $modSettings['sp_articles_index_total'] : 20);
         $per_page = min($total, !empty($modSettings['sp_articles_index_per_page']) ? $modSettings['sp_articles_index_per_page'] : 5);
         $start = !empty($_REQUEST['articles']) ? (int) $_REQUEST['articles'] : 0;
         if ($total > $per_page) {
             $context['article_page_index'] = constructPageIndex($context['portal_url'] . '?articles=%1$d', $start, $total, $per_page, true);
         }
         // If we have some articles
         require_once SUBSDIR . '/PortalArticle.subs.php';
         $context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', 0, $per_page, $start);
         foreach ($context['articles'] as $article) {
             if (empty($modSettings['sp_articles_length']) && ($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
                 $article['body'] = Util::substr($article['body'], 0, $cutoff);
                 if ($article['type'] === 'bbc') {
                     require_once SUBSDIR . '/Post.subs.php';
                     preparsecode($article['body']);
                 }
             }
             $context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
             $context['articles'][$article['id']]['date'] = htmlTime($article['date']);
             // Just want a shorter look on the index page
             if (!empty($modSettings['sp_articles_length'])) {
                 $context['articles'][$article['id']]['preview'] = Util::shorten_html($context['articles'][$article['id']]['preview'], $modSettings['sp_articles_length']);
             }
         }
     }
 }
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:38,代码来源:PortalMain.controller.php

示例2: testPreparseCode

 /**
  * testPreparseCode, runs preparsecode on the bbcode
  */
 public function testPreparseCode()
 {
     foreach ($this->bbPreparse_tests as $testcase) {
         $test = $testcase[0];
         $expected = $testcase[1];
         preparsecode($test);
         $this->assertEqual($expected, $test);
     }
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:12,代码来源:TestPreparse.subs.php

示例3: saveDraft

/**
 * Save a new draft, or update an existing draft.
 */
function saveDraft()
{
    global $smcFunc, $topic, $board, $user_info, $options;
    if (!isset($_REQUEST['draft']) || $user_info['is_guest'] || empty($options['use_drafts'])) {
        return false;
    }
    $msgid = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : 0;
    // Clean up what we may or may not have
    $subject = isset($_POST['subject']) ? $_POST['subject'] : '';
    $message = isset($_POST['message']) ? $_POST['message'] : '';
    $icon = isset($_POST['icon']) ? preg_replace('~[\\./\\\\*:"\'<>]~', '', $_POST['icon']) : 'xx';
    // Sanitise what we do have
    $subject = commonAPI::htmltrim(commonAPI::htmlspecialchars($subject));
    $message = commonAPI::htmlspecialchars($message, ENT_QUOTES);
    preparsecode($message);
    if (commonAPI::htmltrim(commonAPI::htmlspecialchars($subject)) === '' && commonAPI::htmltrim(commonAPI::htmlspecialchars($_POST['message']), ENT_QUOTES) === '') {
        fatal_lang_error('empty_draft', false);
    }
    // Hrm, so is this a new draft or not?
    if (isset($_REQUEST['draft_id']) && (int) $_REQUEST['draft_id'] > 0 || $msgid) {
        $_REQUEST['draft_id'] = (int) $_REQUEST['draft_id'];
        $id_cond = $msgid ? ' 1=1 ' : ' id_draft = {int:draft} ';
        $id_sel = $msgid ? ' AND id_msg = {int:message} ' : ' AND id_board = {int:board} AND id_topic = {int:topic} ';
        // Does this draft exist?
        smf_db_query('
			UPDATE {db_prefix}drafts
			SET subject = {string:subject},
				body = {string:body},
				updated = {int:post_time},
				icon = {string:post_icon},
				smileys = {int:smileys_enabled},
				is_locked = {int:locked},
				is_sticky = {int:sticky}
			WHERE ' . $id_cond . '
				AND id_member = {int:member}
				' . $id_sel . '
			LIMIT 1', array('draft' => $_REQUEST['draft_id'], 'board' => $board, 'topic' => $topic, 'message' => $msgid, 'member' => $user_info['id'], 'subject' => $subject, 'body' => $message, 'post_time' => time(), 'post_icon' => $icon, 'smileys_enabled' => !isset($_POST['ns']) ? 1 : 0, 'locked' => !empty($_POST['lock_draft']) ? 1 : 0, 'sticky' => isset($_POST['sticky']) ? 1 : 0));
        if (smf_db_affected_rows() != 0) {
            return $_REQUEST['draft_id'];
        }
    }
    smf_db_insert('insert', '{db_prefix}drafts', array('id_board' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'id_member' => 'int', 'subject' => 'string', 'body' => 'string', 'updated' => 'int', 'icon' => 'string', 'smileys' => 'int', 'is_locked' => 'int', 'is_sticky' => 'int'), array($board, $topic, $msgid, $user_info['id'], $subject, $message, time(), $icon, !isset($_POST['ns']) ? 1 : 0, !empty($_POST['lock_draft']) ? 1 : 0, isset($_POST['sticky']) ? 1 : 0), array('id_draft'));
    return smf_db_insert_id('{db_prefix}drafts');
}
开发者ID:norv,项目名称:EosAlpha,代码行数:47,代码来源:Subs-Drafts.php

示例4: action_sportal_category

 /**
  * View a specific category, showing all articles it contains
  */
 public function action_sportal_category()
 {
     global $context, $scripturl, $modSettings;
     // Basic article support
     require_once SUBSDIR . '/PortalArticle.subs.php';
     $category_id = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
     if (is_int($category_id)) {
         $category_id = (int) $category_id;
     } else {
         $category_id = Util::htmlspecialchars($category_id, ENT_QUOTES);
     }
     $context['category'] = sportal_get_categories($category_id, true, true);
     if (empty($context['category']['id'])) {
         fatal_lang_error('error_sp_category_not_found', false);
     }
     // Set up the pages
     $total_articles = sportal_get_articles_in_cat_count($context['category']['id']);
     $per_page = min($total_articles, !empty($modSettings['sp_articles_per_page']) ? $modSettings['sp_articles_per_page'] : 10);
     $start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
     if ($total_articles > $per_page) {
         $context['page_index'] = constructPageIndex($context['category']['href'] . ';start=%1$d', $start, $total_articles, $per_page, true);
     }
     // Load the articles in this category
     $context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', $context['category']['id'], $per_page, $start);
     foreach ($context['articles'] as $article) {
         // Cut me mick
         if (($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
             $article['body'] = Util::substr($article['body'], 0, $cutoff);
             if ($article['type'] === 'bbc') {
                 require_once SUBSDIR . '/Post.subs.php';
                 preparsecode($article['body']);
             }
         }
         $context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
         $context['articles'][$article['id']]['date'] = htmlTime($article['date']);
     }
     $context['linktree'][] = array('url' => $scripturl . '?category=' . $context['category']['category_id'], 'name' => $context['category']['name']);
     $context['page_title'] = $context['category']['name'];
     $context['sub_template'] = 'view_category';
 }
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:43,代码来源:PortalCategories.controller.php

示例5: action_install


//.........这里部分代码省略.........
     } elseif (isset($package_installed['old_version']) && $package_installed['old_version'] == $packageInfo['version']) {
         $context['is_installed'] = true;
     }
     if (!isset($package_installed['old_version']) || $context['is_installed']) {
         $actions = parsePackageInfo($packageInfo['xml'], true, 'install');
     }
     $context['actions'] = array();
     $context['ftp_needed'] = false;
     $context['has_failure'] = false;
     $chmod_files = array();
     // No actions found, return so we can display an error
     if (empty($actions)) {
         return;
     }
     // This will hold data about anything that can be installed in other themes.
     $themeFinds = array('candidates' => array(), 'other_themes' => array());
     // Now prepare things for the template.
     foreach ($actions as $action) {
         // Not failed until proven otherwise.
         $failed = false;
         $thisAction = array();
         if ($action['type'] == 'chmod') {
             $chmod_files[] = $action['filename'];
             continue;
         } elseif ($action['type'] == 'readme' || $action['type'] == 'license') {
             $type = 'package_' . $action['type'];
             if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) {
                 $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8');
             } elseif (file_exists($action['filename'])) {
                 $context[$type] = htmlspecialchars(trim(file_get_contents($action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8');
             }
             if (!empty($action['parse_bbc'])) {
                 require_once SUBSDIR . '/Post.subs.php';
                 preparsecode($context[$type]);
                 $context[$type] = parse_bbc($context[$type]);
             } else {
                 $context[$type] = nl2br($context[$type]);
             }
             continue;
         } elseif ($action['type'] == 'redirect') {
             continue;
         } elseif ($action['type'] == 'error') {
             $context['has_failure'] = true;
             if (isset($action['error_msg']) && isset($action['error_var'])) {
                 $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']);
             } elseif (isset($action['error_msg'])) {
                 $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg'];
             }
         } elseif ($action['type'] == 'modification') {
             if (!file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) {
                 $context['has_failure'] = true;
                 $context['actions'][] = array('type' => $txt['execute_modification'], 'action' => Util::htmlspecialchars(strtr($action['filename'], array(BOARDDIR => '.'))), 'description' => $txt['package_action_error'], 'failed' => true);
             } else {
                 if ($action['boardmod']) {
                     $mod_actions = parseBoardMod(@file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
                 } else {
                     $mod_actions = parseModification(@file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
                 }
                 if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') {
                     $mod_actions[0]['filename'] = $action['filename'];
                 }
                 foreach ($mod_actions as $key => $mod_action) {
                     // Lets get the last section of the file name.
                     if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') {
                         $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
                     } elseif (isset($mod_action['filename']) && preg_match('~([\\w]*)/([\\w]*)\\.template\\.php$~', $mod_action['filename'], $matches)) {
开发者ID:scripple,项目名称:Elkarte,代码行数:67,代码来源:Packages.controller.php

示例6: TP_createtopic

function TP_createtopic($title, $text, $icon, $board, $sticky = 0, $submitter)
{
    global $user_info, $board_info, $sourcedir;
    require_once $sourcedir . '/Subs-Post.php';
    $body = str_replace(array("<", ">", "\n", "\t"), array("&lt;", "&gt;", "<br>", "&nbsp;"), $text);
    preparsecode($body);
    // Collect all parameters for the creation or modification of a post.
    $msgOptions = array('id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'], 'subject' => $title, 'body' => $body, 'icon' => $icon, 'smileys_enabled' => '1', 'attachments' => array());
    $topicOptions = array('id' => empty($topic) ? 0 : $topic, 'board' => $board, 'poll' => null, 'lock_mode' => null, 'sticky_mode' => $sticky, 'mark_as_read' => true);
    $posterOptions = array('id' => $submitter, 'name' => '', 'email' => '', 'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count']);
    if (createPost($msgOptions, $topicOptions, $posterOptions)) {
        $topi = $topicOptions['id'];
    } else {
        $topi = 0;
    }
    return $topi;
}
开发者ID:DiegoCortes,项目名称:TinyPortal,代码行数:17,代码来源:TPSubs.php

示例7: articleUpdates

// Add the changes for articles
articleUpdates();
// make sure TPShout is available
$request = $smcFunc['db_query']('', '
	SELECT id FROM {db_prefix}tp_modules 
	WHERE modulename = {string:name}', array('name' => 'TPShout'));
if ($smcFunc['db_num_rows']($request) > 0) {
    $row = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}tp_modules 
		SET logo = {string:logo}', array('logo' => 'tpshoutbox.png'));
} else {
    $newmod = array('version' => '1.2', 'modulename' => 'TPShout', 'title' => 'TP Simple Shout', 'subquery' => 'shout', 'autoload_run' => 'TPShout.php', 'autoload_admin' => 'TPShout.php', 'autorun' => '', 'autorun_admin' => '', 'db' => '', 'permissions' => 'tp_can_admin_shout|1', 'active' => 1, 'languages' => 'english', 'blockrender' => 'tpshout_fetch', 'adminhook' => 'tpshout_adminhook', 'logo' => 'tpshoutbox.png', 'tpversion' => '1.2', 'smfversion' => '2.0.x', 'description' => '[b]TP Simple Shoutbox[/b] is the original shoutbox from v0.9 series of TinyPortal, now converted to a TP module. It allows shout in BBC format, scrolling of shouts, insert of BBC codes and smilies and an admin interface to delete or modify shouts.<br />	', 'author' => 'IchBin', 'email' => 'ichbin@ichbin.us', 'website' => 'http://www.tinyportal.net', 'profile' => 'tpshout_profile', 'frontsection' => 'tpshout_frontpage');
    require_once $sourcedir . '/Subs-Post.php';
    preparsecode($newmod['description']);
    // ok, insert this into modules table.
    $smcFunc['db_insert']('INSERT', '{db_prefix}tp_modules', array('version' => 'string', 'modulename' => 'string', 'title' => 'string', 'subquery' => 'string', 'autoload_run' => 'string', 'autoload_admin' => 'string', 'autorun' => 'string', 'autorun_admin' => 'string', 'db' => 'string', 'permissions' => 'string', 'active' => 'int', 'languages' => 'string', 'blockrender' => 'string', 'adminhook' => 'string', 'logo' => 'string', 'tpversion' => 'string', 'smfversion' => 'string', 'description' => 'string', 'author' => 'string', 'email' => 'string', 'website' => 'string', 'profile' => 'string', 'frontsection' => 'string'), $newmod, array('id'));
}
// check if blocks access2 needs converting
if (isset($convertaccess)) {
    $request = $smcFunc['db_query']('', '
		SELECT id ,access2 FROM {db_prefix}tp_blocks WHERE 1');
    if ($smcFunc['db_num_rows']($request) > 0) {
        $new = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            unset($new);
            $new = array();
            $a = explode('|', $row['access2']);
            if (count($a) > 1) {
                foreach ($a as $b => $what) {
开发者ID:DiegoCortes,项目名称:TinyPortal,代码行数:31,代码来源:install.php

示例8: prepareMailingForPreview

/**
 * Prepare subject and message of an email for the preview box
 *
 * Used in action_mailingcompose and RetrievePreview (Xml.controller.php)
 *
 * @package Mail
 */
function prepareMailingForPreview()
{
    global $context, $modSettings, $scripturl, $user_info, $txt;
    loadLanguage('Errors');
    require_once SUBSDIR . '/Post.subs.php';
    $processing = array('preview_subject' => 'subject', 'preview_message' => 'message');
    // Use the default time format.
    $user_info['time_format'] = $modSettings['time_format'];
    $variables = array('{$board_url}', '{$current_time}', '{$latest_member.link}', '{$latest_member.id}', '{$latest_member.name}');
    $html = $context['send_html'];
    // We might need this in a bit
    $cleanLatestMember = empty($context['send_html']) || $context['send_pm'] ? un_htmlspecialchars($modSettings['latestRealName']) : $modSettings['latestRealName'];
    foreach ($processing as $key => $post) {
        $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : '';
        if (empty($context[$key]) && empty($_REQUEST['xml'])) {
            $context['post_error']['messages'][] = $txt['error_no_' . $post];
        } elseif (!empty($_REQUEST['xml'])) {
            continue;
        }
        preparsecode($context[$key]);
        // Sending as html then we convert any bbc
        if ($html) {
            $enablePostHTML = $modSettings['enablePostHTML'];
            $modSettings['enablePostHTML'] = $context['send_html'];
            $context[$key] = parse_bbc($context[$key]);
            $modSettings['enablePostHTML'] = $enablePostHTML;
        }
        // Replace in all the standard things.
        $context[$key] = str_replace($variables, array(!empty($context['send_html']) ? '<a href="' . $scripturl . '">' . $scripturl . '</a>' : $scripturl, standardTime(forum_time(), false), !empty($context['send_html']) ? '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $cleanLatestMember . '</a>' : ($context['send_pm'] ? '[url=' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . ']' . $cleanLatestMember . '[/url]' : $cleanLatestMember), $modSettings['latestMember'], $cleanLatestMember), $context[$key]);
    }
}
开发者ID:scripple,项目名称:Elkarte,代码行数:38,代码来源:Mail.subs.php

示例9: PackageInstallTest


//.........这里部分代码省略.........
                }
            }
        }
    } elseif (isset($old_version) && $old_version == $packageInfo['version']) {
        $context['is_installed'] = true;
    }
    if (!isset($old_version) || $context['is_installed']) {
        $actions = parsePackageInfo($packageInfo['xml'], true, 'install');
    }
    $context['actions'] = array();
    $context['ftp_needed'] = false;
    $context['has_failure'] = false;
    $chmod_files = array();
    if (empty($actions)) {
        return;
    }
    // This will hold data about anything that can be installed in other themes.
    $themeFinds = array('candidates' => array(), 'other_themes' => array());
    // Now prepare things for the template.
    foreach ($actions as $action) {
        // Not failed until proven otherwise.
        $failed = false;
        if ($action['type'] == 'chmod') {
            $chmod_files[] = $action['filename'];
            continue;
        } elseif ($action['type'] == 'readme') {
            if (file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'])) {
                $context['package_readme'] = htmlspecialchars(trim(file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']), "\n\r"));
            } elseif (file_exists($action['filename'])) {
                $context['package_readme'] = htmlspecialchars(trim(file_get_contents($action['filename']), "\n\r"));
            }
            if (!empty($action['parse_bbc'])) {
                require_once $sourcedir . '/lib/Subs-Post.php';
                preparsecode($context['package_readme']);
                $context['package_readme'] = parse_bbc($context['package_readme']);
            } else {
                $context['package_readme'] = nl2br($context['package_readme']);
            }
            continue;
        } elseif ($action['type'] == 'redirect') {
            continue;
        } elseif ($action['type'] == 'error') {
            $context['has_failure'] = true;
        } elseif ($action['type'] == 'modification') {
            if (!file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'])) {
                $context['has_failure'] = true;
                $context['actions'][] = array('type' => $txt['execute_modification'], 'action' => commonAPI::htmlspecialchars(strtr($action['filename'], array($boarddir => '.'))), 'description' => $txt['package_action_error'], 'failed' => true);
            }
            if ($action['boardmod']) {
                $mod_actions = parseBoardMod(@file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
            } else {
                $mod_actions = parseModification(@file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
            }
            if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') {
                $mod_actions[0]['filename'] = $action['filename'];
            }
            foreach ($mod_actions as $key => $mod_action) {
                // Lets get the last section of the file name.
                if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') {
                    $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
                } elseif (isset($mod_action['filename']) && preg_match('~([\\w]*)/([\\w]*)\\.template\\.php$~', $mod_action['filename'], $matches)) {
                    $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
                } else {
                    $actual_filename = $key;
                }
                if ($mod_action['type'] == 'opened') {
开发者ID:norv,项目名称:EosAlpha,代码行数:67,代码来源:Packages.php

示例10: action_censor

 /**
  * Shows an interface to set and test censored words.
  *
  * - It uses the censor_vulgar, censor_proper, censorWholeWord, and
  * censorIgnoreCase settings.
  * - Requires the admin_forum permission.
  * - Accessed from ?action=admin;area=postsettings;sa=censor.
  *
  * @uses the Admin template and the edit_censored sub template.
  */
 public function action_censor()
 {
     global $txt, $modSettings, $context;
     if (!empty($_POST['save_censor'])) {
         // Make sure censoring is something they can do.
         checkSession();
         validateToken('admin-censor');
         $censored_vulgar = array();
         $censored_proper = array();
         // Rip it apart, then split it into two arrays.
         if (isset($_POST['censortext'])) {
             $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
             foreach ($_POST['censortext'] as $c) {
                 list($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
             }
         } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) {
             if (is_array($_POST['censor_vulgar'])) {
                 foreach ($_POST['censor_vulgar'] as $i => $value) {
                     if (trim(strtr($value, '*', ' ')) == '') {
                         unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
                     }
                 }
                 $censored_vulgar = $_POST['censor_vulgar'];
                 $censored_proper = $_POST['censor_proper'];
             } else {
                 $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
                 $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
             }
         }
         // Set the new arrays and settings in the database.
         $updates = array('censor_vulgar' => implode("\n", $censored_vulgar), 'censor_proper' => implode("\n", $censored_proper), 'censorWholeWord' => empty($_POST['censorWholeWord']) ? '0' : '1', 'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1');
         call_integration_hook('integrate_save_censors', array(&$updates));
         updateSettings($updates);
     }
     // Testing a word to see how it will be censored?
     if (isset($_POST['censortest'])) {
         require_once SUBSDIR . '/Post.subs.php';
         $censorText = htmlspecialchars($_POST['censortest'], ENT_QUOTES, 'UTF-8');
         preparsecode($censorText);
         $pre_censor = $censorText;
         $context['censor_test'] = strtr(censorText($censorText), array('"' => '&quot;'));
     }
     // Set everything up for the template to do its thang.
     $censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
     $censor_proper = explode("\n", $modSettings['censor_proper']);
     $context['censored_words'] = array();
     for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) {
         if (empty($censor_vulgar[$i])) {
             continue;
         }
         // Skip it, it's either spaces or stars only.
         if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
             continue;
         }
         $context['censored_words'][htmlspecialchars(trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? htmlspecialchars($censor_proper[$i], ENT_COMPAT, 'UTF-8') : '';
     }
     call_integration_hook('integrate_censors');
     createToken('admin-censor');
     // Using ajax?
     if (isset($_REQUEST['xml'], $_POST['censortest'])) {
         // Clear the templates
         $template_layers = Template_Layers::getInstance();
         $template_layers->removeAll();
         // Send back a response
         loadTemplate('Json');
         $context['sub_template'] = 'send_json';
         $context['json_data'] = array('result' => true, 'censor' => $pre_censor . ' <i class="fa fa-arrow-circle-right"></i> ' . $context['censor_test'], 'token_val' => $context['admin-censor_token_var'], 'token' => $context['admin-censor_token']);
     } else {
         $context['sub_template'] = 'edit_censored';
         $context['page_title'] = $txt['admin_censored_words'];
     }
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:82,代码来源:ManagePosts.controller.php

示例11: action_editnews

    /**
     * Let the administrator(s) edit the news items for the forum.
     *
     * What it does:
     * - It writes an entry into the moderation log.
     * - This function uses the edit_news administration area.
     * - Called by ?action=admin;area=news.
     * - Requires the edit_news permission.
     * - Can be accessed with ?action=admin;sa=editnews.
     */
    public function action_editnews()
    {
        global $txt, $modSettings, $context, $scripturl;
        require_once SUBSDIR . '/Post.subs.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] = Util::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');
        }
        // We're going to want this for making our list.
        require_once SUBSDIR . '/GenericList.class.php';
        require_once SUBSDIR . '/News.subs.php';
        $context['page_title'] = $txt['admin_edit_news'];
        // Use the standard templates for showing this.
        $listOptions = array('id' => 'news_lists', 'get_items' => array('function' => 'getNews'), 'columns' => array('news' => array('header' => array('value' => $txt['admin_edit_news']), 'data' => array('function' => create_function('$news', '
							return \'<textarea class="" id="data_\' . $news[\'id\'] . \'" rows="3" name="news[]">\' . $news[\'unparsed\'] . \'</textarea>
								<br />
								<div id="preview_\' . $news[\'id\'] . \'"></div>\';
						'), 'class' => 'newsarea')), 'preview' => array('header' => array('value' => $txt['preview']), 'data' => array('function' => create_function('$news', '
							return \'<div id="box_preview_\' . $news[\'id\'] . \'">\' . $news[\'parsed\'] . \'</div>\';
						'), 'class' => 'newspreview')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$news', '
							if (is_numeric($news[\'id\']))
								return \'<input type="checkbox" name="remove[]" value="\' . $news[\'id\'] . \'" class="input_check" />\';
							else
								return \'\';
						'), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=news;sa=editnews', 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'bottom_of_list', 'class' => 'submitbutton', 'value' => '
					<input type="submit" name="save_items" value="' . $txt['save'] . '" class="right_submit" />
					<input type="submit" name="delete_selection" value="' . $txt['editnews_remove_selected'] . '" onclick="return confirm(\'' . $txt['editnews_remove_confirm'] . '\');" class="right_submit" />
					<span id="moreNewsItems_link" style="display: none;">
						<a class="linkbutton" href="javascript:void(0);" onclick="addAnotherNews(); return false;">' . $txt['editnews_clickadd'] . '</a>
					</span>')), 'javascript' => '
			document.getElementById(\'list_news_lists_last\').style.display = "none";
			document.getElementById("moreNewsItems_link").style.display = "";
			var last_preview = 0;
			var txt_preview = ' . javaScriptEscape($txt['preview']) . ';
			var txt_news_error_no_news = ' . javaScriptEscape($txt['news_error_no_news']) . ';

			$(document).ready(function () {
				$("div[id ^= \'preview_\']").each(function () {
					var preview_id = $(this).attr(\'id\').split(\'_\')[1];
					if (last_preview < preview_id)
						last_preview = preview_id;
					make_preview_btn(preview_id);
				});
			});
		');
        // Create the request list.
        createList($listOptions);
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'news_lists';
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:85,代码来源:ManageNews.controller.php

示例12: JavaScriptModify

function JavaScriptModify()
{
    global $sourcedir, $modSettings, $board, $topic, $txt;
    global $user_info, $context, $smcFunc, $language;
    // We have to have a topic!
    if (empty($topic)) {
        obExit(false);
    }
    checkSession('get');
    require_once $sourcedir . '/Subs-Post.php';
    // Assume the first message if no message ID was given.
    $request = $smcFunc['db_query']('', '
			SELECT
				t.locked, t.num_replies, t.id_member_started, t.id_first_msg,
				m.id_msg, m.id_member, m.poster_time, m.subject, m.smileys_enabled, m.body, m.icon,
				m.modified_time, m.modified_name, m.approved
			FROM {db_prefix}messages AS m
				INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
			WHERE m.id_msg = {raw:id_msg}
				AND m.id_topic = {int:current_topic}' . (allowedTo('approve_posts') ? '' : (!$modSettings['postmod_active'] ? '
				AND (m.id_member != {int:guest_id} AND m.id_member = {int:current_member})' : '
				AND (m.approved = {int:is_approved} OR (m.id_member != {int:guest_id} AND m.id_member = {int:current_member}))')), array('current_member' => $user_info['id'], 'current_topic' => $topic, 'id_msg' => empty($_REQUEST['msg']) ? 't.id_first_msg' : (int) $_REQUEST['msg'], 'is_approved' => 1, 'guest_id' => 0));
    if ($smcFunc['db_num_rows']($request) == 0) {
        fatal_lang_error('no_board', false);
    }
    $row = $smcFunc['db_fetch_assoc']($request);
    $smcFunc['db_free_result']($request);
    // Change either body or subject requires permissions to modify messages.
    if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) {
        if (!empty($row['locked'])) {
            isAllowedTo('moderate_board');
        }
        if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) {
            if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
                fatal_lang_error('modify_post_time_passed', false);
            } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
                isAllowedTo('modify_replies');
            } else {
                isAllowedTo('modify_own');
            }
        } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
            isAllowedTo('modify_replies');
        } else {
            isAllowedTo('modify_any');
        }
        // Only log this action if it wasn't your message.
        $moderationAction = $row['id_member'] != $user_info['id'];
    }
    $post_errors = array();
    if (isset($_POST['subject']) && $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) !== '') {
        $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
        // Maximum number of characters.
        if ($smcFunc['strlen']($_POST['subject']) > 100) {
            $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
        }
    } elseif (isset($_POST['subject'])) {
        $post_errors[] = 'no_subject';
        unset($_POST['subject']);
    }
    if (isset($_POST['message'])) {
        if ($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message'])) === '') {
            $post_errors[] = 'no_message';
            unset($_POST['message']);
        } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
            $post_errors[] = 'long_message';
            unset($_POST['message']);
        } else {
            $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
            preparsecode($_POST['message']);
            if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '') {
                $post_errors[] = 'no_message';
                unset($_POST['message']);
            }
        }
    }
    if (isset($_POST['lock'])) {
        if (!allowedTo(array('lock_any', 'lock_own')) || !allowedTo('lock_any') && $user_info['id'] != $row['id_member']) {
            unset($_POST['lock']);
        } elseif (!allowedTo('lock_any')) {
            if ($row['locked'] == 1) {
                unset($_POST['lock']);
            } else {
                $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
            }
        } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
            unset($_POST['lock']);
        } else {
            $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
        }
    }
    if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
        unset($_POST['sticky']);
    }
    if (empty($post_errors)) {
        $msgOptions = array('id' => $row['id_msg'], 'subject' => isset($_POST['subject']) ? $_POST['subject'] : null, 'body' => isset($_POST['message']) ? $_POST['message'] : null, 'icon' => isset($_REQUEST['icon']) ? preg_replace('~[\\./\\\\*\':"<>]~', '', $_REQUEST['icon']) : null);
        $topicOptions = array('id' => $topic, 'board' => $board, 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null, 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null, 'mark_as_read' => true);
        $posterOptions = array();
        // Only consider marking as editing if they have edited the subject, message or icon.
        if (isset($_POST['subject']) && $_POST['subject'] != $row['subject'] || isset($_POST['message']) && $_POST['message'] != $row['body'] || isset($_REQUEST['icon']) && $_REQUEST['icon'] != $row['icon']) {
            // And even then only if the time has passed...
//.........这里部分代码省略.........
开发者ID:valek0972,项目名称:hackits,代码行数:101,代码来源:Post.php

示例13: warning_preview

function warning_preview()
{
    global $context, $sourcedir, $smcFunc, $txt, $user_info, $scripturl, $mbname;
    require_once $sourcedir . '/Subs-Post.php';
    loadLanguage('Errors');
    loadLanguage('ModerationCenter');
    $user = isset($_POST['user']) ? (int) $_POST['user'] : 0;
    $context['post_error']['messages'] = array();
    if (allowedTo('issue_warning')) {
        $warning_body = !empty($_POST['body']) ? trim(censorText($_POST['body'])) : '';
        $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : '';
        if (isset($_POST['issuing'])) {
            if (empty($_POST['title']) || empty($_POST['body'])) {
                $context['post_error']['messages'][] = $txt['warning_notify_blank'];
            }
        } else {
            if (empty($_POST['title'])) {
                $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
            }
            if (empty($_POST['body'])) {
                $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
            }
            // Add in few replacements.
            /**
             * These are the defaults:
             * - {MEMBER} - Member Name. => current user for review
             * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
             * - {FORUMNAME} - Forum Name.
             * - {SCRIPTURL} - Web address of forum.
             * - {REGARDS} - Standard email sign-off.
             */
            $find = array('{MEMBER}', '{FORUMNAME}', '{SCRIPTURL}', '{REGARDS}');
            $replace = array($user_info['name'], $mbname, $scripturl, $txt['regards_team']);
            $warning_body = str_replace($find, $replace, $warning_body);
        }
        if (!empty($_POST['body'])) {
            preparsecode($warning_body);
            $warning_body = parse_bbc($warning_body, true);
        }
        $context['preview_message'] = $warning_body;
    } else {
        $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
    }
    $context['sub_template'] = 'pm';
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:45,代码来源:Xml.php

示例14: JavaScriptModify

function JavaScriptModify()
{
    global $db_prefix, $sourcedir, $modSettings, $board, $topic, $txt;
    global $user_info, $ID_MEMBER, $context, $func, $language;
    // We have to have a topic!
    if (empty($topic)) {
        obExit(false);
    }
    checkSession('get');
    require_once $sourcedir . '/Subs-Post.php';
    // Assume the first message if no message ID was given.
    $request = db_query("\n\t\t\tSELECT \n\t\t\t\tt.locked, t.numReplies, t.ID_MEMBER_STARTED, t.ID_FIRST_MSG,\n\t\t\t\tm.ID_MSG, m.ID_MEMBER, m.posterTime, m.subject, m.smileysEnabled, m.body,\n\t\t\t\tm.modifiedTime, m.modifiedName\n\t\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)\n\t\t\tWHERE m.ID_MSG = " . (empty($_REQUEST['msg']) ? 't.ID_FIRST_MSG' : (int) $_REQUEST['msg']) . "\n\t\t\t\tAND m.ID_TOPIC = {$topic}\n\t\t\t\tAND t.ID_TOPIC = {$topic}", __FILE__, __LINE__);
    if (mysql_num_rows($request) == 0) {
        fatal_lang_error('smf232', false);
    }
    $row = mysql_fetch_assoc($request);
    mysql_free_result($request);
    // Change either body or subject requires permissions to modify messages.
    if (isset($_POST['message']) || isset($_POST['subject']) || isset($_POST['icon'])) {
        if (!empty($row['locked'])) {
            isAllowedTo('moderate_board');
        }
        if ($row['ID_MEMBER'] == $ID_MEMBER && !allowedTo('modify_any')) {
            if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
                fatal_lang_error('modify_post_time_passed', false);
            } elseif ($row['ID_MEMBER_STARTED'] == $ID_MEMBER && !allowedTo('modify_own')) {
                isAllowedTo('modify_replies');
            } else {
                isAllowedTo('modify_own');
            }
        } elseif ($row['ID_MEMBER_STARTED'] == $ID_MEMBER && !allowedTo('modify_any')) {
            isAllowedTo('modify_replies');
        } else {
            isAllowedTo('modify_any');
        }
        // Only log this action if it wasn't your message.
        $moderationAction = $row['ID_MEMBER'] != $ID_MEMBER;
    }
    $post_errors = array();
    if (isset($_POST['subject']) && $func['htmltrim']($_POST['subject']) !== '') {
        $_POST['subject'] = strtr($func['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
        // Maximum number of characters.
        if ($func['strlen']($_POST['subject']) > 100) {
            $_POST['subject'] = addslashes($func['substr'](stripslashes($_POST['subject']), 0, 100));
        }
    } else {
        $post_errors[] = 'no_subject';
        unset($_POST['subject']);
    }
    if (isset($_POST['message'])) {
        if ($func['htmltrim']($_POST['message']) === '') {
            $post_errors[] = 'no_message';
            unset($_POST['message']);
        } elseif (!empty($modSettings['max_messageLength']) && $func['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
            $post_errors[] = 'long_message';
            unset($_POST['message']);
        } else {
            $_POST['message'] = $func['htmlspecialchars']($_POST['message'], ENT_QUOTES);
            preparsecode($_POST['message']);
            if ($func['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '') {
                $post_errors[] = 'no_message';
                unset($_POST['message']);
            }
        }
    }
    if (isset($_POST['lock'])) {
        if (!allowedTo(array('lock_any', 'lock_own')) || !allowedTo('lock_any') && $ID_MEMBER != $row['ID_MEMBER']) {
            unset($_POST['lock']);
        } elseif (!allowedTo('lock_any')) {
            if ($row['locked'] == 1) {
                unset($_POST['lock']);
            } else {
                $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
            }
        } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
            unset($_POST['lock']);
        } else {
            $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
        }
    }
    if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
        unset($_POST['sticky']);
    }
    if (empty($post_errors)) {
        $msgOptions = array('id' => $row['ID_MSG'], 'subject' => isset($_POST['subject']) ? $_POST['subject'] : null, 'body' => isset($_POST['message']) ? $_POST['message'] : null, 'icon' => isset($_POST['icon']) ? preg_replace('~[\\./\\\\*\':"<>]~', '', $_POST['icon']) : null);
        $topicOptions = array('id' => $topic, 'board' => $board, 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null, 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null, 'mark_as_read' => true);
        $posterOptions = array();
        // Only consider marking as editing if they have edited the subject, message or icon.
        if (isset($_POST['subject']) && $_POST['subject'] != $row['subject'] || isset($_POST['message']) && $_POST['message'] != $row['body'] || isset($_POST['icon']) && $_POST['icon'] != $row['icon']) {
            // And even then only if the time has passed...
            if (time() - $row['posterTime'] > $modSettings['edit_wait_time'] || $ID_MEMBER != $row['ID_MEMBER']) {
                $msgOptions['modify_time'] = time();
                $msgOptions['modify_name'] = addslashes($user_info['name']);
            }
        }
        modifyPost($msgOptions, $topicOptions, $posterOptions);
        // If we didn't change anything this time but had before put back the old info.
        if (!isset($msgOptions['modify_time']) && !empty($row['modifiedTime'])) {
            $msgOptions['modify_time'] = $row['modifiedTime'];
            $msgOptions['modify_name'] = $row['modifiedName'];
//.........这里部分代码省略.........
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:Post.php

示例15: Adk_formclear

function Adk_formclear($toclean)
{
    global $smcFunc, $sourcedir;
    require_once $sourcedir . '/Subs-Post.php';
    $toclean = $smcFunc['htmlspecialchars']($toclean, ENT_QUOTES);
    $toclean = $smcFunc['htmltrim']($toclean, ENT_QUOTES);
    preparsecode($toclean);
    return $toclean;
}
开发者ID:lucasruroken,项目名称:adkportal,代码行数:9,代码来源:Subs-adkfunction.php


注:本文中的preparsecode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。