function forward_form($title = "", $text = "", $lang = "", $captchaHTML = '', $msg = '') { $IPBHTML = ""; if (IPSLib::locationHasHooks('skin_emails', $this->_funcHooks['forward_form'])) { $count_7c5bc7202e6623ca381ed344e9ec6db0 = is_array($this->functionData['forward_form']) ? count($this->functionData['forward_form']) : 0; $this->functionData['forward_form'][$count_7c5bc7202e6623ca381ed344e9ec6db0]['title'] = $title; $this->functionData['forward_form'][$count_7c5bc7202e6623ca381ed344e9ec6db0]['text'] = $text; $this->functionData['forward_form'][$count_7c5bc7202e6623ca381ed344e9ec6db0]['lang'] = $lang; $this->functionData['forward_form'][$count_7c5bc7202e6623ca381ed344e9ec6db0]['captchaHTML'] = $captchaHTML; $this->functionData['forward_form'][$count_7c5bc7202e6623ca381ed344e9ec6db0]['msg'] = $msg; } $IPBHTML .= "<form action=\"" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=forums&module=extras&section=forward", "public", ''), "", "") . "\" method=\"post\" name='REPLIER'>\n\t<input type=\"hidden\" name=\"do\" value=\"01\" />\n\t<input type=\"hidden\" name=\"st\" value=\"{$this->request['st']}\" />\n\t<input type=\"hidden\" name=\"f\" value=\"{$this->request['f']}\" />\n\t<input type=\"hidden\" name=\"t\" value=\"{$this->request['t']}\" />\n\t<input type=\"hidden\" name=\"url\" value=\"{$this->request['url']}\" />\n\t<input type=\"hidden\" name=\"title\" value=\"{$this->request['title']}\" />\n\t<input type='hidden' name='k' value='{$this->member->form_hash}' />\n\t" . ($msg ? "\n\t\t<p class='message error'>{$this->lang->words[$msg]}</p><br />\n\t" : "\n\t\t<p class='message'>{$this->lang->words['email_friend']}</p><br />\n\t") . "\n\t\n\t<h2 class='maintitle'>{$this->lang->words['title']}</h2>\n\t<div class='generic_bar'></div>\n\t<div class='ipsForm ipsForm_horizontal'>\n\t\t<fieldset>\n\t\t\t<h3 class='bar'>{$this->lang->words['email_recepient']}</h3>\n\t\t\t<ul class='ipsPad'>\n\t\t\t\t" . (count($this->caches['lang_data']) == 1 ? "\n\t\t\t\t\t<input type='hidden' name='lang' value='{$this->caches['lang_data'][0]['lang_id']}' />\n\t\t\t\t" : "\n\t\t\t\t\t<li class='ipsField clear'>\n\t\t\t\t\t\t<label for='to_lang' class='ipsField_title'>{$this->lang->words['send_lang']}</label>\n\t\t\t\t\t\t<p class='ipsField_content'>\n\t\t\t\t\t\t\t<select name='lang' class='input_select' id='to_lang'>\n\t\t\t\t\t\t\t\t" . $this->__f__51cb3b5822a1e12831217597c9a44779($title, $text, $lang, $captchaHTML, $msg) . "\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</li>\n\t\t\t\t") . "\n\t\t\t\t<li class='ipsField clear'>\n\t\t\t\t\t<label for='to_name' class='ipsField_title'>{$this->lang->words['to_name']}</label>\n\t\t\t\t\t<p class='ipsField_content'>\n\t\t\t\t\t\t<input type=\"text\" id='to_name' class='input_text' name=\"to_name\" value=\"{$this->request['to_name']}\" size=\"30\" maxlength=\"100\" />\n\t\t\t\t\t</p>\n\t\t\t\t</li>\n\t\t\t\t<li class='ipsField clear'>\n\t\t\t\t\t<label for='to_email' class='ipsField_title'>{$this->lang->words['to_email']}</label>\n\t\t\t\t\t<p class='ipsField_content'>\n\t\t\t\t\t\t<input type=\"text\" id='to_email' class='input_text' name=\"to_email\" value=\"{$this->request['to_email']}\" size=\"30\" maxlength=\"100\" />\n\t\t\t\t\t</p>\n\t\t\t\t</li>\n\t\t\t\t<li class='ipsField clear'> \n\t\t\t\t\t<label for='subject' class='ipsField_title'>{$this->lang->words['subject']}</label>\n\t\t\t\t\t<p class='ipsField_content'>\n\t\t\t\t\t\t<input type=\"text\" id=\"subject\" class=\"input_text\" name=\"subject\" value=\"" . ($this->request['subject'] ? "{$this->request['subject']}" : "{$title}") . "\" size=\"30\" maxlength=\"120\" />\n\t\t\t\t\t</p>\n\t\t\t\t</li> \t\t\t\t\n\t\t\t\t<li class='ipsField clear'>\n\t\t\t\t\t<label for='to_message' class='ipsField_title'>{$this->lang->words['message']}</label>\n\t\t\t\t\t<p class='ipsField_content'>\n\t\t\t\t\t\t<textarea id='to_message' cols=\"60\" rows=\"12\" wrap=\"soft\" name=\"message\" class=\"input_text\">" . ($this->request['message'] ? "" . IPSText::br2nl($this->request['message']) . "" : "{$text}") . "</textarea>\n\t\t\t\t\t</p>\n\t\t\t\t</li>\n\t\t\t\t" . ($captchaHTML ? "\n\t\t\t\t\t<li class='ipsField clear'>\n\t\t\t\t\t\t{$captchaHTML}\n\t\t\t\t\t</li>\n\t\t\t\t" : "") . "\n\t\t\t</ul>\n\t\t</fieldset>\n\t\t<fieldset class='submit'>\n\t\t\t<input class='input_submit' type=\"submit\" value=\"{$this->lang->words['submit_send']}\" />\n\t\t</fieldset>\n\t</div>\n</form>"; return $IPBHTML; }
/** * Ban filter overview screen * * @param array IPs * @param array Emails * @param array Usernames * @return string HTML */ public function banOverview($ips, $emails, $names) { $IPBHTML = ""; //--starthtml--// $canRemove = $this->registry->class_permissions->checkPermission('ban_remove'); /* Ban types */ $ban = array(); $ban['bantype'] = $this->registry->output->formDropdown('bantype', array(array('ip', $this->lang->words['ban_ip']), array('email', $this->lang->words['ban_email']), array('name', $this->lang->words['ban_name']))); $ban['bantext'] = $this->registry->output->formSimpleInput('bantext', '', 50); $ban['banreason'] = $this->registry->output->formSimpleInput('banreason', '', 50); /* Remove new lines from the type dropdown or JS won't be happy.. */ $ban['bantype'] = IPSText::br2nl($ban['bantype']); $IPBHTML .= <<<HTML <div class='section_title'> \t<h2>{$this->lang->words['ban_title']}</h2> \t<div class='ipsActionBar clearfix'> \t\t<ul> \t\t\t<li class='ipsActionButton'> \t\t\t\t<a href='#' id='add_banfilter' title='{$this->lang->words['ban_addnew']}'><img src='{$this->settings['skin_acp_url']}/images/icons/add.png' alt='' /> {$this->lang->words['ban_addnew']}</a> \t\t\t</li> \t\t</ul> \t</div> </div> <script tyle='text/javascript' src='{$this->settings['js_app_url']}acp.banfilters.js'></script> <form method='post' id='ban-delete' action='{$this->settings['base_url']}{$this->form_code}'> \t<input type='hidden' name='do' value='ban_delete' /> \t<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->_admin_auth_key}' /> \t<div class='acp-box'> \t\t<h3>{$this->lang->words['ban_bancontrol']}</h3> \t\t \t\t<div id='tabstrip_banForm' class='ipsTabBar with_left with_right'> \t\t\t<span class='tab_left'>«</span> \t\t\t<span class='tab_right'>»</span> \t\t\t<ul> \t\t\t\t<li id='tab_BanIps'>{$this->lang->words['ban_ips']}</li> \t\t\t\t<li id='tab_BanEmails'>{$this->lang->words['ban_emails']}</li> \t\t\t\t<li id='tab_BanNames'>{$this->lang->words['ban_names']}</li> \t\t\t</ul> \t\t</div> \t\t \t\t<div id='tabstrip_banForm_content' class='ipsTabBar_content'> \t\t\t \t\t\t<!-- IP ADDRESSES --> \t\t\t<div id='tab_BanIps_content'> \t\t\t\t<table class='ipsTable double_pad'> \t\t\t\t\t<tr> \t\t\t\t\t\t<th width='1%'> </th> \t\t\t\t\t\t<th width='15%'>{$this->lang->words['ban_ip']}</th> \t\t\t\t\t\t<th width='60%'>{$this->lang->words['ban_form_reason']}</th> \t\t\t\t\t\t<th width='24%'>{$this->lang->words['ban_added_on']}</th> \t\t\t\t\t</tr> HTML; if (is_array($ips) && count($ips)) { foreach ($ips as $r) { $checkbox = $canRemove ? "<input type='checkbox' name='banid_{$r['ban_id']}' value='1' />" : ''; $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$checkbox}</td> \t\t\t\t\t\t<td>{$r['ban_content']}</td> \t\t\t\t\t\t<td>{$r['ban_reason']}</td> \t\t\t\t\t\t<td>{$r['_date']}</td> \t\t\t\t\t</tr> HTML; } } else { $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td colspan='4'>{$this->lang->words['ban_ips_none']}</td> \t\t\t\t\t</tr> HTML; } $IPBHTML .= <<<HTML \t\t \t\t</table> \t\t\t</div> \t\t\t \t\t\t<!-- EMAIL ADDRESSES --> \t\t\t<div id='tab_BanEmails_content'> \t\t\t\t<table class='ipsTable double_pad'> \t\t\t\t\t<tr> \t\t\t\t\t\t<th width='1%'> </th> \t\t\t\t\t\t<th width='20%'>{$this->lang->words['ban_email']}</th> \t\t\t\t\t\t<th width='55%'>{$this->lang->words['ban_form_reason']}</th> \t\t\t\t\t\t<th width='24%'>{$this->lang->words['ban_added_on']}</th> \t\t\t\t\t</tr> HTML; if (is_array($emails) && count($emails)) { foreach ($emails as $r) { $checkbox = $canRemove ? "<input type='checkbox' name='banid_{$r['ban_id']}' value='1' />" : ''; $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$checkbox}</td> \t\t\t\t\t\t<td>{$r['ban_content']}</td> \t\t\t\t\t\t<td>{$r['ban_reason']}</td> \t\t\t\t\t\t<td>{$r['_date']}</td> \t\t\t\t\t</tr> HTML; } } else { $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td colspan='4'>{$this->lang->words['ban_emails_none']}</td> \t\t\t\t\t</tr> HTML; } $IPBHTML .= <<<HTML \t\t \t\t</table> \t\t\t</div> \t\t\t \t\t\t<!-- NAMES --> \t\t\t<div id='tab_BanNames_content'> \t\t\t\t<table class='ipsTable double_pad'> \t\t\t\t\t<tr> \t\t\t\t\t\t<th width='1%'> </th> \t\t\t\t\t\t<th width='15%'>{$this->lang->words['ban_name']}</th> \t\t\t\t\t\t<th width='60%'>{$this->lang->words['ban_form_reason']}</th> \t\t\t\t\t\t<th width='24%'>{$this->lang->words['ban_added_on']}</th> \t\t\t\t\t</tr> HTML; if (is_array($names) && count($names)) { foreach ($names as $r) { $checkbox = $canRemove ? "<input type='checkbox' name='banid_{$r['ban_id']}' value='1' />" : ''; $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$checkbox}</td> \t\t\t\t\t\t<td>{$r['ban_content']}</td> \t\t\t\t\t\t<td>{$r['ban_reason']}</td> \t\t\t\t\t\t<td>{$r['_date']}</td> \t\t\t\t\t</tr> HTML; } } else { $IPBHTML .= <<<HTML \t\t\t\t\t<tr> \t\t\t\t\t\t<td colspan='4'>{$this->lang->words['ban_names_none']}</td> \t\t\t\t\t</tr> HTML; } $IPBHTML .= <<<HTML \t\t \t\t</table> \t\t\t</div> \t\t\t \t\t\t<script type='text/javascript'> \t\t\t\tjQ("#tabstrip_banForm").ipsTabBar({ tabWrap: "#tabstrip_banForm_content" }); \t\t\t</script> \t\t</div> HTML; if ($canRemove) { $IPBHTML .= <<<HTML \t\t<div class='acp-actionbar'> \t\t\t<input type='submit' value='{$this->lang->words['ban_deletebutton']}' class='realbutton redbutton' /> \t\t</div> HTML; } $IPBHTML .= <<<HTML \t</div> </form> <script type='text/javascript'> \tipb.templates['add_banfilter'] = "<div class='acp-box'><h3>{$this->lang->words['ban_addnew']}</h3><form action='{$this->settings['base_url']}{$this->form_code}do=ban_add' method='post'><table class='ipsTable double_pad'><tr><td class='field_title' style='min-width:100px;'><strong class='title'>{$this->lang->words['ban_form_type']}</strong></td><td class='field_field'>{$ban['bantype']}</td></tr><tr><td class='field_title' style='min-width:100px;'><strong class='title'>{$this->lang->words['ban_form_filter']}</strong></td><td class='field_field'>{$ban['bantext']}<br /><span class='desctext'>{$this->lang->words['ban_form_filter_desc']}</span></td></tr><tr><td class='field_title' style='min-width:100px;'><strong class='title'>{$this->lang->words['ban_form_reason']}</strong></td><td class='field_field'>{$ban['banreason']}<br /><span class='desctext'>{$this->lang->words['ban_form_reason_desc']}</span></td></tr></table><div class='acp-actionbar'><input type='submit' value='{$this->lang->words['ban_addnew']}' class='button primary' /></div></form></div>"; </script> HTML; //--endhtml--// return $IPBHTML; }
public function databaseAddField($fieldInfo) { $_save = array('field_database_id' => $fieldInfo['field_database_id'], 'field_name' => trim($fieldInfo['field_name']), 'field_key' => md5(uniqid(microtime(), true)), 'field_description' => trim($fieldInfo['field_description']), 'field_type' => trim($fieldInfo['field_type']), 'field_required' => intval($fieldInfo['field_required']), 'field_user_editable' => intval($fieldInfo['field_user_editable']), 'field_max_length' => intval($fieldInfo['field_max_length']), 'field_extra' => IPSText::br2nl(trim($fieldInfo['field_extra'])), 'field_html' => intval($fieldInfo['field_html']), 'field_is_numeric' => intval($fieldInfo['field_is_numeric']), 'field_truncate' => intval($fieldInfo['field_truncate']), 'field_default_value' => $fieldInfo['field_default_value'], 'field_display_listing' => intval($fieldInfo['field_display_listing']), 'field_display_display' => intval($fieldInfo['field_display_display']), 'field_format_opts' => is_array($fieldInfo['field_format_opts']) && count($fieldInfo['field_format_opts']) ? implode(',', $fieldInfo['field_format_opts']) : ''); //----------------------------------------- // Get possible field types //----------------------------------------- require_once IPSLib::getAppDir('ccs') . '/sources/databases/fields.php'; $fields = new ccs_database_fields($this->registry); $types = $fields->getTypes(); //----------------------------------------- // Validator //----------------------------------------- $validators = $fields->getValidators(); if ($fieldInfo['field_validator'] != 'none') { if (array_key_exists($fieldInfo['field_validator'], $validators)) { if ($fieldInfo['field_validator'] == 'custom') { $_save['field_validator'] = $fieldInfo['field_validator'] . ';_;' . str_replace('\', '\\', $fieldInfo['field_validator_custom']) . ';_;' . $fieldInfo['field_validator_error']; } else { $_save['field_validator'] = $fieldInfo['field_validator']; } } } else { $_save['field_validator'] = ''; } //----------------------------------------- // Verify field type //----------------------------------------- $_isOk = false; foreach ($types as $_type) { if ($_type[0] == $_save['field_type']) { $_isOk = true; $_save = $fields->preSaveField($_save); break; } } if (!$_isOk) { $this->registry->output->showError($this->lang->words['field_type_invalid'], '11CCS52'); } //----------------------------------------- // Check key //----------------------------------------- $_key = $this->DB->buildAndFetch(array('select' => 'field_id', 'from' => 'ccs_database_fields', 'where' => "field_database_id={$_save['field_database_id']} AND field_key='{$_save['field_key']}'")); if ($_key['field_id']) { //$this->registry->output->showError( $this->lang->words['field_key_in_use'] ); $_save['field_key'] = md5(uniqid(microtime(), true)); } //----------------------------------------- // Set position //----------------------------------------- $max = $this->DB->buildAndFetch(array('select' => 'MAX(field_position) as position', 'from' => 'ccs_database_fields', 'where' => "field_database_id={$_save['field_database_id']}")); $_save['field_position'] = $max['position'] + 1; $this->DB->insert('ccs_database_fields', $_save); $id = $this->DB->getInsertId(); //----------------------------------------- // Add field to db //----------------------------------------- $this->DB->addField('ccs_custom_database_' . $fieldInfo['field_database_id'], 'field_' . $id, 'TEXT'); //----------------------------------------- // Update database //----------------------------------------- $this->DB->update('ccs_databases', array('database_field_count' => 'database_field_count+1'), 'database_id=' . $fieldInfo['field_database_id']); $this->rebuildFieldCache(); }
/** * CKEditor will send posts with HTML entites (<). If we have HTML enabled * we need to make sure that these HTML entites are converted back into HTML * and that <br> tags are converted into newlines * @param string $conten. */ protected function _htmlize($content) { return $content; $content = IPSText::br2nl($content); $content = IPSText::UNhtmlspecialchars($content); }
function warnForm($member, $errors = '', $modque = false, $postque = false, $ban = false, $editor_html = '') { $IPBHTML = ""; if (IPSLib::locationHasHooks('skin_modcp', $this->_funcHooks['warnForm'])) { $count_571a68c2d8894723c2cc2d545530e8e6 = is_array($this->functionData['warnForm']) ? count($this->functionData['warnForm']) : 0; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['member'] = $member; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['errors'] = $errors; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['modque'] = $modque; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['postque'] = $postque; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['ban'] = $ban; $this->functionData['warnForm'][$count_571a68c2d8894723c2cc2d545530e8e6]['editor_html'] = $editor_html; } $mod_arr = array('timespan' => 0, 'days' => 0, 'hours' => 0); $mhours = 0; if ($member['mod_posts'] > 0 and $member['mod_posts'] != 1) { $mod_arr = IPSMember::processBanEntry($member['mod_posts']); if ($mod_arr['date_end'] > time()) { $mhours = ceil(($mod_arr['date_end'] - time()) / 3600); } } $post_arr = array('timespan' => 0, 'hours' => 0, 'days' => 0); $phours = 0; if ($member['restrict_post'] > 0 and $member['restrict_post'] != 1) { $post_arr = IPSMember::processBanEntry($member['restrict_post']); if ($post_arr['date_end'] > time()) { $phours = ceil(($post_arr['date_end'] - time()) / 3600); } } $ban_arr = array('timespan' => 0, 'days' => 0, 'hours' => 0); $hours = 0; if ($member['temp_ban'] and $member['temp_ban'] != 1) { $ban_arr = IPSMember::processBanEntry($member['temp_ban']); if ($ban_arr['date_end'] > time()) { $hours = ceil(($ban_arr['date_end'] - time()) / 3600); } } $IPBHTML .= "" . $this->registry->getClass('output')->addJSModule("profile", "0") . "\n<script type='text/javascript'>\n\tipb.profile.viewingProfile = {$member['member_id']};\n</script>\n" . ($errors ? "\n\t<h2>{$this->lang->words['errors_found']}</h2>\n\t<p class='message error'>{$errors}</p>\n\t<br />\n" : "") . "\n<form method=\"post\" action='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&module=modcp&section=editmember&do=dowarn&mid={$member['member_id']}", "public", ''), "", "") . "' id='postingform'>\n<input type=\"hidden\" name=\"key\" value=\"{$this->member->form_hash}\" />\n<input type=\"hidden\" name=\"type\" value=\"{$this->request['type']}\" />\n<input type=\"hidden\" name=\"_st\" value=\"{$this->request['_st']}\" />\n<input type=\"hidden\" name=\"t\" value=\"{$this->request['t']}\" />\n<input type=\"hidden\" name=\"pf\" value=\"{$this->request['pf']}\" />\n<div class='post_form'>\n<h2 class='ipsType_subtitle'>{$this->lang->words['warn_logs_for']} <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("showuser={$member['member_id']}", "public", ''), "{$member['members_seo_name']}", "showuser") . "' title='{$this->lang->words['view_profile']}'>{$member['members_display_name']}</a></h2>\n<div class='generic_bar'></div>\n<div class='general_box'>\n<fieldset class='with_subhead'>\n\t<h3 class='bar noTopBorder'>{$this->lang->words['warn_member_details']}</h3>\n\t<h4>\n\t\t<img class=\"ipsUserPhoto ipsUserPhoto_large\" src='{$member['pp_thumb_photo']}' alt=\"" . sprintf($this->lang->words['users_photo'], $member['members_display_name']) . "\" />\n\t</h4>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t" . $this->registry->getClass('output')->getReplacement("find_topics_link") . " <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&module=search&do=user_activity&mid={$member['member_id']}", "public", ''), "", "") . "'>{$this->lang->words['gbl_find_my_content']}</a>\n\t\t</li>\n\t\t" . ($this->memberData['g_mem_info'] && $this->settings['auth_allow_dnames'] ? "\n\t\t\t<li class='field' id='dname_history'>\n\t\t\t\t" . $this->registry->getClass('output')->getReplacement("display_name") . " <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&module=profile&section=dname&id={$member['member_id']}", "public", ''), "", "") . "' title='{$this->lang->words['view_dname_history']}'>{$this->lang->words['display_history']}</a>\n\t\t\t</li>\n\t\t" : "") . "\n\t\t" . ($this->settings['reputation_enabled'] ? "<li class='field'>\n\t\t\t\t" . ($member['pp_reputation_points'] > 0 ? "\n\t\t\t\t\t<div class='reputation positive' style='min-width: 150px; text-align: center'>\n\t\t\t\t" : "") . "\n\t\t\t\t" . ($member['pp_reputation_points'] < 0 ? "\n\t\t\t\t\t<div class='reputation negative' style='min-width: 150px; text-align: center'>\n\t\t\t\t" : "") . "\n\t\t\t\t" . ($member['pp_reputation_points'] == 0 ? "\n\t\t\t\t\t<div class='reputation zero' style='min-width: 150px; text-align: center'>\n\t\t\t\t" : "") . "\n\t\t\t\t\t<span class='number'>{$member['pp_reputation_points']}</span>\n\t\t\t\t\t" . ($member['author_reputation'] && $member['author_reputation']['text'] ? "\n\t\t\t\t\t\t<p class='title'>{$member['author_reputation']['text']}</p>\n\t\t\t\t\t" : "") . "\n\t\t\t\t\t" . ($member['author_reputation'] && $member['author_reputation']['image'] ? "\n\t\t\t\t\t\t<p class='image'>{$member['author_reputation']['image']}</p>\n\t\t\t\t\t" : "") . "\n\t\t\t\t</div>\n\t\t\t</li>" : "") . "\n\t</ul>\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['warn_details']}</h3>\n\t<h4>{$this->lang->words['w_adjust_level']}<br /><span class='desc'>{$this->lang->words['warn_current_level']} {$member['warn_level']}/{$this->settings['warn_max']}</span></h4>\n\t<ul>\n <li class='field checkbox'>\n <input type=\"radio\" name=\"level\" id=\"nochange\" class=\"input_radio\" value=\"nochange\" " . (($this->request['type'] == 'nochange' or !$this->request['type']) ? "checked='checked'" : "") . " />\n <label for='nochange'>{$this->lang->words['w_nochange']}</label>\n </li>\n\t\t<li class='field checkbox negative'>\n\t\t\t<input type=\"radio\" name=\"level\" id=\"add\" class=\"input_radio\" value=\"add\" " . ($this->request['type'] == 'add' ? "checked='checked'" : "") . " />\n\t\t\t<label for='add'>{$this->lang->words['w_add']}</label>\n\t\t</li>\n\t\t<li class='field checkbox positive'>\n\t\t\t<input type=\"radio\" name=\"level\" id=\"minus\" class=\"input_radio\" value=\"remove\" " . ($this->request['type'] == 'minus' ? "checked='checked'" : "") . " />\n\t\t\t<label for='minus'>{$this->lang->words['w_remove']}</label>\n\t\t</li>\t\n\t\t" . ($this->memberData['g_is_supmod'] ? "<li class='field checkbox custom'>\n\t\t\t\t<input type=\"radio\" name=\"level\" id=\"custom\" class=\"input_radio\" value=\"custom\" " . ($this->request['type'] == 'custom' ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='level_custom'>" . sprintf($this->lang->words['w_change_custom'], $this->settings['warn_max']) . "</label>\n\t\t\t\t <input type='text' id='level_custom' name='level_custom' value='" . (isset($this->request['customLevel']) ? "{$this->request['customLevel']}" : "{$member['warn_level']}") . "' size='3' />\n\t\t\t</li>" : "") . "\n\t</ul>\n\t<h4>{$this->lang->words['w_reason']}<br /><span class='desc'>{$this->lang->words['w_reason2']}</span></h4>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t<textarea rows=\"6\" cols=\"50\" class=\"input_text\" name=\"reason\">" . IPSText::br2nl($this->request['reason']) . "</textarea>\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['member_suspension']}</h3>\n\t" . ($modque == true ? "\t\t<h4>{$this->lang->words['w_modq']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='modq' type=\"checkbox\" name=\"mod_indef\" value=\"1\" " . ($member['mod_posts'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='modq'>{$this->lang->words['w_modq_i']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='mod_value'>{$this->lang->words['w_orfor']}</label>\n\t\t\t\t<input class='input_text' type=\"text\" id='mod_value' name=\"mod_value\" value=\"" . (($mhours >= 24 and $mhours / 24 == ceil($mhours / 24) and $timespan = $mhours / 24) ? "{$timespan}" : "{$mhours}") . "\" size=\"5\" /> \n\t\t\t\t<select name=\"mod_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($mhours >= 24 and $mhours / 24 == ceil($mhours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($mhours < 24 or $mhours / 24 != ceil($mhours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($mhours > 0 ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n\t" . ($postque == true ? "\t\t<h4>{$this->lang->words['w_resposts']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='restrict_posts' type=\"checkbox\" name=\"post_indef\" value=\"1\" " . ($member['restrict_post'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='restrict_posts'>{$this->lang->words['w_resposts_i']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='post_value'>{$this->lang->words['w_orfor']}</label>\n\t\t\t\t<input class='input_text' type=\"text\" id='post_value' name=\"post_value\" value=\"" . (($phours >= 24 and $phours / 24 == ceil($phours / 24) and $timespan = $phours / 24) ? "{$timespan}" : "{$phours}") . "\" size=\"5\" /> \n\t\t\t\t<select name=\"post_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($phours >= 24 and $phours / 24 == ceil($phours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($phours < 24 or $phours / 24 != ceil($phours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($phours > 0 ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n\t" . ($ban == true ? "\t\t<h4>{$this->lang->words['w_suspend']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='suspend_member' type=\"checkbox\" name=\"ban_indef\" value=\"1\" " . ($member['member_banned'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='suspend_member'>{$this->lang->words['w_ban_indef']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='susp_value'>{$this->lang->words['w_suspend_or']}</label>\n\t\t\t\t<input type=\"text\" id='susp_value' class='input_text' name=\"susp_value\" value=\"" . (($hours >= 24 and $hours / 24 == ceil($hours / 24) and $timespan = $hours / 24) ? "{$timespan}" : "{$hours}") . "\" size=\"5\" />\n\t\t\t\t<select name=\"susp_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($hours >= 24 and $hours / 24 == ceil($hours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($hours < 24 or $hours / 24 != ceil($hours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($member['temp_ban'] ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['warn_mem_content']}</h3>\n\t<h4>{$this->lang->words['warn_posts_topics']}</h4>\n\t<ul>\n\t\t<li class='field checkbox'>\n\t\t\t<select name=\"topicPosts_type\" class='input_select'>\n\t\t\t\t<option value='unapprove' " . ($this->request['topicPosts_type'] == 'unapprove' ? "selected='selected'" : "") . ">{$this->lang->words['warn_stuff_unapprove']}</option>\n\t\t\t\t<option value='approve' " . ($this->request['topicPosts_type'] == 'approve' ? "selected='selected'" : "") . ">{$this->lang->words['warn_stuff_approve']}</option>\n\t\t\t</select>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<input type=\"checkbox\" id='topicPosts_topics' class='input_check' name=\"topicPosts_topics\" value=\"1\" />\n\t\t\t<label for='topicPosts_topics'>{$this->lang->words['warn_stuff_alltopics']}</label>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<input type=\"checkbox\" id='topicPosts_replies' class='input_check' name=\"topicPosts_replies\" value=\"1\" />\n\t\t\t<label for='topicPosts_replies'>{$this->lang->words['warn_stuff_allposts']}</label>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<label for='topicPosts_lastx'>{$this->lang->words['warn_stuff_datecutoff']}</label>\n\t\t\t<input type=\"text\" id='topicPosts_lastx' class='input_text' name=\"topicPosts_lastx\" value=\"\" size=\"5\" />\n\t\t\t<select name=\"topicPosts_lastxunits\" class='input_select'>\n\t\t\t\t<option value=\"d\">{$this->lang->words['w_day']}</option>\n\t\t\t\t<option value=\"h\">{$this->lang->words['w_hour']}</option>\n\t\t\t</select>\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset>\n\t<h3 class='bar'>{$this->lang->words['warn_contact_member']}</h3>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t<label for='subj'>{$this->lang->words['w_c_subj']}</label>\n\t\t\t<input id='subj' class='input_text' type=\"text\" name=\"subject\" value=\"{$this->request['subject']}\" size=\"30\" />\n\t\t</li>\n\t\t<li class='field'>\n\t\t\t<label for='method'>{$this->lang->words['w_c']}</label>\n\t\t\t<select id='method' name=\"contactmethod\" class='input_select'>\n\t\t\t\t" . ($member['members_disable_pm'] != 1 ? "\n\t\t\t\t\t<option value=\"pm\">{$this->lang->words['w_c_p']}</option>\n\t\t\t\t" : "") . "\n\t\t\t\t<option value=\"email\">{$this->lang->words['w_c_e']}</option>\n\t\t\t</select>\n\t\t</li>\n\t\t<li class='ipsPad'>\n\t\t\t{$editor_html}\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset class='submit'>\n\t<input type=\"submit\" class='input_submit' value=\"{$this->lang->words['w_submit']}\" tabindex='0'/>\n</fieldset>\n</div>\n</div>\n</form>"; return $IPBHTML; }
/** * Recieves comment, submits to database, and redirects user * * @access private * @return void */ private function _saveComment() { //----------------------------------------- // Make sure we have a report id... //----------------------------------------- $rid = intval($this->request['rid']); if ($rid < 1) { $this->registry->output->showError('reports_no_comment', 10139); } //----------------------------------------- // Lets make sure we even have this report //----------------------------------------- $report = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . $rid)); if ($report['id']) { $postContent = IPSText::getTextClass('editor')->processRawPost($_POST['comment']); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_emoticons = 1; IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parsing_section = 'reports'; $postContent = IPSText::getTextClass('bbcode')->preDbParse($postContent); if (!trim(IPSText::br2nl($postContent))) { $this->registry->output->showError('reports_no_comment_text', 10188); } $build_comment = array('rid' => $rid, 'comment' => $postContent, 'comment_by' => $this->memberData['member_id'], 'comment_date' => time()); $this->DB->insert('rc_comments', $build_comment); $this->DB->update('rc_reports_index', array('num_comments' => $report['num_comments'] + 1, 'date_updated' => time()), "id=" . $report['id']); } $this->registry->output->redirectScreen($this->lang->words['report_comment_saved'], $this->settings['base_url'] . "app=core&module=reports&rid={$report['id']}&do=show_report"); }
/** * 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()); }
/** * Show the form to edit a forum * * @param string [new|edit] * @param boolean Whether to change forum to category/back * @return @e void Outputs to screen */ public function forumForm($type = 'edit', $changetype = 0) { //----------------------------------------- // INIT //----------------------------------------- $addnew_type = isset($this->request['type']) ? $this->request['type'] : 'forum'; $form = array(); $forum = array(); $forum_id = $this->request['f'] ? intval($this->request['f']) : 0; $parentid = intval($this->request['p']) ? intval($this->request['p']) : -1; $cat_id = $this->request['c'] ? intval($this->request['c']) : 0; $f_name = $this->request['name'] ? $this->request['name'] : ''; $subcanpost = $cat_id == 1 ? 0 : 1; $perm_matrix = ""; $dd_state = array(0 => array(1, $this->lang->words['for_active']), 1 => array(0, $this->lang->words['for_readonly'])); $dd_moderate = array(0 => array(0, $this->lang->words['for_no']), 1 => array(1, $this->lang->words['for_modall']), 2 => array(2, $this->lang->words['for_modtop']), 3 => array(3, $this->lang->words['for_modrep'])); $dd_prune = array(0 => array(1, $this->lang->words['for_today']), 1 => array(5, $this->lang->words['for_last5']), 2 => array(7, $this->lang->words['for_last7']), 3 => array(10, $this->lang->words['for_last10']), 4 => array(15, $this->lang->words['for_last15']), 5 => array(20, $this->lang->words['for_last20']), 6 => array(25, $this->lang->words['for_last25']), 7 => array(30, $this->lang->words['for_last30']), 8 => array(60, $this->lang->words['for_last60']), 9 => array(90, $this->lang->words['for_last90']), 10 => array(100, $this->lang->words['for_showall'])); $dd_order = array(0 => array('last_post', $this->lang->words['for_s_last']), 1 => array('title', $this->lang->words['for_s_topic']), 2 => array('starter_name', $this->lang->words['for_s_name']), 3 => array('posts', $this->lang->words['for_s_post']), 4 => array('views', $this->lang->words['for_s_view']), 5 => array('start_date', $this->lang->words['for_s_date']), 6 => array('last_poster_name', $this->lang->words['for_s_poster'])); $dd_by = array(0 => array('Z-A', $this->lang->words['for_desc']), 1 => array('A-Z', $this->lang->words['for_asc'])); $dd_filter = array(0 => array('all', $this->lang->words['for_all']), 1 => array('open', $this->lang->words['for_open']), 2 => array('hot', $this->lang->words['for_hot']), 3 => array('poll', $this->lang->words['for_poll']), 4 => array('locked', $this->lang->words['for_locked']), 5 => array('moved', $this->lang->words['for_moved']), 6 => array('istarted', $this->lang->words['for_istarted']), 7 => array('ireplied', $this->lang->words['for_ireplied'])); //----------------------------------------- // EDIT //----------------------------------------- if ($type == 'edit' or $this->request['duplicate']) { //----------------------------------------- // Check //----------------------------------------- if (!$forum_id) { $this->registry->output->showError($this->lang->words['for_noforumselected'], 11314); } //----------------------------------------- // Do not show forum in forum list //----------------------------------------- $this->registry->getClass('class_forums')->exclude_from_list = $forum_id; //----------------------------------------- // Get this forum //----------------------------------------- $forum = $this->registry->class_forums->getForumById($forum_id); //----------------------------------------- // Check //----------------------------------------- if (!$forum['id']) { $this->registry->output->showError($this->lang->words['for_noid'], 11315); } //----------------------------------------- // Set up code buttons //----------------------------------------- $addnew_type = $forum['parent_id'] == -1 ? 'category' : 'forum'; if ($changetype) { $addnew_type = $addnew_type == 'category' ? 'forum' : 'category'; } if ($addnew_type == 'category') { $title = sprintf($this->lang->words['for_editcat'], $forum['name']); $button = $this->lang->words['for_editcat_button']; $code = "doedit"; } else { $title = sprintf($this->lang->words['for_editfor'], $forum['name']); $button = $this->lang->words['for_editfor_button']; $code = "doedit"; } //----------------------------------------- // Duplicating? //----------------------------------------- if ($this->request['duplicate']) { $forum['id'] = 0; $this->request['f'] = 0; $code = 'donew'; } } else { # Ensure there is an ID $this->request['f'] = 0; if ($changetype) { $addnew_type = $addnew_type == 'category' ? 'forum' : 'category'; } if ($addnew_type == 'category') { $forum = array('sub_can_post' => $subcanpost, 'name' => $f_name ? $f_name : $this->lang->words['for_newcat'], 'parent_id' => $parentid, 'use_ibc' => 1, 'allow_poll' => 1, 'prune' => 100, 'topicfilter' => 'all', 'sort_key' => 'last_post', 'sort_order' => 'Z-A', 'inc_postcount' => 1, 'description' => '', 'redirect_url' => '', 'password' => '', 'password_override' => '', 'redirect_on' => 0, 'redirect_hits' => 0, 'permission_showtopic' => '', 'permission_custom_error' => '', 'use_html' => 0, 'allow_pollbump' => 0, 'forum_allow_rating' => 0, 'preview_posts' => 0, 'notify_modq_emails' => 0, 'can_view_others' => 1); $title = $this->lang->words['for_addcat']; $button = $this->lang->words['for_addcat']; $code = "donew"; } else { $forum = array('sub_can_post' => $subcanpost, 'name' => $f_name ? $f_name : $this->lang->words['for_newfor'], 'parent_id' => $parentid, 'use_ibc' => 1, 'allow_poll' => 1, 'prune' => 100, 'topicfilter' => 'all', 'sort_key' => 'last_post', 'sort_order' => 'Z-A', 'inc_postcount' => 1, 'description' => '', 'redirect_url' => '', 'password' => '', 'password_override' => '', 'redirect_on' => 0, 'redirect_hits' => 0, 'permission_showtopic' => '', 'permission_custom_error' => '', 'use_html' => 0, 'allow_pollbump' => 0, 'forum_allow_rating' => 0, 'preview_posts' => 0, 'notify_modq_emails' => 0, 'min_posts' => 0, 'hide_last_info' => 0, 'can_view_others' => 1); $title = $this->lang->words['for_addfor']; $button = $this->lang->words['for_addfor']; $code = "donew"; } } //----------------------------------------- // Build forumlist //----------------------------------------- $forumlist = $this->registry->getClass('class_forums')->adForumsForumList(); //----------------------------------------- // Build group list //----------------------------------------- $mem_group = array(); foreach ($this->caches['group_cache'] as $g_id => $group) { $mem_group[] = array($g_id, $group['g_title']); } //----------------------------------------- // Generate form items //----------------------------------------- # Main settings $form['name'] = $this->registry->output->formInput('name', IPSText::parseCleanValue(!empty($_POST['name']) ? $_POST['name'] : $forum['name']), null, null, null, "maxlength='128'"); $form['description'] = $this->registry->output->formTextarea("description", IPSText::br2nl(!empty($_POST['description']) ? $_POST['description'] : $forum['description'])); $form['parent_id'] = $this->registry->output->formDropdown("parent_id", $forumlist, !empty($_POST['parent_id']) ? $_POST['parent_id'] : $forum['parent_id']); $form['sub_can_post'] = $this->registry->output->formYesNo('sub_can_post', !empty($_POST['sub_can_post']) ? $_POST['sub_can_post'] : ($forum['sub_can_post'] == 1 ? 0 : 1)); $form['ipseo_priority'] = $this->registry->getClass('output')->formDropdown('ipseo_priority', array(array('1', '1'), array('0.9', '0.9'), array('0.8', '0.8'), array('0.7', '0.7'), array('0.6', '0.6'), array('0.5', '0.5'), array('0.4', '0.4'), array('0.3', '0.3'), array('0.2', '0.2'), array('0.1', '0.1'), array('0', $this->lang->words['sitemap_priority_ignore']), array('', $this->lang->words['sitemap_priority_inherit'])), $forum['ipseo_priority'] === '' ? 0 : $forum['ipseo_priority']); $form['viglink'] = $this->registry->output->formYesNo('viglink', !empty($_POST['viglink']) ? $_POST['viglink'] : $forum['viglink']); # Redirect options $form['redirect_url'] = $this->registry->output->formInput('redirect_url', !empty($_POST['redirect_url']) ? $_POST['redirect_url'] : $forum['redirect_url']); $form['redirect_on'] = $this->registry->output->formYesNo('redirect_on', !empty($_POST['redirect_on']) ? $_POST['redirect_on'] : $forum['redirect_on']); $form['redirect_hits'] = $this->registry->output->formInput('redirect_hits', !empty($_POST['redirect_hits']) ? $_POST['redirect_hits'] : $forum['redirect_hits']); # Answer system $form['bw_enable_answers'] = $this->registry->output->formYesNo('bw_enable_answers', !empty($_POST['bw_enable_answers']) ? $_POST['bw_enable_answers'] : $forum['bw_enable_answers']); # Permission settings $form['permission_showtopic'] = $this->registry->output->formYesNo('permission_showtopic', !empty($_POST['permission_showtopic']) ? $_POST['permission_showtopic'] : $forum['permission_showtopic']); $form['permission_custom_error'] = $this->registry->output->formTextarea("permission_custom_error", IPSText::br2nl(!empty($_POST['permission_custom_error']) ? $_POST['permission_custom_error'] : $forum['permission_custom_error'])); # Forum settings $form['use_html'] = $this->registry->output->formYesNo('use_html', !empty($_POST['use_html']) ? $_POST['use_html'] : $forum['use_html']); $form['use_ibc'] = $this->registry->output->formYesNo('use_ibc', !empty($_POST['use_ibc']) ? $_POST['use_ibc'] : $forum['use_ibc']); $form['allow_poll'] = $this->registry->output->formYesNo('allow_poll', !empty($_POST['allow_poll']) ? $_POST['allow_poll'] : $forum['allow_poll']); $form['allow_pollbump'] = $this->registry->output->formYesNo('allow_pollbump', !empty($_POST['allow_pollbump']) ? $_POST['allow_pollbump'] : $forum['allow_pollbump']); $form['inc_postcount'] = $this->registry->output->formYesNo('inc_postcount', !empty($_POST['inc_postcount']) ? $_POST['inc_postcount'] : $forum['inc_postcount']); $form['forum_allow_rating'] = $this->registry->output->formYesNo('forum_allow_rating', !empty($_POST['forum_allow_rating']) ? $_POST['forum_allow_rating'] : $forum['forum_allow_rating']); $form['min_posts_post'] = $this->registry->output->formInput('min_posts_post', !empty($_POST['min_posts_post']) ? $_POST['min_posts_post'] : $forum['min_posts_post']); $form['min_posts_view'] = $this->registry->output->formInput('min_posts_view', !empty($_POST['min_posts_view']) ? $_POST['min_posts_view'] : $forum['min_posts_view']); $form['can_view_others'] = $this->registry->output->formYesNo('can_view_others', !empty($_POST['can_view_others']) ? $_POST['can_view_others'] : $forum['can_view_others']); $form['hide_last_info'] = $this->registry->output->formYesNo('hide_last_info', !empty($_POST['hide_last_info']) ? $_POST['hide_last_info'] : $forum['hide_last_info']); $form['disable_sharelinks'] = $this->registry->output->formYesNo('disable_sharelinks', !empty($_POST['disable_sharelinks']) ? $_POST['disable_sharelinks'] : $forum['disable_sharelinks']); # Mod settings $form['preview_posts'] = $this->registry->output->formDropdown("preview_posts", $dd_moderate, !empty($_POST['preview_posts']) ? $_POST['preview_posts'] : $forum['preview_posts']); $form['notify_modq_emails'] = $this->registry->output->formInput('notify_modq_emails', !empty($_POST['notify_modq_emails']) ? $_POST['notify_modq_emails'] : $forum['notify_modq_emails']); $form['password'] = $this->registry->output->formInput('password', !empty($_POST['password']) ? $_POST['password'] : $forum['password']); $form['password_override'] = $this->registry->output->formMultiDropdown('password_override[]', $mem_group, !empty($_POST['password_override']) ? $_POST['password_override'] : explode(",", $forum['password_override'])); # Sorting settings $form['prune'] = $this->registry->output->formDropdown("prune", $dd_prune, !empty($_POST['prune']) ? $_POST['prune'] : $forum['prune']); $form['sort_key'] = $this->registry->output->formDropdown("sort_key", $dd_order, !empty($_POST['sort_key']) ? $_POST['sort_key'] : $forum['sort_key']); $form['sort_order'] = $this->registry->output->formDropdown("sort_order", $dd_by, !empty($_POST['sort_order']) ? $_POST['sort_order'] : $forum['sort_order']); $form['topicfilter'] = $this->registry->output->formDropdown("topicfilter", $dd_filter, !empty($_POST['topicfilter']) ? $_POST['topicfilter'] : $forum['topicfilter']); $form['bw_disable_tagging'] = $this->registry->output->formYesNo("bw_disable_tagging", !empty($_POST['bw_disable_tagging']) ? $_POST['bw_disable_tagging'] : $forum['bw_disable_tagging']); $form['bw_disable_prefixes'] = $this->registry->output->formYesNo("bw_disable_prefixes", !empty($_POST['bw_disable_prefixes']) ? $_POST['bw_disable_prefixes'] : $forum['bw_disable_prefixes']); $form['tag_predefined'] = $this->registry->output->formTextarea("tag_predefined", IPSText::br2nl(!empty($_POST['tag_predefined']) ? $_POST['tag_predefined'] : $forum['tag_predefined'])); # Trim the form for categories... $form['addnew_type'] = $addnew_type; $this->request['type'] = $addnew_type; $form['addnew_type_upper'] = ucwords($addnew_type); //----------------------------------------- // Show permission matrix //----------------------------------------- if ($type != 'edit' or $addnew_type == 'category') { /* Permission Class */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions'); $permissions = new $classToLoad(ipsRegistry::instance()); if ($addnew_type == 'category') { $perm_matrix = $permissions->adminPermMatrix('forum', $forum, 'forums', 'view'); } else { $perm_matrix = $permissions->adminPermMatrix('forum', $forum); } } /* Application Tabs */ $form['tabStrip'] = ''; $form['tabContent'] = ''; $tabsUsed = 2; $firstTab = empty($this->request['_initTab']) ? false : trim($this->request['_initTab']); IPSLib::loadInterface('admin/forum_form.php'); foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) { if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php')) { $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php', 'admin_forum_form__' . $app_dir, $app_dir); if (class_exists($_class)) { $_object = new $_class($this->registry); $data = $_object->getDisplayContent($forum, $tabsUsed); $form['tabContent'] .= $data['content']; $form['tabStrip'] .= $data['tabs']; $tabsUsed = $data['tabsUsed'] ? $tabsUsed + $data['tabsUsed'] : $tabsUsed + 1; if ($this->request['_initTab'] == $app_dir) { $firstTab = $tabsUsed; } } } } //----------------------------------------- // Show form... //----------------------------------------- $this->registry->output->extra_nav[] = array('', $title); $this->registry->output->html .= $this->html->forumForm($form, $button, $code, $title, $forum, $perm_matrix, $firstTab); }
/** * Sends the PM * * @return string HTML to be returned via ajax * @since IPB 3.0.0.2008-06-25 */ protected function _PMSend() { /* Check permissions */ if (empty($this->memberData['member_id'])) { $this->returnJsonError('cannotUsePMSystem'); } if (!$this->memberData['g_use_pm']) { $this->returnJsonError('cannotUsePMSystem'); } if ($this->memberData['members_disable_pm']) { $this->returnJsonError('cannotUsePMSystem'); } if ($this->messengerFunctions->checkHasHitMax()) { $this->returnJsonError('cannotUsePMSystem'); } //----------------------------------------- // INIT //----------------------------------------- $toMemberID = intval($this->request['toMemberID']); $msgContent = $this->convertHtmlEntities($this->convertUnicode($_POST['Post'])); $msgTitle = IPSText::parseCleanValue($this->convertHtmlEntities($this->convertUnicode($_POST['subject']))); $this->request['Post'] = IPSText::parseCleanValue($_POST['Post']); //----------------------------------------- // Load lang file //----------------------------------------- $this->registry->getClass('class_localization')->loadLanguageFile(array("public_error"), 'core'); //----------------------------------------- // Language //----------------------------------------- $this->registry->class_localization->loadLanguageFile(array('public_messaging'), 'members'); if (IPSText::mbstrlen(trim(IPSText::br2nl($msgContent))) < 3) { $this->returnJsonError($this->lang->words['err_no_msg']); } //----------------------------------------- // Send .. or.. save... //----------------------------------------- try { $this->messengerFunctions->sendNewPersonalTopic($toMemberID, $this->memberData['member_id'], array(), $msgTitle, $msgContent); return $this->returnJsonArray(array('status' => 'sent')); } catch (Exception $error) { $msg = $error->getMessage(); $toMember = IPSMember::load($toMemberID, 'core'); if (strstr($msg, 'BBCODE_')) { $msg = str_replace('BBCODE_', '', $msg); return $this->returnJsonArray(array('inlineError' => $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->returnJsonArray(array('inlineError' => $_msgString)); } }
/** * Do the actual replacement * * @access protected * @param string $txt Parsed text from database to be edited * @return string BBCode content, ready for editing */ protected function _replaceText($txt) { $_tags = $this->_retrieveTags(); foreach ($_tags as $_tag) { //----------------------------------------- // Determine open and close tags //----------------------------------------- $open_tag = '[' . $_tag; $close_tag = '[/' . $_tag . ']'; //----------------------------------------- // Ok, quotes suck A LOT // We have to first match the CLOSE tag, unlike other bbcode // Then we back-track to find the matching opening tag // Do the replacement, and repeat.... //----------------------------------------- while (($this->end_pos = stripos($txt, $close_tag, $this->end_pos)) !== false) { //----------------------------------------- // Ok at this point, we have a closing quote tag // Set start position to end position point //----------------------------------------- $this->cur_pos = $this->end_pos; //----------------------------------------- // We are at 0 or above still... //----------------------------------------- while ($this->cur_pos > 0) { //----------------------------------------- // Loop over characters moving backwards 1 by 1 //----------------------------------------- $this->cur_pos = $this->cur_pos - 1; //----------------------------------------- // Shouldn't hit this, but if we do we're done //----------------------------------------- if ($this->cur_pos < 0) { break; } //----------------------------------------- // Have we finally hit the first preceeding open tag? //----------------------------------------- if (stripos($txt, $open_tag, $this->cur_pos) === $this->cur_pos) { //----------------------------------------- // Start figuring out open tag length //----------------------------------------- $open_length = strlen($open_tag); //----------------------------------------- // Extract the options (like surgery) //----------------------------------------- $_option = ''; $quoteOptions = array(); //----------------------------------------- // Does we haz it? //----------------------------------------- if (substr($txt, $this->cur_pos + strlen($open_tag), 1) == ' ') { $open_length += 1; $_option = substr($txt, $this->cur_pos + $open_length, strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length)); $quoteOptions = $this->_extractSurgicallyTehOptions($_option); } else { if (strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length) !== 0) { continue; } } //----------------------------------------- // Otherwise replace out the content too //----------------------------------------- $_content = substr($txt, $this->cur_pos + $open_length + strlen($_option) + 1, stripos($txt, $close_tag, $this->cur_pos) - ($this->cur_pos + $open_length + strlen($_option) + 1)); //----------------------------------------- // Turn attachments into links // Prevents em from breaking on other pages //----------------------------------------- preg_match_all("#\\[attachment=(.+?):(.+?)\\]#", $_content, $matches); if (is_array($matches[1]) && count($matches[1])) { foreach ($matches[1] as $idx => $attach_id) { $_content = str_replace("[attachment={$attach_id}:{$matches[2][$idx]}]", $this->registry->getClass('output')->getReplacement('post_attach_link') . " <a href='{$this->settings['base_url']}app=core&module=attach&section=attach&attach_rel_module=post&attach_id={$attach_id}' target='_blank'>{$matches[2][$idx]}</a>", $_content); } } //----------------------------------------- // Trim off leading newlines / brs, etc //----------------------------------------- $_content = IPSText::br2nl($_content); $_content = trim($_content); $_content = nl2br($_content); //----------------------------------------- // And replace... //----------------------------------------- $txt = substr_replace($txt, $this->_buildOutput($_content, $quoteOptions ? $quoteOptions : ''), $this->cur_pos, stripos($txt, $close_tag, $this->cur_pos) + strlen($close_tag) - $this->cur_pos); //----------------------------------------- // Now we break since we've done the inner replacement //----------------------------------------- break; } } //----------------------------------------- // And reset end position to one char further //----------------------------------------- $this->end_pos += 1; //----------------------------------------- // If end_pos is greater than length of text we're done //----------------------------------------- if ($this->end_pos > strlen($txt)) { //----------------------------------------- // Need to reset for next "tag" //----------------------------------------- $this->end_pos = 0; break; } } } return $txt; }
/** * Show the profile information * * @access public * @author Matt Mecham * @return string Processed HTML */ public function formProfileInfo() { /* Load Lang File */ $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members'); /* INIT */ $required_output = ""; $optional_output = ""; /* Permission Check */ if (!$this->memberData['g_edit_profile']) { $this->registry->getClass('output')->showError('members_profile_disabled', 1026); } /* Format the birthday drop boxes.. */ $date = getdate(); $day = array(); $mon = array(); $year = array(); /* Build the day options */ $day[] = array('0', '--'); for ($i = 1; $i < 32; $i++) { $day[] = array($i, $i); } /* Build the month options */ $mon[] = array('0', '--'); for ($i = 1; $i < 13; $i++) { $mon[] = array($i, $this->lang->words['M_' . $i]); } /* Build the years options */ $i = $date['year'] - 1; $j = $date['year'] - 100; $year[] = array('0', '--'); for ($i; $j < $i; $i--) { $year[] = array($i, $i); } /* Custom Fields */ require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); $fields->member_data = $this->member->fetchMemberData(); $fields->initData('edit'); $fields->parseToEdit(); if (count($fields->out_fields)) { foreach ($fields->out_fields as $id => $data) { if ($fields->cache_data[$id]['pf_not_null'] == 1) { $ftype = 'required_output'; } else { $ftype = 'optional_output'; } ${$ftype} .= $this->registry->getClass('output')->getTemplate('ucp')->field_entry($fields->field_names[$id], $fields->field_desc[$id], $data, $id); } } /* Personal Statement */ $personal_statement = IPSText::br2nl($this->memberData['pp_bio_content']); /* Build and return the form */ $template = $this->registry->getClass('output')->getTemplate('ucp')->membersProfileForm($personal_statement, $required_output, $optional_output, $day, $mon, $year); return $template; }
/** * Add a new arn entry * * @access private * @return void [Outputs to screen/redirects] */ private function _doWarn() { //----------------------------------------- // INIT //----------------------------------------- $save = array(); $err = 0; $topicPosts_type = trim($this->request['topicPosts_type']); $topicPosts_topics = intval($this->request['topicPosts_topics']); $topicPosts_replies = intval($this->request['topicPosts_replies']); $topicPosts_lastx = intval($this->request['topicPosts_lastx']); $topicPosts_lastxunits = trim($this->request['topicPosts_lastxunits']); $level_custom = intval($this->request['level_custom']); $ban_indef = intval($this->request['ban_indef']); $member_banned = intval($this->warn_member['member_banned']); $warn_level = intval($this->warn_member['warn_level']); //----------------------------------------- // Load Mod Squad //----------------------------------------- require_once IPSLib::getAppDir('forums') . '/sources/classes/moderate.php'; $moderatorLibrary = new moderatorLibrary($this->registry); //----------------------------------------- // Security checks //----------------------------------------- if ($this->type == 'member') { $this->registry->output->showError('warn_member_notes', 2028); } //----------------------------------------- // Check security fang //----------------------------------------- if ($this->request['key'] != $this->member->form_hash) { $this->registry->output->showError('warn_bad_key', 3020); } //----------------------------------------- // As Celine Dion once squawked, "Show me the reason" //----------------------------------------- if (trim($this->request['reason']) == "") { $this->_showForm('we_no_reason'); return; } //----------------------------------------- // Other checks //----------------------------------------- if (!$this->settings['warn_past_max'] && $this->request['level'] != 'nochange') { if ($this->request['level'] == 'custom') { if ($level_custom > $this->settings['warn_max']) { $err = 1; } else { if ($level_custom < $this->settings['warn_min']) { $err = 2; } } } else { if ($this->request['level'] == 'add') { if ($warn_level >= $this->settings['warn_max']) { $err = 1; } } else { if ($warn_level <= $this->settings['warn_min']) { $err = 2; } } } if ($err) { $this->registry->output->showError($err == 1 ? 'warn_past_max_high' : 'warn_past_max_low', 10251); } } //----------------------------------------- // Plussy - minussy? //----------------------------------------- if ($this->request['level'] == 'nochange') { $save['wlog_type'] = 'nochan'; } else { $save['wlog_type'] = $this->request['level'] == 'custom' ? 'custom' : ($this->request['level'] == 'add' ? 'neg' : 'pos'); } $save['wlog_date'] = time(); //----------------------------------------- // Contacting the member? //----------------------------------------- $test_content = trim(IPSText::br2nl($_POST['contact'])); if ($test_content != "") { if (trim($this->request['subject']) == "") { $this->_showForm('we_no_subject'); return; } unset($test_content); if (IPSText::getTextClass('editor')->method == 'rte') { $this->request['contact'] = IPSText::getTextClass('editor')->processRawPost('contact'); } IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'warn'; $save['wlog_contact'] = $this->request['contactmethod']; $save['wlog_contact_content'] = "<subject>" . $this->request['subject'] . "</subject><content>" . $this->request['contact'] . "</content>"; $save['wlog_contact_content'] = IPSText::getTextClass('bbcode')->preDbParse($save['wlog_contact_content']); if ($this->request['contactmethod'] == 'email') { IPSText::getTextClass('bbcode')->parse_smilies = 0; IPSText::getTextClass('bbcode')->parse_html = 1; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'warn'; IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others']; $this->request['contact'] = IPSText::getTextClass('bbcode')->preDisplayParse(IPSText::getTextClass('bbcode')->preDbParse($this->request['contact'])); //----------------------------------------- // Send the email //----------------------------------------- IPSText::getTextClass('email')->getTemplate("email_member"); IPSText::getTextClass('email')->buildMessage(array('MESSAGE' => IPSText::br2nl($this->request['contact']), 'MEMBER_NAME' => $this->warn_member['members_display_name'], 'FROM_NAME' => $this->memberData['members_display_name'])); IPSText::getTextClass('email')->subject = $this->request['subject']; IPSText::getTextClass('email')->to = $this->warn_member['email']; IPSText::getTextClass('email')->from = $this->settings['email_out']; IPSText::getTextClass('email')->sendMail(); } else { //----------------------------------------- // Grab PM class //----------------------------------------- require_once IPSLib::getAppDir('members') . '/sources/classes/messaging/messengerFunctions.php'; $messengerFunctions = new messengerFunctions($this->registry); try { $messengerFunctions->sendNewPersonalTopic($this->warn_member['member_id'], $this->memberData['member_id'], array(), $this->request['subject'], IPSText::getTextClass('editor')->method == 'rte' ? nl2br($_POST['contact']) : $_POST['contact'], array('origMsgID' => 0, 'fromMsgID' => 0, 'postKey' => md5(microtime()), 'trackMsg' => 0, 'addToSentFolder' => 0, 'hideCCUser' => 0, 'forcePm' => 1)); } catch (Exception $error) { $msg = $error->getMessage(); $toMember = IPSMember::load($this->warn_member['member_id'], 'core'); if (strstr($msg, 'BBCODE_')) { $msg = str_replace('BBCODE_', '', $msg); $this->registry->output->showError($msg, 10252); } else { if (isset($this->lang->words['err_' . $msg])) { $this->lang->words['err_' . $msg] = $this->lang->words['err_' . $msg]; $this->lang->words['err_' . $msg] = str_replace('#NAMES#', implode(",", $messengerFunctions->exceptionData), $this->lang->words['err_' . $msg]); $this->lang->words['err_' . $msg] = str_replace('#TONAME#', $toMember['members_display_name'], $this->lang->words['err_' . $msg]); $this->lang->words['err_' . $msg] = str_replace('#FROMNAME#', $this->memberData['members_display_name'], $this->lang->words['err_' . $msg]); $this->registry->output->showError('err_' . $msg, 10253); } else { if ($msg != 'CANT_SEND_TO_SELF') { $_msgString = $this->lang->words['err_UNKNOWN'] . ' ' . $msg; $this->registry->output->showError($_msgString, 10254); } } } } } } else { unset($test_content); } //----------------------------------------- // Right - is we banned or wha? //----------------------------------------- $restrict_post = ''; $mod_queue = ''; $susp = ''; $_notes = array(); $_notes['content'] = $this->request['reason']; $_notes['mod'] = $this->request['mod_value']; $_notes['post'] = $this->request['post_value']; $_notes['susp'] = $this->request['susp_value']; $_notes['ban'] = $ban_indef; $_notes['topicPosts_type'] = $topicPosts_type; $_notes['topicPosts_topics'] = $topicPosts_topics; $_notes['topicPosts_replies'] = $topicPosts_replies; $_notes['topicPosts_lastx'] = $topicPosts_lastx; $_notes['topicPosts_lastxunits'] = $topicPosts_lastxunits; $save['wlog_notes'] = serialize($_notes); //----------------------------------------- // Member Content //----------------------------------------- if ($topicPosts_type == 'unapprove' or $topicPosts_type == 'approve') { $time = $topicPosts_lastxunits == 'd' ? $topicPosts_lastx * 24 : $topicPosts_lastx; $approve = $topicPosts_type == 'approve' ? TRUE : FALSE; if ($topicPosts_topics and $this->canApproveTopics and ($topicPosts_replies and $this->canApprovePosts)) { $moderatorLibrary->toggleApproveMemberContent($this->warn_member['member_id'], $approve, 'all', $time); } else { if ($topicPosts_topics and $this->canApproveTopics) { $moderatorLibrary->toggleApproveMemberContent($this->warn_member['member_id'], $approve, 'topics', $time); } else { if ($topicPosts_replies and $this->canApprovePosts) { $moderatorLibrary->toggleApproveMemberContent($this->warn_member['member_id'], $approve, 'replies', $time); } } } } else { if ($topicPosts_type == 'delete') { $time = $topicPosts_lastxunits == 'd' ? $topicPosts_lastx * 24 : $topicPosts_lastx; if ($topicPosts_topics and $this->canDeleteTopics and ($topicPosts_replies and $this->canDeletePosts)) { $moderatorLibrary->deleteMemberContent($this->warn_member['member_id'], 'all', $time); } else { if ($topicPosts_topics and $this->canDeleteTopics) { $moderatorLibrary->deleteMemberContent($this->warn_member['member_id'], 'topics', $time); } else { if ($topicPosts_replies and $this->canDeletePosts) { $moderatorLibrary->deleteMemberContent($this->warn_member['member_id'], 'replies', $time); } } } } } //----------------------------------------- // Member Suspension //----------------------------------------- if ($this->canModQueue) { if ($this->request['mod_indef'] == 1) { $mod_queue = 1; } elseif ($this->request['mod_value'] > 0) { $mod_queue = IPSMember::processBanEntry(array('timespan' => intval($this->request['mod_value']), 'unit' => $this->request['mod_unit'])); } } if ($this->canRemovePostAbility) { if ($this->request['post_indef'] == 1) { $restrict_post = 1; } elseif ($this->request['post_value'] > 0) { $restrict_post = IPSMember::processBanEntry(array('timespan' => intval($this->request['post_value']), 'unit' => $this->request['post_unit'])); } } if ($this->canSuspend) { if ($ban_indef) { $member_banned = 1; } else { if ($this->request['susp_value'] > 0) { $susp = IPSMember::processBanEntry(array('timespan' => intval($this->request['susp_value']), 'unit' => $this->request['susp_unit'])); } } /* Were banned but now unticked? */ if (!$ban_indef and $member_banned) { $member_banned = 0; } } $save['wlog_mid'] = $this->warn_member['member_id']; $save['wlog_addedby'] = $this->memberData['member_id']; //----------------------------------------- // Enter into warn loggy poos (eeew - poo) //----------------------------------------- $this->DB->insert('warn_logs', $save); //----------------------------------------- // Update member //----------------------------------------- if ($this->request['level'] != 'nochange') { if ($this->request['level'] == 'custom') { $warn_level = $level_custom; } else { if ($this->request['level'] == 'add') { $warn_level++; } else { $warn_level--; } } if ($warn_level > $this->settings['warn_max']) { $warn_level = $this->settings['warn_max']; } if ($warn_level < intval($this->settings['warn_min'])) { $warn_level = intval($this->settings['warn_min']); } } IPSMember::save($this->warn_member['member_id'], array('core' => array('mod_posts' => $mod_queue, 'restrict_post' => $restrict_post, 'temp_ban' => $susp, 'member_banned' => $member_banned, 'warn_level' => $warn_level, 'warn_lastwarn' => time()))); //----------------------------------------- // Now what? Show success screen, that's what!! //----------------------------------------- $this->lang->words['w_done_te'] = sprintf($this->lang->words['w_done_te'], $this->warn_member['members_display_name']); $tid = intval($this->request['t']); $topic = array(); if ($tid > 0) { $topic = $this->DB->buildAndFetch(array('select' => 't.tid, t.title, t.title_seo', 'from' => array('topics' => 't'), 'where' => "t.tid={$tid}", 'add_join' => array(array('select' => 'f.id, f.name, f.name_seo', 'from' => array('forums' => 'f'), 'where' => 'f.id=t.forum_id', 'type' => 'left')))); } $this->output .= $this->registry->getClass('output')->getTemplate('mod')->warn_success($topic); }
/** * Legacy, generic method: builds an email from a template, replacing variables * * @deprecated * @param array Replacement keys to values * @param bool Do not "clean" * @param bool Raw HTML * @param array Member data - necessary if including unsubscribe link * @return @e void */ public function buildMessage($words, $noClean = false, $rawHtml = FALSE, $memberData = array()) { /* Init */ $ptWords = array(); $htmlWords = array(); $subjWords = array(); /* Try this first */ if (!$this->plainTextTemplate && !$this->htmlTemplate && $this->message) { $this->setPlainTextTemplate($this->message, true); } /* need to converge some stuff here */ if (!$this->plainTextTemplate && $this->template) { /* Sniff, sniff */ if (stristr($this->template, '<br')) { if (!$this->htmlTemplate) { $this->setHtmlTemplate($this->template); } $this->setPlainTextTemplate(IPSText::br2nl($this->template)); } else { if (!$this->htmlTemplate) { $this->setHtmlTemplate(nl2br($this->template)); } $this->setPlainTextTemplate($this->template); } } /* HTML enabled but no specific template: Auto convert */ if ($this->html_email && !$this->htmlTemplate) { /* It will be dynamically updated at the end */ $this->setHtmlTemplate($this->plainTextTemplate); } /* HTML email with HTML template but no plain text version */ if ($this->htmlTemplate && !$this->plainTextTemplate) { $msg = $this->htmlTemplate; $msg = preg_replace('/<#(.+?)#>/', '{{{-\\1-}}}', $msg); $msg = str_replace("<br />", "\n", $msg); $msg = str_replace("<br>", "\n", $msg); $msg = IPSText::stripTags($msg); $msg = html_entity_decode($msg, ENT_QUOTES); $msg = str_replace('\', '\\', $msg); $msg = str_replace('$', '$', $msg); $msg = preg_replace('/\\{\\{\\{(.+?)\\}\\}\\}/', '<#\\1#>', $msg); $this->setPlainTextTemplate($msg); } if ($this->plainTextTemplate && !$this->template && ($this->html_email && !$this->htmlTemplate)) { $this->error++; $this->fatalError("Could not build the email message, no template assigned", "Make sure a template is assigned first."); } /* Bit more clean up */ $this->plainTextTemplate = str_replace(array("\r\n", "\r", "\n"), "\n", $this->plainTextTemplate); $this->htmlTemplate = str_replace(array("\r\n", "\r", "\n"), "\n", $this->htmlTemplate); /* Apply HTML wrapper */ $this->htmlTemplate = $this->applyHtmlWrapper($this->subject, $rawHtml ? $this->htmlTemplate : $this->convertTextEmailToHtmlEmail($this->htmlTemplate, $rawHtml)); /* Add unsubscribe link */ if ($this->unsubscribe and !empty($memberData)) { $this->registry->class_localization->loadLanguageFile(array('public_global'), 'core', $this->language ? $this->language : IPSLib::getDefaultLanguage(), TRUE); $key = md5($memberData['email'] . ':' . $memberData['members_pass_hash']); $link = $this->registry->output->buildUrl("app=core&module=global&section=unsubscribe&member={$memberData['member_id']}&key={$key}", 'publicNoSession'); $this->plainTextTemplate = str_replace("<#UNSUBSCRIBE#>", "{$this->registry->class_localization->words['email_unsubscribe']}: {$link}", $this->plainTextTemplate); $this->htmlTemplate = str_replace("<#UNSUBSCRIBE#>", "<a href='{$link}'>" . $this->registry->class_localization->words['email_unsubscribe'] . '</a>', $this->htmlTemplate); } /* Add some default words */ $words['BOARD_ADDRESS'] = $this->settings['board_url'] . '/index.' . $this->settings['php_ext']; $words['WEB_ADDRESS'] = $this->settings['home_url']; $words['BOARD_NAME'] = $this->settings['board_name']; $words['SIGNATURE'] = $this->settings['signature'] ? $this->settings['signature'] : ''; /* Swap the words: 10.7.08 - Added replacements in subject */ foreach ($words as $k => $v) { if (!$noClean) { $ptWords[$k] = $this->cleanMessage($v); } $subjWords[$k] = $this->cleanMessage($v, false, false); /* Convert over words too so links are linkified */ $htmlWords[$k] = $rawHtml ? $v : $this->convertTextEmailToHtmlEmail($v, $rawHtml); } $this->_words = $ptWords; $this->plainTextTemplate = preg_replace_callback("/<#(.+?)#>/", array(&$this, '_swapWords'), $this->plainTextTemplate); $this->_words = $htmlWords; $this->htmlTemplate = preg_replace_callback("/<#(.+?)#>/", array(&$this, '_swapWords'), str_replace(array('<#', '#>'), array('<#', '#>'), $this->htmlTemplate)); $this->_words = $subjWords; $this->subject = preg_replace_callback("/<#(.+?)#>/", array(&$this, '_swapWords'), $this->subject); $this->_words = array(); /* Final touches */ $this->htmlTemplate = preg_replace('#<!--hook\\.([^\\>]+?)-->#', '', $this->htmlTemplate); $this->htmlTemplate = $this->registry->getClass('output')->parseIPSTags($this->htmlTemplate); /* strip all tags if not HTML */ if (!$this->settings['email_use_html']) { $this->plainTextTemplate = IPSText::stripTags($this->plainTextTemplate); } $this->plainTextTemplate = IPSText::stripTags(stripslashes($this->lang->words['email_header'])) . $this->plainTextTemplate . IPSText::stripTags(stripslashes($this->lang->words['email_footer'])); /* Some older apps use $this->message, so give them plaintext */ $this->message = $this->plainTextTemplate; }
function warnForm($member, $tid = 0, $st = 0, $errors = '', $modque = false, $postque = false, $ban = false, $editor_html = '') { $IPBHTML = ""; $mod_arr = array('timespan' => 0, 'days' => 0, 'hours' => 0); $mhours = 0; if ($member['mod_posts'] > 0 and $member['mod_posts'] != 1) { $mod_arr = IPSMember::processBanEntry($member['mod_posts']); $mhours = ceil(($mod_arr['date_end'] - time()) / 3600); } $post_arr = array('timespan' => 0, 'hours' => 0, 'days' => 0); $phours = 0; if ($member['restrict_post'] > 0 and $member['restrict_post'] != 1) { $post_arr = IPSMember::processBanEntry($member['restrict_post']); $phours = ceil(($post_arr['date_end'] - time()) / 3600); } $ban_arr = array('timespan' => 0, 'days' => 0, 'hours' => 0); $hours = 0; if ($member['temp_ban'] and $member['temp_ban'] != 1) { $ban_arr = IPSMember::processBanEntry($member['temp_ban']); $hours = ceil(($ban_arr['date_end'] - time()) / 3600); } $IPBHTML .= "" . $this->registry->getClass('output')->addJSModule("profile", "0") . "\n<script type='text/javascript'>\n\tipb.profile.viewingProfile = {$member['member_id']};\n</script>\n" . ($errors ? "\n\t<h2>{$this->lang->words['errors_found']}</h2>\n\t<p class='message error'>{$errors}</p>\n\t<br />\n" : "") . "\n<!-- SKINNOTE: form validation -->\n<form method=\"post\" action='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&module=warn&section=warn&do=dowarn&mid={$member['member_id']}&t={$tid}&st={$st}&type={$this->request['type']}", 'public', ''), "", "") . "' id='postingform'>\n<input type=\"hidden\" name=\"key\" value=\"{$this->member->form_hash}\" />\n<div class='post_form'>\n<h2 class='maintitle'>{$this->lang->words['warn_logs_for']} <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("showuser={$member['member_id']}", 'public', ''), "{$member['members_display_name']}", "showuser") . "' title='{$this->lang->words['view_profile']}'>{$member['members_display_name']}</a></h2>\n<div class='generic_bar'></div>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['warn_member_details']}</h3>\n\t<h4>\n\t\t<img class=\"photo\" src='{$member['pp_main_photo']}' alt=\"{$member['members_display_name']}{$this->lang->words['users_photo']}\" />\n\t</h4>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t" . $this->registry->getClass('output')->getReplacement("find_posts_link") . " <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&module=search&do=user_posts&mid={$member['member_id']}" . (!in_array($this->settings['search_method'], array('traditional', 'sphinx')) ? "&search_filter_app[forums]=1" : "") . "", 'public', ''), "", "") . "'>{$this->lang->words['find_posts']}</a>\n\t\t</li>\n\t\t<li class='field'>\n\t\t\t" . $this->registry->getClass('output')->getReplacement("find_topics_link") . " <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&module=search&do=user_posts&mid={$member['member_id']}&search_filter_app[forums]=1&view_by_title=1", 'public', ''), "", "") . "'>{$this->lang->words['find_topics']}</a>\n\t\t</li>\n\t\t" . ($this->memberData['g_mem_info'] && $this->settings['auth_allow_dnames'] ? "\n\t\t\t<li class='field' id='dname_history'>\n\t\t\t\t" . $this->registry->getClass('output')->getReplacement("display_name") . " <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=members&module=profile&section=dname&id={$member['member_id']}", 'public', ''), "", "") . "' title='{$this->lang->words['view_dname_history']}'>{$this->lang->words['display_history']}</a>\n\t\t\t</li>\n\t\t" : "") . "\n\t\t" . ($this->settings['reputation_enabled'] ? "<li class='field'>\n\t\t\t\t{$this->lang->words['warn_rep']} {$member['pp_reputation_points']}\n\t\t\t\t" . ($member['author_reputation'] && $member['author_reputation']['text'] ? "\n\t\t\t\t\t<p class='title'>{$member['author_reputation']['text']}</p>\n\t\t\t\t" : "") . "\n\t\t\t\t" . ($member['author_reputation'] && $member['author_reputation']['image'] ? "\n\t\t\t\t\t<p class='image'>{$member['author_reputation']['image']}</p>\n\t\t\t\t" : "") . "\n\t\t\t</li>" : "") . "\n\t</ul>\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['warn_details']}</h3>\n\t<h4>{$this->lang->words['w_adjust_level']}<br /><span class='desc'>{$this->lang->words['warn_current_level']} {$member['warn_level']}/{$this->settings['warn_max']}</span></h4>\n\t<ul>\n\t\t<li class='field checkbox negative'>\n\t\t\t<input type=\"radio\" name=\"level\" id=\"add\" class=\"input_radio\" value=\"add\" " . ($this->request['type'] == 'add' ? "checked='checked'" : "") . " />\n\t\t\t<label for='add'>{$this->lang->words['w_add']}</label>\n\t\t</li>\n\t\t<li class='field checkbox positive'>\n\t\t\t<input type=\"radio\" name=\"level\" id=\"minus\" class=\"input_radio\" value=\"remove\" " . ($this->request['type'] == 'minus' ? "checked='checked'" : "") . " />\n\t\t\t<label for='minus'>{$this->lang->words['w_remove']}</label>\n\t\t</li>\t\n\t\t" . ($this->memberData['g_is_supmod'] ? "<li class='field checkbox custom'>\n\t\t\t\t<input type=\"radio\" name=\"level\" id=\"custom\" class=\"input_radio\" value=\"custom\" " . ($this->request['type'] == 'custom' ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='level_custom'>" . sprintf($this->lang->words['w_change_custom'], $this->settings['warn_max']) . "</label>\n\t\t\t\t <input type='text' id='level_custom' name='level_custom' value='" . (isset($this->request['customLevel']) ? "{$this->request['customLevel']}" : "{$member['warn_level']}") . "' size='3' />\n\t\t\t</li>" : "") . "\n\t\t<li class='field checkbox'>\n\t\t\t<input type=\"radio\" name=\"level\" id=\"nochange\" class=\"input_radio\" value=\"nochange\" " . ($this->request['type'] == 'nochange' ? "checked='checked'" : "") . " />\n\t\t\t<label for='nochange'>{$this->lang->words['w_nochange']}</label>\n\t\t</li>\t\t\n\t</ul>\n\t<h4>{$this->lang->words['w_reason']}<br /><span class='desc'>{$this->lang->words['w_reason2']}</span></h4>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t<textarea rows=\"6\" cols=\"70\" class=\"input_text\" name=\"reason\">" . IPSText::br2nl($this->request['reason']) . "</textarea>\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['member_suspension']}</h3>\n\t" . ($modque == true ? "\t\t<h4>{$this->lang->words['w_modq']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='modq' type=\"checkbox\" name=\"mod_indef\" value=\"1\" " . ($member['mod_posts'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='modq'>{$this->lang->words['w_modq_i']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='mod_value'>{$this->lang->words['w_orfor']}</label>\n\t\t\t\t<input class='input_text' type=\"text\" id='mod_value' name=\"mod_value\" value=\"" . (($mhours > 24 and $mhours / 24 == ceil($mhours / 24) and $timespan = $mhours / 24) ? "{$timespan}" : "{$mhours}") . "\" size=\"5\" /> \n\t\t\t\t<select name=\"mod_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($mhours > 24 and $mhours / 24 == ceil($mhours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($mhours < 24 or $mhours / 24 != ceil($mhours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($mhours > 0 ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n\t" . ($postque == true ? "\t\t<h4>{$this->lang->words['w_resposts']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='restrict_posts' type=\"checkbox\" name=\"post_indef\" value=\"1\" " . ($member['restrict_post'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='restrict_posts'>{$this->lang->words['w_resposts_i']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='post_value'>{$this->lang->words['w_orfor']}</label>\n\t\t\t\t<input class='input_text' type=\"text\" id='post_value' name=\"post_value\" value=\"" . (($phours > 24 and $phours / 24 == ceil($phours / 24) and $timespan = $phours / 24) ? "{$timespan}" : "{$phours}") . "\" size=\"5\" /> \n\t\t\t\t<select name=\"post_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($phours > 24 and $phours / 24 == ceil($phours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($phours < 24 or $phours / 24 != ceil($phours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($phours > 0 ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n\t" . ($ban == true ? "\t\t<h4>{$this->lang->words['w_suspend']}</h4>\n\t\t<ul>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<input class='input_check' id='suspend_member' type=\"checkbox\" name=\"ban_indef\" value=\"1\" " . ($member['member_banned'] == 1 ? "checked='checked'" : "") . " />\n\t\t\t\t<label for='suspend_member'>{$this->lang->words['w_ban_indef']}</label>\n\t\t\t</li>\n\t\t\t<li class='field checkbox'>\n\t\t\t\t<label for='susp_value'>{$this->lang->words['w_suspend_or']}</label>\n\t\t\t\t<input type=\"text\" id='susp_value' class='input_text' name=\"susp_value\" value=\"" . (($hours > 24 and $hours / 24 == ceil($hours / 24) and $timespan = $hours / 24) ? "{$timespan}" : "{$hours}") . "\" size=\"5\" />\n\t\t\t\t<select name=\"susp_unit\" class='input_select'>\n\t\t\t\t\t<option value=\"d\" " . (($hours > 24 and $hours / 24 == ceil($hours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_day']}</option>\n\t\t\t\t\t<option value=\"h\" " . (($hours < 24 or $hours / 24 != ceil($hours / 24)) ? "selected='selected'" : "") . ">{$this->lang->words['w_hour']}</option>\n\t\t\t\t</select>\n\t\t\t\t" . ($member['temp_ban'] ? "\n\t\t\t\t\t<span class='desc'>{$this->lang->words['w_restricted']}</span>\n\t\t\t\t" : "") . "\n\t\t\t</li>\n\t\t</ul>" : "") . "\n</fieldset>\n<fieldset class='with_subhead'>\n\t<h3 class='bar'>{$this->lang->words['warn_mem_content']}</h3>\n\t<h4>{$this->lang->words['warn_posts_topics']}</h4>\n\t<ul>\n\t\t<li class='field checkbox'>\n\t\t\t<select name=\"topicPosts_type\" class='input_select'>\n\t\t\t\t<option value='unapprove' " . ($this->request['topicPosts_type'] == 'unapprove' ? "selected='selected'" : "") . ">{$this->lang->words['warn_stuff_unapprove']}</option>\n\t\t\t\t<option value='approve' " . ($this->request['topicPosts_type'] == 'approve' ? "selected='selected'" : "") . ">{$this->lang->words['warn_stuff_approve']}</option>\n\t\t\t</select>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<input type=\"checkbox\" id='topicPosts_topics' class='input_check' name=\"topicPosts_topics\" value=\"1\" />\n\t\t\t<label for='topicPosts_topics'>{$this->lang->words['warn_stuff_alltopics']}</label>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<input type=\"checkbox\" id='topicPosts_replies' class='input_check' name=\"topicPosts_replies\" value=\"1\" />\n\t\t\t<label for='topicPosts_replies'>{$this->lang->words['warn_stuff_allposts']}</label>\n\t\t</li>\n\t\t<li class='field checkbox'>\n\t\t\t<label for='topicPosts_lastx'>{$this->lang->words['warn_stuff_datecutoff']}</label>\n\t\t\t<input type=\"text\" id='topicPosts_lastx' class='input_text' name=\"topicPosts_lastx\" value=\"\" size=\"5\" />\n\t\t\t<select name=\"topicPosts_lastxunits\" class='input_select'>\n\t\t\t\t<option value=\"d\">{$this->lang->words['w_day']}</option>\n\t\t\t\t<option value=\"h\">{$this->lang->words['w_hour']}</option>\n\t\t\t</select>\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset>\n\t<h3 class='bar'>{$this->lang->words['warn_contact_member']}</h3>\n\t<ul>\n\t\t<li class='field'>\n\t\t\t<label for='subj'>{$this->lang->words['w_c_subj']}</label>\n\t\t\t<input id='subj' class='input_text' type=\"text\" name=\"subject\" value=\"{$this->request['subject']}\" size=\"30\" />\n\t\t</li>\n\t\t<li class='field'>\n\t\t\t<label for='method'>{$this->lang->words['w_c']}</label>\n\t\t\t<select id='method' name=\"contactmethod\" class='input_select'>\n\t\t\t\t" . ($member['members_disable_pm'] != 1 ? "\n\t\t\t\t\t<option value=\"pm\">{$this->lang->words['w_c_p']}</option>\n\t\t\t\t" : "") . "\n\t\t\t\t<option value=\"email\">{$this->lang->words['w_c_e']}</option>\n\t\t\t</select>\n\t\t</li>\n\t\t<li>\n\t\t\t{$editor_html}\n\t\t</li>\n\t</ul>\n</fieldset>\n<fieldset class='submit'>\n\t<input type=\"submit\" class='input_submit' value=\"{$this->lang->words['w_submit']}\" tabindex='0'/> {$this->lang->words['or']} <a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("showtopic={$tid}&st={$st}", 'public', ''), "", "") . "' title='{$this->lang->words['cancel']}' class='cancel' tabindex='0'>{$this->lang->words['cancel']}</a>\n</fieldset>\n\t\n</div>\n</form>"; return $IPBHTML; }
/** * Rebuild the RSS Stream cache * * @access public * @param mixed $rss_import_id ID of the stream to import * @param bool $return Set to true to return true/false * @param bool $id_is_array Set to true if the first paramter is an array of ids * @return mixed **/ public function rssImportRebuildCache($rss_import_id, $return = true, $id_is_array = false) { /* INIT */ $errors = array(); $affected_forum_ids = array(); $affected_members = array(); $rss_error = array(); $rss_import_ids = array(); $items_imported = 0; /* Check the ID */ if (!$rss_import_id) { $rss_import_id = $this->request['rss_import_id'] == 'all' ? 'all' : intval($this->request['rss_import_id']); } /* No ID Found */ if (!$rss_import_id) { $this->registry->output->global_message = $this->lang->words['im_noid']; $this->rssImportOverview(); return; } /* Create an array of ids */ if ($id_is_array == 1) { $rss_import_ids = explode(",", $rss_import_id); } /* Load the classes we need */ if (!$this->classes_loaded) { /* Get the RSS Class */ if (!is_object($this->class_rss)) { require_once IPS_KERNEL_PATH . 'classRss.php'; $this->class_rss = new classRss(); $this->class_rss->use_sockets = $this->use_sockets; $this->class_rss->rss_max_show = 100; } /* Get the post class */ require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php'; $this->post = new classPost($this->registry); /* Load the mod libarry */ if (!$this->func_mod) { require_once IPSLib::getAppDir('forums') . '/sources/classes/moderate.php'; $this->func_mod = new moderatorLibrary($this->registry); } $this->classes_loaded = 1; } /* INIT Forums */ if (!is_array($this->registry->class_forums->forum_by_id) or !count($this->registry->class_forums->forum_by_id)) { $this->registry->class_forums->forumsInit(); } /* Query the RSS imports */ $this->DB->build(array('select' => '*', 'from' => 'rss_import')); $outer = $this->DB->execute(); /* Loop through and build cache */ while ($row = $this->DB->fetch($outer)) { /* Are we caching this one? */ if ($rss_import_id == 'all' or $row['rss_import_id'] == $rss_import_id or $id_is_array == 1 and in_array($row['rss_import_id'], $rss_import_ids)) { /* Skip non-existent forums - bad stuff happens */ if (!isset($this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']])) { continue; } /* Allowing badwords? */ IPSText::getTextClass('bbcode')->bypass_badwords = $row['rss_import_allow_html']; /* Set this import's doctype */ $this->class_rss->doc_type = IPS_DOC_CHAR_SET; $this->class_rss->feed_charset = $row['rss_import_charset']; if (strtolower($row['rss_import_charset']) != IPS_DOC_CHAR_SET) { $this->class_rss->convert_charset = 1; } else { $this->class_rss->convert_charset = 0; } /* Set this import's authentication */ $this->class_rss->auth_req = $row['rss_import_auth']; $this->class_rss->auth_user = $row['rss_import_auth_user']; $this->class_rss->auth_pass = $row['rss_import_auth_pass']; /* Clear RSS object's error cache first */ $this->class_rss->errors = array(); $this->class_rss->rss_items = array(); /* Reset the rss count as this is a new feed */ $this->class_rss->rss_count = 0; $this->class_rss->rss_max_show = $row['rss_import_pergo']; /* Parse RSS */ $this->class_rss->parseFeedFromUrl($row['rss_import_url']); /* Check for errors */ if (is_array($this->class_rss->errors) and count($this->class_rss->errors)) { $rss_error = array_merge($rss_error, $this->class_rss->errors); continue; } if (!is_array($this->class_rss->rss_channels) or !count($this->class_rss->rss_channels)) { $rss_error[] = sprintf($this->lang->words['im_noopen'], $row['rss_import_url']); continue; } /* Update last check time */ $this->DB->update('rss_import', array('rss_import_last_import' => time()), 'rss_import_id=' . $row['rss_import_id']); /* Apparently so: Parse feeds and check for already imported GUIDs */ $final_items = array(); $items = array(); $check_guids = array(); $final_guids = array(); $count = 0; if (!is_array($this->class_rss->rss_items) or !count($this->class_rss->rss_items)) { $rss_error[] = $row['rss_import_url'] . $this->lang->words['im_noimport']; continue; } /* Loop through the channels */ foreach ($this->class_rss->rss_channels as $channel_id => $channel_data) { if (is_array($this->class_rss->rss_items[$channel_id]) and count($this->class_rss->rss_items[$channel_id])) { /* Loop through the items in this channel */ foreach ($this->class_rss->rss_items[$channel_id] as $item_data) { /* Item Data */ $item_data['content'] = $item_data['content'] ? $item_data['content'] : $item_data['description']; $item_data['guid'] = md5($row['rss_import_id'] . ($item_data['guid'] ? $item_data['guid'] : preg_replace("#\\s|\r|\n#is", "", $item_data['title'] . $item_data['link'] . $item_data['description']))); $item_data['unixdate'] = intval($item_data['unixdate']) ? intval($item_data['unixdate']) : time(); /* Convert char set? */ if ($row['rss_import_charset'] and strtolower(IPS_DOC_CHAR_SET) != strtolower($row['rss_import_charset'])) { $item_data['title'] = IPSText::convertCharsets($item_data['title'], $row['rss_import_charset'], IPS_DOC_CHAR_SET); $item_data['content'] = IPSText::convertCharsets($item_data['content'], $row['rss_import_charset'], IPS_DOC_CHAR_SET); } /* Dates */ if ($item_data['unixdate'] < 1) { $item_data['unixdate'] = time(); } else { if ($item_data['unixdate'] > time()) { $item_data['unixdate'] = time(); } } /* Error check */ if (!$item_data['title'] or !$item_data['content']) { $rss_error[] = sprintf($this->lang->words['im_notitle'], $item_data['title']); continue; } /* Add to array */ $items[$item_data['guid']] = $item_data; $check_guids[] = $item_data['guid']; } } } /* Check GUIDs */ if (!count($check_guids)) { $rss_error[] = $this->lang->words['im_noitems']; continue; } $this->DB->build(array('select' => '*', 'from' => 'rss_imported', 'where' => "rss_imported_guid IN ('" . implode("','", $check_guids) . "')")); $this->DB->execute(); while ($guid = $this->DB->fetch()) { $final_guids[$guid['rss_imported_guid']] = $guid['rss_imported_guid']; } /* Compare GUIDs */ $item_count = 0; foreach ($items as $guid => $data) { if (in_array($guid, $final_guids)) { continue; } else { $item_count++; /* Make sure each item has a unique date */ $final_items[$data['unixdate'] . $item_count] = $data; } } /* Sort Array */ krsort($final_items); /* Pick off last X */ $count = 1; $tmp_final_items = $final_items; $final_items = array(); foreach ($tmp_final_items as $date => $data) { $final_items[$date] = $data; if ($count >= $row['rss_import_pergo']) { break; } $count++; } /* Anything left? */ if (!count($final_items)) { continue; } /* Figure out MID */ $member = $this->DB->buildAndFetch(array('select' => 'member_id, name, members_display_name, ip_address', 'from' => 'members', 'where' => "member_id={$row['rss_import_mid']}")); if (!$member['member_id']) { continue; } /* Set member in post class */ $this->post->setAuthor($member['member_id']); $this->post->setForumData($this->registry->getClass('class_forums')->forum_by_id[$row['rss_import_forum_id']]); /* Make 'dem posts */ $affected_forum_ids[] = $row['rss_import_forum_id']; foreach ($final_items as $topic_item) { /* Fix & */ $topic_item['title'] = str_replace('&', '&', $topic_item['title']); $topic_item['title'] = trim(IPSText::br2nl($topic_item['title'])); $topic_item['title'] = strip_tags($topic_item['title']); $topic_item['title'] = IPSText::parseCleanValue($topic_item['title']); /* Fix up &reg; */ $topic_item['title'] = str_replace('&reg;', '®', $topic_item['title']); if ($row['rss_import_topic_pre']) { $topic_item['title'] = str_replace(' ', ' ', str_replace('&nbsp;', ' ', $row['rss_import_topic_pre'])) . ' ' . $topic_item['title']; } /* Build topic insert array */ $topic = array('title' => IPSText::mbsubstr($topic_item['title'], 0, 250), 'title_seo' => IPSText::makeSeoTitle(IPSText::mbsubstr($topic_item['title'], 0, 250)), 'description' => '', 'state' => $row['rss_import_topic_open'] ? 'open' : 'closed', 'posts' => 0, 'starter_id' => $member['member_id'], 'starter_name' => $member['members_display_name'], 'start_date' => $topic_item['unixdate'], 'last_poster_id' => $member['member_id'], 'last_poster_name' => $member['members_display_name'], 'last_post' => $topic_item['unixdate'], 'icon_id' => 0, 'author_mode' => 1, 'poll_state' => 0, 'last_vote' => 0, 'views' => 0, 'forum_id' => $row['rss_import_forum_id'], 'approved' => $row['rss_import_topic_hide'] ? 0 : 1, 'pinned' => 0); /* More post class stuff */ $this->post->setPublished($row['rss_import_topic_hide'] ? FALSE : TRUE); /* Sort post content: Convert HTML to BBCode */ IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = intval($row['rss_import_allow_html']); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; $this->memberData['_canUseRTE'] = true; $_POST['ed-0_wysiwyg_used'] = 1; IPSText::getTextClass('editor')->method = 'rte'; /* Clean up.. */ $topic_item['content'] = preg_replace("#<br />(\r)?\n#is", "<br />", $topic_item['content']); /* Add in Show link... */ if ($row['rss_import_showlink'] and $topic_item['link']) { $the_link = str_replace('{url}', trim($topic_item['link']), $row['rss_import_showlink']); if ($row['rss_import_allow_html']) { $_POST['_tmpPostField'] = IPSText::getTextClass('bbcode')->preEditParse(stripslashes($the_link)); $the_link = "<br /><br />" . IPSText::getTextClass('bbcode')->preDbParse(IPSText::getTextClass('editor')->processRawPost('_tmpPostField')); } else { $the_link = "<br /><br />" . $the_link; } $topic_item['content'] .= $the_link; } if (!$row['rss_import_allow_html']) { $_POST['_tmpPostField'] = stripslashes($topic_item['content']); //IPSText::getTextClass( 'bbcode' )->preEditParse( stripslashes($topic_item['content']) ); $post_content = IPSText::getTextClass('bbcode')->preDbParse(IPSText::getTextClass('editor')->processRawPost('_tmpPostField')); } else { $post_content = stripslashes($topic_item['content']); } /* Build Post insert array */ $post = array('author_id' => $member['member_id'], 'use_sig' => 1, 'use_emo' => 1, 'ip_address' => $member['ip_address'], 'post_date' => $topic_item['unixdate'], 'icon_id' => 0, 'post' => $post_content, 'author_name' => $member['members_display_name'], 'topic_id' => "", 'queued' => 0, 'post_htmlstate' => 0); /* Insert the topic into the database to get the last inserted value of the auto_increment field follow suit with the post */ $this->DB->insert('topics', $topic); $post['topic_id'] = $this->DB->getInsertId(); $topic['tid'] = $post['topic_id']; /* Update the post info with the upload array info */ $post['post_key'] = md5(uniqid(microtime())); $post['new_topic'] = 1; /* Add post to DB */ $this->DB->insert('posts', $post); $post['pid'] = $this->DB->getInsertId(); /* Update topic with firstpost ID */ $this->DB->build(array('update' => 'topics', 'set' => "topic_firstpost=" . $post['pid'], 'where' => "tid=" . $topic['tid'])); $this->DB->execute(); /* Insert GUID match */ $this->DB->insert('rss_imported', array('rss_imported_impid' => $row['rss_import_id'], 'rss_imported_guid' => $topic_item['guid'], 'rss_imported_tid' => $topic['tid'])); /* Are we tracking this forum? If so generate some mailies - yay! */ $this->post->forum = $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']]; $this->post->sendOutTrackedForumEmails($row['rss_import_forum_id'], $topic['tid'], $topic['title'], $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']]['name'], $post['post'], $member['member_id'], $member['members_display_name']); if ($topic['approved'] == 0) { $this->post->sendNewTopicForApprovalEmails($topic['tid'], $topic['title'], $topic['starter_name'], $post['pid']); } $this->import_count++; /* Increment user? */ if ($row['rss_import_inc_pcount'] and $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']]['inc_postcount']) { if (!$affected_members[$member['member_id']] or $affected_members[$member['member_id']] < 0) { $affected_members[$member['member_id']] = 0; } $affected_members[$member['member_id']]++; } } } } /* Update Members */ if (is_array($affected_members) and count($affected_members)) { foreach ($affected_members as $mid => $inc) { if ($mid and $inc) { $this->post->setAuthor($mid); $this->post->incrementUsersPostCount($inc); } } } /* Recount Stats */ if (is_array($affected_forum_ids) and count($affected_forum_ids)) { foreach ($affected_forum_ids as $fid) { $this->func_mod->forumRecount($fid); } $this->func_mod->statsRecount(); } /* Return */ if ($return) { $this->registry->output->global_message = $this->lang->words['im_recached']; if (count($rss_error)) { $this->registry->output->global_message .= "<br />" . implode("<br />", $rss_error); } $this->rssImportOverview(); return; } else { return TRUE; } }
/** * 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) { //----------------------------------------- // Show the form again //----------------------------------------- return FALSE; } /* Got a topics table to update? */ $updateTopicTable = array(); //----------------------------------------- // Reset some data //----------------------------------------- $post['ip_address'] = $this->_originalPost['ip_address']; $post['topic_id'] = $this->_originalPost['topic_id']; $post['author_id'] = $this->_originalPost['author_id']; $post['post_date'] = $this->_originalPost['post_date']; $post['author_name'] = $this->_originalPost['author_name']; $post['queued'] = $this->_originalPost['queued']; $post['edit_time'] = $this->getDate() ? $this->getDate() : IPS_UNIX_TIME_NOW; $post['edit_name'] = $this->getAuthor('members_display_name'); if ($this->_originalPost['new_topic'] == 1) { /* Tagging */ if (isset($_POST['ipsTags'])) { $this->registry->tags->replace($_POST['ipsTags'], array('meta_id' => $topic['tid'], 'meta_parent_id' => $topic['forum_id'], 'member_id' => $this->memberData['member_id'], 'meta_visible' => $topic['approved'])); } /* Like if not ajax edit */ if (!IPS_IS_AJAX) { $this->addTopicToTracker($topic['tid']); } //----------------------------------------- // Update open and close times //----------------------------------------- if ($this->can_set_open_time and $this->times['open']) { $updateTopicTable['topic_open_time'] = intval($this->times['open']); if ($topic['topic_open_time'] and $this->times['open']) { $updateTopicTable['state'] = 'closed'; if (IPS_UNIX_TIME_NOW > $topic['topic_open_time']) { if (IPS_UNIX_TIME_NOW < $topic['topic_close_time']) { $updateTopicTable['state'] = 'open'; } } } if (!$this->times['open'] and $topic['topic_open_time']) { if ($topic['state'] == 'closed') { $updateTopicTable['state'] = 'open'; } } } else { if ($this->can_set_open_time and $topic['topic_open_time']) { $updateTopicTable['topic_open_time'] = 0; } } if ($this->can_set_close_time and $this->times['close']) { $updateTopicTable['topic_close_time'] = intval($this->times['close']); //----------------------------------------- // Was a close time, but not now? //----------------------------------------- if (!$this->times['close'] and $topic['topic_close_time']) { if ($topic['state'] == 'closed') { $updateTopicTable['state'] = 'open'; } } } else { if ($this->can_set_close_time and $topic['topic_close_time']) { $updateTopicTable['topic_close_time'] = 0; } } if ($this->edit_title) { if ($this->getForumID() != $topic['forum_id']) { $updateTopicTable['forum_id'] = $this->getForumID(); } } } //----------------------------------------- // Update poll //----------------------------------------- if ($this->can_add_poll) { if (is_array($this->poll_questions) and count($this->poll_questions)) { $poll_only = 0; if ($this->settings['ipb_poll_only'] and $this->request['poll_only'] == 1) { $poll_only = 1; } $poll_view_voters = !$this->poll_data['votes'] ? $this->request['poll_view_voters'] : $this->poll_data['poll_view_voters']; if ($topic['poll_state']) { $_pollData = array('votes' => intval($this->poll_total_votes), 'choices' => addslashes(serialize($this->poll_questions)), 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters)); /* Data Hook Location */ IPSLib::doDataHooks($_pollData, 'editPostUpdatePoll'); $this->DB->update('polls', $_pollData, 'tid=' . $topic['tid']); if ($this->poll_data['choices'] != serialize($this->poll_questions) or $this->poll_data['votes'] != intval($this->poll_total_votes)) { $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => $this->lang->words['edited_poll'], 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING')))); } } else { $_pollData = array('tid' => $topic['tid'], 'forum_id' => $this->getForumData('id'), 'start_date' => IPS_UNIX_TIME_NOW, 'choices' => addslashes(serialize($this->poll_questions)), 'starter_id' => $this->getAuthor('member_id'), 'votes' => 0, 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters)); /* Data Hook Location */ IPSLib::doDataHooks($_pollData, 'editPostAddPoll'); $this->DB->insert('polls', $_pollData); $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => sprintf($this->lang->words['added_poll'], $this->request['poll_question']), 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING')))); /* Update topics table later */ $updateTopicTable['poll_state'] = 1; $updateTopicTable['last_vote'] = 0; } } else { /* Remove the poll */ $this->DB->delete('polls', 'tid=' . $topic['tid']); $this->DB->delete('voters', 'tid=' . $topic['tid']); /* Update topics table later */ $updateTopicTable['poll_state'] = 0; $updateTopicTable['last_vote'] = 0; } } //----------------------------------------- // Update topic title? //----------------------------------------- if ($this->edit_title == 1) { //----------------------------------------- // Update topic title //----------------------------------------- if ($this->_topicTitle != "") { if ($this->_topicTitle != $topic['title'] or !$topic['title_seo']) { $updateTopicTable['title'] = $this->_topicTitle; $updateTopicTable['title_seo'] = IPSText::makeSeoTitle($this->_topicTitle); $_forumUpdate = array(); if ($topic['tid'] == $this->getForumData('last_id')) { $_forumUpdate['last_title'] = $updateTopicTable['title']; $_forumUpdate['seo_last_title'] = $updateTopicTable['title_seo']; } if ($topic['tid'] == $this->getForumData('newest_id')) { $_forumUpdate['newest_title'] = $updateTopicTable['title']; } if (count($_forumUpdate)) { $this->DB->update('forums', $_forumUpdate, 'id=' . $this->getForumData('id')); } if ($this->moderator['edit_topic'] == 1 or $this->getAuthor('g_is_supmod') == 1) { $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => sprintf($this->lang->words['edited_topic_title'], $topic['title'], $this->_topicTitle), 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING')))); } } } } //----------------------------------------- // Reason for edit? //----------------------------------------- if ($this->_bypassPermChecks or isset($this->moderator['edit_post']) && $this->moderator['edit_post'] or $this->getAuthor('g_is_supmod')) { $post['post_edit_reason'] = trim($this->request['post_edit_reason']); } //----------------------------------------- // Update the database (ib_forum_post) //----------------------------------------- $post['append_edit'] = 1; if ($this->_bypassPermChecks or $this->getAuthor('g_append_edit')) { if ($this->request['add_edit'] != 1) { $post['append_edit'] = 0; } } /* HTML Status */ $post['post_htmlstate'] = $this->getSettings('post_htmlstatus'); /* Typecast */ $this->DB->setDataType('post_edit_reason', 'string'); /* Data Hook Location */ IPSLib::doDataHooks($post, 'editPostData'); $this->DB->update('posts', $post, 'pid=' . $this->_originalPost['pid']); /* Got a topic to update? */ $updateTopicTable['post_data'] = $post; $updateTopicTable['forum_data'] = $this->getForumData(); IPSLib::doDataHooks($updateTopicTable, 'editPostTopicData'); unset($updateTopicTable['post_data'], $updateTopicTable['forum_data']); // Remove added data if (count($updateTopicTable)) { $this->DB->update('topics', $updateTopicTable, 'tid=' . $topic['tid']); } /* remove saved content */ if ($this->memberData['member_id']) { $this->editor->removeAutoSavedContent(array('member_id' => $this->memberData['member_id'], 'autoSaveKey' => 'edit-' . intval($this->_originalPost['pid']))); } /* Add to cache */ IPSContentCache::update($this->_originalPost['pid'], 'post', $this->formatPostForCache($post['post'])); /* Upload Attachments */ $this->uploadAttachments($this->post_key, $this->_originalPost['pid']); //----------------------------------------- // Make attachments "permanent" //----------------------------------------- $this->makeAttachmentsPermanent($this->post_key, $this->_originalPost['pid'], 'post', array('topic_id' => $topic['tid'])); //----------------------------------------- // Make sure paperclip symbol is OK //----------------------------------------- $this->recountTopicAttachments($topic['tid']); //----------------------------------------- // Leave data for other apps //----------------------------------------- $this->setTopicData($topic); $this->setPostData(array_merge($this->_originalPost, $post)); return TRUE; }
/** * Wizard launcher. Should determine the next step necessary and act appropriately. * * @access public * @param array Session data * @return string HTML to output to screen */ public function returnNextStep($session) { $session['config_data'] = unserialize($session['wizard_config']); $session['wizard_step'] = $this->request['step'] ? $this->request['step'] : 1; if ($session['wizard_step'] > 1 and !$this->request['continuing']) { $session = $this->_storeSubmittedData($session); } $newStep = $session['wizard_step'] + 1; $html = ''; switch ($newStep) { //----------------------------------------- // Step 2: Allow to select block type //----------------------------------------- case 2: $session['config_data']['type'] = $session['config_data']['type'] ? $session['config_data']['type'] : 'html'; $html = $this->html->custom__wizard_2($session); break; //----------------------------------------- // Step 3: Fill in name and description //----------------------------------------- //----------------------------------------- // Step 3: Fill in name and description //----------------------------------------- case 3: $session['config_data']['hide_empty'] = $session['config_data']['hide_empty'] ? $session['config_data']['hide_empty'] : 0; $session['config_data']['title'] = $session['config_data']['title'] ? $session['config_data']['title'] : $session['wizard_name']; //----------------------------------------- // Category, if available //----------------------------------------- $categories = array(); $this->DB->build(array('select' => '*', 'from' => 'ccs_containers', 'where' => "container_type='block'", 'order' => 'container_order ASC')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $categories[] = array($r['container_id'], $r['container_name']); } if (count($categories)) { array_unshift($categories, array('0', $this->lang->words['no_selected_cat'])); } $html = $this->html->custom__wizard_3($session, $categories); break; //----------------------------------------- // Step 4: Configure the caching options //----------------------------------------- //----------------------------------------- // Step 4: Configure the caching options //----------------------------------------- case 4: $html = $this->html->custom__wizard_4($session); break; //----------------------------------------- // Step 5: Edit the HTML template //----------------------------------------- //----------------------------------------- // Step 5: Edit the HTML template //----------------------------------------- case 5: if ($session['config_data']['type'] == 'basic') { IPSText::getTextClass('bbcode')->bypass_badwords = 1; IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = 1; IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'global'; if (IPSText::getTextClass('editor')->method == 'rte') { $session['config_data']['content'] = IPSText::getTextClass('bbcode')->convertForRTE($session['config_data']['content']); } else { $session['config_data']['content'] = IPSText::getTextClass('bbcode')->preEditParse($session['config_data']['content']); } $editor_area = IPSText::getTextClass('editor')->showEditor($session['config_data']['content'], 'custom_content'); } else { $editor_area = $this->registry->output->formTextarea("custom_content", IPSText::br2nl($session['config_data']['content']), 100, 30, "custom_content", "style='width:100%;'"); } $html = $this->html->custom__wizard_5($session, $editor_area); break; //----------------------------------------- // Step 6: Save to DB final, and show code to add to pages //----------------------------------------- //----------------------------------------- // Step 6: Save to DB final, and show code to add to pages //----------------------------------------- case 6: $block = array('block_active' => 1, 'block_name' => $session['config_data']['title'], 'block_key' => $session['config_data']['key'], 'block_description' => $session['config_data']['description'], 'block_type' => 'custom', 'block_content' => $session['config_data']['content'], 'block_category' => $session['config_data']['category'], 'block_cache_ttl' => $session['config_data']['cache_ttl'], 'block_config' => serialize(array('type' => $session['config_data']['type'], 'hide_empty' => $session['config_data']['hide_empty']))); if ($session['config_data']['block_id']) { $this->DB->update('ccs_blocks', $block, 'block_id=' . $session['config_data']['block_id']); $block['block_id'] = $session['config_data']['block_id']; //----------------------------------------- // Clear page caches //----------------------------------------- $this->DB->update('ccs_pages', array('page_cache' => null)); } else { $this->DB->insert('ccs_blocks', $block); $block['block_id'] = $this->DB->getInsertId(); } //----------------------------------------- // Recache block //----------------------------------------- $block['block_cache_output'] = $this->recacheBlock($block); $block['block_cache_last'] = time(); //----------------------------------------- // Delete wizard session and show done screen //----------------------------------------- $this->DB->delete('ccs_block_wizard', "wizard_id='{$session['wizard_id']}'"); $html = $this->html->custom__wizard_DONE($block); break; } return $html; }
private function _compilePost(&$content, $publish) { //---------------------------------------------------------------- // Do we have a valid post? //---------------------------------------------------------------- ipsRegistry::$settings['blog_max_entry_length'] = ipsRegistry::$settings['blog_max_entry_length'] ? ipsRegistry::$settings['blog_max_entry_length'] : 2140000; if (strlen(trim(IPSText::br2nl($content))) < 1) { $this->error = $this->registry->class_localization->words['blogger_emptypost']; return false; } if (strlen($content) > ipsRegistry::$settings['blog_max_entry_length'] * 1024) { $this->error = $this->registry->class_localization->words['blogger_toolong']; return false; } //------------------------------------------------- // check to make sure we have a valid entry title //------------------------------------------------- $title = $content['title']; # Fix & $title = str_replace('&', '&', $title); $title = IPSText::parseCleanValue($title); # Fix up &reg; $title = str_replace('&reg;', '®', $title); $title = IPSText::getTextClass('parser')->stripBadWords($title); $title = str_replace("<br>", "", $title); $title = trim($title); //------------------------------------------------- // More unicode.. //------------------------------------------------- $temp = IPSText::stripslashes($title); $temp = preg_replace("/&#([0-9]+);/", "-", $temp); if (strlen($temp) > 64) { $this->error = $this->registry->class_localization->words['blogger_title_toolong']; return false; } if (strlen($temp) < 2 or !$title) { $this->error = $this->registry->class_localization->words['blogger_notitle']; return false; } //-------------------------------------------- // Sort post content: Convert HTML to BBCode //-------------------------------------------- IPSText::getTextClass('parser')->parse_smilies = 1; IPSText::getTextClass('parser')->parse_html = 0; IPSText::getTextClass('parser')->parse_bbcode = 1; IPSText::getTextClass('parser')->parsing_section = 'blog_entry'; //-------------------------------------------- // Clean up.. //-------------------------------------------- $content = preg_replace("#<br />(\r)?\n#is", "<br />", $content); //----------------------------------------- // Post process the editor // Now we have safe HTML and bbcode //----------------------------------------- $content = IPSText::getTextClass('parser')->preDbParse(IPSText::getTextClass('editor')->processRawPost(IPSText::stripslashes($content))); $dte = time(); $this->entry = array('blog_id' => $this->blog['blog_id'], 'entry_author_id' => $this->memberData['member_id'], 'entry_author_name' => $this->memberData['members_display_name'], 'entry_date' => $dte, 'entry_name' => $title, 'entry' => $content, 'entry_status' => $publish ? 'published' : 'draft', 'entry_post_key' => md5(microtime()), 'entry_html_state' => 0, 'entry_use_emo' => 1, 'entry_last_update' => $dte, 'entry_gallery_album' => 0, 'entry_poll_state' => 0); // If we had any errors, parse them back to this class // so we can track them later. if (is_array(IPSText::getTextClass('parser')->error) && count(IPSText::getTextClass('parser')->error) > 0) { $this->error = implode(" : ", IPSText::getTextClass('parser')->error); return false; } return true; }
/** * Builds an array of output for used in threaded view * * @access public * @param array $post * @param integer $depth * @return array **/ public function _threadedRenderListRow($post, $depth) { $post['depthguide'] = ""; $this->settings['post_showtext_notitle'] = 1; for ($i = 1; $i < $depth; $i++) { $post['depthguide'] .= $this->depth_guide[$i]; } // Last child? if ($depth > 0) { $last_id = count($this->structured_pids[$post['post_parent']]) - 1; if ($this->structured_pids[$post['post_parent']][$last_id] == $post['pid']) { $this->depth_guide[$depth] = '<img src="' . $this->settings['img_url'] . '/spacer.gif" alt="" width="20" height="16">'; $post['depthguide'] .= "<img src='" . $this->settings['img_url'] . "/to_post_no_children.gif' alt='-' />"; } else { $this->depth_guide[$depth] = '<img src="' . $this->settings['img_url'] . '/to_down_pipe.gif" alt="|" />'; $post['depthguide'] .= "<img src='" . $this->settings['img_url'] . "/to_post_with_children.gif' alt='-' />"; } } if (!$post['post_title']) { if ($this->settings['post_showtext_notitle']) { $post_text = IPSText::getTextClass('bbcode')->stripAllTags(strip_tags(IPSText::br2nl($post['post']))); if (IPSText::mbstrlen($post_text) > 50) { $post['post_title'] = IPSText::truncate($post_text, 50) . '...'; } else { $post['post_title'] = $post_text; } if (!trim($post['post_title'])) { $post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title']; } } else { $post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title']; } } $post['linked_name'] = IPSLib::makeProfileLink($post['author_name'], $post['author_id']); $post['formatted_date'] = $this->registry->class_localization->getDate($post['post_date'], 'LONG'); $post['new_post'] = 't_threaded_read'; if ($post['post_date'] > $this->topics->last_read_tid) { $post['new_post'] = 't_threaded_read'; } if (strstr($this->used_post_ids, ',' . $post['pid'] . ',')) { $post['_show_highlight'] = 1; } return $post; }
/** * 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); } if (IPSText::mbstrlen($event_title) > 64) { $this->registry->output->showError('calendar_title_too_long', 10420); } /* Are we an admin, and have we set w/groups can see */ if ($this->memberData['g_access_cp']) { if (is_array($_POST['e_groups'])) { foreach ($this->cache->getCache('group_cache') as $gid => $groupCache) { if ($groupCache['g_access_cp']) { $_POST['e_groups'][] = $gid; } } $read_perms = implode(",", $_POST['e_groups']); } if ($read_perms == "") { $read_perms = '*'; } } /* Check dates: Range */ if ($form_type == 'range') { if ($end_year < $year) { $this->registry->output->showError('calendar_range_wrong', 10421); } if ($end_year == $year) { if ($end_month < $month) { $this->registry->output->showError('calendar_range_wrong', 10422); } if ($end_month == $month and $end_day <= $day) { $this->registry->output->showError('calendar_range_wrong', 10423); } } $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year) + $offset; // # Midday $_final_unix_to = gmmktime(23, 59, 59, $end_month, $end_day, $end_year) + $offset; // # End of the day $event_ranged = 1; $set_time = 0; $hour_min = array(); } elseif ($form_type == 'recur') { if ($this->request['recur_unit']) { $event_repeat = 1; } if ($end_year < $year) { $this->registry->output->showError('calendar_range_wrong', 10424); } if ($end_year == $year) { if ($end_month < $month) { $this->registry->output->showError('calendar_range_wrong', 10425); } if ($end_month == $month and $end_day <= $day) { $this->registry->output->showError('calendar_range_wrong', 10426); } } $hour = 0; $min = 0; if ($set_time) { if (is_array($hour_min)) { $hour = $hour_min[0]; $min = $hour_min[1]; } } $_final_unix_from = gmmktime($hour, $min, 0, $month, $day, $year) + $offset; $_final_unix_to = gmmktime($hour, $min, 0, $end_month, $end_day, $end_year) + $offset; # End of the day $event_recur = 1; } else { $hour = 0; $min = 0; if ($set_time) { if (is_array($hour_min)) { $hour = $hour_min[0]; $min = $hour_min[1]; } } $_final_unix_from = gmmktime($hour, $min, 0, $month, $day, $year) - $offset; $_final_unix_to = 0; } /* Do we have a sensible date? */ if (!checkdate($month, $day, $year)) { $this->registry->output->showError('calendar_invalid_date', 10427); } /* Post process the editor, now we have safe HTML and bbcode */ IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_smilies = intval($allow_emoticons); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'calendar'; $this->request['Post'] = IPSText::getTextClass('editor')->processRawPost('Post'); $this->request['Post'] = IPSText::getTextClass('bbcode')->preDbParse($this->request['Post']); /* Event approved? */ $event_approved = $this->can_avoid_queue ? 1 : ($this->calendar_cache[$event_calendar_id]['cal_moderate'] ? 0 : 1); if ($private_event == 1) { $event_approved = 1; } /* Create new event */ if ($type == 'add') { /* Add it to the DB */ $this->DB->insert('cal_events', array('event_calendar_id' => $event_calendar_id, 'event_member_id' => $this->memberData['member_id'], 'event_content' => $this->request['Post'], 'event_title' => $event_title, 'event_smilies' => $allow_emoticons, 'event_perms' => $read_perms, 'event_private' => $private_event, 'event_approved' => $event_approved, 'event_unixstamp' => time(), 'event_recurring' => $recur_unit, 'event_tz' => $event_tz, 'event_timeset' => count($hour_min) > 0 ? intval($hour_min[0]) . ":" . intval($hour_min[1]) : 0, 'event_unix_from' => $_final_unix_from, 'event_unix_to' => $_final_unix_to, 'event_all_day' => $event_all_day)); /* Recache */ $this->calendarCallRecache(); /* Bounce */ if ($event_approved) { $this->registry->output->redirectScreen($this->lang->words['new_event_redirect'], $this->settings['base_url'] . "app=calendar&module=calendar&cal_id={$event_calendar_id}"); } else { $this->registry->output->redirectScreen($this->lang->words['new_event_mod'], $this->settings['base_url'] . "app=calendar&module=calendar&cal_id{$event_calendar_id}"); } } else { /* Update the database recored */ $this->DB->update('cal_events', array('event_calendar_id' => $event_calendar_id, 'event_content' => $this->request['Post'], 'event_title' => $event_title, 'event_smilies' => $allow_emoticons, 'event_perms' => $read_perms, 'event_private' => $private_event, 'event_approved' => $event_approved, 'event_unixstamp' => time(), 'event_recurring' => $recur_unit, 'event_tz' => $event_tz, 'event_timeset' => count($hour_min) > 0 ? intval($hour_min[0]) . ":" . intval($hour_min[1]) : 0, 'event_unix_from' => $_final_unix_from, 'event_unix_to' => $_final_unix_to, 'event_all_day' => $event_all_day), 'event_id=' . $event_id); /* Recache */ $this->calendarCallRecache(); /* Bounce */ if ($event_approved) { $this->registry->output->redirectScreen($this->lang->words['edit_event_redirect'], $this->settings['base_url'] . "app=calendar&module=calendar&cal_id={$event_calendar_id}&do=showevent&event_id={$event_id}"); } else { $this->registry->output->redirectScreen($this->lang->words['new_event_mod'], $this->settings['base_url'] . "app=calendar&module=calendar&cal_id={$event_calendar_id}"); } } }
/** * Save the form * * @return @e void [Outputs to screen] */ protected function save() { //----------------------------------------- // INIT //----------------------------------------- $name = trim(IPSText::alphanumericalClean($this->request['name'])); $this->hookId = intval($this->request['id']); $this->hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $this->hookId)); $this->data = IPSLib::isSerialized($this->hook['hook_extra_data']) ? unserialize($this->hook['hook_extra_data']) : array('display' => array()); $output = ''; //----------------------------------------- // Got a hook? //----------------------------------------- if (!$this->hook['hook_id']) { $this->returnJsonError($this->lang->words['hook_cannot_load']); } //----------------------------------------- // Run the proper operation //----------------------------------------- switch ($name) { case 'settings': $_settingGroups = $this->hooksFunctions->getSettingGroups(); $_settings = $this->hooksFunctions->getSettings(); $toSave = array(); $toDisplay = array(); $toSave['settingGroups'] = array(); $toSave['settings'] = array(); if (is_array($this->request['setting_groups']) and count($this->request['setting_groups'])) { $toSave['settingGroups'] = $this->request['setting_groups']; foreach ($_settingGroups as $data) { if (in_array($data[0], $toSave['settingGroups'])) { $toDisplay['settingGroups'][] = $data[1]; } } } if (is_array($this->request['settings']) and count($this->request['settings'])) { $toSave['settings'] = $this->request['settings']; foreach ($_settings as $data) { if (in_array($data[0], $toSave['settings'])) { $toDisplay['settings'][] = $data[1]; } } } if (count($toSave['settingGroups'])) { $this->data['settingGroups'] = $toSave['settingGroups']; } else { unset($this->data['settingGroups']); } if (count($toSave['settings'])) { $this->data['settings'] = $toSave['settings']; } else { unset($this->data['settings']); } if (count($toDisplay['settingGroups'])) { $output .= "{$this->lang->words['hook_setting_groups']} " . implode(', ', $toDisplay['settingGroups']); } if (count($toDisplay['settings'])) { if (count($toDisplay['settingGroups'])) { $output .= '<br />'; } $output .= "{$this->lang->words['hook_settings']} " . implode(', ', $toDisplay['settings']); } if ($output) { $this->data['display']['settings'] = $output; } else { $output = $this->lang->words['hook_no_settings']; if (isset($this->data['display']['settings'])) { unset($this->data['display']['settings']); } } break; case 'language': $_langFiles = $this->hooksFunctions->getLanguageFiles(); $ids = array(); $files = array(); $strings = array(); $toDisplay = array(); $this->data['language'] = array(); foreach ($_POST as $k => $v) { if (preg_match("/^language_(\\d+)\$/", $k, $matches)) { $files[$matches[1]] = $v; $strings[$matches[1]] = $this->request['strings_' . $matches[1]]; $ids[$matches[1]] = $matches[1]; } } foreach ($ids as $id) { if ($files[$id] and $strings[$id]) { $this->data['language'][$files[$id]] = $strings[$id]; $toDisplay[] = "{$this->lang->words['hook_from']} {$files[$id]}: " . implode(', ', $strings[$id]); } } if (!count($this->data['language'])) { unset($this->data['language']); } if (count($toDisplay)) { $output .= implode('<br />', $toDisplay); } if ($output) { $this->data['display']['language'] = $output; } else { $output = $this->lang->words['hook_no_language']; if (isset($this->data['display']['language'])) { unset($this->data['display']['language']); } } break; case 'modules': $_modules = $this->hooksFunctions->getModules(); $toSave = array(); $toDisplay = array(); if (is_array($this->request['modules']) and count($this->request['modules'])) { $toSave = $this->request['modules']; } foreach ($_modules as $data) { if (in_array($data[0], $toSave)) { $toDisplay[] = $data[1]; } } if (count($toDisplay)) { $output .= "{$this->lang->words['hook_modules']} " . implode(', ', $toDisplay); } if (count($toSave)) { $this->data['modules'] = $toSave; } else { unset($this->data['modules']); } if ($output) { $this->data['display']['modules'] = $output; } else { $output = $this->lang->words['hook_no_modules']; if (isset($this->data['display']['modules'])) { unset($this->data['display']['modules']); } } break; case 'help': $_help = $this->hooksFunctions->getHelpFiles(); $toSave = array(); $toDisplay = array(); if (is_array($this->request['help']) and count($this->request['help'])) { $toSave = $this->request['help']; } foreach ($_help as $data) { if (in_array($data[0], $toSave)) { $toDisplay[] = $data[1]; } } if (count($toDisplay)) { $output .= "{$this->lang->words['hook_help']} " . implode(', ', $toDisplay); } if (count($toSave)) { $this->data['help'] = $toSave; } else { unset($this->data['help']); } if ($output) { $this->data['display']['help'] = $output; } else { $output = $this->lang->words['hook_no_help']; if (isset($this->data['display']['help'])) { unset($this->data['display']['help']); } } break; case 'skins': $_skinFiles = $this->hooksFunctions->getSkinGroups(); $ids = array(); $files = array(); $templates = array(); $toDisplay = array(); $this->data['templates'] = array(); foreach ($_POST as $k => $v) { if (preg_match("/^skin_(\\d+)\$/", $k, $matches)) { $files[$matches[1]] = $v; $_templates = array(); foreach ($this->request['templates_' . $matches[1]] as $v) { if ($v) { $templates[$matches[1]][] = $v; } } $ids[$matches[1]] = $matches[1]; } } foreach ($ids as $id) { if ($files[$id] and $templates[$id]) { $this->data['templates'][$files[$id]] = $templates[$id]; $toDisplay[] = "{$this->lang->words['hook_from']} {$files[$id]}: " . implode(', ', $templates[$id]); } } if (!count($this->data['templates'])) { unset($this->data['templates']); } if (count($toDisplay)) { $output .= implode('<br />', $toDisplay); } if ($output) { $this->data['display']['templates'] = $output; } else { $output = $this->lang->words['hook_no_skin']; if (isset($this->data['display']['templates'])) { unset($this->data['display']['templates']); } } break; case 'css': /* INIT */ $_cssFiles = $this->hooksFunctions->getCSSFiles(); $toSave = array(); $toDisplay = array(); /* Check to see if any were selected */ if (is_array($this->request['css']) && count($this->request['css'])) { $toSave = $this->request['css']; } /* Output */ foreach ($_cssFiles as $data) { if (in_array($data[0], $toSave)) { $toDisplay[] = $data[1]; } } if (count($toDisplay)) { $output .= "{$this->lang->words['hook_css']} " . implode(', ', $toDisplay); } /* Save */ if (count($toSave)) { $this->data['css'] = $toSave; } else { unset($this->data['css']); } if ($output) { $this->data['display']['css'] = $output; } else { $output = $this->lang->words['hook_no_css']; if (isset($this->data['display']['css'])) { unset($this->data['display']['css']); } } break; case 'replacements': /* INIT */ $_replacements = $this->hooksFunctions->getSkinReplacements(); $toSave = array(); $toDisplay = array(); /* Check to see if any were selected */ if (is_array($this->request['replacements']) && count($this->request['replacements'])) { $toSave = $this->request['replacements']; } /* Output */ foreach ($_replacements as $data) { if (in_array($data[0], $toSave)) { $toDisplay[] = $data[1]; } } if (count($toDisplay)) { $output .= "{$this->lang->words['hook_replacements']} " . implode(', ', $toDisplay); } /* Save */ if (count($toSave)) { $this->data['replacements'] = $toSave; } else { unset($this->data['replacements']); } if ($output) { $this->data['display']['replacements'] = $output; } else { $output = $this->lang->words['hook_no_replacements']; if (isset($this->data['display']['replacements'])) { unset($this->data['display']['replacements']); } } break; case 'tasks': $_tasks = $this->hooksFunctions->getTasks(); $toSave = array(); $toDisplay = array(); if (is_array($this->request['tasks']) and count($this->request['tasks'])) { $toSave = $this->request['tasks']; } foreach ($_tasks as $data) { if (in_array($data[0], $toSave)) { $toDisplay[] = $data[1]; } } if (count($toDisplay)) { $output .= "{$this->lang->words['hook_tasks']} " . implode(', ', $toDisplay); } if (count($toSave)) { $this->data['tasks'] = $toSave; } else { unset($this->data['tasks']); } if ($output) { $this->data['display']['tasks'] = $output; } else { $output = $this->lang->words['hook_no_tasks']; if (isset($this->data['display']['tasks'])) { unset($this->data['display']['tasks']); } } break; case 'database': $types = array(array('0', $this->lang->words['hook_db_select']), array('create', $this->lang->words['hook_db_create']), array('alter', $this->lang->words['hook_db_alter']), array('update', $this->lang->words['hook_db_update']), array('insert', $this->lang->words['hook_db_insert'])); $alters = array(array('add', $this->lang->words['hook_db_addnew']), array('change', $this->lang->words['hook_db_change']), array('remove', $this->lang->words['hook_db_drop'])); $ids = array(); $toDisplay = array(); $this->data['database'] = array(); /* Since this is more complicated, just get ids for now... */ foreach ($_POST as $k => $v) { if (preg_match("/^type_(\\d+)\$/", $k, $matches)) { $ids[$matches[1]] = $matches[1]; } } /* Now loop through and set stuff properly.. */ foreach ($ids as $id) { $type = $this->request['type_' . $id]; if (!$type) { continue; } switch ($type) { case 'create': $name = $this->request['name_' . $id]; $fields = IPSText::br2nl($_POST['fields_' . $id]); $tabletype = $this->request['tabletype_' . $id]; if (!$name or !$fields) { continue; } $this->data['database']['create'][] = array('name' => $name, 'fields' => $fields, 'tabletype' => $tabletype); $text = "CREATE TABLE {$name} (\r\r\n\t\t\t\t\t\t\t\t\t\t{$fields}\r\r\n\t\t\t\t\t\t\t\t\t\t)"; if ($tabletype) { $text .= " ENGINE=" . $tabletype; } $toDisplay[] = nl2br($text); break; case 'alter': $altertype = $this->request['altertype_' . $id]; $table = $this->request['table_' . $id]; $field = $this->request['field_' . $id]; $newfield = $this->request['newfield_' . $id]; $fieldtype = $this->request['fieldtype_' . $id]; $default = $_POST['default_' . $id]; if (!$altertype or !$table or !$field) { continue; } $this->data['database']['alter'][] = array('altertype' => $altertype, 'table' => $table, 'field' => $field, 'newfield' => $newfield, 'fieldtype' => $fieldtype, 'default' => $default); $text = "ALTER TABLE {$table}"; switch ($altertype) { case 'add': $text .= " ADD {$field} {$fieldtype}"; if ($default !== '') { $text .= " DEFAULT {$default}"; } break; case 'change': $text .= " CHANGE {$field} {$newfield} {$fieldtype}"; if ($default !== '') { $text .= " DEFAULT {$default}"; } break; case 'remove': $text .= " DROP {$field}"; break; } $toDisplay[] = nl2br($text); break; case 'update': $table = $this->request['table_' . $id]; $field = $this->request['field_' . $id]; $newvalue = $_POST['newvalue_' . $id]; $oldvalue = $_POST['oldvalue_' . $id]; $where = $_POST['where_' . $id]; if (!$table or !$field or !$newvalue) { continue; } $this->data['database']['update'][] = array('table' => $table, 'field' => $field, 'newvalue' => $newvalue, 'oldvalue' => $oldvalue, 'where' => $where); $text = "UPDATE {$table} SET {$field}='{$newvalue}'"; if ($where) { $text .= " WHERE " . $where; } $toDisplay[] = nl2br($text); break; case 'insert': $table = $this->request['table_' . $id]; $updates = $_POST['updates_' . $id]; $fordelete = $_POST['fordelete_' . $id]; if (!$table or !$updates) { continue; } $this->data['database']['insert'][] = array('table' => $table, 'updates' => $updates, 'fordelete' => $fordelete); $cols = array(); $vals = array(); $index = 0; $toins = explode(',', $updates); foreach ($toins as $insertQuery) { $piece = explode('=', $insertQuery); $cols[$index] = $piece[0]; $vals[$index] = $piece[1]; $index++; } $text = "INSERT INTO {$table} ("; $text .= implode(', ', $cols); $text .= ") VALUES ('"; $text .= implode("', '", $vals); $text .= "')"; $toDisplay[] = nl2br($text); break; } } if (!count($this->data['database'])) { unset($this->data['database']); } if (count($toDisplay)) { $output .= implode('<br />', $toDisplay); } if ($output) { $this->data['display']['database'] = $output; } else { $output = $this->lang->words['hook_no_db']; if (isset($this->data['display']['database'])) { unset($this->data['display']['database']); } } break; case 'custom': $toSave = ''; $toDisplay = ''; if ($this->request['custom']) { $toSave = $this->request['custom']; $toDisplay = $this->request['custom']; } if ($toDisplay) { $output .= "install_" . $toDisplay; } if ($toSave) { $this->data['custom'] = $toSave; } else { unset($this->data['custom']); } if ($output) { $this->data['display']['custom'] = $output; } else { $output = $this->lang->words['hook_no_custom']; if (isset($this->data['display']['custom'])) { unset($this->data['display']['custom']); } } break; } /* Handle array data and save to DB */ if (empty($this->data['display'])) { unset($this->data['display']); } $this->DB->update('core_hooks', array('hook_extra_data' => count($this->data) ? serialize($this->data) : ''), 'hook_id=' . $this->hookId); //----------------------------------------- // Print... //----------------------------------------- $return = array('success' => true, 'message' => $output); $this->returnJsonArray($return); }
/** * Show the form to edit a forum * * @access public * @param string [new|edit] * @param boolean Whether to change forum to category/back * @return void Outputs to screen **/ public function forumForm($type = 'edit', $changetype = 0) { //----------------------------------------- // INIT //----------------------------------------- $addnew_type = ($this->request['type'] and $this->request['type']) ? $this->request['type'] : 'forum'; $form = array(); $forum = array(); $forum_id = $this->request['f'] ? intval($this->request['f']) : 0; $parentid = intval($this->request['p']) ? intval($this->request['p']) : -1; $cat_id = $this->request['c'] ? intval($this->request['c']) : 0; $f_name = $this->request['name'] ? $this->request['name'] : ''; $subcanpost = $cat_id == 1 ? 0 : 1; $perm_matrix = ""; $dd_state = array(0 => array(1, $this->lang->words['for_active']), 1 => array(0, $this->lang->words['for_readonly'])); $dd_moderate = array(0 => array(0, $this->lang->words['for_no']), 1 => array(1, $this->lang->words['for_modall']), 2 => array(2, $this->lang->words['for_modtop']), 3 => array(3, $this->lang->words['for_modrep'])); $dd_prune = array(0 => array(1, $this->lang->words['for_today']), 1 => array(5, $this->lang->words['for_last5']), 2 => array(7, $this->lang->words['for_last7']), 3 => array(10, $this->lang->words['for_last10']), 4 => array(15, $this->lang->words['for_last15']), 5 => array(20, $this->lang->words['for_last20']), 6 => array(25, $this->lang->words['for_last25']), 7 => array(30, $this->lang->words['for_last30']), 8 => array(60, $this->lang->words['for_last60']), 9 => array(90, $this->lang->words['for_last90']), 10 => array(100, $this->lang->words['for_showall'])); $dd_order = array(0 => array('last_post', $this->lang->words['for_s_last']), 1 => array('title', $this->lang->words['for_s_topic']), 2 => array('starter_name', $this->lang->words['for_s_name']), 3 => array('posts', $this->lang->words['for_s_post']), 4 => array('views', $this->lang->words['for_s_view']), 5 => array('start_date', $this->lang->words['for_s_date']), 6 => array('last_poster_name', $this->lang->words['for_s_poster'])); $dd_by = array(0 => array('Z-A', $this->lang->words['for_desc']), 1 => array('A-Z', $this->lang->words['for_asc'])); $dd_filter = array(0 => array('all', $this->lang->words['for_all']), 1 => array('open', $this->lang->words['for_open']), 2 => array('hot', $this->lang->words['for_hot']), 3 => array('poll', $this->lang->words['for_poll']), 4 => array('locked', $this->lang->words['for_locked']), 5 => array('moved', $this->lang->words['for_moved']), 6 => array('istarted', $this->lang->words['for_istarted']), 7 => array('ireplied', $this->lang->words['for_ireplied'])); //----------------------------------------- // EDIT //----------------------------------------- if ($type == 'edit') { //----------------------------------------- // Check //----------------------------------------- if (!$forum_id) { $this->registry->output->showError($this->lang->words['for_noforumselected'], 11314); } //----------------------------------------- // Do not show forum in forum list //----------------------------------------- $this->forum_functions->exclude_from_list = $forum_id; //----------------------------------------- // Get this forum //----------------------------------------- $forum = $this->DB->buildAndFetch(array('select' => 'f.*', 'from' => array('forums' => 'f'), 'where' => 'f.id=' . $this->request['f'], 'add_join' => array(array('select' => 'p.*', 'from' => array('permission_index' => 'p'), 'where' => "p.perm_type_id=f.id AND p.app='forums' AND p.perm_type='forum'", 'type' => 'left')))); //----------------------------------------- // Check //----------------------------------------- if ($forum['id'] == "") { $this->registry->output->showError($this->lang->words['for_noid'], 11315); } //----------------------------------------- // Set up code buttons //----------------------------------------- $addnew_type = $forum['parent_id'] == -1 ? 'category' : 'forum'; if ($changetype) { $addnew_type = $addnew_type == 'category' ? 'forum' : 'category'; } if ($addnew_type == 'category') { $title = sprintf($this->lang->words['for_editcat'], $forum['name']); $button = $this->lang->words['for_editcat_button']; $code = "doedit"; } else { $title = sprintf($this->lang->words['for_editfor'], $forum['name']); $button = $this->lang->words['for_editfor_button']; $code = "doedit"; } if ($addnew_type == 'category') { $convert = "<input type='submit' class='realbutton' onclick='ACPForums.convert()' value='{$this->lang->words['for_changefor']}' />"; } else { $convert = "<input type='submit' class='realbutton' onclick='ACPForums.convert()' value='{$this->lang->words['for_changecat']}' />"; } } else { # Ensure there is an ID $this->request['f'] = 0; if ($changetype) { $addnew_type = $addnew_type == 'category' ? 'forum' : 'category'; } if ($addnew_type == 'category') { $forum = array('sub_can_post' => $subcanpost, 'name' => $f_name ? $f_name : $this->lang->words['for_newcat'], 'parent_id' => $parentid, 'use_ibc' => 1, 'quick_reply' => 1, 'allow_poll' => 1, 'prune' => 100, 'topicfilter' => 'all', 'sort_key' => 'last_post', 'sort_order' => 'Z-A', 'inc_postcount' => 1, 'description' => '', 'status' => 0, 'redirect_url' => '', 'password' => '', 'password_override' => '', 'redirect_on' => 0, 'redirect_hits' => 0, 'permission_showtopic' => '', 'permission_custom_error' => '', 'use_html' => 0, 'allow_pollbump' => 0, 'forum_allow_rating' => 0, 'preview_posts' => 0, 'notify_modq_emails' => 0, 'can_view_others' => 1); $title = $this->lang->words['for_addcat']; $button = $this->lang->words['for_addcat']; $code = "donew"; } else { $forum = array('sub_can_post' => $subcanpost, 'name' => $f_name ? $f_name : $this->lang->words['for_newfor'], 'parent_id' => $parentid, 'use_ibc' => 1, 'quick_reply' => 1, 'allow_poll' => 1, 'prune' => 100, 'topicfilter' => 'all', 'sort_key' => 'last_post', 'sort_order' => 'Z-A', 'inc_postcount' => 1, 'description' => '', 'status' => 1, 'redirect_url' => '', 'password' => '', 'password_override' => '', 'redirect_on' => 0, 'redirect_hits' => 0, 'permission_showtopic' => '', 'permission_custom_error' => '', 'use_html' => 0, 'allow_pollbump' => 0, 'forum_allow_rating' => 0, 'preview_posts' => 0, 'notify_modq_emails' => 0, 'min_posts' => 0, 'hide_last_info' => 0, 'can_view_others' => 1); $title = $this->lang->words['for_addfor']; $button = $this->lang->words['for_addfor']; $code = "donew"; } if ($addnew_type == 'category') { $convert = "<input type='submit' class='realbutton' onclick='ACPForums.convert()' value='{$this->lang->words['for_changefor']}' />"; } else { $convert = "<input type='submit' class='realbutton' onclick='ACPForums.convert()' value='{$this->lang->words['for_changecat']}' />"; } } //----------------------------------------- // Build forumlist //----------------------------------------- $forumlist = $this->forum_functions->adForumsForumList(); //----------------------------------------- // Build group list //----------------------------------------- $mem_group = array(); foreach ($this->caches['group_cache'] as $g_id => $group) { $mem_group[] = array($g_id, $group['g_title']); } //----------------------------------------- // Page title... //----------------------------------------- //$this->registry->output->html_help_title = $title; //----------------------------------------- // Generate form items //----------------------------------------- # Main settings $form['name'] = $this->registry->output->formInput('name', (isset($_POST['name']) and $_POST['name']) ? IPSText::parseCleanValue($_POST['name']) : $forum['name']); $form['description'] = $this->registry->output->formTextarea("description", IPSText::br2nl((isset($_POST['description']) and $_POST['description']) ? $_POST['description'] : $forum['description'])); $form['parent_id'] = $this->registry->output->formDropdown("parent_id", $forumlist, (isset($_POST['parent_id']) and $_POST['parent_id']) ? $_POST['parent_id'] : $forum['parent_id']); $form['status'] = $this->registry->output->formDropdown("status", $dd_state, (isset($_POST['status']) and $_POST['status']) ? $_POST['status'] : $forum['status']); $form['sub_can_post'] = $this->registry->output->formYesNo('sub_can_post', (isset($_POST['sub_can_post']) and $_POST['sub_can_post']) ? $_POST['sub_can_post'] : ($forum['sub_can_post'] == 1 ? 0 : 1)); # Redirect options $form['redirect_url'] = $this->registry->output->formInput('redirect_url', (isset($_POST['redirect_url']) and $_POST['redirect_url']) ? $_POST['redirect_url'] : $forum['redirect_url']); $form['redirect_on'] = $this->registry->output->formYesNo('redirect_on', (isset($_POST['redirect_on']) and $_POST['redirect_on']) ? $_POST['redirect_on'] : $forum['redirect_on']); $form['redirect_hits'] = $this->registry->output->formInput('redirect_hits', (isset($_POST['redirect_hits']) and $_POST['redirect_hits']) ? $_POST['redirect_hits'] : $forum['redirect_hits']); # Permission settings $form['permission_showtopic'] = $this->registry->output->formYesNo('permission_showtopic', (isset($_POST['permission_showtopic']) and $_POST['permission_showtopic']) ? $_POST['permission_showtopic'] : $forum['permission_showtopic']); $form['permission_custom_error'] = $this->registry->output->formTextarea("permission_custom_error", IPSText::br2nl((isset($_POST['permission_custom_error']) and $_POST['permission_custom_error']) ? $_POST['permission_custom_error'] : $forum['permission_custom_error'])); # Forum settings $form['use_html'] = $this->registry->output->formYesNo('use_html', (isset($_POST['use_html']) and $_POST['use_html']) ? $_POST['use_html'] : $forum['use_html']); $form['use_ibc'] = $this->registry->output->formYesNo('use_ibc', (isset($_POST['use_ibc']) and $_POST['use_ibc']) ? $_POST['use_ibc'] : $forum['use_ibc']); $form['quick_reply'] = $this->registry->output->formYesNo('quick_reply', (isset($_POST['quick_reply']) and $_POST['quick_reply']) ? $_POST['quick_reply'] : $forum['quick_reply']); $form['allow_poll'] = $this->registry->output->formYesNo('allow_poll', (isset($_POST['allow_poll']) and $_POST['allow_poll']) ? $_POST['allow_poll'] : $forum['allow_poll']); $form['allow_pollbump'] = $this->registry->output->formYesNo('allow_pollbump', (isset($_POST['allow_pollbump']) and $_POST['allow_pollbump']) ? $_POST['allow_pollbump'] : $forum['allow_pollbump']); $form['inc_postcount'] = $this->registry->output->formYesNo('inc_postcount', (isset($_POST['inc_postcount']) and $_POST['inc_postcount']) ? $_POST['inc_postcount'] : $forum['inc_postcount']); $form['forum_allow_rating'] = $this->registry->output->formYesNo('forum_allow_rating', (isset($_POST['forum_allow_rating']) and $_POST['forum_allow_rating']) ? $_POST['forum_allow_rating'] : $forum['forum_allow_rating']); $form['min_posts_post'] = $this->registry->output->formInput('min_posts_post', (isset($_POST['min_posts_post']) and $_POST['min_posts_post']) ? $_POST['min_posts_post'] : $forum['min_posts_post']); $form['min_posts_view'] = $this->registry->output->formInput('min_posts_view', (isset($_POST['min_posts_view']) and $_POST['min_posts_view']) ? $_POST['min_posts_view'] : $forum['min_posts_view']); $form['can_view_others'] = $this->registry->output->formYesNo('can_view_others', (isset($_POST['can_view_others']) and $_POST['can_view_others']) ? $_POST['can_view_others'] : $forum['can_view_others']); $form['hide_last_info'] = $this->registry->output->formYesNo('hide_last_info', (isset($_POST['hide_last_info']) and $_POST['hide_last_info']) ? $_POST['hide_last_info'] : $forum['hide_last_info']); # Mod settings $form['preview_posts'] = $this->registry->output->formDropdown("preview_posts", $dd_moderate, (isset($_POST['preview_posts']) and $_POST['preview_posts']) ? $_POST['preview_posts'] : $forum['preview_posts']); $form['notify_modq_emails'] = $this->registry->output->formInput('notify_modq_emails', (isset($_POST['notify_modq_emails']) and $_POST['notify_modq_emails']) ? $_POST['notify_modq_emails'] : $forum['notify_modq_emails']); $form['password'] = $this->registry->output->formInput('password', (isset($_POST['password']) and $_POST['password']) ? $_POST['password'] : $forum['password']); $form['password_override'] = $this->registry->output->formMultiDropdown('password_override[]', $mem_group, (isset($_POST['password_override']) and $_POST['password_override']) ? $_POST['password_override'] : explode(",", $forum['password_override'])); # Sorting settings $form['prune'] = $this->registry->output->formDropdown("prune", $dd_prune, (isset($_POST['prune']) and $_POST['prune']) ? $_POST['prune'] : $forum['prune']); $form['sort_key'] = $this->registry->output->formDropdown("sort_key", $dd_order, (isset($_POST['sort_key']) and $_POST['sort_key']) ? $_POST['sort_key'] : $forum['sort_key']); $form['sort_order'] = $this->registry->output->formDropdown("sort_order", $dd_by, (isset($_POST['sort_order']) and $_POST['sort_order']) ? $_POST['sort_order'] : $forum['sort_order']); $form['topicfilter'] = $this->registry->output->formDropdown("topicfilter", $dd_filter, (isset($_POST['topicfilter']) and $_POST['topicfilter']) ? $_POST['topicfilter'] : $forum['topicfilter']); # Trim the form for categories... $form['addnew_type'] = $addnew_type; $this->request['type'] = $addnew_type; $form['addnew_type_upper'] = ucwords($addnew_type); $form['convert_button'] =& $convert; //----------------------------------------- // Show permission matrix //----------------------------------------- if ($type != 'edit' or $addnew_type == 'category') { /* Permission Class */ require_once IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php'; $permissions = new classPublicPermissions(ipsRegistry::instance()); if ($addnew_type == 'category') { $perm_matrix = $permissions->adminPermMatrix('forum', $forum, 'forums', 'view'); } else { $perm_matrix = $permissions->adminPermMatrix('forum', $forum); } } //----------------------------------------- // Show form... //----------------------------------------- $this->registry->output->html .= $this->html->forumForm($form, $button, $code, $title, $forum, $perm_matrix); //----------------------------------------- // Nav and print //----------------------------------------- //ipsRegistry::getClass('adminOuput')->nav[] = array( $this->form_code, 'Manage Forums' ); //ipsRegistry::getClass('adminOuput')->nav[] = array( '', 'Add/Edit '.ucwords($addnew_type) ); }
/** * Encode special characters in a string for iCalendar * * @param string String to encode * @param bool Line-fold * @param string Encoded string */ protected function _encodeSpecialCharacters($text, $lineFold = true) { $text = strip_tags(IPSText::br2nl($text)); $text = str_replace("\\", "\\\\", $text); $text = str_replace("\n", '\\n', $text); $text = str_replace("\r", '\\n', $text); $text = str_replace(',', '\\,', $text); $text = str_replace(';', '\\;', $text); //$text = str_replace( ':' , '\:', $text ); $text = str_replace('"', '\\"', $text); if ($lineFold) { $text = $this->_foldLines($text); } return $text; }
/** * 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(); } //----------------------------------------- // Compile the poll //----------------------------------------- $this->poll_questions = $this->compilePollData(); if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) { //----------------------------------------- // Show the form again //----------------------------------------- return FALSE; } //----------------------------------------- // Grab the edit time //----------------------------------------- $time = ipsRegistry::getClass('class_localization')->getDate(time(), 'LONG'); //----------------------------------------- // Reset some data //----------------------------------------- $post['ip_address'] = $this->_originalPost['ip_address']; $post['topic_id'] = $this->_originalPost['topic_id']; $post['author_id'] = $this->_originalPost['author_id']; $post['post_date'] = $this->_originalPost['post_date']; $post['author_name'] = $this->_originalPost['author_name']; $post['queued'] = $this->_originalPost['queued']; $post['edit_time'] = time(); $post['edit_name'] = $this->getAuthor('members_display_name'); //----------------------------------------- // If the post icon has changed, update the topic post icon //----------------------------------------- if ($this->_originalPost['new_topic'] == 1) { if ($post['icon_id'] != $this->_originalPost['icon_id']) { $this->DB->update('topics', array('icon_id' => $post['icon_id']), 'tid=' . $topic['tid']); } } //----------------------------------------- // Update open and close times //----------------------------------------- if ($this->_originalPost['new_topic'] == 1) { $times = array(); if ($this->can_set_open_time and $this->times['open']) { $times['topic_open_time'] = intval($this->times['open']); if ($topic['topic_open_time'] and $this->times['open']) { $times['state'] = "closed"; if (time() > $topic['topic_open_time']) { if (time() < $topic['topic_close_time']) { $times['state'] = "open"; } } } if (!$this->times['open'] and $topic['topic_open_time']) { if ($topic['state'] == 'closed') { $times['state'] = 'open'; } } } if ($this->can_set_close_time and $this->times['close']) { $times['topic_close_time'] = intval($this->times['close']); //----------------------------------------- // Was a close time, but not now? //----------------------------------------- if (!$this->times['close'] and $topic['topic_close_time']) { if ($topic['state'] == 'closed') { $times['state'] = 'open'; } } } if (count($times)) { $this->DB->update('topics', $times, "tid=" . $topic['tid']); } } //----------------------------------------- // Update poll //----------------------------------------- if ($this->can_add_poll) { if (is_array($this->poll_questions) and count($this->poll_questions)) { $poll_only = 0; if ($this->settings['ipb_poll_only'] and $this->request['poll_only'] == 1) { $poll_only = 1; } $poll_view_voters = !$this->poll_data['votes'] ? $this->request['poll_view_voters'] : $this->poll_data['poll_view_voters']; if ($topic['poll_state']) { $this->DB->update('polls', array('votes' => intval($this->poll_total_votes), 'choices' => addslashes(serialize($this->poll_questions)), 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters)), 'tid=' . $topic['tid']); if ($this->poll_data['choices'] != serialize($this->poll_questions) or $this->poll_data['votes'] != intval($this->poll_total_votes)) { $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Edited poll", 'query_string' => my_getenv('QUERY_STRING'))); } } else { $this->DB->insert('polls', array('tid' => $topic['tid'], 'forum_id' => $this->getForumData('id'), 'start_date' => time(), 'choices' => addslashes(serialize($this->poll_questions)), 'starter_id' => $this->getAuthor('member_id'), 'votes' => 0, 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters))); $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Added a poll to the topic titled '" . $this->request['poll_question'] . "'", 'query_string' => my_getenv('QUERY_STRING'))); $this->DB->update('topics', array('poll_state' => 1, 'last_vote' => 0, 'total_votes' => 0), 'tid=' . $topic['tid']); } } else { //----------------------------------------- // Remove the poll //----------------------------------------- $this->DB->buildAndFetch(array('delete' => 'polls', 'where' => "tid=" . $topic['tid'])); $this->DB->buildAndFetch(array('delete' => 'voters', 'where' => "tid=" . $topic['tid'])); $this->DB->update('topics', array('poll_state' => 0, 'last_vote' => 0, 'total_votes' => 0), 'tid=' . $topic['tid']); } } //----------------------------------------- // Update topic title? //----------------------------------------- if ($this->edit_title == 1) { //----------------------------------------- // Update topic title //----------------------------------------- if ($this->_topicTitle != "") { if ($this->_topicTitle != $topic['title'] or $this->_topicDescription != $topic['description'] or !$topic['title_seo']) { $this->DB->update('topics', array('title' => $this->_topicTitle, 'title_seo' => IPSText::makeSeoTitle($this->_topicTitle), 'description' => $this->_topicDescription), "tid=" . $topic['tid']); if ($topic['tid'] == $this->getForumData('last_id')) { $this->DB->update('forums', array('last_title' => $this->_topicTitle), 'id=' . $this->getForumData('id')); //ipsRegistry::getClass('class_forums')->updateForumCache(); } if ($this->moderator['edit_topic'] == 1 or $this->getAuthor('g_is_supmod') == 1) { $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Edited topic title or description '{$topic['title']}' to '" . $this->_topicTitle . "' via post form", 'query_string' => my_getenv('QUERY_STRING'))); } } } } //----------------------------------------- // Reason for edit? //----------------------------------------- if ($this->moderator['edit_post'] or $this->getAuthor('g_is_supmod')) { $post['post_edit_reason'] = trim($this->request['post_edit_reason']); } //----------------------------------------- // Update the database (ib_forum_post) //----------------------------------------- $post['append_edit'] = 1; if ($this->getAuthor('g_append_edit')) { if ($this->request['add_edit'] != 1) { $post['append_edit'] = 0; } } $this->DB->force_data_type = array('post_edit_reason' => 'string'); $this->DB->update('posts', $post, 'pid=' . $this->_originalPost['pid']); if ($this->_originalPost['topic_firstpost']) { $pid = 0; $title = $r['title']; } else { $pid = serialize(array('pid' => $r['pid'], 'title' => $r['title'])); $title = ''; } /* Remove from the search index */ $this->registry->class_forums->removePostFromSearchIndex($post['topic_id'], $this->_originalPost['pid'], $topic['posts'] ? 0 : 1); /* Update the search index */ $topic_title = $this->_topicTitle ? $this->_topicTitle : $topic['title']; /* Add to cache */ IPSContentCache::update($this->_originalPost['pid'], 'post', $this->formatPostForCache($post['post'])); /* Upload Attachments */ $this->uploadAttachments($this->post_key, $this->_originalPost['pid']); //----------------------------------------- // Make attachments "permanent" //----------------------------------------- $this->makeAttachmentsPermanent($this->post_key, $this->_originalPost['pid'], 'post', array('topic_id' => $topic['tid'])); //----------------------------------------- // Make sure paperclip symbol is OK //----------------------------------------- $this->recountTopicAttachments($topic['tid']); //----------------------------------------- // Leave data for other apps //----------------------------------------- $this->setTopicData($topic); $this->setPostData(array_merge($this->_originalPost, $post)); return TRUE; }
/** * 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'); }
/** * Hook add/edit form * This dynamic form allows users to associate multiple files with a single hook. * * @param string [add|edit] * @return @e void [Outputs to screen] */ protected function _hookForm($type = 'add') { /* Init vars */ $form = array(); $files = array(); $hookData = array(); $requirements = array(); $entryPoints = array('foreach' => array(array('outer.pre', $this->lang->words['h_outerpre']), array('inner.pre', $this->lang->words['h_innerpre']), array('inner.post', $this->lang->words['h_innerpost']), array('outer.post', $this->lang->words['h_outerpost'])), 'if' => array(array('pre.startif', $this->lang->words['h_prestartif']), array('post.startif', $this->lang->words['h_poststartif']), array('pre.else', $this->lang->words['h_preelse']), array('post.else', $this->lang->words['h_postelse']), array('pre.endif', $this->lang->words['h_preendif']), array('post.endif', $this->lang->words['h_postendif']))); /* Edit time? */ if ($type == 'edit') { $id = intval($this->request['id']); if (!$id) { $this->registry->output->showError($this->lang->words['h_noedit'], 1116); } $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id)); if (!$hookData['hook_id']) { $this->registry->output->showError($this->lang->words['h_noedit'], 1117); } /* Sort out extra stuff and requirements */ $hookData['hook_extra_data'] = unserialize($hookData['hook_extra_data']); $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']); /* Old data? - @todo: we should remove that around 3.3(4?) */ if (!isset($hookData['hook_requirements']['required_applications']['core']) && isset($hookData['hook_requirements']['hook_ipb_version_min']) && ($hookData['hook_requirements']['hook_ipb_version_min'] > 0 || $hookData['hook_requirements']['hook_ipb_version_max'] > 0)) { $requirements['core'] = array('min_version' => intval($hookData['hook_requirements']['hook_ipb_version_min']), 'max_version' => intval($hookData['hook_requirements']['hook_ipb_version_max'])); } if (is_array($hookData['hook_requirements']['required_applications']) && count($hookData['hook_requirements']['required_applications'])) { /* Get the setup class */ require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php'; /*noLibHook*/ foreach ($hookData['hook_requirements']['required_applications'] as $appKey => $versionData) { /* Fetch and check versions */ if (!isset($this->cachedVersions[$appKey])) { $this->cachedVersions[$appKey] = IPSSetUp::fetchXmlAppVersions($appKey); } $_versions = $this->cachedVersions[$appKey]; krsort($_versions); /* Setup our default 'no version' value */ $versions = array(array(0, $this->lang->words['h_any_version'])); foreach ($_versions as $long => $human) { if ($long < 30000 && in_array($appKey, array('core', 'forums', 'members'))) { continue; } $versions[] = array($long, $human); } $versionData['_versions'] = $versions; $requirements[$appKey] = $versionData; } } /* Sort out hook files */ $index = 1; $skinGroups = $this->hooksFunctions->getSkinGroups(); $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id)); $outer = $this->DB->execute(); /* Get them outside the while cycle to prevent warnings */ $_dataHooks = IPSLib::getDataHookLocations(); while ($r = $this->DB->fetch($outer)) { $r['hook_data'] = unserialize($r['hook_data']); if ($r['hook_type'] == 'templateHooks') { $templates = $this->hooksFunctions->getSkinMethods($r['hook_data']['skinGroup']); $hookIds = $this->hooksFunctions->getHookIds($r['hook_data']['skinFunction'], $r['hook_data']['type']); $r['_skinDropdown'] = $this->registry->output->formDropdown("skinGroup[{$index}]", $skinGroups, $r['hook_data']['skinGroup'], "skinGroup[{$index}]", "onchange='getTemplatesForAdd({$index});'"); $r['_templateDropdown'] = $this->registry->output->formDropdown("skinFunction[{$index}]", $templates, $r['hook_data']['skinFunction'], "skinFunction[{$index}]", "onchange='getTypeOfHook({$index});'"); $r['_hookTypeDropdown'] = $this->registry->output->formDropdown("type[{$index}]", array(array(0, $this->lang->words['a_selectone']), array('foreach', $this->lang->words['hook_foreach_loop']), array('if', $this->lang->words['hook_if_statement'])), $r['hook_data']['type'], "type[{$index}]", "onchange='getHookIds({$index});'"); $r['_hookIdsDropdown'] = $this->registry->output->formDropdown("id[{$index}]", $hookIds, $r['hook_data']['id'], "id[{$index}]", "onchange='getHookEntryPoints({$index});'"); $r['_hookEPDropdown'] = $this->registry->output->formDropdown("position[{$index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'], $r['hook_data']['position']); } if ($r['hook_type'] == 'dataHooks') { $r['_dataLocationDropdown'] = $this->registry->output->formDropdown("dataLocation[{$index}]", $_dataHooks, $r['hook_data']['dataLocation']); } $files[$index] = $r; $index++; } $action = 'do_edit_hook'; } else { $action = 'do_create_hook'; } /* Info */ foreach (array('hook_name', 'hook_desc', 'hook_key', 'hook_version_human', 'hook_version_long', 'hook_author', 'hook_email', 'hook_website', 'hook_update_check') as $_hook_key) { $form[$_hook_key] = $this->registry->output->formSimpleInput($_hook_key, isset($this->request[$_hook_key]) ? $this->request[$_hook_key] : $hookData[$_hook_key], 60); } /* Requirements */ foreach (array('hook_php_version_min', 'hook_php_version_max') as $_version_key) { $form[$_version_key] = $this->registry->output->formSimpleInput($_version_key, isset($this->request[$_version_key]) ? $this->request[$_version_key] : $hookData['hook_requirements'][$_version_key], 20); } /* Setup the global caches DD */ $_caches = array(); $this->DB->build(array('select' => 'cs_key', 'from' => 'cache_store', 'order' => 'cs_key ASC')); $this->DB->execute(); while ($gc = $this->DB->fetch()) { $_caches[] = array($gc['cs_key'], $gc['cs_key']); } sort($_caches); $form['hook_global_caches'] = $this->registry->output->formMultiDropdown('hook_global_caches[]', $_caches, isset($_POST['hook_global_caches']) ? $_POST['hook_global_caches'] : explode(',', $hookData['hook_global_caches']), 15); /* Get some data for the javascript */ $form['jsDataTypes'] = IPSText::br2nl($this->registry->output->formDropdown("type[#{index}]", array(array(0, $this->lang->words['a_selectone']), array('foreach', $this->lang->words['hook_foreach_loop']), array('if', $this->lang->words['hook_if_statement'])), '', "type[#{index}]", "onchange='getHookIds(#{index});'")); $form['jsDataPoints'] = IPSText::br2nl($this->registry->output->formDropdown("position[#{index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'])); /* Output */ $this->registry->output->extra_nav[] = array($this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks']); $this->registry->output->html .= $this->html->hookForm($form, $action, $hookData, $files, $requirements); }
/** * Save a bbcode [add|edit] * * @param string [add|edit] * @return @e void [Outputs to screen] */ protected function _bbcodeSave($type = 'add') { if ($type == 'edit') { if (!$this->request['id']) { $this->registry->output->global_message = $this->lang->words['no_bbcode_found_edit']; $this->_bbcodeForm($type); return; } $bbcode = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_id=' . intval($this->request['id']))); if (!$bbcode['bbcode_id']) { $this->registry->output->showError($this->lang->words['no_bbcode_found_edit'], 111162); } if ($this->request['bbcode_tag']) { $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'")); if ($duplicate['bbcode_id'] && $duplicate['bbcode_id'] != $this->request['id']) { $this->registry->output->global_message = $this->lang->words['tag_already']; $this->_bbcodeForm($type); return; } /* Check aliases */ $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\'')); $this->DB->execute(); while ($row = $this->DB->fetch()) { if ($row['bbcode_id'] == $this->request['id']) { continue; } foreach (explode(',', $row['bbcode_aliases']) as $alias) { if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) { $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']); $this->_bbcodeForm($type); return; } } } } } else { $bbcode = array(); if ($this->request['bbcode_tag']) { $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'")); if ($duplicate['bbcode_id']) { $this->registry->output->global_message = $this->lang->words['tag_already']; $this->_bbcodeForm($type); return; } /* Check aliases */ $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\'')); $this->DB->execute(); while ($row = $this->DB->fetch()) { foreach (explode(',', $row['bbcode_aliases']) as $alias) { if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) { $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']); $this->_bbcodeForm($type); return; } } } } } //----------------------------------------- // Fix BR tags //----------------------------------------- $this->request['bbcode_aliases'] = str_replace(array(' ', "\n"), '', IPSText::br2nl($this->request['bbcode_aliases'])); //----------------------------------------- // check... //----------------------------------------- if (!$this->request['bbcode_title'] or !$this->request['bbcode_tag'] or !$this->request['bbcode_replace'] and !$this->request['bbcode_php_plugin']) { $this->registry->output->global_message = $this->lang->words['complete_form']; $this->_bbcodeForm($type); return; } if (!$this->request['bbcode_single_tag'] and !strstr($this->request['bbcode_replace'], '{content}') and !$this->request['bbcode_php_plugin']) { $this->registry->output->global_message = $this->lang->words['must_use_content']; $this->_bbcodeForm($type); return; } if (!strstr($this->request['bbcode_replace'], '{option}') and $this->request['bbcode_useoption'] and !$this->request['bbcode_php_plugin']) { $this->registry->output->global_message = $this->lang->words['must_use_option']; $this->_bbcodeForm($type); return; } if (preg_match("/[^a-zA-Z0-9_]/", $this->request['bbcode_tag'])) { $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num']; $this->_bbcodeForm($type); return; } $_aliases = explode(",", $this->request['bbcode_aliases']); foreach ($_aliases as $_alias) { if (preg_match("/[^a-zA-Z0-9_]/", $_alias)) { $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num']; $this->_bbcodeForm($type); return; } } $array = array('bbcode_title' => $this->request['bbcode_title'], 'bbcode_desc' => IPSText::safeslashes($_POST['bbcode_desc']), 'bbcode_tag' => preg_replace("/[^a-zA-Z0-9_]/", "", $this->request['bbcode_tag']), 'bbcode_replace' => IPSText::safeslashes($_POST['bbcode_replace']), 'bbcode_example' => IPSText::safeslashes($_POST['bbcode_example']), 'bbcode_useoption' => $this->request['bbcode_useoption'], 'bbcode_switch_option' => intval($this->request['bbcode_switch_option']), 'bbcode_menu_option_text' => trim($this->request['bbcode_menu_option_text']), 'bbcode_menu_content_text' => trim($this->request['bbcode_menu_content_text']), 'bbcode_single_tag' => intval($this->request['bbcode_single_tag']), 'bbcode_groups' => is_array($this->request['bbcode_groups']) ? implode(',', $this->request['bbcode_groups']) : '', 'bbcode_sections' => is_array($this->request['bbcode_sections']) ? implode(',', $this->request['bbcode_sections']) : '', 'bbcode_php_plugin' => trim($this->request['bbcode_php_plugin']), 'bbcode_no_parsing' => intval($this->request['bbcode_no_parsing']), 'bbcode_optional_option' => intval($this->request['bbcode_optional_option']), 'bbcode_aliases' => $this->request['bbcode_aliases'], 'bbcode_image' => $this->request['bbcode_image'], 'bbcode_app' => $this->request['bbcode_app'], 'bbcode_protected' => intval($this->request['bbcode_protected']), 'bbcode_custom_regex' => str_replace("\", '\\', IPSText::stripslashes($_POST['bbcode_custom_regex']))); if ($type == 'add') { $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}'")); if ($check['bbcode_tag']) { $this->registry->output->global_message = $this->lang->words['must_use_unique_btag']; $this->_bbcodeForm($type); return; } $this->DB->insert('custom_bbcode', $array); $this->registry->output->global_message = $this->lang->words['new_bbcode']; } else { $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}' AND bbcode_id<>" . intval($this->request['id']))); if ($check['bbcode_tag']) { $this->registry->output->global_message = $this->lang->words['must_use_unique_btag']; $this->_bbcodeForm($type); return; } if ($this->request['drop_cache']) { IPSContentCache::truncate(); } $this->DB->update('custom_bbcode', $array, 'bbcode_id=' . intval($this->request['id'])); $this->registry->output->global_message = $this->lang->words['edited_bbcode']; } $this->bbcodeRebuildCache(); $this->_bbcodeStart(); }
/** * Saves the add/edit calendar event form * * @param string $type Either add or edit * @return @e void */ public function calendarEventSave($type = 'add') { //----------------------------------------- // Check permissions //----------------------------------------- if ($this->request['auth_key'] != $this->member->form_hash) { $this->registry->output->showError('no_permission', 10410, null, null, 403); } if ($this->request['preview']) { return $this->calendarEventForm($type); } //----------------------------------------- // Init //----------------------------------------- $event_id = intval($this->request['event_id']); $calendar_id = intval($this->request['event_calendar_id']); $_calendar = $this->functions->getCalendar($calendar_id); $event_title = IPSText::getTextClass('bbcode')->stripBadWords(trim($this->request['event_title'])); $start_date = ''; $end_date = ''; $recurring = 0; //----------------------------------------- // Verify start date/time //----------------------------------------- switch ($this->settings['cal_date_format']) { case 'american': default: $_startBits = explode('/', $this->request['start_date']); if ($this->request['set_enddate']) { $_endBits = $this->request['end_date'] ? explode('/', $this->request['end_date']) : array(); } break; case 'danish': $_inputStart = explode('/', $this->request['start_date']); $_startBits = array(0 => $_inputStart[1], 1 => $_inputStart[2], 2 => $_inputStart[0]); if ($this->request['set_enddate']) { $_inputEnd = $this->request['end_date'] ? explode('/', $this->request['end_date']) : array(); $_endBits = array(0 => $_inputEnd[1], 1 => $_inputEnd[2], 2 => $_inputEnd[0]); } break; case 'italian': $_inputStart = explode('/', $this->request['start_date']); $_startBits = array(0 => $_inputStart[1], 1 => $_inputStart[0], 2 => $_inputStart[2]); if ($this->request['set_enddate']) { $_inputEnd = $this->request['end_date'] ? explode('/', $this->request['end_date']) : array(); $_endBits = array(0 => $_inputEnd[1], 1 => $_inputEnd[0], 2 => $_inputEnd[2]); } break; case 'db': $_inputStart = explode('-', $this->request['start_date']); $_startBits = array(0 => $_inputStart[1], 1 => $_inputStart[2], 2 => $_inputStart[0]); if ($this->request['set_enddate']) { $_inputEnd = $this->request['end_date'] ? explode('-', $this->request['end_date']) : array(); $_endBits = array(0 => $_inputEnd[1], 1 => $_inputEnd[2], 2 => $_inputEnd[0]); } break; } if (!$this->request['start_date'] or count($_startBits) != 3) { $this->registry->output->showError('calendar_invalid_date', 10427.0); } else { if (!@checkdate($_startBits[0], $_startBits[1], $_startBits[2])) { $this->registry->output->showError('calendar_invalid_date', 10427.1); } } if ($this->request['all_day']) { $start_date = gmmktime(0, 0, 0, $_startBits[0], $_startBits[1], $_startBits[2]); } else { $_time = explode(':', $this->request['start_time']); if ($this->settings['cal_time_format'] == 'standard') { if (count($_time) != 2 or $_time[0] > 12 or $_time[1] > 59) { $this->registry->output->showError('calendar_invalid_time', 10427.2); } if ($this->request['start_time_ampm'] == 'PM' and $_time[0] < 12) { $_time[0] += 12; } else { if ($this->request['start_time_ampm'] == 'AM' and $_time[0] == 12) { $_time[0] = 0; } } } else { if (count($_time) != 2 or $_time[0] > 23 or $_time[1] > 59) { $this->registry->output->showError('calendar_invalid_time', 10427.2); } } $start_date = gmmktime($_time[0], $_time[1], 0, $_startBits[0], $_startBits[1], $_startBits[2]); } //----------------------------------------- // Verify end date/time //----------------------------------------- if ($this->request['set_enddate']) { if (count($_endBits) != 3) { $this->registry->output->showError('calendar_invalid_date', 10427.3); } else { if (!@checkdate($_endBits[0], $_endBits[1], $_endBits[2])) { $this->registry->output->showError('calendar_invalid_date', 10427.4); } } if ($this->request['all_day']) { $end_date = gmmktime(0, 0, 0, $_endBits[0], $_endBits[1], $_endBits[2]); } else { $_time = explode(':', $this->request['end_time']); if ($this->settings['cal_time_format'] == 'standard') { if (count($_time) != 2 or $_time[0] > 12 or $_time[1] > 59) { $this->registry->output->showError('calendar_invalid_date', 10427.5); } if ($this->request['end_time_ampm'] == 'PM') { $_time[0] += 12; } } else { if (count($_time) != 2 or $_time[0] > 23 or $_time[1] > 59) { $this->registry->output->showError('calendar_invalid_date', 10427.5); } } $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); } } //----------------------------------------- // Set event view permissions //----------------------------------------- if ($this->memberData['g_access_cp']) { if (is_array($this->request['e_groups'])) { foreach ($this->cache->getCache('group_cache') as $group) { if ($group['g_access_cp']) { $this->request['e_groups'][] = $group['g_id']; } } $read_perms = implode(",", $this->request['e_groups']); } } $read_perms = $read_perms ? $read_perms : '*'; //----------------------------------------- // Get editor and format post //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite'); $editor = new $classToLoad(); $event_content = $editor->process($_POST['Post']); IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_smilies = intval($this->request['enableemo']); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'calendar'; $event_content = IPSText::getTextClass('bbcode')->preDbParse($event_content); //----------------------------------------- // Event approved? //----------------------------------------- if ($this->request['e_type'] == 'private') { $event_approved = 1; } else { $event_approved = $this->registry->permissions->check('nomod', $_calendar) ? 1 : ($_calendar['cal_moderate'] ? 0 : 1); } //----------------------------------------- // Store the event //----------------------------------------- if ($type == 'add') { //----------------------------------------- // Format array for storage //----------------------------------------- $_eventData = array('event_calendar_id' => $calendar_id, 'event_member_id' => $this->memberData['member_id'], 'event_content' => $event_content, 'event_title' => $event_title, 'event_title_seo' => IPSText::makeSeoTitle($event_title), 'event_smilies' => intval($this->request['enableemo']), 'event_comments' => 0, 'event_perms' => $read_perms, 'event_private' => $this->request['e_type'] == 'private' ? 1 : 0, 'event_approved' => $event_approved, 'event_saved' => time(), 'event_lastupdated' => time(), 'event_recurring' => $recurring, 'event_start_date' => $start_date, 'event_end_date' => $end_date, 'event_post_key' => $this->request['post_key'], 'event_rsvp' => $this->registry->permissions->check('askrsvp', $_calendar) ? intval($this->request['event_rsvp']) : 0, 'event_sequence' => 0, 'event_all_day' => intval($this->request['all_day'])); //----------------------------------------- // Data hooks //----------------------------------------- IPSLib::doDataHooks($_eventData, 'calendarAddEvent'); //----------------------------------------- // Insert //----------------------------------------- $this->DB->insert('cal_events', $_eventData); $event_id = $this->DB->getInsertId(); //----------------------------------------- // Set language strings //----------------------------------------- $_langString = $event_approved ? $this->lang->words['new_event_redirect'] : $this->lang->words['new_event_mod']; } else { //----------------------------------------- // Format array for storage //----------------------------------------- $_eventData = array('event_calendar_id' => $calendar_id, 'event_content' => $event_content, 'event_title' => $event_title, 'event_title_seo' => IPSText::makeSeoTitle($event_title), 'event_smilies' => intval($this->request['enableemo']), 'event_perms' => $read_perms, 'event_private' => $this->request['e_type'] == 'private' ? 1 : 0, 'event_approved' => $event_approved, 'event_lastupdated' => time(), 'event_recurring' => $recurring, 'event_start_date' => $start_date, 'event_end_date' => $end_date, 'event_post_key' => $this->request['post_key'], 'event_rsvp' => $this->registry->permissions->check('askrsvp', $_calendar) ? intval($this->request['event_rsvp']) : $event['event_rsvp'], 'event_sequence' => intval($event['event_rsvp']) + 1, 'event_all_day' => intval($this->request['all_day'])); //----------------------------------------- // Data hooks //----------------------------------------- IPSLib::doDataHooks($_eventData, 'calendarEditEvent'); //----------------------------------------- // Update database //----------------------------------------- $this->DB->update('cal_events', $_eventData, 'event_id=' . $event_id); //----------------------------------------- // Set language strings //----------------------------------------- $_langString = $event_approved ? $this->lang->words['edit_event_redirect'] : $this->lang->words['new_event_mod']; } //----------------------------------------- // Upload attachments //----------------------------------------- if ($this->memberData['g_attach_max'] != -1) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach'); $class_attach = new $classToLoad($this->registry); $class_attach->type = 'event'; $class_attach->attach_post_key = $_eventData['event_post_key']; $class_attach->attach_rel_id = $event_id; $class_attach->init(); $class_attach->processMultipleUploads(); $class_attach->postProcessUpload(array()); } //----------------------------------------- // Send notifications //----------------------------------------- if ($event_approved) { require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $_like = classes_like::bootstrap('calendar', $type == 'edit' ? 'events' : 'calendars'); $_url = $this->registry->output->buildSEOUrl('app=calendar&module=calendar&section=view&do=showevent&event_id=' . $event_id, 'public', $_eventData['event_title_seo'], 'cal_event'); $_like->sendNotifications($type == 'edit' ? $event_id : $_eventData['event_calendar_id'], array('immediate', 'offline'), array('notification_key' => $type == 'edit' ? 'updated_event' : 'new_event', 'notification_url' => $_url, 'email_template' => $type . '_event_follow', 'email_subject' => sprintf($this->lang->words[$type . '_event_follow_subject'], $_url, $_eventData['event_title']), 'build_message_array' => array('NAME' => '-member:members_display_name-', 'AUTHOR' => $this->memberData['members_display_name'], 'TITLE' => $_eventData['event_title'], 'URL' => $_url))); } //----------------------------------------- // Rebuild cache //----------------------------------------- $this->cache->rebuildCache('calendar_events', 'calendar'); //----------------------------------------- // Redirect //----------------------------------------- if ($event_approved) { $this->registry->output->redirectScreen($_langString, $this->settings['base_url'] . "app=calendar&module=calendar&section=view&do=showevent&event_id=" . $event_id, $_eventData['event_title_seo'], 'cal_event'); } else { $this->registry->output->redirectScreen($_langString, $this->settings['base_url'] . "app=calendar&module=calendar&section=view&cal_id=" . $calendar_id, $this->caches['calendars'][$calendar_id]['cal_title_seo'], 'cal_calendar'); } }