本文整理匯總了PHP中IPSText::removeControlCharacters方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::removeControlCharacters方法的具體用法?PHP IPSText::removeControlCharacters怎麽用?PHP IPSText::removeControlCharacters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::removeControlCharacters方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _completeRegistrationSave
/**
* Save the data to complete the partial member record login/registration
*
* @access private
* @return void [Outputs to screen/redirects]
*/
private function _completeRegistrationSave()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$mid = intval($this->request['mid']);
$key = intval($this->request['key']);
$in_email = strtolower(trim($this->request['EmailAddress']));
$banfilters = array();
$form_errors = array('dname' => array(), 'email' => array(), 'general' => array());
$members_display_name = trim($this->request['members_display_name']);
$poss_session_id = "";
//-----------------------------------------
// Get DB row
//-----------------------------------------
$reg = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id={$mid} AND partial_date={$key}"));
$tmp_member = IPSMember::load($mid);
//-----------------------------------------
// Got it?
//-----------------------------------------
if (!$reg['partial_id'] or !$tmp_member['member_id']) {
$this->registry->output->showError('partial_reg_noid', 10117);
}
//-----------------------------------------
// Load ban filters
//-----------------------------------------
$this->DB->build(array('select' => '*', 'from' => 'banfilters'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$banfilters[$r['ban_type']][] = $r['ban_content'];
}
//-----------------------------------------
// Custom profile field stuff
//-----------------------------------------
require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
$custom_fields = new customProfileFields();
$custom_fields->initData('edit');
$custom_fields->parseToSave($this->request, 'register');
/* Check */
if ($custom_fields->error_messages) {
$form_errors['general'] = $custom_fields->error_messages;
}
//-----------------------------------------
// Remove 'sneaky' spaces
//-----------------------------------------
if ($this->settings['strip_space_chr']) {
$members_display_name = IPSText::removeControlCharacters($members_display_name);
}
//-----------------------------------------
// Testing email addresses?
//-----------------------------------------
if (!$reg['partial_email_ok']) {
//-----------------------------------------
// Check the email address
//-----------------------------------------
if (!IPSText::checkEmailAddress($in_email)) {
$form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
}
//-----------------------------------------
// Test email address
//-----------------------------------------
$this->request['EmailAddress_two'] = strtolower(trim($this->request['EmailAddress_two']));
if ($this->request['EmailAddress_two'] != $in_email) {
$form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
}
//-----------------------------------------
// Are they banned [EMAIL]?
//-----------------------------------------
if (is_array($banfilters['email']) and count($banfilters['email'])) {
foreach ($banfilters['email'] as $email) {
$email = str_replace('\\*', '.*', preg_quote($email, "/"));
if (preg_match("/^{$email}\$/i", $in_email)) {
$form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
break;
}
}
}
/* Is this email addy taken? */
if (IPSMember::checkByEmail($in_email) == TRUE) {
$form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
}
//-----------------------------------------
// Load handler...
//-----------------------------------------
require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
$han_login = new han_login($this->registry);
$han_login->init();
if ($han_login->emailExistsCheck(trim(strtolower($member['email'])), trim(strtolower($in_email)))) {
$form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
}
}
if ($this->settings['auth_allow_dnames']) {
/* Check the username */
$user_check = IPSMember::getFunction()->cleanAndCheckName($members_display_name, $tmp_member, 'members_display_name');
//.........這裏部分代碼省略.........
示例2: _completeRegistrationSave
//.........這裏部分代碼省略.........
}
} else {
if ($connectService == 'vkontakte' and $member['vk_uid']) {
/* Already VKd? */
if ($logInMember['vk_uid'] and $member['vk_uid'] != $logInMember['vk_uid']) {
/* User already has vkontakte link */
$form_errors['serviceLogIn'][] = sprintf($this->lang->words['connect_already_linked'], $login_user, ucfirst($connectService));
}
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect');
$vk = new $classToLoad($this->registry, $key);
if ($vk->finishNewConnection($logInMember['member_id'], $member['member_id']) !== true) {
/* Unknown error */
$form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
}
}
}
}
/* Ok to proceed? */
if (!count($form_errors['serviceLogIn'])) {
IPSMember::remove($member['member_id']);
/* Here, so log us in!! */
$r = $han_login->loginWithoutCheckingCredentials($logInMember['member_id'], TRUE);
/* Boing */
if (is_array($r)) {
$this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=core&module=usercp§ion=register&tab=core&area=' . $connectService);
}
}
}
}
//-----------------------------------------
// Remove 'sneaky' spaces
//-----------------------------------------
if ($this->settings['strip_space_chr']) {
$members_display_name = IPSText::removeControlCharacters($members_display_name);
}
//-----------------------------------------
// Testing email addresses?
//-----------------------------------------
if (!$reg['partial_email_ok'] and $in_email) {
//-----------------------------------------
// Check the email address
//-----------------------------------------
if (!IPSText::checkEmailAddress($in_email)) {
$form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
}
//-----------------------------------------
// Test email address
//-----------------------------------------
$this->request['EmailAddress_two'] = strtolower(trim($this->request['EmailAddress_two']));
if ($in_email and $this->request['EmailAddress_two'] != $in_email) {
$form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
}
/* Is this email banned or does it exist already? */
if (IPSMember::isBanned('email', $in_email) || IPSMember::checkByEmail($in_email) || $han_login->emailExistsCheck(trim(strtolower($in_email)))) {
$form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
}
} else {
if (!$reg['partial_email_ok'] and !$in_email and !$login_user) {
$form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
}
}
if ($this->settings['auth_allow_dnames']) {
/* Check the username */
$user_check = IPSMember::getFunction()->cleanAndCheckName($members_display_name, $tmp_member, 'members_display_name');
if (is_array($user_check['errors']) && count($user_check['errors'])) {
$form_errors['dname'][] = isset($this->lang->words[$user_check['errors']['dname']]) ? $this->lang->words[$user_check['errors']['dname']] : $user_check['errors']['dname'];
示例3: _cleanName
/**
* Clean a username or display name
*
* @access protected
* @param string Name
* @param string Field (name or members_display_name)
* @return array array( 'name' => $cleaned_name, 'errors' => array() )
*/
protected function _cleanName($name, $field = 'members_display_name')
{
$original = $name;
$name = trim($name);
if ($field == 'name') {
// Commented out for bug report #15354
//$name = str_replace( '|', '|' , $name );
/* Remove multiple spaces */
$name = preg_replace("/\\s{2,}/", " ", $name);
}
//-----------------------------------------
// Remove line breaks
//-----------------------------------------
if (ipsRegistry::$settings['usernames_nobr']) {
$name = IPSText::br2nl($name);
$name = str_replace("\n", "", $name);
$name = str_replace("\r", "", $name);
}
//-----------------------------------------
// Remove sneaky spaces
//-----------------------------------------
if (ipsRegistry::$settings['strip_space_chr']) {
/* use hexdec to convert between '0xAD' and chr */
$name = IPSText::removeControlCharacters($name);
}
//-----------------------------------------
// Trim after above ops
//-----------------------------------------
$name = trim($name);
//-----------------------------------------
// Test unicode name
//-----------------------------------------
$unicode_name = $this->_getUnicodeName($name);
//-----------------------------------------
// Do we have a name?
//-----------------------------------------
if ($field == 'name' or $field == 'members_display_name' and ipsRegistry::$settings['auth_allow_dnames']) {
if (!$name or IPSText::mbstrlen($name) < 3 or IPSText::mbstrlen($name) > ipsRegistry::$settings['max_user_name_length']) {
ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_register'), 'core');
$key = $field == 'members_display_name' ? 'reg_error_no_name' : 'reg_error_username_none';
$text = sprintf(ipsRegistry::getClass('class_localization')->words[$key], ipsRegistry::$settings['max_user_name_length']);
//-----------------------------------------
// Only show note about special chars when relevant
//-----------------------------------------
if (strpos($name, '&') !== false) {
$text .= ipsRegistry::getClass('class_localization')->words['reg_error_no_name_spec'];
}
return array('name' => $original, 'errors' => array($text));
}
}
//-----------------------------------------
// Blocking certain chars in username?
//-----------------------------------------
if (ipsRegistry::$settings['username_characters']) {
$check_against = preg_quote(ipsRegistry::$settings['username_characters'], "/");
if (!preg_match("/^[" . $check_against . "]+\$/i", $name)) {
return array('name' => $original, 'errors' => array(str_replace('{chars}', ipsRegistry::$settings['username_characters'], ipsRegistry::$settings['username_errormsg'])));
}
}
//-----------------------------------------
// Manually check against bad chars
//-----------------------------------------
if (strpos($unicode_name, '\') !== false or strpos($unicode_name, '&#quot;') !== false or strpos($unicode_name, '$') !== false or strpos($unicode_name, '&#lt;') !== false or strpos($unicode_name, '$') !== false or strpos($unicode_name, ']') !== false or strpos($unicode_name, '[') !== false or strpos($unicode_name, ',') !== false or strpos($unicode_name, '|') !== false or strpos($unicode_name, '&#gt;') !== false) {
ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_register'), 'core');
return array('name' => $original, 'errors' => array(ipsRegistry::getClass('class_localization')->words['reg_error_chars']));
}
return array('name' => $name, 'errors' => array());
}
示例4: postParseCleanValue
/**
* Clean _GET _POST value after settings loaded
*
* @access public
* @param string Input
* @return string Cleaned Input
* @since 2.1
*/
public static function postParseCleanValue($val)
{
if ($val == "") {
return "";
}
/* This looks wrong but it's correct. During FURL set up in registry this function is called before settings are loaded
* and we want to strip hidden chars in this instance, so.. */
if (!isset(ipsRegistry::$settings['strip_space_chr']) or ipsRegistry::$settings['strip_space_chr']) {
$val = IPSText::removeControlCharacters($val);
}
return $val;
}
示例5: 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) {
//.........這裏部分代碼省略.........
示例6: save_member_name
/**
* Update a user's login or display name
*
* @param string Field to update
* @return @e void [Outputs to screen]
*/
protected function save_member_name($field = 'members_display_name')
{
$member_id = intval($this->request['member_id']);
$member = IPSMember::load($member_id);
//-----------------------------------------
// Allowed to edit administrators?
//-----------------------------------------
if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin', 'members', 'members')) {
$this->registry->output->showError($this->lang->words['m_editadmin']);
}
if ($field == 'members_display_name') {
$display_name = $this->request['display_name'];
$display_name = str_replace("+", "+", $display_name);
} else {
$display_name = $this->request['name'];
$display_name = str_replace("+", "+", $display_name);
$display_name = str_replace('|', '|', $display_name);
$display_name = trim(preg_replace("/\\s{2,}/", " ", $display_name));
}
if ($this->settings['strip_space_chr']) {
// use hexdec to convert between '0xAD' and chr
$display_name = IPSText::removeControlCharacters($display_name);
}
if ($field == 'members_display_name' and preg_match("#[\\[\\];,\\|]#", IPSText::UNhtmlspecialchars($display_name))) {
$this->registry->output->showError($this->lang->words['m_displaynames']);
}
try {
if (IPSMember::getFunction()->updateName($member_id, $display_name, $field, TRUE) === TRUE) {
if ($field == 'members_display_name') {
ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_dnamelog'], $member['members_display_name'], $display_name));
} else {
ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_namelog'], $member['name'], $display_name));
//-----------------------------------------
// If updating a name, and display names
// disabled, update display name too
//-----------------------------------------
if (!ipsRegistry::$settings['auth_allow_dnames']) {
IPSMember::getFunction()->updateName($member_id, $display_name, 'members_display_name', TRUE);
}
//-----------------------------------------
// I say, did we choose to email 'dis member?
//-----------------------------------------
if ($this->request['send_email'] == 1) {
//-----------------------------------------
// By golly, we did!
//-----------------------------------------
$msg = trim(IPSText::stripslashes(nl2br($_POST['email_contents'])));
$msg = str_replace("{old_name}", $member['name'], $msg);
$msg = str_replace("{new_name}", $display_name, $msg);
$msg = str_replace("<#BOARD_NAME#>", $this->settings['board_name'], $msg);
$msg = str_replace("<#BOARD_ADDRESS#>", $this->settings['board_url'] . '/index.' . $this->settings['php_ext'], $msg);
IPSText::getTextClass('email')->message = stripslashes(IPSText::getTextClass('email')->cleanMessage($msg));
IPSText::getTextClass('email')->subject = $this->lang->words['m_changesubj'];
IPSText::getTextClass('email')->to = $member['email'];
IPSText::getTextClass('email')->sendMail();
}
}
$this->cache->rebuildCache('stats', 'global');
} else {
# We should absolutely never get here. So this is a fail-safe, really to
# prevent a "false" positive outcome for the end-user
$this->registry->output->showError($this->lang->words['m_namealready']);
}
} catch (Exception $error) {
// $this->returnJsonError( $error->getMessage() );
switch ($error->getMessage()) {
case 'NO_USER':
$this->registry->output->showError($this->lang->words['m_noid']);
break;
case 'NO_PERMISSION':
case 'NO_NAME':
$this->registry->output->showError(sprintf($this->lang->words['m_morethan3'], $this->settings['max_user_name_length']));
break;
case 'ILLEGAL_CHARS':
$this->registry->output->showError($this->lang->words['m_illegal']);
break;
case 'USER_NAME_EXISTS':
$this->registry->output->showError($this->lang->words['m_namealready']);
break;
default:
$this->registry->output->showError($error->getMessage());
break;
}
}
$this->registry->output->global_message = $this->lang->words[$field . '_updated_success'];
$this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=members&do=viewmember&member_id=' . $member_id);
}
示例7: 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();
}
//-----------------------------------------
//.........這裏部分代碼省略.........
示例8: 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);
}
//.........這裏部分代碼省略.........
示例9: save_member_name
/**
* Update a user's login or display name
*
* @access protected
* @param string Field to update
* @return void [Outputs to screen]
*/
protected function save_member_name($field = 'members_display_name')
{
$member_id = intval($this->request['member_id']);
$member = IPSMember::load($member_id);
//-----------------------------------------
// Allowed to edit administrators?
//-----------------------------------------
if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin', 'members', 'members')) {
$this->returnJsonError($this->lang->words['m_editadmin']);
exit;
}
if ($field == 'members_display_name') {
$display_name = $this->convertAndMakeSafe($_POST['display_name'], 1);
$display_name = str_replace("+", "+", $display_name);
} else {
$display_name = $this->convertAndMakeSafe($_POST['name'], 1);
$display_name = str_replace("+", "+", $display_name);
$display_name = str_replace('|', '|', $display_name);
$display_name = trim(preg_replace("/\\s{2,}/", " ", $display_name));
}
if ($this->settings['strip_space_chr']) {
// use hexdec to convert between '0xAD' and chr
$display_name = IPSText::removeControlCharacters($display_name);
}
if ($field == 'members_display_name' and preg_match("#[\\[\\];,\\|]#", str_replace(''', "'", str_replace('&', '&', $members_display_name)))) {
$this->returnJsonError($this->lang->words['m_displaynames']);
}
try {
if (IPSMember::getFunction()->updateName($member_id, $display_name, $field) === TRUE) {
if ($field == 'members_display_name') {
ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_dnamelog'], $member['members_display_name'], $display_name));
} else {
ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_namelog'], $member['name'], $display_name));
//-----------------------------------------
// If updating a name, and display names
// disabled, update display name too
//-----------------------------------------
if (!ipsRegistry::$settings['auth_allow_dnames']) {
IPSMember::getFunction()->updateName($member_id, $display_name, 'members_display_name');
}
//-----------------------------------------
// I say, did we choose to email 'dis member?
//-----------------------------------------
if ($this->request['send_email'] == 1) {
//-----------------------------------------
// By golly, we did!
//-----------------------------------------
$msg = trim(IPSText::stripslashes(nl2br($_POST['email_contents'])));
$msg = str_replace("{old_name}", $member['name'], $msg);
$msg = str_replace("{new_name}", $display_name, $msg);
$msg = str_replace("<#BOARD_NAME#>", $this->settings['board_name'], $msg);
$msg = str_replace("<#BOARD_ADDRESS#>", $this->settings['board_url'] . '/index.' . $this->settings['php_ext'], $msg);
IPSText::getTextClass('email')->message = stripslashes(IPSText::getTextClass('email')->cleanMessage($msg));
IPSText::getTextClass('email')->subject = $this->lang->words['m_changesubj'];
IPSText::getTextClass('email')->to = $member['email'];
IPSText::getTextClass('email')->sendMail();
}
}
$this->cache->rebuildCache('stats', 'global');
} else {
# We should absolutely never get here. So this is a fail-safe, really to
# prevent a "false" positive outcome for the end-user
$this->returnJsonError($this->lang->words['m_namealready']);
}
} catch (Exception $error) {
$this->returnJsonError($error->getMessage());
switch ($error->getMessage()) {
case 'NO_USER':
$this->returnJsonError($this->lang->words['m_noid']);
break;
case 'NO_PERMISSION':
case 'NO_NAME':
$this->returnJsonError(sprintf($this->lang->words['m_morethan3'], $this->settings['max_user_name_length']));
break;
case 'ILLEGAL_CHARS':
$this->returnJsonError($this->lang->words['m_illegal']);
break;
case 'USER_NAME_EXISTS':
$this->returnJsonError($this->lang->words['m_namealready']);
break;
default:
$this->returnJsonError($error->getMessage());
break;
}
}
//-----------------------------------------
// Load handler...
//-----------------------------------------
if ($field == 'name') {
require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
$han_login = new han_login($this->registry);
$han_login->init();
$han_login->changeName($member['name'], $display_name, $member['email']);
//.........這裏部分代碼省略.........
示例10: calendarEventSave
//.........這裏部分代碼省略.........
$end_date = gmmktime($_time[0], $_time[1], 0, $_endBits[0], $_endBits[1], $_endBits[2]);
}
}
if ($end_date and $end_date < $start_date) {
$this->registry->output->showError('calendar_range_wrong', 10421);
} else {
if ($this->request['end_date'] and $this->request['set_enddate'] and !$end_date) {
$this->registry->output->showError('calendar_range_wrong', 10421.1);
}
}
//-----------------------------------------
// Set recurring flag
//-----------------------------------------
if ($this->request['set_recurfields']) {
if (!$end_date) {
$this->registry->output->showError('recurring_requires_enddate', 10427.6);
}
$recurring = intval($this->request['recur_unit']);
}
//-----------------------------------------
// Adjust to GMT
//-----------------------------------------
if ($this->request['event_timezone'] and !$this->request['all_day']) {
$start_date = $start_date - $this->request['event_timezone'] * 3600;
if ($end_date) {
$end_date = $end_date - $this->request['event_timezone'] * 3600;
}
}
$start_date = gmstrftime("%Y-%m-%d %H:%M:00", $start_date);
$end_date = $end_date ? gmstrftime("%Y-%m-%d %H:%M:00", $end_date) : 0;
//-----------------------------------------
// Check posted content for errors
//-----------------------------------------
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($_POST['Post'])))) < 1) {
$this->registry->output->showError('calendar_post_too_short', 10417, null, null, 403);
}
$this->settings['max_post_length'] = $this->settings['max_post_length'] ? $this->settings['max_post_length'] : 2140000;
if (IPSText::mbstrlen($_POST['Post']) > $this->settings['max_post_length'] * 1024) {
$this->registry->output->showError('calendar_post_too_long', 10418, null, null, 403);
}
if (!$event_title or IPSText::mbstrlen($event_title) < 2) {
$this->registry->output->showError('calendar_no_title', 10419, null, null, 403);
}
if (IPSText::mbstrlen($event_title) > 200) {
$this->registry->output->showError('calendar_title_too_long', 10420, null, null, 403);
}
//-----------------------------------------
// Adding or editing?
//-----------------------------------------
if ($type == 'edit') {
//-----------------------------------------
// Get event
//-----------------------------------------
if (!$event_id) {
$this->registry->output->showError('calendar_event_not_found', 10414, null, null, 404);
}
$event = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id));
if (!$event['event_id']) {
$this->registry->output->showError('calendar_event_not_found', 10415, null, null, 404);
}
//-----------------------------------------
// Do we have permission to edit?
//-----------------------------------------
if (!$this->memberData['g_is_supmod'] and $this->memberData['member_id'] != $event['event_member_id']) {
$this->registry->output->showError('calendar_no_edit_perm', 10416, null, null, 403);
}