|
From: Jon O. <jon...@us...> - 2005-03-28 20:55:03
|
Update of /cvsroot/mxbb/kb_076_mxaddon/root In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9026/modules/kb_076_mxaddon/root Modified Files: kb.php kb_search.php Log Message: ## 2005/03/28 - Version KB MOD 2.01 ## - Name changed, since much is rewritten ;) ## - Updated with latest phpBB security patches ## - Category (PRIVATE) permissions ## - Subcategories ## - Comments phpBB forum set per category ## - Text reformatting options: img, link and linewidth controls ## - Rewritten BBcode/html handling (once more yes) ## - Custom fields added ## - wysiwyg feature (tinymce) ## - All reported bugs in dev thread fixed Index: kb_search.php =================================================================== RCS file: /cvsroot/mxbb/kb_076_mxaddon/root/kb_search.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** kb_search.php 9 Jan 2005 22:16:31 -0000 1.1 --- kb_search.php 28 Mar 2005 20:54:54 -0000 1.2 *************** *** 16,21 **** * (at your option) any later version. */ define( 'IN_PHPBB', true ); ! $phpbb_root_path = './'; include( $phpbb_root_path . 'extension.inc' ); include( $phpbb_root_path . 'common.' . $phpEx ); --- 16,28 ---- * (at your option) any later version. */ + + define( 'MXBB_MODULE', false ); // Switch for making this run as a phpBB mod or mxBB module + define( 'IN_PHPBB', true ); ! define( 'IN_PORTAL', true ); ! ! // when run as a phpBB mod these paths are identical ! $phpbb_root_path = $module_root_path = $mx_root_path = './'; ! include( $phpbb_root_path . 'extension.inc' ); include( $phpbb_root_path . 'common.' . $phpEx ); *************** *** 32,35 **** --- 39,45 ---- include( $phpbb_root_path . 'includes/kb_constants.' . $phpEx ); include( $phpbb_root_path . 'includes/functions_kb.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_auth.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_field.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_mx.' . $phpEx ); include_once( $phpbb_root_path . 'includes/bbcode.' . $phpEx ); include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); *************** *** 62,65 **** --- 72,80 ---- $search_id = ( isset( $HTTP_GET_VARS['search_id'] ) ) ? $HTTP_GET_VARS['search_id'] : ''; + if ( $search_id ) + { + $mode = 'results'; + } + $show_results = ( isset( $HTTP_POST_VARS['show_results'] ) ) ? $HTTP_POST_VARS['show_results'] : 'posts'; *************** *** 99,108 **** case "results": // Cycle through options ... ! if ( $search_keywords != '' ) ! { ! if ( $search_keywords != '' ) { $stopword_array = @file( $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt' ); $synonym_array = @file( $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_synonyms.txt' ); --- 114,125 ---- case "results": + $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); + // Cycle through options ... ! if ( $search_id == '' || $search_keywords != '' ) { + + $stopword_array = @file( $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt' ); $synonym_array = @file( $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_synonyms.txt' ); *************** *** 162,166 **** if ( !( $result = $db->sql_query( $sql ) ) ) { ! message_die( GENERAL_ERROR, 'Could not obtain matched articles list', '', __LINE__, __FILE__, $sql ); } --- 179,183 ---- if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Could not obtain matched articles list', '', __LINE__, __FILE__, $sql ); } *************** *** 215,269 **** unset( $result_list ); $total_match_count = count( $search_ids ); ! } ! ! // Store new result data ! ! $search_results = implode( ', ', $search_ids ); ! $per_page = $board_config['topics_per_page']; ! ! // Combine both results and search data (apart from original query) ! // so we can serialize it and place it in the DB ! ! $store_search_data = array(); ! // Limit the character length (and with this the results displayed at all following pages) to prevent ! // truncated result arrays. Normally, search results above 12000 are affected. ! // - to include or not to include ! /* ! $max_result_length = 60000; ! if (strlen($search_results) > $max_result_length) { ! $search_results = substr($search_results, 0, $max_result_length); ! $search_results = substr($search_results, 0, strrpos($search_results, ',')); ! $total_match_count = count(explode(', ', $search_results)); ! } ! */ ! ! for( $i = 0; $i < count( $store_vars ); $i++ ) ! { ! $store_search_data[$store_vars[$i]] = $$store_vars[$i]; ! } ! ! $result_array = serialize( $store_search_data ); ! unset( $store_search_data ); ! ! mt_srand ( ( double ) microtime() * 1000000 ); ! $search_id = mt_rand(); ! ! $sql = "UPDATE " . KB_SEARCH_TABLE . " ! SET search_id = $search_id, search_array = '" . str_replace( "\'", "''", $result_array ) . "' ! WHERE session_id = '" . $userdata['session_id'] . "'"; ! if ( !( $result = $db->sql_query( $sql ) ) || !$db->sql_affectedrows() ) ! { ! $sql = "INSERT INTO " . KB_SEARCH_TABLE . " (search_id, session_id, search_array) ! VALUES($search_id, '" . $userdata['session_id'] . "', '" . str_replace( "\'", "''", $result_array ) . "')"; ! if ( !( $result = $db->sql_query( $sql ) ) ) { ! message_die( GENERAL_ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql ); } } else { ! if ( intval( $search_id ) ) { $sql = "SELECT search_array --- 232,288 ---- unset( $result_list ); $total_match_count = count( $search_ids ); ! ! // Store new result data ! ! $search_results = implode( ', ', $search_ids ); ! $per_page = $board_config['topics_per_page']; ! ! // Combine both results and search data (apart from original query) ! // so we can serialize it and place it in the DB ! ! $store_search_data = array(); ! ! // Limit the character length (and with this the results displayed at all following pages) to prevent ! // truncated result arrays. Normally, search results above 12000 are affected. ! // - to include or not to include ! /* ! $max_result_length = 60000; ! if (strlen($search_results) > $max_result_length) ! { ! $search_results = substr($search_results, 0, $max_result_length); ! $search_results = substr($search_results, 0, strrpos($search_results, ',')); ! $total_match_count = count(explode(', ', $search_results)); ! } ! */ ! ! for( $i = 0; $i < count( $store_vars ); $i++ ) { ! $store_search_data[$store_vars[$i]] = $$store_vars[$i]; ! } ! ! $result_array = serialize( $store_search_data ); ! unset( $store_search_data ); ! ! mt_srand ( ( double ) microtime() * 1000000 ); ! $search_id = mt_rand(); ! ! $sql = "UPDATE " . KB_SEARCH_TABLE . " ! SET search_id = $search_id, search_array = '" . str_replace( "\'", "''", $result_array ) . "' ! WHERE session_id = '" . $userdata['session_id'] . "'"; ! if ( !( $result = $db->sql_query( $sql ) ) || !$db->sql_affectedrows() ) { ! $sql = "INSERT INTO " . KB_SEARCH_TABLE . " (search_id, session_id, search_array) ! VALUES($search_id, '" . $userdata['session_id'] . "', '" . str_replace( "\'", "''", $result_array ) . "')"; ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql ); ! } } } else { ! $search_id = intval($search_id); ! if ( $search_id ) { $sql = "SELECT search_array *************** *** 273,279 **** if ( !( $result = $db->sql_query( $sql ) ) ) { ! message_die( GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql ); } ! if ( $row = $db->sql_fetchrow( $result ) ) { --- 292,298 ---- if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql ); } ! if ( $row = $db->sql_fetchrow( $result ) ) { *************** *** 302,306 **** if ( !$result = $db->sql_query( $sql ) ) { ! message_die( GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql ); } --- 321,325 ---- if ( !$result = $db->sql_query( $sql ) ) { ! mx_message_die( GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql ); } *************** *** 322,337 **** // Output header ! $page_title = $lang['Search']; if ( !$is_block ) { ! include( $phpbb_root_path . 'includes/page_header.' . $phpEx ); } ! include ( $phpbb_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_search_results.tpl' ) ); ! make_jumpbox( $phpbb_root_path . 'viewforum.' . $phpEx ); $l_search_matches = ( $total_match_count == 1 ) ? sprintf( $lang['Found_search_match'], $total_match_count ) : sprintf( $lang['Found_search_matches'], $total_match_count ); --- 341,356 ---- // Output header ! $page_title = $lang['KB_title'] . ' - ' . $lang['Search']; if ( !$is_block ) { ! include( $mx_root_path . 'includes/page_header.' . $phpEx ); } ! // include ( $module_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_search_results.tpl' ) ); ! $l_search_matches = ( $total_match_count == 1 ) ? sprintf( $lang['Found_search_match'], $total_match_count ) : sprintf( $lang['Found_search_matches'], $total_match_count ); *************** *** 369,373 **** for( $i = 0; $i < count( $searchset ); $i++ ) { ! $article_url = append_sid( this_kb_mxurl( "mode=article&k=" . $searchset[$i]['article_id'] . "&highlight=$highlight_active" ) ); $post_date = create_date( $board_config['default_dateformat'], $searchset[$i]['article_date'], $board_config['board_timezone'] ); --- 388,392 ---- for( $i = 0; $i < count( $searchset ); $i++ ) { ! $article_url = append_sid( this_kb_mxurl( "mode=article&k=" . $searchset[$i]['article_id'] . "&highlight=$highlight_active", true ) ); $post_date = create_date( $board_config['default_dateformat'], $searchset[$i]['article_date'], $board_config['board_timezone'] ); *************** *** 378,382 **** $kb_cat = get_kb_cat( $searchset[$i]['article_category_id'] ); ! $temp_url = append_sid( this_kb_mxurl( 'mode=cat&cat=' . $searchset[$i]['article_category_id'] ) ); $category = '<a href="' . $temp_url . '" class="name">' . $kb_cat['category_name'] . '</a>'; --- 397,401 ---- $kb_cat = get_kb_cat( $searchset[$i]['article_category_id'] ); ! $temp_url = append_sid( this_kb_mxurl( 'mode=cat&cat=' . $searchset[$i]['article_category_id'], true ) ); $category = '<a href="' . $temp_url . '" class="name">' . $kb_cat['category_name'] . '</a>'; *************** *** 404,410 **** ); } ! } ! $base_url = this_kb_mxurl_search( "search_id=$search_id" ); $template->assign_vars( array( 'PAGINATION' => generate_pagination( $base_url, $total_match_count, $per_page, $start ), --- 423,429 ---- ); } ! ! $base_url = this_kb_mxurl_search( "search_id=$search_id", true ); $template->assign_vars( array( 'PAGINATION' => generate_pagination( $base_url, $total_match_count, $per_page, $start ), *************** *** 424,438 **** // Output the basic page ! $page_title = $lang['Search']; if ( !$is_block ) { ! include( $phpbb_root_path . 'includes/page_header.' . $phpEx ); } ! include ( $phpbb_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_search_body.tpl' ) ); ! make_jumpbox( $phpbb_root_path . 'viewforum.' . $phpEx ); $template->assign_vars( array( 'L_SEARCH_QUERY' => $lang['Search_query'], --- 443,457 ---- // Output the basic page ! $page_title = $lang['KB_title'] . ' - ' . $lang['Search']; if ( !$is_block ) { ! include( $mx_root_path . 'includes/page_header.' . $phpEx ); } ! //include ( $module_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_search_body.tpl' ) ); ! $template->assign_vars( array( 'L_SEARCH_QUERY' => $lang['Search_query'], *************** *** 442,446 **** 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], ! 'S_SEARCH_ACTION' => append_sid( this_kb_mxurl_search( "mode=results" ) ), 'S_HIDDEN_FIELDS' => '', 'S_SEARCH' => $lang['Search'] ) --- 461,465 ---- 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], ! 'S_SEARCH_ACTION' => append_sid( this_kb_mxurl_search( "mode=results", true ) ), 'S_HIDDEN_FIELDS' => '', 'S_SEARCH' => $lang['Search'] ) *************** *** 452,456 **** $template->pparse( 'body' ); // load footer ! include ( $phpbb_root_path . "includes/kb_footer." . $phpEx ); if ( !$is_block ) --- 471,475 ---- $template->pparse( 'body' ); // load footer ! //include ( $module_root_path . "includes/kb_footer." . $phpEx ); if ( !$is_block ) *************** *** 459,461 **** } ! ?> --- 478,480 ---- } ! ?> \ No newline at end of file Index: kb.php =================================================================== RCS file: /cvsroot/mxbb/kb_076_mxaddon/root/kb.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** kb.php 9 Jan 2005 22:16:31 -0000 1.1 --- kb.php 28 Mar 2005 20:54:54 -0000 1.2 *************** *** 19,25 **** * (at your option) any later version. */ define( 'IN_PHPBB', true ); ! $phpbb_root_path = './'; include( $phpbb_root_path . 'extension.inc' ); include( $phpbb_root_path . 'common.' . $phpEx ); --- 19,31 ---- * (at your option) any later version. */ + define( 'MXBB_MODULE', false ); // Switch for making this run as a phpBB mod or mxBB module + define( 'IN_PHPBB', true ); ! define( 'IN_PORTAL', true ); ! ! // when run as a phpBB mod these paths are identical ! $phpbb_root_path = $module_root_path = $mx_root_path = './'; ! include( $phpbb_root_path . 'extension.inc' ); include( $phpbb_root_path . 'common.' . $phpEx ); *************** *** 37,69 **** include( $phpbb_root_path . 'includes/kb_constants.' . $phpEx ); include( $phpbb_root_path . 'includes/functions_kb.' . $phpEx ); include_once( $phpbb_root_path . 'includes/bbcode.' . $phpEx ); include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); $show_new = true; - // options - if ( !$board_config['allow_html'] ) - { - $html_on = 0; - } - else - { - $html_on = ( $submit || $refresh ) ? ( ( !empty( $HTTP_POST_VARS['disable_html'] ) ) ? 0 : true ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); - } - if ( !$board_config['allow_bbcode'] ) - { - $bbcode_on = 0; - } - else - { - $bbcode_on = ( $submit || $refresh ) ? ( ( !empty( $HTTP_POST_VARS['disable_bbcode'] ) ) ? 0 : true ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); - } - if ( !$board_config['allow_smilies'] ) - { - $smilies_on = 0; - } - else - { - $smilies_on = ( $submit || $refresh ) ? ( ( !empty( $HTTP_POST_VARS['disable_smilies'] ) ) ? 0 : true ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); - } // page number --- 43,57 ---- include( $phpbb_root_path . 'includes/kb_constants.' . $phpEx ); include( $phpbb_root_path . 'includes/functions_kb.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_auth.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_field.' . $phpEx ); + include( $phpbb_root_path . 'includes/functions_kb_mx.' . $phpEx ); include_once( $phpbb_root_path . 'includes/bbcode.' . $phpEx ); include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); + // Instanciate custom fields + $kb_custom_field = new kb_custom_field(); + $kb_custom_field->init(); + $show_new = true; // page number *************** *** 82,85 **** --- 70,74 ---- { $print_version = ( isset( $HTTP_POST_VARS['print'] ) ) ? $HTTP_POST_VARS['print'] : $HTTP_GET_VARS['print']; + $print_version = htmlspecialchars( $print_version ); } else *************** *** 106,119 **** } ! $is_admin = ( ( $userdata['user_level'] == ADMIN || is_group_member( $kb_config['mod_group'], $userdata['user_id'] ) ) && $userdata['session_logged_in'] ) ? true : 0; ! // DEBUG ! // if (is_group_member($kb_config['mod_group'], $userdata['user_id'])) ! // { ! // message_die(GENERAL_ERROR, "you're group moderator...."."mod_group:".$kb_config['mod_group']. ", user_id:".$userdata['user_id'] , '', '', '', ''); ! // } ! // else ! // { ! // message_die(GENERAL_ERROR, "you're not group moderator..."."mod_group:".$kb_config['mod_group'] . ", user_id".$userdata['user_id'] , '', '', '', ''); ! // } // mode --- 95,146 ---- } ! // options ! $kb_wysiwyg = false; ! if ( $kb_config['wysiwyg'] ) // Html Textblock ! { ! if ( file_exists( $mx_root_path . 'modules/tinymce/jscripts/tiny_mce/blank.htm' ) ) ! { ! $bbcode_on = false; ! $html_on = true; ! $smilies_on = false; ! $kb_wysiwyg = true; ! } ! } ! ! if ( !$kb_wysiwyg ) ! { ! $bbcode_on = $kb_config['allow_bbcode'] ? true : false; ! $html_on = $kb_config['allow_html'] ? true : false; ! $smilies_on = $kb_config['allow_smilies'] ? true : false; ! } ! ! if ( MXBB_MODULE ) ! { ! // Newssuite operation mode? ! //------------------------------------------------------------------------- ! $total_blockk = count( $HTTP_SESSION_VARS['mx_pages']['page_' . $page_id]['blocks'] ); ! ! $kb_config['news_operate_mode'] = ''; ! for( $blockk = 0; $blockk < $total_blockk; $blockk++ ) ! { ! if ( $HTTP_SESSION_VARS['block_' . $block_rows[$blockk]['block_id']]['news_source_switch']['parameter_value'] == 'kb' && $HTTP_SESSION_VARS['block_' . $block_rows[$blockk]['block_id']]['news_mode_operate']['parameter_value'] == 'Source' ) ! { ! $newssuite_select_par = $HTTP_SESSION_VARS['block_' . $block_rows[$blockk]['block_id']]['news_type_select']['parameter_value']; ! // Extract 'what posts to view info', the cool Array ;) ! $news_type_select_data = array(); ! $news_type_select_temp = $newssuite_select_par; ! $news_type_select_temp = stripslashes( $news_type_select_temp ); ! $news_type_select_data = eval( "return " . $news_type_select_temp . ";" ); ! $kb_config['news_operate_mode'] = true; ! } ! else ! { ! $kb_config['news_operate_mode'] = ''; ! } ! } ! // ------------------------------------------------------------------------- ! } ! ! $is_admin = ( ( $userdata['user_level'] == ADMIN ) && $userdata['session_logged_in'] ) ? true : 0; // mode *************** *** 131,161 **** } if ( $mode == 'article' ) { ! include( $phpbb_root_path . 'includes/kb_article.' . $phpEx ); } else if ( $mode == 'cat' ) { ! include( $phpbb_root_path . 'includes/kb_cat.' . $phpEx ); } else if ( $mode == 'add' ) { ! include( $phpbb_root_path . 'includes/kb_add.' . $phpEx ); } else if ( $mode == 'search' ) { ! include( $phpbb_root_path . 'includes/kb_search.' . $phpEx ); } else if ( $mode == 'edit' ) { ! include( $phpbb_root_path . 'includes/kb_edit.' . $phpEx ); } else if ( $mode == 'rate' ) { ! include( $phpbb_root_path . 'includes/kb_rate.' . $phpEx ); } else if ( $mode == 'stats' ) { ! include( $phpbb_root_path . 'includes/kb_stats.' . $phpEx ); } else if ( $mode == 'moderate' ) --- 158,190 ---- } + $reader_mode = false; + if ( $mode == 'article' ) { ! include( $module_root_path . 'includes/kb_article.' . $phpEx ); } else if ( $mode == 'cat' ) { ! include( $module_root_path . 'includes/kb_cat.' . $phpEx ); } else if ( $mode == 'add' ) { ! include( $module_root_path . 'includes/kb_post.' . $phpEx ); } else if ( $mode == 'search' ) { ! include( $module_root_path . 'includes/kb_search.' . $phpEx ); } else if ( $mode == 'edit' ) { ! include( $module_root_path . 'includes/kb_post.' . $phpEx ); } else if ( $mode == 'rate' ) { ! include( $module_root_path . 'includes/kb_rate.' . $phpEx ); } else if ( $mode == 'stats' ) { ! include( $module_root_path . 'includes/kb_stats.' . $phpEx ); } else if ( $mode == 'moderate' ) *************** *** 169,177 **** if ( !$is_block ) { ! include( $phpbb_root_path . 'includes/page_header.' . $phpEx ); } ! make_jumpbox( $phpbb_root_path . 'viewforum.' . $phpEx, '' ); // load header ! include ( $phpbb_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_index_body.tpl' ) --- 198,206 ---- if ( !$is_block ) { ! include( $mx_root_path . 'includes/page_header.' . $phpEx ); } ! // load header ! include ( $module_root_path . "includes/kb_header." . $phpEx ); $template->set_filenames( array( 'body' => 'kb_index_body.tpl' ) *************** *** 186,196 **** $template->pparse( 'body' ); // load footer ! include ( $phpbb_root_path . "includes/kb_footer." . $phpEx ); if ( !$is_block && !$print_version ) { ! include( $phpbb_root_path . 'includes/page_tail.' . $phpEx ); } ! ?> \ No newline at end of file --- 215,226 ---- $template->pparse( 'body' ); + // load footer ! include ( $module_root_path . "includes/kb_footer." . $phpEx ); if ( !$is_block && !$print_version ) { ! include( $mx_root_path . 'includes/page_tail.' . $phpEx ); } ! ?> |