|
From: Jon O. <jon...@us...> - 2005-04-01 23:34:22
|
Update of /cvsroot/mxbb/mx_kb/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8515/modules/mx_kb/includes Modified Files: functions_kb.php kb_article.php kb_post.php Added Files: functions_kb_mx.php Log Message: for compatibility with 2.7.5 Index: kb_article.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/includes/kb_article.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** kb_article.php 1 Apr 2005 20:39:47 -0000 1.19 --- kb_article.php 1 Apr 2005 23:33:52 -0000 1.20 *************** *** 24,28 **** die( "Hacking attempt" ); } - $article_id = !isset( $article_id ) ? intval( $HTTP_GET_VARS['k'] ) : $article_id; $start = ( isset( $HTTP_GET_VARS['start'] ) ) ? intval( $HTTP_GET_VARS['start'] ) : 0; --- 24,27 ---- *************** *** 34,41 **** if ( !( $result = $db->sql_query( $sql ) ) ) { ! message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); if ( count($row) > 0 ) { --- 33,41 ---- if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); + if ( count($row) > 0 ) { *************** *** 238,242 **** $gen_simple_header = TRUE; } ! if ( !$is_block) { include( $mx_root_path . 'includes/page_header.' . $phpEx ); --- 238,243 ---- $gen_simple_header = TRUE; } ! ! if ( !$is_block && !$print_version) { include( $mx_root_path . 'includes/page_header.' . $phpEx ); *************** *** 297,301 **** { $kb_comment = array(); ! // Populate the kb_comment variable $kb_comment = kb_get_data($row, $userdata); --- 298,302 ---- { $kb_comment = array(); ! // Populate the kb_comment variable $kb_comment = kb_get_data($row, $userdata); Index: kb_post.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/includes/kb_post.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** kb_post.php 1 Apr 2005 14:14:48 -0000 1.6 --- kb_post.php 1 Apr 2005 23:33:52 -0000 1.7 *************** *** 515,518 **** --- 515,519 ---- 'L_ADD_ARTICLE' => $lang['Add_article'], + 'L_MESSAGE_TITLE' => $lang['Message'], 'L_ARTICLE_TITLE' => $lang['Article_title'], --- NEW FILE: functions_kb_mx.php --- <?php /** ------------------------------------------------------------------------ * subject : mx-portal, CMS & portal * begin : june, 2002 * copyright : (C) 2002-2005 MX-System * email : jon...@ho... * project site : www.mx-system.com * * description : * ------------------------------------------------------------------------- * * $Id: functions_kb_mx.php,v 1.1 2005/04/01 23:33:52 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License', or * ('at your option) any later version. */ if ( !function_exists( mx_smilies_pass ) ) { function mx_smilies_pass($message) { global $board_config; $smilies_path = $board_config['smilies_path']; $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; $message = smilies_pass($message); $board_config['smilies_path'] = $smilies_path; return $message; } } if ( !function_exists( mx_generate_smilies ) ) { function mx_generate_smilies($mode, $page_id) { global $board_config, $template, $phpEx; $smilies_path = $board_config['smilies_path']; $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; generate_smilies($mode, $page_id); $board_config['smilies_path'] = $smilies_path; $template->assign_vars(array( 'U_MORE_SMILIES' => append_sid(PHPBB_URL . "posting.$phpEx?mode=smilies")) ); } } if ( !function_exists( mx_message_die ) ) { function mx_message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '') { global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images; global $userdata, $user_ip, $session_length; global $starttime; message_die($msg_code, $msg_text, $msg_title, $err_line, $err_file, $sql); } } if ( !function_exists( mx_auth_group_cache ) ) { // Validates if user belongs to group included in group_ids list // Also, adds all usergroups to userdata array function mx_auth_group_cache( $group_ids = '', $group_mod_mode = false ) { global $userdata, $db; if ( $group_ids == '' ) { return false; } $group_ids_array = explode(",", $group_ids); // Try to reuse usergroups result. if ( $group_mod_mode ) { $userdata_key = 'mx_usergroups_mod' . $userdata['user_id']; if ( empty( $userdata[$userdata_key] ) ) { // Check if user is group moderator.. $sql = "SELECT gr.group_id FROM " . GROUPS_TABLE . " gr, " . USER_GROUP_TABLE . " ugr WHERE gr.group_id = ugr.group_id AND gr.group_moderator = '" . $userdata['user_id'] . "' AND ugr.user_pending = '0' "; if ( !( $result = $db->sql_query( $sql ) ) ) { message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); } $group_row = $db->sql_fetchrowset( $result ); $userdata[$userdata_key_mod] = $group_row; } } else { $userdata_key = 'mx_usergroups' . $userdata['user_id']; if ( empty( $userdata[$userdata_key] ) ) { // Check if user is member of the proper group.. $sql = "SELECT group_id FROM " . USER_GROUP_TABLE . " WHERE user_id='" . $userdata['user_id'] . "' AND user_pending = 0"; if ( !( $result = $db->sql_query( $sql ) ) ) { message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); } $group_row = $db->sql_fetchrowset( $result ); $userdata[$userdata_key] = $group_row; } } for ( $i = 0; $i < count( $userdata[$userdata_key] ); $i++ ) { if ( in_array( $userdata[$userdata_key][$i]['group_id'], $group_ids_array ) ) { $is_member = true; return $is_member; } } return false; } } if ( !function_exists( mx_add_search_words ) ) { // Add search words for blocks function mx_add_search_words($mode, $post_id, $post_text, $post_title = '', $mx_mode = 'mx') { global $db, $phpbb_root_path, $board_config, $lang; // $search_match_table = SEARCH_MATCH_TABLE; // $search_word_table = SEARCH_WORD_TABLE; switch ( $mx_mode ) { case 'mx': $search_match_table = MX_MATCH_TABLE; $search_word_table = MX_WORD_TABLE; $db_key = 'block_id'; break; case 'kb': $search_match_table = KB_MATCH_TABLE; $search_word_table = KB_WORD_TABLE; $db_key = 'article_id'; break; } $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"); $search_raw_words = array(); $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array)); $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array)); @set_time_limit(0); $word = array(); $word_insert_sql = array(); while ( list($word_in, $search_matches) = @each($search_raw_words) ) { $word_insert_sql[$word_in] = ''; if ( !empty($search_matches) ) { for ($i = 0; $i < count($search_matches); $i++) { $search_matches[$i] = trim($search_matches[$i]); if( $search_matches[$i] != '' ) { $word[] = $search_matches[$i]; if ( !strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'") ) { $word_insert_sql[$word_in] .= ( $word_insert_sql[$word_in] != "" ) ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'"; } } } } } if ( count($word) ) { sort($word); $prev_word = ''; $word_text_sql = ''; $temp_word = array(); for($i = 0; $i < count($word); $i++) { if ( $word[$i] != $prev_word ) { $temp_word[] = $word[$i]; $word_text_sql .= ( ( $word_text_sql != '' ) ? ', ' : '' ) . "'" . $word[$i] . "'"; } $prev_word = $word[$i]; } $word = $temp_word; $check_words = array(); switch( SQL_LAYER ) { case 'postgresql': case 'msaccess': case 'mssql-odbc': case 'oracle': case 'db2': $sql = "SELECT word_id, word_text FROM " . $search_word_table . " WHERE word_text IN ($word_text_sql)"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not select words', '', __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) { $check_words[$row['word_text']] = $row['word_id']; } break; } $value_sql = ''; $match_word = array(); for ($i = 0; $i < count($word); $i++) { $new_match = true; if ( isset($check_words[$word[$i]]) ) { $new_match = false; } if ( $new_match ) { switch( SQL_LAYER ) { case 'mysql': case 'mysql4': $value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\', 0)'; break; case 'mssql': case 'mssql-odbc': $value_sql .= ( ( $value_sql != '' ) ? ' UNION ALL ' : '' ) . "SELECT '" . $word[$i] . "', 0"; break; default: $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) VALUES ('" . $word[$i] . "', 0)"; if( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); } break; } } } if ( $value_sql != '' ) { switch ( SQL_LAYER ) { case 'mysql': case 'mysql4': $sql = "INSERT IGNORE INTO " . $search_word_table . " (word_text, word_common) VALUES $value_sql"; break; case 'mssql': case 'mssql-odbc': $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) $value_sql"; break; } if ( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); } } } while( list($word_in, $match_sql) = @each($word_insert_sql) ) { $title_match = ( $word_in == 'title' ) ? 1 : 0; if ( $match_sql != '' ) { $sql = "INSERT INTO " . $search_match_table . " ($db_key, word_id, title_match) SELECT $post_id, word_id, $title_match FROM " . $search_word_table . " WHERE word_text IN ($match_sql)"; if ( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql); } } } if ($mode == 'single') { // remove_common('single', 4/10, $word); } return; } function mx_remove_search_post($post_id_sql, $mx_mode = 'mx') { global $db; // $search_match_table = SEARCH_MATCH_TABLE; // $search_word_table = SEARCH_WORD_TABLE; switch ( $mx_mode ) { case 'mx': $search_match_table = MX_MATCH_TABLE; $search_word_table = MX_WORD_TABLE; $db_key = 'block_id'; break; case 'kb': $search_match_table = KB_MATCH_TABLE; $search_word_table = KB_WORD_TABLE; $db_key = 'article_id'; break; } $words_removed = false; switch ( SQL_LAYER ) { case 'mysql': case 'mysql4': $sql = "SELECT word_id FROM " . $search_match_table . " WHERE $db_key IN ($post_id_sql) GROUP BY word_id"; if ( $result = $db->sql_query($sql) ) { $word_id_sql = ''; while ( $row = $db->sql_fetchrow($result) ) { $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; } $sql = "SELECT word_id FROM " . $search_match_table . " WHERE word_id IN ($word_id_sql) GROUP BY word_id HAVING COUNT(word_id) = 1"; if ( $result = $db->sql_query($sql) ) { $word_id_sql = ''; while ( $row = $db->sql_fetchrow($result) ) { $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; } if ( $word_id_sql != '' ) { $sql = "DELETE FROM " . $search_word_table . " WHERE word_id IN ($word_id_sql)"; if ( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql); } $words_removed = $db->sql_affectedrows(); } } } break; default: $sql = "DELETE FROM " . $search_word_table . " WHERE word_id IN ( SELECT word_id FROM " . $search_match_table . " WHERE word_id IN ( SELECT word_id FROM " . $search_match_table . " WHERE $db_key IN ($post_id_sql) GROUP BY word_id ) GROUP BY word_id HAVING COUNT(word_id) = 1 )"; if ( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql); } $words_removed = $db->sql_affectedrows(); break; } $sql = "DELETE FROM " . $search_match_table . " WHERE $db_key IN ($post_id_sql)"; if ( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } return $words_removed; } } ?> Index: functions_kb.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/includes/functions_kb.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** functions_kb.php 1 Apr 2005 20:39:46 -0000 1.25 --- functions_kb.php 1 Apr 2005 23:33:52 -0000 1.26 *************** *** 842,846 **** } - while ( $category = $db->sql_fetchrow( $result ) ) { --- 842,845 ---- *************** *** 853,857 **** // - // Get number of articles in cat - newssuite addon $sql_num = "SELECT count(article_id) AS total --- 852,855 ---- *************** *** 1822,1826 **** global $news_type_select_data, $kb_type_select_data, $kb_config; ! if ( !MXBB_MODULE ) { return true; --- 1820,1824 ---- global $news_type_select_data, $kb_type_select_data, $kb_config; ! if ( !MXBB_MODULE || MXBB_27x ) { return true; |