function convert_posts($message) { $pattern = array('#\\[b:[a-z0-9]{10}\\]#i', '#\\[/b:[a-z0-9]{10}\\]#i', '#\\[i:[a-z0-9]{10}\\]#i', '#\\[/i:[a-z0-9]{10}\\]#i', '#\\[u:[a-z0-9]{10}\\]#i', '#\\[/u:[a-z0-9]{10}\\]#i', '#\\[list=([a-z0-9]):[a-z0-9]{10}\\]#i', '#\\[list:[a-z0-9]{10}\\]#i', '#\\[/list:[a-z0-9]:[a-z0-9]{10}\\]#i', '#\\[\\*:[a-z0-9]{10}\\]#i', '#\\[color=(.*?):[a-z0-9]{10}\\]#i', '#\\[/color:[a-z0-9]{10}\\]#i', '#:roll:#i', '#:wink:#i', '#\\[img:[a-z0-9]{10}\\]#i', '#\\[/img:[a-z0-9]{10}\\]#i', '#\\[size=[0-9]{1}:[a-z0-9]{10}\\]#i', '#\\[size=[0-9]{2}:[a-z0-9]{10}\\]#i', '#\\[/size:[a-z0-9]{10}\\]#i', '#\\[quote:(.*?)\\]#i', '#\\[/quote:[a-z0-9]{10}\\]#i', '#\\[code:[0-9]:[a-z0-9]{10}\\]#i', '#\\[/code:[0-9]:[a-z0-9]{10}\\]#i'); $replace = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[list=$1]', '[list]', '[/list]', '[*]', '[color=$1]', '[/color]', ':rolleyes:', ';)', '[img]', '[/img]', '', '', '', '[quote]', '[/quote]', '[code]', '[/code]'); $errors = array(); return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors); }
function convert_posts($message) { $message = html_entity_decode($message); $pattern = array('#\\<b>(.*?)</b>#is', '#\\<i>(.*?)</i>#is', '#\\<u>(.*?)</u>#is', '#\\<!--emo&(.*?)-->(.*?)<!--endemo-->#i', "#<img src=[\"'].*?['\"] class=['\"]bbc_emoticon['\"] alt=['\"](.*?)['\"] />#i", "#<img src=[\"'](\\S+?)['\"].+?" . ">#", "#\\<span style='font-family:(.*?)'>(.*?)</span>#i", "#\\<span style='font-size:(.*?)pt;line-height:100%'>(.*?)</span>#i", "#\\<span style='color:(.*?)'>(.*?)</span>#i", "#\\<a href='(.*?)' target='_blank'>(.*?)</a>#i", "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#", "#<!--QuoteBegin-{1,2}([^>]+?)\\+([^>]+?)-->(.+?)<!--QuoteEBegin-->#", "#<!--QuoteBegin-{1,2}([^>]+?)\\+-->(.+?)<!--QuoteEBegin-->#", "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#", "#\\[right\\]\\[snapback\\](.*?)\\[/snapback\\]\\[/right\\]<br>#", "#<!--c1-->(.+?)<!--ec1-->#", "#<!--c2-->(.+?)<!--ec2-->#", '#\\<ul>(.*?)</ul>#i', '#\\<li>(.*?)</li>#i', '#\\<a href="mailto:(.*?)">(.*?)</a>#i', "#\\<a href='(.*?)' target='_blank'>(.*?)</a>#i", '#\\<br>#i', '#\\<br />#i', '#\\[size="(\\d*)"\\](.*?)\\[\\/size\\]#i'); $replace = array('[b]$1[/b]', '[i]$1[/i]', '[u]$1[/u]', '$1', '$1', '[img]$1[/img]', '[font=$1]$2[/font]', '[size=$1]$2[/size]', '[color=$1]$2[/color]', '[url=$1]$2[/url]', '[quote]', '[quote=$1,$2]', '[quote=$1]', '[/quote]', '', '[code]', '[/code]', "\r\n\$1\r\n", " * \$1\r\n", '[email=$1]$2[/email]', '[url=$1]$2[/url]', "\r\n", "\r\n", '[h]$2[/h]'); $errors = array(); return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors); }
function convert_posts($message) { $message = convert_to_utf8($message); $message = str_replace("\n", '', $message); $pattern = array('#<!--b--><span class="b">#i', '#</span><!--/b-->#i', '#<!--i--><span class="i">#i', '#</span><!--/i-->#i', '#<!--u--><span class="u">#i', '#</span><!--/u-->#i', '#<!--s--><span class="s">#i', '#</span><!--/u-->#i', '#<!--center--><span class="center">#i', '#</span><!--/center-->#i', '#<!--list(num)?--><(ul|ol)>#i', '#</(ul|ol)><!--/list(num)?-->#i', '#<li><span class="nodisplay">\\[\\*\\]</span>#i', '#</li>#i', '#<!--color=--><span style="color:\\s*(.*?);?">#i', '#</span><!--/color=-->#i', '#<!--img--><img src="#i', '#" alt="Posted Image" />(<!--/img-->)?#i', '#<img src="smileys\\/.*?" alt="(.*?)" class="smiley" />#i', '#<!--url=--><a href="(.*?)">#i', '#(<!--url-->)?<a href="(.*?)">#i', '#<!--email--><a href="mailto:(.*?)">#i', '#</a>(<!--/url=?-->)?#i', '#</a><!--/email-->#i', '#<!--flash--><object type="application/x-shockwave-flash" data="(.*?)" width="560" height="436"><param name="quality" value="high" /><param name="movie" value="(.*?)" /></object><span class="nodisplay">\\[flash\\]\\[/flash\\]</span><!--/flash-->#i', '#<!--youtube--><object width="425" height="350"><param name="movie" value="(.*?)"></param><param name="wmode" value="transparent"></param><embed src="(.*?)" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><!--/youtube-->#i', '#<!--size=--><span style="font-size:[0-9]{1,2}px;?">#i', '#</span><!--/(size|font)=-->#i', '#<!--font=--><span style="font-family:(.*?)">#i', '#<!--quote=?--><blockquote class="citationb?">(<p><span class="u">(.*?)</span></p>)?<p>#i', '#</p></blockquote><!--/quote=?-->#i', '#<!--(code|php)--><span class="code">(<p>)?<code>#i', '#</code>(</p>)?</span><!--/(code|php)-->#i', '#<!--spoil--><span class="spoil"><span class="spoil_info" onclick="hideAndShow\\(\'spoil[0-9a-f]{32}\'\\);">Spoiler</span><span class="spoil_spoiler" id="spoil[0-9a-f]{32}">#i', '#</span></span><script type="text/javascript">hideAndShow\\(\'spoil[0-9a-f]{32}\'\\);</script><!--/spoil-->#i', '#<br />#i'); $replace = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '', '', '[list]', '[/list]', '[*]', '[/*]', '[color=$1]', '[/color]', '[img]', '[/img]', '$1', '[url=$1]', '[url]', '[email=$1]', '[/url]', '[/email]', '[url]$1[/url]', '[url]$1[/url]', '', '', '', '[quote]', '[/quote]', '[code]', '[/code]', '[quote]', '[/quote]', "\n"); $errors = array(); return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors); }
// Preparse signatures // Preparse signatures case 'preparse_sigs': $query_str = '?stage=rebuild_idx'; // If we don't need to parse the sigs, skip this stage if (isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION) { break; } require PUN_ROOT . 'include/parser.php'; // Fetch users to process this cycle $result = $db->query('SELECT id, signature FROM ' . $db->prefix . 'users WHERE id > ' . $start_at . ' ORDER BY id ASC LIMIT ' . PER_PAGE) or error('Unable to fetch users', __FILE__, __LINE__, $db->error()); $temp = array(); $end_at = 0; while ($cur_item = $db->fetch_assoc($result)) { echo sprintf($lang_update['Preparsing item'], $lang_update['signature'], $cur_item['id']) . '<br />' . "\n"; $db->query('UPDATE ' . $db->prefix . 'users SET signature = \'' . $db->escape(preparse_bbcode($cur_item['signature'], $temp, true)) . '\' WHERE id = ' . $cur_item['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error()); $end_at = $cur_item['id']; } // Check if there is more work to do if ($end_at > 0) { $result = $db->query('SELECT 1 FROM ' . $db->prefix . 'users WHERE id > ' . $end_at . ' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result) > 0) { $query_str = '?stage=preparse_sigs&start_at=' . $end_at; } } break; // Rebuild the search index // Rebuild the search index case 'rebuild_idx': $query_str = '?stage=finish'; // If we don't need to update the search index, skip this stage
if (mb_strlen($message) > 65535) { $errors[] = $lang_post['Too long message']; } else { if (!$pun_config['p_message_all_caps'] && mb_strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD) { $message = ucwords(mb_strtolower($message)); } } } // MOD CONVENIENT FORUM URL BEGIN //if ($pun_config['o_convenient_url_enable'] == 1) convert_forum_url($message); // MOD CONVENIENT FORUM URL END // Validate BBCode syntax if ($pun_config['p_message_bbcode'] == 1 && strpos($message, '[') !== false && strpos($message, ']') !== false) { include_once PUN_ROOT . 'include/parser.php'; $message = preparse_bbcode($message, $errors); } include PUN_ROOT . 'include/search_idx.php'; $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0; $subscribe = isset($_POST['subscribe']) ? 1 : 0; // Did everything go according to plan? if (!$errors && !isset($_POST['preview'])) { // MERGE POSTS BEGIN $merged = false; if (isset($_POST['merge'])) { $_POST['merge'] = 1; } else { $_POST['merge'] = 0; } if (!$pun_user['is_guest'] && !$fid && (($is_admmod && $_POST['merge']) == 1 || !$is_admmod) && $cur_posting['poster_id'] && $cur_posting['message'] && $_SERVER['REQUEST_TIME'] - $cur_posting['posted'] < $pun_config['o_timeout_merge']) { // Preparing separator
if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) { message(sprintf($lang_prof_reg['Sig too long'], $pun_config['p_sig_length'], pun_strlen($form['signature']) - $pun_config['p_sig_length'])); } else { if (substr_count($form['signature'], "\n") > $pun_config['p_sig_lines'] - 1) { message(sprintf($lang_prof_reg['Sig too many lines'], $pun_config['p_sig_lines'])); } else { if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$pun_user['is_admmod']) { $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature'])); } } } // Validate BBCode syntax if ($pun_config['p_sig_bbcode'] == '1') { require PUN_ROOT . 'include/parser.php'; $errors = array(); $form['signature'] = preparse_bbcode($form['signature'], $errors, true); if (count($errors) > 0) { message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'); } } } break; case 'display': $form = array('disp_topics' => pun_trim($_POST['form']['disp_topics']), 'disp_posts' => pun_trim($_POST['form']['disp_posts']), 'show_smilies' => isset($_POST['form']['show_smilies']) ? '1' : '0', 'show_img' => isset($_POST['form']['show_img']) ? '1' : '0', 'show_img_sig' => isset($_POST['form']['show_img_sig']) ? '1' : '0', 'show_avatars' => isset($_POST['form']['show_avatars']) ? '1' : '0', 'show_sig' => isset($_POST['form']['show_sig']) ? '1' : '0'); if ($form['disp_topics'] != '') { $form['disp_topics'] = intval($form['disp_topics']); if ($form['disp_topics'] < 3) { $form['disp_topics'] = 3; } else { if ($form['disp_topics'] > 75) { $form['disp_topics'] = 75;
// Validate signature if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) { message($lang_prof_reg['Sig too long'] . ' ' . $pun_config['p_sig_length'] . ' ' . $lang_prof_reg['characters'] . '.'); } else { if (substr_count($form['signature'], "\n") > $pun_config['p_sig_lines'] - 1) { message($lang_prof_reg['Sig too many lines'] . ' ' . $pun_config['p_sig_lines'] . ' ' . $lang_prof_reg['lines'] . '.'); } else { if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && strtoupper($form['signature']) == $form['signature'] && $pun_user['g_id'] > PUN_MOD) { $form['signature'] = ucwords(strtolower($form['signature'])); } } } // Validate BBCode syntax if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false) { require PUN_ROOT . 'include/parser.php'; $form['signature'] = preparse_bbcode($form['signature'], $foo, true); } if (!isset($form['use_avatar']) || $form['use_avatar'] != '1') { $form['use_avatar'] = '0'; } break; case 'display': $form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style')); if ($form['disp_topics'] != '' && intval($form['disp_topics']) < 3) { $form['disp_topics'] = 3; } if ($form['disp_topics'] != '' && intval($form['disp_topics']) > 75) { $form['disp_topics'] = 75; } if ($form['disp_posts'] != '' && intval($form['disp_posts']) < 3) { $form['disp_posts'] = 3;
/** * Use FluxBB's parser to preparse BBCode tags for message * * @param type $message * @param type &$errors * @return type */ function preparse_bbcode($message, &$errors) { global $re_list, $lang_common; $errors = array(); require_once PUN_ROOT . 'include/parser.php'; $message = preparse_bbcode($message, $errors); if (!empty($errors)) { conv_log('convert_message: bbcode error: ' . implode(', ', $errors)); } return $message; }
/** * Convert BBcode */ function convert_message($message) { static $patterns, $replacements; global $re_list; $errors = array(); require_once PUN_ROOT . 'include/parser.php'; if (!isset($patterns)) { $patterns = array('%\\[quote=\'(.*?)\'.*?\\]\\s*%si' => '[quote=$1]', '%\\[/?(font|size|align)(?:\\=[^\\]]*)?\\]%i' => ''); } $message = preg_replace(array_keys($patterns), array_values($patterns), $message); if (!isset($replacements)) { $replacements = array('[php]' => '[code]', '[/php]' => '[/code]'); } return preparse_bbcode(str_replace(array_keys($replacements), array_values($replacements), $message), $errors); }
require FORUM_ROOT . 'include/parser.php'; } // Now we're definitely using UTF-8, so we convert the output properly $forum_db->set_names('utf8'); // Determine where to start if ($start_at == 0) { $start_at = 1; } $end_at = $start_at + PER_PAGE; // Fetch users to process this cycle $query = array('SELECT' => 'id, signature', 'FROM' => 'users', 'WHERE' => 'id >= ' . $start_at . ' AND id < ' . $end_at, 'ORDER BY' => 'id'); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); while ($cur_item = $forum_db->fetch_assoc($result)) { echo 'Preparsing signature ' . $cur_item['id'] . '…<br />' . "\n"; $preparse_errors = array(); $query = array('UPDATE' => 'users', 'SET' => 'signature = \'' . $forum_db->escape(preparse_bbcode($cur_item['signature'], $preparse_errors, true)) . '\'', 'WHERE' => 'id = ' . $cur_item['id']); $forum_db->query_build($query) or error(__FILE__, __LINE__); } // Check if there is more work to do $query = array('SELECT' => 'id', 'FROM' => 'users', 'WHERE' => 'id >= ' . $end_at, 'ORDER BY' => 'id ASC', 'LIMIT' => '1'); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $start_id = $forum_db->result($result); if (is_null($start_id) || $start_id === false) { $query_str = '?stage=finish'; } else { $query_str = '?stage=preparse_sigs&req_per_page=' . PER_PAGE . '&start_at=' . $start_id; } unset($start_id); break; // Show results page // Show results page
private function prepare_message(&$errors) { if (!isset($_POST['req_message'])) { message(App::$lang_common['Bad request']); } $message = forum_linebreaks(forum_trim($_POST['req_message'])); if ($message == '') { $errors[] = App::$lang['No message']; } else { if (strlen($message) > App::$forum_config['o_reputation_maxmessage']) { $errors[] = sprintf(App::$lang['Too long message'], App::$forum_config['o_reputation_maxmessage']); } } if (App::$forum_config['p_message_bbcode'] == '1' || App::$forum_config['o_make_links'] == '1') { if (!defined('FORUM_PARSER_LOADED')) { require FORUM_ROOT . 'include/parser.php'; } $message = preparse_bbcode($message, $errors); } return $message; }
function pun_pm_preview($receiver, $subject, $body, &$errors) { global $forum_config, $forum_page, $lang_pun_pm, $forum_user; if ($body == '') { $errors[] = $lang_pun_pm['Empty body']; } elseif (strlen($body) > FORUM_MAX_POSTSIZE_BYTES) { $errors[] = sprintf($lang_pun_pm['Too long message'], forum_number_format(strlen($body)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES)); } elseif ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($body) == $body && !$forum_page['is_admmod']) { $body = utf8_ucwords(utf8_strtolower($body)); } // Validate BBCode syntax if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') { global $smilies; if (!defined('FORUM_PARSER_LOADED')) { require FORUM_ROOT . 'include/parser.php'; } $body = preparse_bbcode($body, $errors); } ($hook = get_hook('pun_pm_fn_preview_pre_errors_check')) ? eval($hook) : null; if (count($errors)) { return false; } $message['sender'] = $forum_user['username']; $message['sender_id'] = $forum_user['id']; $message['body'] = $body; $message['subject'] = $subject; $message['status'] = 'draft'; $message['sent_at'] = time(); ($hook = get_hook('pun_pm_fn_preview_end')) ? eval($hook) : null; return pun_pm_message($message, 'inbox'); }
public function setup_variables($errors, $is_admmod) { $post = array(); if (!$this->user->is_guest) { $post['username'] = $this->user->username; $post['email'] = $this->user->email; } else { $post['username'] = feather_trim($this->request->post('req_username')); $post['email'] = strtolower(feather_trim($this->config['p_force_guest_email'] == '1' ? $this->request->post('req_email') : $this->request->post('email'))); } if ($this->request->post('req_subject')) { $post['subject'] = feather_trim($this->request->post('req_subject')); } $post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0'; $post['subscribe'] = $this->request->post('subscribe') ? '1' : '0'; $post['stick_topic'] = $this->request->post('stick_topic') && $is_admmod ? '1' : '0'; $post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message'))); // Validate BBCode syntax if ($this->config['p_message_bbcode'] == '1') { require_once FEATHER_ROOT . 'include/parser.php'; $post['message'] = preparse_bbcode($post['message'], $errors); } // Replace four-byte characters (MySQL cannot handle them) $post['message'] = strip_bad_multibyte_chars($post['message']); $post['time'] = time(); return $post; }
public function setup_variables($cur_post, $is_admmod, $can_edit_subject, $errors) { global $pd; $post = array(); $post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0'; $post['stick_topic'] = $this->request->post('stick_topic') ? '1' : '0'; if (!$is_admmod) { $post['stick_topic'] = $cur_post['sticky']; } // Clean up message from POST $post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message'))); // Validate BBCode syntax if ($this->config['p_message_bbcode'] == '1') { require_once FEATHER_ROOT . 'include/parser.php'; $post['message'] = preparse_bbcode($post['message'], $errors); } // Replace four-byte characters (MySQL cannot handle them) $post['message'] = strip_bad_multibyte_chars($post['message']); // Get the subject if ($can_edit_subject) { $post['subject'] = feather_trim($this->request->post('req_subject')); } return $post; }
function startescrow_send_message($body, $subject, $receiver_username, $amount, &$message_id) { global $lang_escrows, $forum_user, $forum_db, $forum_url, $forum_config, $forum_flash; $errors = array(); $receiver_id = startescrow_get_receiver_id($receiver_username, $errors); if ($receiver_id == 'NULL' && empty($errors)) { $errors[] = $lang_escrows['Empty receiver']; } // Clean up body from POST $body = forum_linebreaks($body); if ($body == '') { $errors[] = $lang_escrows['Empty body']; } elseif (strlen($body) > FORUM_MAX_POSTSIZE_BYTES) { $errors[] = sprintf($lang_escrows['Too long message'], forum_number_format(strlen($body)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES)); } elseif ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($body) == $body && !$forum_page['is_admmod']) { $body = utf8_ucwords(utf8_strtolower($body)); } // Validate BBCode syntax if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') { global $smilies; if (!defined('FORUM_PARSER_LOADED')) { require FORUM_ROOT . 'include/parser.php'; } $body = preparse_bbcode($body, $errors); } // Sending message to the buyer $btcaddress = get_free_btcaddress($errors); //book the address if (count($errors)) { return $errors; } $now = time(); // Send new message // Save to DB $query = array('INSERT' => 'sender_id, receiver_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\''); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $endtime = $now + $forum_config['o_empty_escrow_duration'] * 3600; $endtime = date('Y-m-d H:i:s ', $endtime); // Send message to the buyer $body = sprintf($lang_escrows['Escrow buyer message'], $endtime, $amount, $btcaddress); // Save to DB $query = array('INSERT' => 'receiver_id, sender_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\''); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); // ########### Add to escrows table $query = array('INSERT' => 'time, buyerid, sellerid, amount, subject, status, recivedtime, btcaddress', 'INTO' => 'escrows', 'VALUES' => $now . ', ' . $forum_user['id'] . ', ' . $receiver_id . ', ' . $amount . ', \'' . $forum_db->escape($subject) . '\', 0, 0, \'' . $btcaddress . '\''); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); startescrow_clear_cache($receiver_id); // Clear cached 'New messages' in the user table $forum_flash->add_info($lang_escrows['Escrow started']); redirect(forum_link($forum_url['pun_pm_inbox']), $lang_escrows['Message sent']); }
public function update_profile($id, $info, $section) { global $lang_common, $lang_profile, $lang_prof_reg, $pd; $username_updated = false; // Validate input depending on section switch ($section) { case 'essentials': $form = array('timezone' => floatval($this->request->post('form_timezone')), 'dst' => $this->request->post('form_dst') ? '1' : '0', 'time_format' => intval($this->request->post('form_time_format')), 'date_format' => intval($this->request->post('form_date_format'))); // Make sure we got a valid language string if ($this->request->post('form_language')) { $languages = forum_list_langs(); $form['language'] = feather_trim($this->request->post('form_language')); if (!in_array($form['language'], $languages)) { message($lang_common['Bad request'], '404'); } } if ($this->user->is_admmod) { $form['admin_note'] = feather_trim($this->request->post('admin_note')); // Are we allowed to change usernames? if ($this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && $this->user->g_mod_rename_users == '1') { $form['username'] = feather_trim($this->request->post('req_username')); if ($form['username'] != $info['old_username']) { // Check username require FEATHER_ROOT . 'lang/' . $this->user->language . '/register.php'; $errors = ''; $errors = check_username($form['username'], $errors, $id); if (!empty($errors)) { message($errors[0]); } $username_updated = true; } } // We only allow administrators to update the post count if ($this->user->g_id == FEATHER_ADMIN) { $form['num_posts'] = intval($this->request->post('num_posts')); } } if ($this->config['o_regs_verify'] == '0' || $this->user->is_admmod) { require FEATHER_ROOT . 'include/email.php'; // Validate the email address $form['email'] = strtolower(feather_trim($this->request->post('req_email'))); if (!is_valid_email($form['email'])) { message($lang_common['Invalid email']); } } break; case 'personal': $form = array('realname' => $this->request->post('form_realname') ? feather_trim($this->request->post('form_realname')) : '', 'url' => $this->request->post('form_url') ? feather_trim($this->request->post('form_url')) : '', 'location' => $this->request->post('form_location') ? feather_trim($this->request->post('form_location')) : ''); // Add http:// if the URL doesn't contain it already (while allowing https://, too) if ($this->user->g_post_links == '1') { if ($form['url'] != '') { $url = url_valid($form['url']); if ($url === false) { message($lang_profile['Invalid website URL']); } $form['url'] = $url['url']; } } else { if (!empty($form['url'])) { message($lang_profile['Website not allowed']); } $form['url'] = ''; } if ($this->user->g_id == FEATHER_ADMIN) { $form['title'] = feather_trim($this->request->post('title')); } elseif ($this->user->g_set_title == '1') { $form['title'] = feather_trim($this->request->post('title')); if ($form['title'] != '') { // A list of words that the title may not contain // If the language is English, there will be some duplicates, but it's not the end of the world $forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower($lang_common['Member']), utf8_strtolower($lang_common['Moderator']), utf8_strtolower($lang_common['Administrator']), utf8_strtolower($lang_common['Banned']), utf8_strtolower($lang_common['Guest'])); if (in_array(utf8_strtolower($form['title']), $forbidden)) { message($lang_profile['Forbidden title']); } } } break; case 'messaging': $form = array('jabber' => feather_trim($this->request->post('form_jabber')), 'icq' => feather_trim($this->request->post('form_icq')), 'msn' => feather_trim($this->request->post('form_msn')), 'aim' => feather_trim($this->request->post('form_aim')), 'yahoo' => feather_trim($this->request->post('form_yahoo'))); // If the ICQ UIN contains anything other than digits it's invalid if (preg_match('%[^0-9]%', $form['icq'])) { message($lang_prof_reg['Bad ICQ']); } break; case 'personality': $form = array(); // Clean up signature from POST if ($this->config['o_signatures'] == '1') { $form['signature'] = feather_linebreaks(feather_trim($this->request->post('signature'))); // Validate signature if (feather_strlen($form['signature']) > $this->config['p_sig_length']) { message(sprintf($lang_prof_reg['Sig too long'], $this->config['p_sig_length'], feather_strlen($form['signature']) - $this->config['p_sig_length'])); } elseif (substr_count($form['signature'], "\n") > $this->config['p_sig_lines'] - 1) { message(sprintf($lang_prof_reg['Sig too many lines'], $this->config['p_sig_lines'])); } elseif ($form['signature'] && $this->config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$this->user->is_admmod) { $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature'])); } // Validate BBCode syntax if ($this->config['p_sig_bbcode'] == '1') { require FEATHER_ROOT . 'include/parser.php'; $errors = array(); $form['signature'] = preparse_bbcode($form['signature'], $errors, true); if (count($errors) > 0) { message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'); } } } break; case 'display': $form = array('disp_topics' => feather_trim($this->request->post('form_disp_topics')), 'disp_posts' => feather_trim($this->request->post('form_disp_posts')), 'show_smilies' => $this->request->post('form_show_smilies') ? '1' : '0', 'show_img' => $this->request->post('form_show_img') ? '1' : '0', 'show_img_sig' => $this->request->post('form_show_img_sig') ? '1' : '0', 'show_avatars' => $this->request->post('form_show_avatars') ? '1' : '0', 'show_sig' => $this->request->post('form_show_sig') ? '1' : '0'); if ($form['disp_topics'] != '') { $form['disp_topics'] = intval($form['disp_topics']); if ($form['disp_topics'] < 3) { $form['disp_topics'] = 3; } elseif ($form['disp_topics'] > 75) { $form['disp_topics'] = 75; } } if ($form['disp_posts'] != '') { $form['disp_posts'] = intval($form['disp_posts']); if ($form['disp_posts'] < 3) { $form['disp_posts'] = 3; } elseif ($form['disp_posts'] > 75) { $form['disp_posts'] = 75; } } // Make sure we got a valid style string if ($this->request->post('form_style')) { $styles = forum_list_styles(); $form['style'] = feather_trim($this->request->post('form_style')); if (!in_array($form['style'], $styles)) { message($lang_common['Bad request'], '404'); } } break; case 'privacy': $form = array('email_setting' => intval($this->request->post('form_email_setting')), 'notify_with_post' => $this->request->post('form_notify_with_post') ? '1' : '0', 'auto_notify' => $this->request->post('form_auto_notify') ? '1' : '0'); if ($form['email_setting'] < 0 || $form['email_setting'] > 2) { $form['email_setting'] = $this->config['o_default_email_setting']; } break; default: message($lang_common['Bad request'], '404'); } // Single quotes around non-empty values and nothing for empty values $temp = array(); foreach ($form as $key => $input) { $temp[$key] = $input; } if (empty($temp)) { message($lang_common['Bad request'], '404'); } DB::for_table('users')->where('id', $id)->find_one()->set($temp)->save(); // If we changed the username we have to update some stuff if ($username_updated) { $bans_updated = DB::for_table('bans')->where('username', $info['old_username'])->update_many('username', $form['username']); DB::for_table('posts')->where('poster_id', $id)->update_many('poster', $form['username']); DB::for_table('posts')->where('edited_by', $info['old_username'])->update_many('edited_by', $form['username']); DB::for_table('topics')->where('poster', $info['old_username'])->update_many('poster', $form['username']); DB::for_table('topics')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']); DB::for_table('forums')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']); DB::for_table('online')->where('ident', $info['old_username'])->update_many('ident', $form['username']); // If the user is a moderator or an administrator we have to update the moderator lists $group_id = DB::for_table('users')->where('id', $id)->find_one_col('group_id'); $group_mod = DB::for_table('groups')->where('g_id', $group_id)->find_one_col('g_moderator'); if ($group_id == FEATHER_ADMIN || $group_mod == '1') { $select_mods = array('id', 'moderators'); $result = DB::for_table('forums')->select_many($select_mods)->find_many(); foreach ($result as $cur_forum) { $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array(); if (in_array($id, $cur_moderators)) { unset($cur_moderators[$info['old_username']]); $cur_moderators[$form['username']] = $id; uksort($cur_moderators, 'utf8_strcasecmp'); DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set('moderators', serialize($cur_moderators))->save(); } } } // Regenerate the users info cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_users_info_cache(); // Check if the bans table was updated and regenerate the bans cache when needed if ($bans_updated) { generate_bans_cache(); } } redirect(get_link('user/' . $id . '/section/' . $section . '/'), $lang_profile['Profile redirect']); }