|
From: Jon O. <jon...@us...> - 2005-05-06 06:48:23
|
Update of /cvsroot/mxbb/core27x/modules/mx_textblocks/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13016/modules/mx_textblocks/admin Added Files: admin_edit.php mx_textblock_edit.php Log Message: Initital core 2.7.x commit :-) --- NEW FILE: admin_edit.php --- <?php /*************************************************************************** * mx_block_edit.php * ------------------- * begin : December, 2002 * copyright : (C) 2002 MX-System * email : su...@mx... * * $Id: admin_edit.php,v 1.1 2005/05/06 06:48:10 jonohlsson Exp $ * ***************************************************************************/ $no_page_header = TRUE; if( !empty($setmodules) ) { return; } define('IN_PORTAL', 1); $mx_root_path = '../../../'; // // Security and page header // require( $mx_root_path . 'admin/pagestart.php'); mx_message_die(GENERAL_MESSAGE, 'Sorry, but this block is NOT designed to be configured in the AdminCP <br /> - please use the EDIT feature in normal portal mode instead.'); include_once($mx_root_path . 'admin/page_footer_admin.'.$phpEx); ?> --- NEW FILE: mx_textblock_edit.php --- <?php /*************************************************************************** * mx_textblocks_edit.php * ------------------- * begin : Monday, Mar 31, 2003 * copyright : (C) 2001 The phpBB Group * email : su...@ph... * * $Id: mx_textblock_edit.php,v 1.1 2005/05/06 06:48:10 jonohlsson Exp $ * ***************************************************************************/ define('IN_PORTAL', 1); $mx_root_path = '../../../'; $module_root_path = '../'; include_once($mx_root_path . 'extension.inc'); include_once($mx_root_path . 'common.'.$phpEx); include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); mx_init_userprefs($userdata); // // End session management // // ********************************************************************** // Read language definition // ********************************************************************** if ( !file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_main.'.$phpEx ); } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ); } $page_id = isset($HTTP_POST_VARS['page']) ? $HTTP_POST_VARS['page'] : $page_id; $block_id = $HTTP_POST_VARS['id']; if ( empty( $block_id ) ) { $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; header($header_location . append_sid( PORTAL_URL . "index.$phpEx?page=" . $page_id, true)); exit; } $block_config = read_block_config( $block_id ); $is_auth_ary = array(); $is_auth_ary = block_auth(AUTH_EDIT, $block_id , $userdata, $block_config[$block_id][auth_edit], $block_config[$block_id][auth_edit_group] ); if ( !$is_auth_ary[auth_edit] ) { $user_id = ( isset($HTTP_GET_VARS[POST_USERS_URL]) ) ? '&' . POST_USERS_URL . '=' . $HTTP_GET_VARS[POST_USERS_URL] : ''; $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; header($header_location . append_sid( PORTAL_URL . "login.$phpEx?redirect=" . PORTAL_URL . "mx_block_edit.$phpEx?mode=$mode" . $user_id, true)); } $s_hidden_fields .= '<input type="hidden" name="id" value="' . $block_id . '" />'; $s_hidden_fields .= '<input type="hidden" name="page" value="' . $page_id. '" />'; $html_entities_match = array('#&#', '#<#', '#>#'); $html_entities_replace = array('&', '<', '>'); // // Parameters // $submit = ( isset($HTTP_POST_VARS['post'] ) ) ? TRUE : 0; $cancel = ( isset($HTTP_POST_VARS['cancel'] ) ) ? TRUE : 0; $preview = ( isset($HTTP_POST_VARS['preview']) ) ? TRUE : 0; $refresh = $preview || $submit_search; if ( !empty($HTTP_POST_VARS['mode']) || !empty($HTTP_GET_VARS['mode']) ) { $mode = ( !empty($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; } else { $mode = ''; } // // Cancel // if ( $cancel ) { $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; header($header_location . append_sid( PORTAL_URL . "index.$phpEx?page=" . $page_id, true)); exit; } $error = FALSE; // // Toggles // if ( !$board_config['allow_html'] ) { $html_on = 0; } else { // $html_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE ) : $userdata['user_allowhtml']; $html_on = TRUE; } if ( !$board_config['allow_bbcode'] ) { $bbcode_on = 0; } else { // $bbcode_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE ) : $userdata['user_allowbbcode']; $bbcode_on = TRUE; } if ( !$board_config['allow_smilies'] ) { $smilies_on = 0; } else { $smilies_on = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE ) : $userdata['user_allowsmile']; } $attach_sig = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0 ) : $userdata['user_attachsig']; $user_sig = ( $userdata['user_sig'] != '' && $board_config['allow_sig'] ) ? $userdata['user_sig'] : ""; // // Define all config data // // Main parameters $block_title_par = "block_title"; $block_info_par = ( $mode == 'edithtml' ) ? "Html" : "Text"; // Style parameters $block_style_par = "block_style"; $text_style_par = "text_style"; $title_style_par = "title_style"; $show_title_par = "show_title"; $text_style_options = array(); $text_style_options = array("none", "gen", "gensmall", "genmed", "genlarge", "postbody"); $new_vars = array(); $new_vars = array($block_info_par, $block_style_par, $text_style_par, $title_style_par, $show_title_par); $new = array(); // Extract info - main loop for($j = 0; $j < count($new_vars); $j++) { $new[$new_vars[$j]] = ( isset($HTTP_POST_VARS[$new_vars[$j]]) ) ? $HTTP_POST_VARS[$new_vars[$j]] : $block_config[$block_id][$new_vars[$j]]['parameter_value']; $parameter_id = $block_config[$block_id][$new_vars[$j]]['parameter_id']; if( $submit ) { if ( empty($new[$new_vars[$j]]) ) { $error = TRUE; $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_title']; } else { if ( $new_vars[$j] == 'Text' ) { if ( $bbcode_on && $mode != 'edithtml' ) { $bbcode_uid = make_bbcode_uid(); } $new[$new_vars[$j]] = prepare_message($new[$new_vars[$j]], $html_on, $bbcode_on, $smilies_on, $bbcode_uid); } $sql = "UPDATE " . BLOCK_SYSTEM_PARAMETER_TABLE . " SET parameter_value = '" . str_replace("\'", "''", $new[$new_vars[$j]]) . "', bbcode_uid = '$bbcode_uid' WHERE block_id = $block_id AND parameter_id = $parameter_id"; if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) { mx_message_die(GENERAL_ERROR, "Could not update textblock information.", "", __LINE__, __FILE__, $sql); } } } } // if ($submit || 1==1) // { // message_die(GENERAL_MESSAGE, $message); // } // For title, cache and submit if( $submit ) { $new['block_title'] = ( isset($HTTP_POST_VARS['block_title']) ) ? $HTTP_POST_VARS['block_title'] : $block_config[$block_id]['block_title']; $sql = "UPDATE " . BLOCK_TABLE . " SET block_title = '" . str_replace("\'", "''", $new['block_title']) . "' WHERE block_id = $block_id"; if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) { mx_message_die(GENERAL_ERROR, "Could not update textblock information.", "", __LINE__, __FILE__, $sql); } read_block_config( $block_id, FALSE); // Update cache $cache_dir = $mx_root_path . 'cache/'; if ( file_exists( $cache_dir . "block_config.xml") ) { include($phpbb_root_path.'includes/sql_parse.'.$phpEx); include_once( $mx_root_path . "cache/mx_cache.php"); // file of easy_parser class write_cache_config(); } $template->assign_vars(array( 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid( PORTAL_URL . "index.$phpEx?page=" . $page_id) . '">') ); $msg = $lang['Block_Config_updated'] . '<br /><br />'. sprintf($lang['Click_return_index'], '<a href="' . append_sid( PORTAL_URL . "index.$phpEx?page=" . $page_id) . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $msg); } // Main parameters $block_title = ( isset($HTTP_POST_VARS[$block_title_par]) ) ? $HTTP_POST_VARS[$block_title_par] : $block_config[$block_id][$block_title_par] ; $block_info = $new[$block_info_par]; $bbcode_uid = $block_config[$block_id][$block_info_par]['bbcode_uid']; if ( $mode == 'edit') { $block_info = preg_replace("/\:(([a-z0-9]:)?)$bbcode_uid/si", '', $block_info); $block_info = str_replace('<br />', "\n", $block_info); $block_info = preg_replace('#</textarea>#si', '</textarea>', $block_info); } else { $block_info = str_replace('<br />', "\n", $block_info); $block_info = preg_replace('#</textarea>#si', '</textarea>', $block_info); } if ($preview) { $preview_title = trim(strip_tags(stripslashes($block_title))); $preview_info = trim($block_info) ; $preview_info = preg_replace('#<textarea>#si', '<textarea>', $preview_info); } // Style parameters $block_style_yes = ( $new[$block_style_par] == 'TRUE') ? "checked=\"checked\"" : ""; $block_style_no = ( !($new[$block_style_par] == 'TRUE')) ? "checked=\"checked\"" : ""; $text_style_list = '<select name="text_style">'; for($j = 0; $j < count($text_style_options); $j++) { if ( $new[$text_style_par] == $text_style_options[$j] ) { $status = "selected"; } else { $status = ''; } $text_style_list .= '<option value="' .$text_style_options[$j] . '" ' . $status . '>' . $text_style_options[$j] . '</option>'; } $text_style_list .= '</select>'; $text_style_yes = ( $new[$text_style_par] == 'TRUE') ? "checked=\"checked\"" : ""; $text_style_no = ( !($new[$text_style_par] == 'TRUE') ) ? "checked=\"checked\"" : ""; $title_style_yes = ( $new[$title_style_par] == 'TRUE') ? "checked=\"checked\"" : ""; $title_style_no = ( !($new[$title_style_par] == 'TRUE') ) ? "checked=\"checked\"" : ""; $show_title_yes = ( $new[$show_title_par] == 'TRUE') ? "checked=\"checked\"" : ""; $show_title_no = ( !($new[$show_title_par] == 'TRUE') ) ? "checked=\"checked\"" : ""; // // Start output, first preview, then errors then post form // $title = $block_config[$block_id]['block_title']; $page_title = $title; $template->assign_block_vars("switch_view", array()); include($mx_root_path . 'includes/page_header.'.$phpEx); //-------------------------------------------------------- // Previews Layout //-------------------------------------------------------- if ( $preview && !$error ) { $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); if ( $bbcode_on && $mode != 'edithtml') { $bbcode_uid = make_bbcode_uid(); } // $preview_info = stripslashes(preg_replace($html_entities_match, $html_entities_replace, $preview_info)); $preview_info = stripslashes(prepare_message($preview_info, $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); // // Finalise processing as per viewtopic // if ( !$html_on ) { if ( $user_sig != '' || !$userdata['user_allowhtml'] ) { $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); } } if ( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] ) { $user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']); } if ( $bbcode_on && $mode != 'edithtml') { $preview_info = bbencode_second_pass($preview_info, $bbcode_uid); } if ( count($orig_word) ) { $preview_title = preg_replace($orig_word, $replacement_word, $preview_title); $preview_info = preg_replace($orig_word, $replacement_word, $preview_info); } if ( $smilies_on && $mode != 'edithtml') { $preview_info = mx_smilies_pass($preview_info); } $preview_info = make_clickable($preview_info); $preview_info = str_replace("\n", '<br />', $preview_info); $s_hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />'; $s_hidden_fields .= '<input type="hidden" name="page" value="' . $page_id. '" />'; $template->set_filenames(array( "preview" => 'mx_textblock_preview.tpl') ); $template->assign_vars(array( 'BLOCK_TITLE' => $preview_title, 'BLOCK_INFO' => $preview_info, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'L_BLOCK_TITLE' => $lang['Block_Title'], 'L_PREVIEW' => $lang['Preview'] )); $template->assign_var_from_handle('POST_PREVIEW_BOX', 'preview'); } //-------------------------------------------------------- // Default Layout //-------------------------------------------------------- $template->set_filenames(array( 'body' => 'mx_textblock_edit.tpl') ); // // Send smilies to template // if ($mode != 'edithtml') { mx_generate_smilies('inline', PAGE_INDEX); } if ( $mode == 'edit' ) { $POST_ACTION= $module_root_path . "admin/mx_textblock_edit.$phpEx?mode=edit"; } elseif ( $mode == 'edithtml' ) { $POST_ACTION= $module_root_path . "admin/mx_textblock_edit.$phpEx?mode=edithtml"; } else { $POST_ACTION= $module_root_path . "admin/mx_textblock_edit.$phpEx"; } if ( $mode != 'edithtml' ) { $template->assign_block_vars("switch_bbcodes", array()); } if ( !empty($new[$text_style_par]) ) { $template->assign_block_vars("switch_text_style", array()); } if ( !empty($new[$block_style_par]) ) { $template->assign_block_vars("switch_block_style", array()); } if ( !empty($new[$title_style_par]) ) { $template->assign_block_vars("switch_title_style", array()); } if ( !empty($new[$show_title_par]) ) { $template->assign_block_vars("switch_show_title", array()); } $template->assign_vars(array( 'BLOCK_TITLE' => $block_title, 'BLOCK_INFO' => $block_info, 'HTML_STATUS' => $html_status, 'SMILIES_STATUS' => $smilies_status, 'BLOCK_TEXT_NAME' => $block_info_par, 'L_BLOCK_STYLE' => $lang['Block_Style'], 'L_TEXT_STYLE' => $lang['Text_Style'], 'L_TITLE_STYLE' => $lang['Title_Style'], 'L_SHOW_TITLE' => $lang['Show_Title'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_BLOCK_STYLE_EXPLAIN' => $lang['Block_Style_Explain'], 'L_TEXT_STYLE_EXPLAIN' => $lang['Text_Style_Explain'], 'L_TITLE_STYLE_EXPLAIN' => $lang['Title_Style_Explain'], 'L_SHOW_TITLE_EXPLAIN' => $lang['Show_Title_Explain'], 'L_BLOCK_TITLE' => $lang['Block_Title'], 'L_BLOCK_INFO' => $lang['Block_Info'], 'L_OPTIONS' => $lang['Options'], 'L_PREVIEW' => $lang['Preview'], 'L_SUBMIT' => $lang['Submit'], 'L_CANCEL' => $lang['Cancel'], 'L_DISABLE_HTML' => $lang['Disable_HTML_pm'], 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_pm'], 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_pm'], 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], 'L_EMPTY_MESSAGE' => $lang['Empty_message'], 'L_FONT_COLOR' => $lang['Font_color'], 'L_COLOR_DEFAULT' => $lang['color_default'], 'L_COLOR_DARK_RED' => $lang['color_dark_red'], 'L_COLOR_RED' => $lang['color_red'], 'L_COLOR_ORANGE' => $lang['color_orange'], 'L_COLOR_BROWN' => $lang['color_brown'], 'L_COLOR_YELLOW' => $lang['color_yellow'], 'L_COLOR_GREEN' => $lang['color_green'], 'L_COLOR_OLIVE' => $lang['color_olive'], 'L_COLOR_CYAN' => $lang['color_cyan'], 'L_COLOR_BLUE' => $lang['color_blue'], 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], 'L_COLOR_INDIGO' => $lang['color_indigo'], 'L_COLOR_VIOLET' => $lang['color_violet'], 'L_COLOR_WHITE' => $lang['color_white'], 'L_COLOR_BLACK' => $lang['color_black'], 'L_FONT_SIZE' => $lang['Font_size'], 'L_FONT_TINY' => $lang['font_tiny'], 'L_FONT_SMALL' => $lang['font_small'], 'L_FONT_NORMAL' => $lang['font_normal'], 'L_FONT_LARGE' => $lang['font_large'], 'L_FONT_HUGE' => $lang['font_huge'], 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'], 'S_HTML_CHECKED' => ( !$html_on ) ? ' checked="checked"' : '', 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? ' checked="checked"' : '', 'S_HIDDEN_FORM_FIELDS' => $s_hidden_fields, 'S_POST_ACTION' => append_sid("$POST_ACTION"), 'S_BLOCK_STYLE_YES' => $block_style_yes, 'S_BLOCK_STYLE_NO' => $block_style_no, 'S_TEXT_STYLE' => $text_style_list, 'S_TITLE_STYLE_YES' => $title_style_yes, 'S_TITLE_STYLE_NO' => $title_style_no, 'S_SHOW_TITLE_YES' => $show_title_yes, 'S_SHOW_TITLE_NO' => $show_title_no, //+ MX System 'U_PHPBB_ROOT_PATH' => PHPBB_URL //- MX System )); $template->pparse('body'); include($mx_root_path . 'includes/page_tail.'.$phpEx); ?> |