本文整理匯總了PHP中IPSText::mbstrlen方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::mbstrlen方法的具體用法?PHP IPSText::mbstrlen怎麽用?PHP IPSText::mbstrlen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::mbstrlen方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getMemberNames
/**
* Returns possible matches for the string input
*
* @access private
* @return void Outputs to screen
*/
private function _getMemberNames()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$name = $this->convertAndMakeSafe(ipsRegistry::$request['name'], 0);
//-----------------------------------------
// Check length
//-----------------------------------------
if (IPSText::mbstrlen($name) < 3) {
$this->returnJsonError('requestTooShort');
}
//-----------------------------------------
// Try query...
//-----------------------------------------
$this->DB->build(array('select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id', 'from' => array('members' => 'm'), 'where' => "LOWER(m.members_display_name) LIKE '" . $this->DB->addSlashes($name) . "%'", 'order' => $this->DB->buildLength('m.members_display_name') . ' ASC', 'limit' => array(0, 15), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'))));
$this->DB->execute();
//-----------------------------------------
// Got any results?
//-----------------------------------------
if (!$this->DB->getTotalRows()) {
$this->returnJsonArray(array());
}
$return = array();
while ($r = $this->DB->fetch()) {
$photo = IPSMember::buildProfilePhoto($r);
$group = IPSLib::makeNameFormatted('', $r['member_group_id']);
$return[$r['member_id']] = array('name' => $r['members_display_name'], 'showas' => '<strong>' . $r['members_display_name'] . '</strong> (' . $group . ')', 'img' => $photo['pp_thumb_photo'], 'img_w' => $photo['pp_mini_width'], 'img_h' => $photo['pp_mini_height']);
}
$this->returnJsonArray($return);
}
示例2: _getMembers
/**
* Returns possible matches for the string input
*
* @return @e void Outputs to screen
*/
protected function _getMembers()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$name = IPSText::convertUnicode($this->convertAndMakeSafe($this->request['name'], 0), true);
$name = IPSText::convertCharsets($name, 'utf-8', IPS_DOC_CHAR_SET);
//-----------------------------------------
// Check length
//-----------------------------------------
if (IPSText::mbstrlen($name) < 3) {
$this->returnJsonError('requestTooShort');
}
//-----------------------------------------
// Try query...
//-----------------------------------------
$this->DB->build(array('select' => 'm.members_display_name, m.member_id, m.members_seo_name, m.member_group_id', 'from' => array('members' => 'm'), 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes(strtolower($name)) . "%'", 'order' => $this->DB->buildLength('m.members_display_name') . ' ASC', 'limit' => array(0, 15), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'))));
$this->DB->execute();
//-----------------------------------------
// Got any results?
//-----------------------------------------
if (!$this->DB->getTotalRows()) {
$this->returnJsonArray(array());
}
$return = array();
while ($r = $this->DB->fetch()) {
$url = $this->registry->output->buildSEOUrl("app=core&module=modcp&do=editmember&mid={$r['member_id']}", 'public');
$photo = IPSMember::buildProfilePhoto($r);
$group = IPSMember::makeNameFormatted('', $r['member_group_id']);
$return[$r['member_id']] = array('name' => $r['members_display_name'], 'showas' => '<strong>' . $r['members_display_name'] . '</strong> (' . $group . ')', 'img' => $photo['pp_thumb_photo'], 'img_w' => $photo['pp_mini_width'], 'img_h' => $photo['pp_mini_height'], 'url' => $url);
}
$this->returnJsonArray($return);
}
示例3: _buildOutput
//.........這裏部分代碼省略.........
}
}
}
//-----------------------------------------
// Some security checking
//-----------------------------------------
if (IPSText::xssCheckUrl($option) !== TRUE) {
return $content;
}
/* Check for mangled or embedded URLs */
if (stristr($option, '[attachment') or stristr($option, '[quote') or stristr($option, '[url') or stristr($option, '[/url') or stristr($content, '[url') or stristr($content, '[/url')) {
return $content;
}
//-----------------------------------------
// Fix quotes in urls
//-----------------------------------------
$option = str_replace(array(''', "'"), '%27', $option);
$option = str_replace(array('"', '"'), '%22', $option);
foreach ($this->cache->getCache('bbcode') as $bbcode) {
$_tags = $this->_retrieveTags();
foreach ($_tags as $tag) {
if (strpos($option, '[' . $tag) !== false) {
return $content;
}
}
}
//-----------------------------------------
// URL filtering?
//-----------------------------------------
if ($this->settings['ipb_use_url_filter']) {
$list_type = $this->settings['ipb_url_filter_option'] == "black" ? "blacklist" : "whitelist";
if ($this->settings['ipb_url_' . $list_type]) {
$list_values = array();
$list_values = explode("\n", str_replace("\r", "", $this->settings['ipb_url_' . $list_type]));
if ($list_type == "whitelist") {
$list_values[] = "http://{$_SERVER['HTTP_HOST']}/*";
}
if (count($list_values)) {
$good_url = 0;
foreach ($list_values as $my_url) {
if (!trim($my_url)) {
continue;
}
$my_url = preg_quote($my_url, '/');
$my_url = str_replace('\\*', "(.*?)", $my_url);
if ($list_type == "blacklist") {
if (preg_match('/' . $my_url . '/i', $option)) {
$this->warning = 'domain_not_allowed';
return $content;
}
} else {
if (preg_match('/' . $my_url . '/i', $option)) {
$good_url = 1;
}
}
}
if (!$good_url and $list_type == "whitelist") {
$this->warning = 'domain_not_allowed';
return $content;
}
}
}
}
//-----------------------------------------
// Let's remove any nested links..
//-----------------------------------------
$content = preg_replace('/<a href=\'(.+?)\'(.*?)>(.+?)<\\/a>/is', "\\3", $content);
//-----------------------------------------
// Need to "truncate" the "content" to ~35
// EDIT: but only if it's the same as content
//-----------------------------------------
/* Changes here @link http://community.invisionpower.com/tracker/issue-36082-long-links-on-mobile-extend-width/ */
if (empty($this->settings['__noTruncateUrl']) and IPSText::mbstrlen($content) > 38 and (substr($content, 0, 7) == 'http://' or substr($content, 0, 8) == 'https://')) {
$content = htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($content)), 0, 20)) . '...' . htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($content)), -15));
}
//-----------------------------------------
// Adding rel='nofollow'?
//-----------------------------------------
$rels = array();
$rel = '';
$_title = '';
/* Fetch actual host for better matching */
$data = @parse_url($option);
if ($this->settings['posts_add_nofollow']) {
if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
$rels[] = "nofollow";
}
}
if ($this->settings['links_external']) {
if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
/* Look a little closer */
$rels[] = "external";
$_title = $this->lang->words['bbc_external_link'];
}
}
if (count($rels)) {
$rel = " rel='" . implode(' ', $rels) . "'";
}
return "<a href='{$option}' class='bbc_url' title='{$_title}'{$rel}>{$content}</a>";
}
示例4: updateStatusWithUrl
/**
* Post a status update to twitter based on native content
* Which may be longer and such and so on and so forth, etc
*
* @access public
* @param string Content
* @param string URL to add
* @param bool Always add the URL regardless of content length
* @param bool Add a hashtag
*/
public function updateStatusWithUrl($content, $url, $alwaysAdd = TRUE, $hashtag = '')
{
if (is_string($hashtag) && !empty($hashtag)) {
if (substr($hashtag, 0, 1) != '#') {
$hashtag = '#' . $hashtag;
}
$hashtag = ' ' . $hashtag;
} else {
if (!is_string($hashtag)) {
$hashtag = '';
}
}
/* Ensure content is correctly de-html-ized */
$content = IPSText::UNhtmlspecialchars($content);
/* Is the text longer than 140 chars? */
if ($alwaysAdd === TRUE or IPSText::mbstrlen($content) > 140) {
/* Leave 26 chars for URL shortener */
$less = 26 + strlen($hashtag);
if (IPSText::mbstrlen($content) > 140 - $less) {
$content = IPSText::mbsubstr($content, 0, 140 - ($less + 3)) . '...' . $hashtag;
}
if (IPSText::mbstrlen($url) > 26) {
/* Generate short URL */
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/url/shorten.php', 'urlShorten');
$shorten = new $classToLoad();
try {
$data = $shorten->shorten($url, IPS_URL_SHORTEN_SERVICE);
$url = $data['url'];
} catch (Exception $ex) {
/* Stop the exception bubbling back to parent classes */
}
}
return $this->updateStatus($content . ' ' . $url);
} else {
/* Just post it */
return $this->updateStatus($content);
}
}
示例5: _cleanTags
/**
* Cleans incoming tags
* @param String or Array Comma delim string or array of tags
* @param Bool If TRUE, will check minimum and maximum amounts of tags - not necessary for searching
* @return Array Array of cleaned tags
*/
private function _cleanTags($tags, $checkForMinimumAndMaximum = TRUE)
{
/* Sort out tags */
if (!is_array($tags)) {
if (strstr($tags, ',')) {
$_tags = explode(',', IPSText::cleanPermString($tags));
$tags = array();
foreach ($_tags as $t) {
if ($t) {
$tags[] = $this->_stripHtml(trim($this->_forceLower() ? IPSText::mbstrtolower($t) : $t));
}
}
} else {
if (!strlen($tags)) {
return false;
}
$tags = array($this->_stripHtml($this->_forceLower() ? IPSText::mbstrtolower($tags) : $tags));
}
}
/* So.. got tags to parse? */
if (count($tags)) {
/* Make sure they are all unique */
$tags = array_unique($tags);
/* Check for min/max string length */
if ($checkForMinimumAndMaximum and ($this->_getMaxLen() or $this->_getMinLen())) {
$_tags = $tags;
$tags = array();
foreach ($_tags as $tag) {
if ($this->_getMaxLen()) {
if (IPSText::mbstrlen($tag) > $this->_getMaxLen()) {
continue;
}
}
if ($this->_getMinLen()) {
if (IPSText::mbstrlen($tag) < $this->_getMinLen()) {
continue;
}
}
$tags[] = $tag;
}
}
/* removes any bad words */
$badwords = $this->cache->getCache('badwords');
if ($this->_mustCleanWords() and is_array($badwords) && count($badwords)) {
$_tags = $tags;
$tags = array();
foreach ($_tags as $tag) {
$_bad = false;
foreach ($badwords as $badword) {
if (strtolower($tag) == strtolower($badword['type'])) {
$_bad = true;
break;
}
}
if (!$_bad) {
$tags[] = $tag;
}
}
}
}
/* Now, do we have a sufficient number of tags? */
if ($checkForMinimumAndMaximum && $this->_getMaxTags() && count($tags) > $this->_getMaxTags()) {
$this->setErrorMsg('too_many_tags');
return false;
}
/* Perhaps not enough? */
if ($checkForMinimumAndMaximum && $this->_getMinTags() && count($tags) < $this->_getMinTags()) {
$this->setErrorMsg('too_few_tags');
return false;
}
/* Generic catch all in case min/max tags aren't set up. */
if (!count($tags)) {
$this->setErrorMsg('no_good_tags');
return false;
}
/* Phew. */
return $tags;
}
示例6: _sendNewPersonalTopic
/**
* Sends the PM
*
* @access private
* @return void, or HTML form
*/
private function _sendNewPersonalTopic()
{
//-----------------------------------------
// INIT
//-----------------------------------------
if ($this->messengerFunctions->checkHasHitMax()) {
$this->registry->getClass('output')->showError('maxperday_hit', 10272);
}
$msgTitle = IPSText::getTextClass('bbcode')->stripBadWords(trim(IPSText::parseCleanValue($_POST['msg_title'])));
$authKey = $this->request['auth_key'];
$sendToName = $this->request['entered_name'];
$sendToID = intval($this->request['toMemberID']);
$sendType = trim($this->request['sendType']);
$_inviteUsers = trim($this->request['inviteUsers']);
$msgContent = $_POST['Post'];
$topicID = $this->request['topicID'];
$inviteUsers = array();
$draft = $this->request['save'] ? TRUE : FALSE;
//-----------------------------------------
// Error checking
//-----------------------------------------
if (IPSText::mbstrlen(trim($msgTitle)) < 2) {
return $this->_showNewTopicForm($this->lang->words['err_no_title']);
}
if (IPSText::mbstrlen(trim(IPSText::br2nl($_POST['Post']))) < 3) {
return $this->_showNewTopicForm($this->lang->words['err_no_msg']);
}
if ($this->request['auth_key'] != $this->member->form_hash) {
$this->registry->getClass('output')->_showNewTopicForm('messenger_bad_key', 2024);
}
if ($sendToID and $sendToName == "") {
return $this->_showNewTopicForm($this->lang->words['err_no_chosen_member']);
}
//-----------------------------------------
// Invite Users
//-----------------------------------------
if ($this->memberData['g_max_mass_pm'] and $_inviteUsers) {
$_tmp = array();
foreach (explode(',', $_inviteUsers) as $name) {
$name = trim($name);
if ($name) {
$inviteUsers[] = $name;
}
}
}
//-----------------------------------------
// Grab member ID
//-----------------------------------------
$toMember = $sendToID ? IPSMember::load($sendToID, 'core') : IPSMember::load($sendToName, 'core', 'displayname');
if (!$toMember['member_id']) {
return $this->_showNewTopicForm($this->lang->words['err_no_chosen_member']);
}
//-----------------------------------------
// Send .. or.. save...
//-----------------------------------------
try {
$this->messengerFunctions->sendNewPersonalTopic($toMember['member_id'], $this->memberData['member_id'], $inviteUsers, $msgTitle, $msgContent, array('isDraft' => $draft, 'topicID' => $topicID, 'sendMode' => $sendType, 'postKey' => $this->_postKey));
} catch (Exception $error) {
$msg = $error->getMessage();
if (strstr($msg, 'BBCODE_')) {
$msg = str_replace('BBCODE_', '', $msg);
return $this->_showNewTopicForm($this->lang->words[$msg]);
} else {
if (isset($this->lang->words['err_' . $msg])) {
$_msgString = $this->lang->words['err_' . $msg];
$_msgString = str_replace('#NAMES#', implode(",", $this->messengerFunctions->exceptionData), $_msgString);
$_msgString = str_replace('#TONAME#', $toMember['members_display_name'], $_msgString);
$_msgString = str_replace('#FROMNAME#', $this->memberData['members_display_name'], $_msgString);
$_msgString = str_replace('#DATE#', $this->messengerFunctions->exceptionData[0], $_msgString);
} else {
$_msgString = $this->lang->words['err_UNKNOWN'] . ' ' . $msg;
}
}
return $this->_showNewTopicForm($_msgString);
}
//-----------------------------------------
// Swap and serve...
//-----------------------------------------
if ($draft !== TRUE) {
$text = str_replace("<#FROM_MEMBER#>", $this->memberData['members_display_name'], $this->lang->words['sent_text']);
$text = str_replace("<#MESSAGE_TITLE#>", $msgTitle, $text);
} else {
$text = "Your message has been saved as a draft";
}
$this->registry->getClass('output')->redirectScreen($text, $this->settings['base_url'] . 'app=members&module=messaging&section=view&do=inbox');
}
示例7: _writeToLog
/**
* Write to the admin log in loggy ma log
*
* @param string Username
* @param string ok/fail flag
* @return @e void
* @note This is private so that a hacker couldn't get into ACP, upload a new hook that lets them clear the log, and then clear the login log
*/
private function _writeToLog($username = '', $flag = 'fail')
{
//-----------------------------------------
// INIT
//-----------------------------------------
$username = $username ? $username : $this->request['username'];
$flag = $flag == 'ok' ? 1 : 0;
$admin_post_details = array();
//-----------------------------------------
// Generate POST / GET details
//-----------------------------------------
foreach ($_GET as $k => $v) {
$admin_post_details['get'][$k] = $v;
}
foreach ($_POST as $k => $v) {
if ($k == 'password' and IPSText::mbstrlen($v) > 1) {
$v = $v ? (IPSText::mbstrlen($v) - 1 > 0 ? str_repeat('*', IPSText::mbstrlen($v) - 1) : '') . substr($v, -1, 1) : '';
}
$admin_post_details['post'][$k] = $v;
}
//-----------------------------------------
// Write to disk...
//-----------------------------------------
$this->DB->insert('admin_login_logs', array('admin_ip_address' => $this->member->ip_address, 'admin_username' => $username, 'admin_time' => time(), 'admin_success' => $flag, 'admin_post_details' => serialize($admin_post_details)));
}
示例8: _finishUrlsForDisplay
/**
* Finish URLs for display
* Truncates them, applies white/black lists, adds rel / targets
* @param string In
* @return string Out
*/
protected function _finishUrlsForDisplay($txt)
{
/* If HTML mode, don't clean links */
if (parent::$Perms['parseHtml']) {
return $txt;
}
/* Reset counter */
$this->cache->updateCacheWithoutSaving('_tmp_bbcode_media', 0);
/* Parse media URLs that are NOT linked */
$txt = preg_replace_callback('#(^|\\s|\\)|\\(|\\{|\\}|>|\\]|\\[|;|href=\\S)((http|https|news|ftp)://(?:[^<>\\)\\[\\"\\s]+|[a-zA-Z0-9/\\._\\-!&\\#;,%\\+\\?:=]+))(</a>)?#is', array($this, '_parseMediaUrls_CallBack'), $txt);
/* LEGACY stuffs - a post from < 3.4 may not be HTMLised properly */
if ($this->_urlsEnabled === true && preg_match('#(http|https)://#', $txt) && !stristr($txt, '<a')) {
$txt = $this->_autoLinkUrls($txt);
}
preg_match_all('#<a\\s+?(?:[^>]*?)href=["\']([^"\']+?)?["\']([^>]*?)?>(.+?)</a>#is', $txt, $urlMatches);
/* Finish up URLs and such */
for ($i = 0; $i < count($urlMatches[0]); $i++) {
$raw = $urlMatches[0][$i];
$url = $urlMatches[1][$i];
$attr = $urlMatches[2][$i];
$text = $urlMatches[3][$i];
$done = false;
$pm = true;
preg_match('#data-ipb=["\']([^"\']+?)?["\']#i', $raw, $matches);
if ($matches[1] && stristr($matches[1], 'noparse')) {
continue;
} else {
if ($matches[1] && stristr($matches[1], 'nomediaparse')) {
$pm = false;
}
}
preg_match('#rel=["\']([^"\']+?)?["\']#i', $raw, $matches);
if ($matches[1] && stristr($matches[1], 'lightbox')) {
continue;
}
/* Urls disabled? */
if ($this->_urlsEnabled !== true) {
$txt = str_replace($raw, $url, $txt);
continue;
}
/* Restored 1st March, Matt @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/some-previously-embedded-content-youtube-etc-now-showing-as-links-after-upgrade-r41411 */
/* Is this a media URL? */
/* Updated 14 May, http://community.invisionpower.com/resources/bugs.html/_/ip-board/url-tags-get-changed-to-media-tags-automatically-r40467 -
Editor now sets "noparsemedia" data-ipb attribute, which we can skip here for automatic parsing */
if ($pm and $this->settings['bbcode_automatic_media'] and isset($this->_bbcodes['media']) and ($this->_bbcodes['media']['bbcode_sections'] == 'all' or in_array(parent::$Perms['parseArea'], explode(',', $this->_bbcodes['media']['bbcode_sections'])))) {
$media = $this->cache->getCache('mediatag');
if ($url == $text && is_array($media) and count($media)) {
foreach ($media as $type => $r) {
if (preg_match("#^" . $r['match'] . "\$#is", $url)) {
$this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 1);
$_result = $this->_parseBBCode('[media]' . $url . '[/media]', 'display', array('media'));
$this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 0);
$txt = str_replace($raw, $_result, $txt);
$done = true;
}
}
}
}
/* Format the URL */
if ($done !== true) {
// -----------------------------------------
// URL filtering?
// -----------------------------------------
if (!$this->isAllowedUrl($url)) {
/* Unlink */
$txt = str_replace($raw, $url, $txt);
}
// -----------------------------------------
// Let's remove any nested links..
// -----------------------------------------
$text = preg_replace('/<a href=[\'"](.+?)[\'"](.*?)>(.+?)<\\/a>/is', "\\3", $text);
// -----------------------------------------
// Need to "truncate" the "content" to ~35
// EDIT: but only if it's the same as content
// -----------------------------------------
/*
* Changes here @link
* http://community.invisionpower.com/tracker/issue-36082-long-links-on-mobile-extend-width/ # V V Don't split if URL has entities V V #
*/
if (empty($this->settings['__noTruncateUrl']) and IPSText::mbstrlen($text) > 38 && !preg_match('#&\\#([0-9]{2,4})#i', $text) and (substr($text, 0, 7) == 'http://' or substr($text, 0, 8) == 'https://')) {
$text = htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($text)), 0, 20)) . '...' . htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($text)), -15));
}
// -----------------------------------------
// Adding rel='nofollow'?
// -----------------------------------------
$rels = array();
$rel = '';
$_title = '';
/* Skipping VigLink? */
if ($this->settings['viglink_norewrite'] and IPSMember::isInGroup(parent::$Perms['memberData'], explode(',', $this->settings['viglink_norewrite']))) {
$rels[] = 'norewrite';
}
/* Fetch actual host for better matching */
$data = @parse_url($url);
//.........這裏部分代碼省略.........
示例9: formatSearchTerm
/**
* Formats search term for SQL
*
* @access private
* @param string Raw IPB santized form input
* @return array array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
*/
public function formatSearchTerm($search_term)
{
$isBoolean = $this->isBoolean();
$andor = isset($this->request['andor_type']) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
$removedTerms = array();
/* Fix up some sanitized HTML */
$search_term = str_replace("&", '&', IPSText::parseCleanValue(rawurldecode($search_term)));
$search_term = str_replace(""", '"', $search_term);
$search_term = IPSText::mbstrtolower($search_term);
/* Check for disallowed search terms */
while (preg_match_all('/(?:^|\\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\\s+|$)/', $search_term, $removed_search_terms)) {
$removedTerms[] = $removed_search_terms[0][0];
$search_term = preg_replace('/(^|\\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\\s+|$)/', str_replace(" ", " ", "\$1\$2"), $search_term);
}
/* remove < min char words */
if (substr_count($search_term, '"') != 2) {
$_words = explode(' ', $search_term);
$search_term = '';
foreach ($_words as $_w) {
if (IPSText::mbstrlen($_w) >= $this->settings['min_search_word']) {
$search_term .= $_w . ' ';
} else {
if ($_w) {
$removedTerms[] = $_w;
}
}
}
}
/* Remove some formatting */
//$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
// | is an OR operator for sphinx - don't want to block globally
if ($search_term) {
$search_term = str_replace(array('\\', '/'), '', trim($search_term));
/* Sphinx chars are not allowed */
$search_term = str_replace(array('.', ')', '(', '!', '@', '[', ']', '~', '^'), '', $search_term);
$search_term = preg_replace('#(?!\\s)-#', '\\1‐', $search_term);
if ($andor == 'and' and !(substr_count($search_term, '"') == 2)) {
$search_term = '+' . preg_replace('/\\s+(?!-|~)/', " +", $search_term);
}
}
return array('search_term' => $search_term, 'removed' => $removedTerms);
}
示例10: editPost
/**
* Edit a post
*
* Usage:
* $post->setForumID(1);
* $post->setTopicID(5);
* $post->setPostID(100);
* $post->setAuthor( $member );
*
* $post->setPostContent( "Hello [b]there![/b]" );
* # Optional: No bbcode, etc parsing will take place
* # $post->setPostContentPreFormatted( "Hello <b>there!</b>" );
* $post->editPost();
*
* Exception Error Codes:
* NO_POSTING_PPD : No post ID set
* NO_CONTENT : No post content set
* CONTENT_TOO_LONG : Post is too long
*
* @return mixed
*/
public function editPost()
{
//-----------------------------------------
// Global checks and functions
//-----------------------------------------
try {
$this->globalSetUp();
} catch (Exception $error) {
$e = $error->getMessage();
if ($e != 'NO_POSTING_PPD') {
$this->_postErrors = $error->getMessage();
}
}
if ($this->_bypassPermChecks !== TRUE && IPSMember::isOnModQueue($this->getAuthor()) === NULL) {
$this->_postErrors = 'warnings_restrict_post_perm';
}
if (!$this->getPostContent() and !$this->getPostContentPreFormatted()) {
$this->_postErrors = 'NO_CONTENT';
}
//-----------------------------------------
// Get topic
//-----------------------------------------
try {
$topic = $this->editSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
//-----------------------------------------
// Parse the post, and check for any errors.
//-----------------------------------------
$post = $this->compilePostData();
//-----------------------------------------
// Do we have a valid post?
//-----------------------------------------
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
$this->_postErrors = 'NO_CONTENT';
}
if (IPSText::mbstrlen($post['post']) > $this->settings['max_post_length'] * 1024) {
$this->_postErrors = 'CONTENT_TOO_LONG';
}
if ($this->_postErrors != "") {
//-----------------------------------------
// Show the form again
//-----------------------------------------
return FALSE;
}
//-----------------------------------------
// Ajax specifics
//-----------------------------------------
if ($this->getIsAjax() === TRUE) {
# Prevent polls from being edited
$this->can_add_poll = 0;
# Prevent titles from being edited
$this->edit_title = 0;
# Prevent open time from being edited
$this->can_set_open_time = 0;
# Prevent close time from being edited
$this->can_set_close_time = 0;
# Set Settings
$this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'] ? 1 : 0, 'enableEmoticons' => $this->_originalPost['use_emo'] ? 1 : 0, 'post_htmlstatus' => $this->getSettings('post_htmlstatus')));
if (!$this->getAuthor('g_append_edit')) {
$this->request['add_edit'] = ($this->_originalPost['append_edit'] or !$this->getAuthor('g_append_edit') ? 1 : 0);
}
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
if ($this->can_add_poll) {
//-----------------------------------------
// Load the poll from the DB
//-----------------------------------------
$this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . intval($topic['tid'])));
$this->poll_answers = !empty($this->poll_data['choices']) && IPSLib::isSerialized($this->poll_data['choices']) ? IPSLib::safeUnserialize(stripslashes($this->poll_data['choices'])) : array();
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
$this->poll_questions = $this->compilePollData();
if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) {
//.........這裏部分代碼省略.........
示例11: _saveGroup
/**
* Save the group [add/edit]
*
* @param string 'add' or 'edit'
* @return @e void [Outputs to screen]
*/
protected function _saveGroup($type = 'edit')
{
//-----------------------------------------
// INIT
//-----------------------------------------
$group_id = intval($this->request['id']);
$oldGroup = $this->caches['group_cache'][$group_id];
//-----------------------------------------
// Auth check...
//-----------------------------------------
ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
//-----------------------------------------
// Check...
//-----------------------------------------
if (!$this->request['g_title']) {
$this->registry->output->showError($this->lang->words['g_title_error'], 1127);
}
if (intval($this->request['g_max_mass_pm']) > 500) {
$this->registry->output->showError($this->lang->words['g_mass_pm_too_large'], 1127);
}
#MSSQL needs a check on this
if (IPSText::mbstrlen($this->request['g_title']) > 32) {
$this->registry->output->showError($this->lang->words['g_title_error'], 1127);
}
if ($type == 'edit') {
if (!$group_id) {
$this->registry->output->showError($this->lang->words['g_whichgroup'], 1128);
}
//-----------------------------------------
// Check restrictions.
//-----------------------------------------
if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_edit_admin');
}
}
//-----------------------------------------
// Check restrictions.
//-----------------------------------------
if (($type == 'add' or !$this->caches['group_cache'][$group_id]['g_access_cp']) and $this->request['g_access_cp']) {
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_add_admin');
}
//-----------------------------------------
// Sort out the perm mask id things
//-----------------------------------------
$new_perm_set_id = 0;
if ($this->request['g_new_perm_set']) {
$this->DB->insert('forum_perms', array('perm_name' => $this->request['g_new_perm_set']));
$new_perm_set_id = $this->DB->getInsertId();
} else {
if (!is_array($this->request['permid'])) {
$this->registry->output->showError($this->lang->words['g_oneperm'], 1129);
}
}
$this->lang->loadLanguageFile(array('admin_permissions'), 'members');
//-----------------------------------------
// Some other generic fields
//-----------------------------------------
$promotion_a = '-1';
// id
$promotion_b = '-1';
// posts
if ($this->request['g_promotion_id'] and $this->request['g_promotion_id'] > 0) {
$promotion_a = $this->request['g_promotion_id'];
$promotion_b = $this->request['g_promotion_posts'];
}
if ($this->request['g_attach_per_post'] and $this->request['g_attach_max'] > 0) {
if ($this->request['g_attach_per_post'] > $this->request['g_attach_max']) {
$this->registry->output->global_message = $this->lang->words['g_pergreater'];
$this->_groupForm('edit');
return;
}
}
$this->request['p_max'] = str_replace(":", "", $this->request['p_max']);
$this->request['p_width'] = str_replace(":", "", $this->request['p_width']);
$this->request['p_height'] = str_replace(":", "", $this->request['p_height']);
$this->request['g_attach_max'] = intval($this->request['g_attach_max']);
$this->request['g_attach_per_post'] = intval($this->request['g_attach_per_post']);
$this->request['p_max'] = intval($this->request['p_max']);
$sig_limits = array($this->request['use_signatures'], $this->request['max_images'], $this->request['max_dims_x'], $this->request['max_dims_y'], $this->request['max_urls'], $this->request['max_lines']);
//-----------------------------------------
// Set the db array
//-----------------------------------------
$db_string = array('g_view_board' => intval($this->request['g_view_board']), 'g_mem_info' => intval($this->request['g_mem_info']), 'g_can_add_friends' => intval($this->request['g_can_add_friends']), 'g_use_search' => intval($this->request['g_use_search']), 'g_edit_profile' => intval($this->request['g_edit_profile']), 'g_use_pm' => intval($this->request['g_use_pm']), 'g_pm_perday' => intval($this->request['g_pm_perday']), 'g_is_supmod' => intval($this->request['g_is_supmod']), 'g_access_cp' => intval($this->request['g_access_cp']), 'g_title' => trim($this->request['g_title']), 'g_access_offline' => intval($this->request['g_access_offline']), 'g_dname_changes' => intval($this->request['g_dname_changes']), 'g_dname_date' => intval($this->request['g_dname_date']), 'prefix' => trim(IPSText::safeslashes($_POST['prefix'])), 'suffix' => trim(IPSText::safeslashes($_POST['suffix'])), 'g_hide_from_list' => intval($this->request['g_hide_from_list']), 'g_perm_id' => $new_perm_set_id ? $new_perm_set_id : implode(",", $this->request['permid']), 'g_icon' => trim(IPSText::safeslashes($_POST['g_icon'])), 'g_attach_max' => $this->request['g_attach_max'] == '' ? 0 : intval($this->request['g_attach_max']), 'g_max_messages' => intval($this->request['g_max_messages']), 'g_max_mass_pm' => intval($this->request['g_max_mass_pm']), 'g_pm_flood_mins' => intval($this->request['g_pm_flood_mins']), 'g_search_flood' => intval($this->request['g_search_flood']), 'g_promotion' => $promotion_a . '&' . $promotion_b, 'g_photo_max_vars' => $this->request['p_max'] . ':' . $this->request['p_width'] . ':' . $this->request['p_height'], 'g_dohtml' => intval($this->request['g_dohtml']), 'g_bypass_badwords' => intval($this->request['g_bypass_badwords']), 'g_can_msg_attach' => intval($this->request['g_can_msg_attach']), 'g_attach_per_post' => intval($this->request['g_attach_per_post']), 'g_rep_max_positive' => intval($this->request['g_rep_max_positive']), 'g_rep_max_negative' => intval($this->request['g_rep_max_negative']), 'g_signature_limits' => implode(':', $sig_limits), 'g_hide_online_list' => intval($this->request['g_hide_online_list']), 'g_displayname_unit' => intval($this->request['g_displayname_unit']), 'g_sig_unit' => intval($this->request['g_sig_unit']), 'g_max_notifications' => intval($this->request['g_max_notifications']), 'g_max_bgimg_upload' => intval($this->request['g_max_bgimg_upload']), 'g_bitoptions' => IPSBWOPtions::freeze($this->request, 'groups', 'global'));
$this->DB->setDataType('g_title', 'string');
//-----------------------------------------
// Ok? Load interface and child classes
//-----------------------------------------
IPSLib::loadInterface('admin/group_form.php');
$_groupPlugins = array();
foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php')) {
$_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php', 'admin_group_form__' . $app_dir, $app_dir);
$_groupPlugins[$_class] = new $_class($this->registry);
$remote = $_groupPlugins[$_class]->getForSave();
//.........這裏部分代碼省略.........
示例12: save
/**
* Save member
*
* @param int Member key: Either Array, ID or email address. If it's an array, it must be in the format:
* array( 'core' => array( 'field' => 'member_id', 'value' => 1 ) ) - useful for passing custom fields through
* @param array Fields to save in the following format: array( 'members' => array( 'email' => 'test@test.com',
* 'joined' => time() ),
* 'extendedProfile' => array( 'signature' => 'My signature' ) );
* Tables: members, pfields_content, profile_portal.
* You can also use the aliases: 'core [members]', 'extendedProfile [profile_portal]', and 'customFields [pfields_content]'
* @return boolean True if the save was successful
*
* Exception Error Codes:
* NO_DATA : No data to save
* NO_VALID_KEY : No valid key to save
* NO_AUTO_LOAD : Could not autoload the member as she does not exist
* INCORRECT_TABLE : Table one is attempting to save to does not exist
* NO_MEMBER_GROUP_ID: Member group ID is in the array but blank
*/
public static function save($member_key, $save = array())
{
$member_id = 0;
$member_email = '';
$member_field = '';
$_updated = 0;
$bitWiseFields = ipsRegistry::fetchBitWiseOptions('global');
$member_k_array = array('members' => array(), 'pfields_content' => array(), 'profile_portal' => array());
$_tables = array_keys($save);
$_MEMBERKEY = 'member_id';
$_MEMBERVALUE = $member_key;
//-----------------------------------------
// Test...
//-----------------------------------------
if (!is_array($save) or !count($save)) {
throw new Exception('NO_DATA');
}
//-----------------------------------------
// ID or email?
//-----------------------------------------
if (!is_array($member_key)) {
if (strstr($member_key, '@')) {
$_MEMBERKEY = 'email';
if (IPSText::mbstrlen($member_key) > 150) {
throw new Exception('NO_VALID_KEY');
}
$member_k_array['members'] = array('field' => 'email', 'value' => "'" . ipsRegistry::instance()->DB()->addSlashes(strtolower($member_key)) . "'");
//-----------------------------------------
// Check to see if we've got more than the core
// table to save on.
//-----------------------------------------
$_got_more_than_core = FALSE;
foreach ($_tables as $table) {
if (isset(self::$remap[$table])) {
$table = self::$remap[$table];
}
if ($table != 'members') {
$_got_more_than_core = TRUE;
break;
}
}
if ($_got_more_than_core === TRUE) {
/* Get the ID */
$_memberTmp = self::load($member_key, 'core');
if ($_memberTmp['member_id']) {
$member_k_array['pfields_content'] = array('field' => 'member_id', 'value' => $_memberTmp['member_id']);
$member_k_array['profile_portal'] = array('field' => 'pp_member_id', 'value' => $_memberTmp['member_id']);
} else {
throw new Exception("NO_AUTO_LOAD");
}
}
} else {
$member_k_array['members'] = array('field' => 'member_id', 'value' => intval($member_key));
$member_k_array['pfields_content'] = array('field' => 'member_id', 'value' => intval($member_key));
$member_k_array['profile_portal'] = array('field' => 'pp_member_id', 'value' => intval($member_key));
self::_updateCache($member_key, $save);
}
} else {
$_member_k_array = $member_k_array;
foreach ($member_key as $table => $data) {
if (isset(self::$remap[$table])) {
$table = self::$remap[$table];
}
if (!in_array($table, array_keys($_member_k_array))) {
throw new Exception('INCORRECT_TABLE');
}
$member_k_array[$table] = $data;
}
}
//-----------------------------------------
// Test...
//-----------------------------------------
if (!is_array($member_k_array) or !count($member_k_array)) {
throw new Exception('NO_DATA');
}
//-----------------------------------------
// Now save...
//-----------------------------------------
foreach ($save as $table => $data) {
if (isset(self::$remap[$table])) {
$table = self::$remap[$table];
//.........這裏部分代碼省略.........
示例13: sqlViewResults
//.........這裏部分代碼省略.........
if (preg_match("#^SELECT(?:.*)\\s+?FROM\\s+?(\\S+?)(;?)(?:\\s|\$)#i", $sql['sql'], $match)) {
$the_queries[$key]['tableName'] = $match[1];
}
/* Check the sql */
$test_sql = str_replace("\\'", "", $sql['sql']);
$apos_count = substr_count($test_sql, "'");
if ($apos_count % 2 != 0) {
$columns[$queryCntForArray][] = $this->lang->words['manual_error'];
$rows[$queryCntForArray][] = array('error' => $this->lang->words['manual_invalid'] . htmlspecialchars($sql['sql']));
unset($apos_count, $test_sql);
continue;
}
unset($apos_count, $test_sql);
/* Check for drop and flush */
if (preg_match("/^(DROP|FLUSH)/i", $sql['sql'])) {
$columns[$queryCntForArray][] = $this->lang->words['manual_error'];
$rows[$queryCntForArray][] = array('error' => $this->lang->words['manual_notallowed']);
continue;
} else {
if (preg_match("/^(?!SELECT)/i", preg_replace("#\\s{1,}#s", "", $sql['sql'])) and preg_match("/admin_login_logs/i", preg_replace("#\\s{1,}#s", "", $sql['sql'])) || preg_match("/admin_permission_rows/i", preg_replace("#\\s{1,}#s", "", $sql['sql']))) {
$columns[$queryCntForArray][] = $this->lang->words['manual_error'];
$rows[$queryCntForArray][] = array('error' => $this->lang->words['manual_loginlogs']);
continue;
}
}
/* Setup for query */
$this->DB->error = "";
$this->DB->allow_sub_select = 1;
/* Run the query */
$this->DB->query($sql['sql'], 1);
/* Check for errors... */
if ($this->DB->error != "") {
$columns[$queryCntForArray][] = $this->lang->words['manual_error'];
$rows[$queryCntForArray][] = array('error' => htmlspecialchars($this->DB->error));
continue;
}
/* Build display rows */
$rows[$queryCntForArray] = array();
$columns[$queryCntForArray] = array();
if (preg_match("/^SELECT/i", $sql['sql']) or preg_match("/^SHOW/i", $sql['sql']) or preg_match("/^EXPLAIN/i", $sql['sql'])) {
/* Sort out the pages and stuff, auto limit if need be */
if (!preg_match("/^EXPLAIN/i", $sql['sql']) && !preg_match("/^SHOW/i", $sql['sql']) and !preg_match("/LIMIT[ 0-9,]+\$/i", $sql['sql'])) {
/* Start value */
$start = $this->request['st'] ? intval($this->request['st']) : 0;
/* Count the number of rows we got back */
$rows_returned = $this->DB->getTotalRows();
/* Paginate the results */
if ($rows_returned > $limit) {
$links = $this->registry->output->generatePagination(array('totalItems' => $rows_returned, 'itemsPerPage' => $limit, 'currentStartValue' => $start, 'baseUrl' => "{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode($sql['sql'])));
/* Reformat the query with a LIMIT */
if (substr($sql['sql'], -1, 1) == ";") {
$sql['sql'] = substr($sql['sql'], 0, -1);
}
$sql['sql'] .= " LIMIT {$start}, {$limit}";
/* Re-run with limit */
$this->DB->query($sql['sql'], 1);
}
}
/* Create the columns array */
$fields = $this->DB->getResultFields();
$cnt = count($fields);
for ($i = 0; $i < $cnt; $i++) {
$columns[$queryCntForArray][] = $fields[$i]->name;
}
/* Populate the rows array */
while ($r = $this->DB->fetch()) {
/* Loop through the results and add to row */
$row = array();
for ($i = 0; $i < $cnt; $i++) {
if ($man_query == 1) {
if (IPSText::mbstrlen($r[$fields[$i]->name]) > 200 and !preg_match("/^SHOW/i", $sql['sql'])) {
if (!$this->request['notruncate']) {
$r[$fields[$i]->name] = IPSText::truncate($r[$fields[$i]->name], 200) . '...';
}
$truncated[] = $fields[$i]->name;
}
}
if (!$this->request['notruncate'] or strlen($r[$fields[$i]->name]) < 201) {
$row[] = nl2br(htmlspecialchars(wordwrap($r[$fields[$i]->name], 50, "\n", 1)));
} else {
$row[] = htmlspecialchars($r[$fields[$i]->name]);
}
}
/* Add to output array */
$rows[$queryCntForArray][] = $row;
}
} else {
$columns[$queryCntForArray][] = '';
$rows[$queryCntForArray][] = array($this->lang->words['query_executed_successfully']);
}
$this->DB->freeResult();
$queryCntForArray++;
}
}
if (count($the_queries) == 1 && $the_queries[0]['tableName']) {
$this->registry->output->extra_nav[] = array("{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode("SELECT * FROM {$the_queries[0]['tableName']}"), $the_queries[0]['tableName']);
}
/* Output */
$this->registry->output->html .= $this->html->sqlViewResults($the_queries, $columns, $rows, $links, $truncated);
}
示例14: editPost
/**
* Post a reply
* Very simply posts a reply. Simple.
*
* Usage:
* $post->setFopicID(1);
* $post->setTopicID(5);
* $post->setPostID(100);
* $post->setAuthor( $member );
*
* $post->setPostContent( "Hello [b]there![/b]" );
* # Optional: No bbcode, etc parsing will take place
* # $post->setPostContentPreFormatted( "Hello <b>there!</b>" );
* $post->editPost();
*
* Exception Error Codes:
* NO_TOPIC_ID : No topic ID set
* NO_FORUM_ID : No forum ID set
* NO_AUTHOR_SET : No Author set
* NO_CONTENT : No post content set
* CONTENT_TOO_LONG : Post is too long
* NO_SUCH_TOPIC : No such topic
* NO_SUCH_FORUM : No such forum
* NO_REPLY_PERM : Author cannot reply to this topic
* TOPIC_LOCKED : The topic is locked
* NO_REPLY_POLL : Cannot reply to this poll only topic
* TOPIC_LOCKED : The topic is locked
* NO_REPLY_POLL : This is a poll only topic
* NO_POST_FORUM : Unable to post in that forum
* FORUM_LOCKED : Forum read only
*
* @access public
* @return mixed
*/
public function editPost()
{
//-----------------------------------------
// Set up
//-----------------------------------------
$topic_id = intval($this->getTopicID());
$forum_id = intval($this->getForumID());
//-----------------------------------------
// Global checks and functions
//-----------------------------------------
try {
$this->globalSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
if (!$this->getPostContent() and !$this->getPostContentPreFormatted()) {
$this->_postErrors = 'NO_CONTENT';
}
//-----------------------------------------
// Get topic
//-----------------------------------------
try {
$topic = $this->editSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
//-----------------------------------------
// Parse the post, and check for any errors.
//-----------------------------------------
$post = $this->compilePostData();
//-----------------------------------------
// Do we have a valid post?
//-----------------------------------------
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
$this->_postErrors = 'NO_CONTENT';
}
if (IPSText::mbstrlen($postContent) > $this->settings['max_post_length'] * 1024) {
$this->_postErrors = 'CONTENT_TOO_LONG';
}
//-----------------------------------------
// Ajax specifics
//-----------------------------------------
if ($this->getIsAjax() === TRUE) {
# Prevent polls from being edited
$this->can_add_poll = 0;
# Prevent titles from being edited
$this->edit_title = 0;
# Set Settings
$this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'] ? 1 : 0, 'enableEmoticons' => $this->_originalPost['use_emo'] ? 1 : 0, 'post_htmlstatus' => intval($this->_originalPost['post_htmlstate'])));
$this->request['iconid'] = $this->_originalPost['icon_id'];
if (!$this->getAuthor('g_append_edit')) {
$this->request['add_edit'] = ($this->_originalPost['append_edit'] or !$this->getAuthor('g_append_edit') ? 1 : 0);
}
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
if ($this->can_add_poll) {
//-----------------------------------------
// Load the poll from the DB
//-----------------------------------------
$this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . $topic['tid']));
$this->DB->execute();
$this->poll_answers = $this->poll_data['choices'] ? unserialize(stripslashes($this->poll_data['choices'])) : array();
}
//-----------------------------------------
//.........這裏部分代碼省略.........
示例15: calendarEventSave
/**
* Saves the add/edit calendar event form
*
* @access public
* @param string $type Either add or edit
* @return void
*/
public function calendarEventSave($type = 'add')
{
/* INIT */
$read_perms = '*';
$end_day = "";
$end_month = "";
$end_year = "";
$end_date = "";
$event_ranged = 0;
$event_repeat = 0;
$can_edit = 0;
$form_type = $this->request['formtype'];
$event_id = intval($this->request['event_id']);
$calendar_id = intval($this->request['calendar_id']);
$allow_emoticons = $this->request['enableemo'] == 'yes' ? 1 : 0;
$private_event = $this->request['e_type'] == 'private' ? 1 : 0;
$event_title = trim($this->request['event_title']);
$day = intval($this->request['e_day']);
$month = intval($this->request['e_month']);
$year = intval($this->request['e_year']);
$end_day = intval($this->request['end_day']);
$end_month = intval($this->request['end_month']);
$end_year = intval($this->request['end_year']);
$recur_unit = intval($this->request['recur_unit']);
$event_tz = intval($this->request['event_tz']);
$offset = 0;
$event_all_day = 0;
$event_calendar_id = intval($this->request['event_calendar_id']);
$set_time = intval($this->request['set_times']);
$hour_min = array();
if ($set_time) {
$hour_min = strstr($this->request['event_timestart'], ":") ? explode(":", $this->request['event_timestart']) : 0;
if (intval($hour_min[0]) < 0 || intval($hour_min[0]) > 23) {
$hour_min[0] = 0;
}
if (intval($hour_min[1]) < 0 || intval($hour_min[1]) > 59) {
$hour_min[1] = 0;
}
if ($hour_min[0] || $hour_min[1]) {
$offset = $event_tz * 3600;
} else {
$hour_min = array();
$offset = 0;
}
} else {
$event_all_day = 1;
}
$this->settings['max_post_length'] = $this->settings['max_post_length'] ? $this->settings['max_post_length'] : 2140000;
/* Check Permissions */
if (!$this->memberData['member_id']) {
$this->registry->output->showError('calendar_no_guests', 10412);
}
$this->calendarBuildPermissions($event_calendar_id);
if (!$this->can_post) {
$this->registry->output->showError('calendar_no_post_perm', 10413);
}
/* WHATDOWEDO? */
if ($type == 'add') {
} else {
/* Check ID */
if (!$event_id) {
$this->registry->output->showError('calendar_event_not_found', 10414);
}
/* Get the event */
$this->DB->build(array('select' => '*', 'from' => 'cal_events', 'where' => "event_id={$event_id}"));
$this->DB->execute();
if (!($event = $this->DB->fetch())) {
$this->registry->output->showError('calendar_event_not_found', 10415);
}
/* Do we have permission to edit this event */
if ($this->memberData['member_id'] == $event['event_member_id']) {
$can_edit = 1;
} else {
if ($this->memberData['g_is_supmod'] == 1) {
$can_edit = 1;
}
}
if ($can_edit != 1) {
$this->registry->output->showError('calendar_no_edit_perm', 10416);
}
}
/* Do we have a valid post? */
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($_POST['Post'])))) < 1) {
$this->registry->output->showError('calendar_post_too_short', 10417);
}
/* Check the post length */
if (IPSText::mbstrlen($_POST['Post']) > $this->settings['max_post_length'] * 1024) {
$this->registry->output->showError('calendar_post_too_long', 10418);
}
/* Fix up the event title */
if (IPSText::mbstrlen($event_title) < 2 or !$event_title) {
$this->registry->output->showError('calendar_no_title', 10419);
}
//.........這裏部分代碼省略.........