Update of /cvsroot/mxbb/mx_kb/kb/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4009/modules/mx_kb/kb/modules Added Files: kb_article.php kb_cat.php kb_main.php kb_moderator.php kb_post.php kb_post_comment.php kb_rate.php kb_search.php kb_stats.php Log Message: in progress commit for mx_kb --- NEW FILE: kb_stats.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_stats.php,v 1.1 2005/12/08 15:06:47 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_stats extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $phpEx, $kb_config, $mx_request_vars, $userdata; global $mx_root_path, $module_root_path, $is_block, $phpEx; // // Request vars // $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); $stats = $mx_request_vars->request('stats', MX_TYPE_NO_TAGS, ''); $this->generate_jumpbox( 'auth_view', 0, 0, true ); $template->set_filenames( array( 'body' => 'kb_stats_body.tpl' ) ); if ( $stats == 'toprated' ) { $path_kb = $lang['Top_toprated']; } elseif ( $stats == 'latest' ) { $path_kb = $lang['Top_latest']; } elseif ( $stats == 'mostpopular' ) { $path_kb = $lang['Top_most_popular']; } $template->assign_vars( array( 'L_CATEGORY_NAME' => $category_name, 'L_ARTICLE' => $lang['Article'], 'L_CAT' => $lang['Category'], 'L_ARTICLE_TYPE' => $lang['Article_type'], 'L_ARTICLE_CATEGORY' => $lang['Category'], 'L_ARTICLE_DATE' => $lang['Date'], 'L_ARTICLE_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_VOTES' => $lang['Votes'], 'L_CATEGORY' => $lang['Category_sub'], 'L_ARTICLES' => $lang['Articles'], 'PATH' => '» ' . $path_kb, 'U_CAT' => append_sid( this_kb_mxurl( 'mode=cat&cat=' . $category_id ) ) )); $this->display_stats( $stats, '1', 'articlerow', $start, $kb_config['pagination'] ); // // Stats pagination is inactivated for now ;) // if ( $total_articles > 0 ) { // $pagination = generate_pagination( this_kb_mxurl( "mode=cat&cat=$category_id" ), $total_articles, $kb_config['pagination'], $start ) . ' '; } if ( $total_articles > 0 ) { // $template->assign_block_vars( 'pagination', array() ); } // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', 0, 0, true ); } } ?> --- NEW FILE: kb_post.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_post.php,v 1.1 2005/12/08 15:06:47 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_post extends mx_kb_public { function main( $action ) { global $template, $mx_kb_functions, $lang, $board_config, $phpEx, $kb_config, $db, $images, $userdata, $_POST; global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars; global $HTTP_POST_VARS; // // Includes // include_once( $phpbb_root_path . 'includes/bbcode.'.$phpEx); include_once( $phpbb_root_path . 'includes/functions_post.' . $phpEx ); // // Request vars // $article_id = $mx_request_vars->request('k', MX_TYPE_INT, ''); $kb_post_mode = empty( $article_id ) ? 'add' : 'edit'; $this->page_title = $kb_post_mode == 'add' ? $lang['Add_article'] : $lang['Edit_article']; if ( $mx_request_vars->is_request('cat') ) { $category_id = $mx_request_vars->request('cat', MX_TYPE_INT, 0); } else if( $kb_post_mode == 'edit') { $category_id = $this->get_cat_id($article_id); } else { mx_message_die( GENERAL_MESSAGE, $lang['Category_not_exsist'] ); } $delete = $mx_request_vars->request('delete', MX_TYPE_NO_TAGS, ''); $submit = $mx_request_vars->is_request('article_submit'); $preview = $mx_request_vars->is_request('preview'); $cancel = $mx_request_vars->is_request('cancel'); // // Instatiate custom fields (only used in kb_article) // include_once( $module_root_path . 'kb/includes/functions_field.' . $phpEx ); $mx_kb_custom_field = new mx_kb_custom_field(); $mx_kb_custom_field->init(); // // wysiwyg // if ( $kb_config['allow_wysiwyg'] && file_exists( $mx_root_path . 'modules/tinymce/jscripts/tiny_mce/blank.htm' )) { $bbcode_on = false; $html_on = true; $smilies_on = false; $links_on = false; $images_on = false; $html_entities_match = array( ); $html_entities_replace = array( ); $template->assign_block_vars( "tinyMCE", array() ); } else { $bbcode_on = $kb_config['allow_bbcode'] ? true : false; $html_on = $kb_config['allow_html'] ? true : false; $smilies_on = $kb_config['allow_smilies'] ? true : false; $links_on = $kb_config['allow_links'] ? true : false; $images_on = $kb_config['allow_images'] ? true : false; $board_config['allow_html_tags'] = $kb_config['allowed_html_tags']; $template->assign_block_vars( 'formatting', array() ); } // // post article ----------------------------------------------------------------------------ADD/EDIT // if ( $submit ) { if ( !$mx_request_vars->is_request('article_name') || !$mx_request_vars->is_request('article_desc') || !$mx_request_vars->is_request('message') ) { $message = $lang['Empty_fields'] . '<br /><br />' . sprintf( $lang['Empty_fields_return'], '<a href="' . append_sid( this_kb_mxurl( 'mode=add' ) ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } $article_title = ( !empty( $_POST['article_name'] ) ) ? htmlspecialchars( trim ( $_POST['article_name'] ) ) : ''; $article_description = ( !empty( $_POST['article_desc'] ) ) ? htmlspecialchars( trim ( $_POST['article_desc'] ) ) : ''; $bbcode_uid = $mx_request_vars->request('bbcode_uid', MX_TYPE_NO_TAGS, ''); if ( empty( $bbcode_uid ) ) { $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; } $article_text = str_replace( '<br />', "\n", $_POST['message'] ); $article_text = prepare_message( trim($article_text), $html_on, $bbcode_on, $smilies_on, $bbcode_uid ); $article_text = bbencode_first_pass( $article_text, $bbcode_uid ); /* $article_title = ( !empty( $HTTP_POST_VARS['article_name'] ) ) ? htmlspecialchars( trim ( $HTTP_POST_VARS['article_name'] ) ) : ''; $article_description = ( !empty( $HTTP_POST_VARS['article_desc'] ) ) ? htmlspecialchars( trim ( $HTTP_POST_VARS['article_desc'] ) ) : ''; $article_text = ( !empty( $HTTP_POST_VARS['message'] ) ) ? $HTTP_POST_VARS['message'] : ''; // // Check message // if ( !empty( $article_text ) ) { if ( empty( $bbcode_uid ) ) { $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; } $article_text = prepare_message( trim( $article_text ), $html_on, $bbcode_on, $smilies_on, $bbcode_uid ); } */ $date = time(); $author_id = $userdata['user_id'] > 0 ? intval( $userdata['user_id'] ) : '-1'; $type_id = $mx_request_vars->request('type_id', MX_TYPE_INT, ''); $username = $HTTP_POST_VARS['username']; // // Check username // if (!empty($username)) { $username = phpbb_clean_username($username); if (!$userdata['session_logged_in'] || ($userdata['session_logged_in'] && $username != $userdata['username'])) { include($phpbb_root_path . 'includes/functions_validate.'.$phpEx); $result = validate_username($username); if ($result['error']) { $error_msg = (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg']; mx_message_die(GENERAL_MESSAGE, $error_msg ); } } else { $username = ''; } } switch ( $kb_post_mode ) { case 'edit': // UPDATE Article ------------------------------------------- if ( !($this->auth_user[$category_id]['auth_edit'] || $this->auth_user[$category_id]['auth_mod']) ) { $message = $lang['No_edit'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } // // Approve // if ( $this->auth_user[$category_id]['auth_mod'] || $this->auth_user[$category_id]['auth_approval_edit'] ) // approval auth { $approve = 1; // approved } else { $approve = 2; // edited unapproved } $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET article_category_id = '$category_id', article_title = '" . str_replace( "\'", "''", $article_title ) . "', article_description = '" . str_replace( "\'", "''", $article_description ) . "', article_body = '" . str_replace( "\'", "''", $article_text ) . "', article_type = '" . $approve . "', article_date = '" . $date . "', approved = '" . $type_id . "', bbcode_uid = '" . $bbcode_uid . "' WHERE article_id = ". $article_id; if ( !( $results = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not edit article", '', __LINE__, __FILE__, $sql ); } $this->modified( true ); break; case 'add': // ADD NEW --------------------------------------------------------------------------------- if ( !($this->auth_user[$category_id]['auth_post'] || $this->auth_user[$category_id]['auth_mod']) ) { $message = $lang['No_add'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } if ( $this->auth_user[$category_id]['auth_approval'] || $this->auth_user[$category_id]['auth_mod'] ) { $approve = 1; // approved } else { $approve = 0; // unapproved } $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " ( article_category_id , article_title , article_description , article_date , article_author_id , username , bbcode_uid , article_body , article_type , approved, views ) VALUES ( '$category_id', '" . str_replace( "\'", "''", $article_title ) . "', '" . str_replace( "\'", "''", $article_description ) . "', '$date', '$author_id', '$username', '$bbcode_uid', '" . str_replace( "\'", "''", $article_text ) . "', '$type_id', '$approve', '0')"; if ( !( $results = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not submit aritcle", '', __LINE__, __FILE__, $sql ); } // // Get new article id // $sql = "SELECT MAX(article_id) AS new_id FROM " . KB_ARTICLES_TABLE; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't find max article_id", "", __LINE__, __FILE__, $sql); } $temp_row = $db->sql_fetchrow($result); $article_id = $temp_row['new_id']; $this->modified( true ); break; } // // Update custom fields // $mx_kb_custom_field->file_update_data( $article_id ); $this->_kb(); // // Notification // if ( $kb_config['notify'] > 0 ) { // // Instatiate notification // $mx_kb_notification = new mx_kb_notification(); $mx_notification_mode = $kb_config['notify'] == 1 ? MX_PM_MODE : MX_MAIL_MODE; $mx_kb_notification->init( $mx_notification_mode, $article_id ); // // Now send notification // $mx_notification_action = $kb_post_mode == 'add' ? MX_NEW_NOTIFICATION : MX_EDITED_NOTIFICATION; $mx_kb_notification->notify( $mx_notification_mode, $mx_notification_action ); if ( $kb_config['notify_group'] > 0 ) { $mx_kb_notification->notify( $mx_notification_mode, $mx_notification_action, - intval($kb_config['notify_group']) ); } } /* // // Autocomment // if ( $kb_config['autogenerate_comments'] ) { $title = ( !empty( $_POST['subject'] ) ) ? htmlspecialchars( trim ( $_POST['subject'] ) ) : ''; $comment_bbcode_uid = make_bbcode_uid(); $comments_text = str_replace( '<br />', "\n", $_POST['message'] ); $comments_text = prepare_message( trim($comments_text), $html_on, $bbcode_on, $smilies_on, $comment_bbcode_uid ); $comments_text = bbencode_first_pass( $comments_text, $comment_bbcode_uid ); if ( $length > $kb_config['max_comment_chars'] ) { mx_message_die( GENERAL_ERROR, 'Your comment is too long!<br/>The maximum length allowed in characters is ' . $kb_config['max_comment_chars'] . '' ); } if ( $mx_request_vars->is_request('cid') ) { if ( $this->comments[$article_data['article_category_id']]['internal_comments'] ) { $sql = "UPDATE " . KB_COMMENTS_TABLE . " SET comments_text = '" . str_replace( "\'", "''", $comments_text ) . "', comments_title = '" . str_replace( "\'", "''", $title ) . "', comment_bbcode_uid = '" . $comment_bbcode_uid . "' WHERE comments_id = " . $mx_request_vars->request('cid', MX_TYPE_INT, 0) . " AND article_id = ". $item_id; } else { include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); $mx_kb_comments = new mx_kb_comments(); $mx_kb_comments->init( $item_id ); $mx_kb_comments->post( 'update', $cid, $title, $comments_text, $userdata['user_id'], $userdata['username'], 0, '', '', $comment_bbcode_uid); } } else { if ( $this->comments[$article_data['article_category_id']]['internal_comments'] ) { $time = time(); $poster_id = intval( $userdata['user_id'] ); $sql = "INSERT INTO " . KB_COMMENTS_TABLE . "(article_id, comments_text, comments_title, comments_time, comment_bbcode_uid, poster_id) VALUES('$item_id','" . str_replace( "\'", "''", $comments_text ) . "','" . str_replace( "\'", "''", $title ) . "','$time', '$comment_bbcode_uid','$poster_id')"; } else { include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); $mx_kb_comments = new mx_kb_comments(); $mx_kb_comments->init( $item_id ); $mx_kb_comments->post( 'insert', '', $title, $comments_text, $userdata['user_id'], $userdata['username'], 0, '', '', $comment_bbcode_uid); } } } */ /* $kb_comment = array(); // Populate the kb_comment variable $kb_comment = kb_get_data($kb_row, $userdata, $kb_post_mode); // Compose post header $subject = $lang['KB_comment_prefix'] . $kb_comment['article_title']; $message_temp = kb_compose_comment( $kb_comment ); $kb_message = $message_temp['message']; $kb_update_message = $message_temp['update_message']; // Insert phpBB post if using kb commenting if ( $approve == 1 && $kb_config['use_comments'] && $this->auth_user[$category_id]['auth_comment']) { $topic_data = kb_insert_post( $kb_message, $subject, $kb_comment['category_forum_id'], $kb_comment['article_editor_id'], $kb_comment['article_editor'], $kb_comment['article_editor_sig'], $kb_comment['topic_id'], $kb_update_message ); $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET topic_id = " . $topic_data['topic_id'] . " WHERE article_id = " . $kb_comment['article_id']; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not update article data", '', __LINE__, __FILE__, $sql ); } } $kb_notify_info = $kb_post_mode == 'add' ? 'new' : 'edited'; kb_notify( $kb_config['notify'], $kb_message, $kb_config['admin_id'], $kb_comment['article_editor_id'], $kb_notify_info ); */ if ( $approve == 1 ) { $message = $lang['Article_submitted'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf($lang['Click_return_article'], '<a href="' . append_sid(this_kb_mxurl("mode=article&k=" . $article_id)). '">', '</a>') . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); } else { $message = $lang['Article_submitted_Approve'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); } mx_message_die( GENERAL_MESSAGE, $message ); } // ---------------------------------------------------------------------------------------------------------- MAIN FORM // ---------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------- // // Instatiate text tools // $mx_kb_text_tools = new mx_kb_text_tools(); // // PreText HIDE/SHOW // if ( $kb_config['show_pretext'] ) { // Pull Header/Body info. $pt_header = $kb_config['pt_header']; $pt_body = $kb_config['pt_body']; $template->set_filenames( array( 'pretext' => 'kb_post_pretext.tpl' ) ); $template->assign_vars( array( 'PRETEXT_HEADER' => $pt_header, 'PRETEXT_BODY' => $pt_body ) ); $template->assign_var_from_handle( 'KB_PRETEXT_BOX', 'pretext' ); } // // Security // if ( !$this->auth_user[$category_id]['auth_mod'] ) { if ( $kb_post_mode == 'edit' && !$this->auth_user[$category_id]['auth_edit'] ) { $message = $lang['No_edit'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } if ( $kb_post_mode == 'add' && ( !$this->auth_user[$category_id]['auth_post'] || $kb_config['enable_module'] == 0 ) ) { $message = $lang['No_add'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } } // // First (re)declare basic variables // if ( $kb_post_mode == 'edit' ) { $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } $kb_row = $db->sql_fetchrow( $result ); } $kb_title = ( isset( $HTTP_POST_VARS['article_name'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['article_name'] ) ) ) : $kb_row['article_title']; $kb_desc = ( isset( $HTTP_POST_VARS['article_desc'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['article_desc'] ) ) ): $kb_row['article_description']; $kb_text = ( isset( $HTTP_POST_VARS['message'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['message'] ) ) ) : $kb_row['article_body']; $type_id = ( isset( $HTTP_POST_VARS['type_id'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['type_id'] ) ) ) : $kb_row['article_type']; $bbcode_uid = ( isset( $HTTP_POST_VARS['bbcode_uid'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['bbcode_uid'] ) ) ) : $kb_row['bbcode_uid']; $username = ( isset( $HTTP_POST_VARS['username'] ) ) ? htmlspecialchars( trim( stripslashes( $HTTP_POST_VARS['username'] ) ) ) : $kb_row['username']; if ( $preview ) { $preview_title = $kb_title; $preview_desc = $kb_desc; $preview_text = $kb_text; $orig_word = array(); $replacement_word = array(); obtain_word_list( $orig_word, $replacement_word ); $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; $preview_text = stripslashes(prepare_message(addslashes(unprepare_message($preview_text)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); // Now we run comment suite before checking for smilies // so admins can add them in messages if they like // and so smilies are not counted as images in sigs. // this is done here again incase above conditions are // not met. if (!$kb_config['allow_images'] || !$kb_config['allow_links']) { $preview_text = $mx_kb_text_tools->remove_images_links( $preview_text, $kb_config['allow_images'], $kb_config['no_image_message'], $kb_config['allow_links'], $kb_config['no_link_message'] ); } if ( $bbcode_on ) { $preview_text = bbencode_second_pass( $preview_text, $bbcode_uid ); } if ( count( $orig_word ) ) { $preview_title = preg_replace( $orig_word, $replacement_word, $preview_title ); $preview_desc = preg_replace( $orig_word, $replacement_word, $preview_desc ); $preview_text = preg_replace( $orig_word, $replacement_word, $preview_text ); } if ( $smilies_on ) { $preview_text = mx_smilies_pass( $preview_text ); } $preview_text = make_clickable( $preview_text ); $preview_text = str_replace( "\n", '<br />', $preview_text ); $template->set_filenames( array( 'preview' => 'kb_post_preview.tpl' ) ); $template->assign_vars( array( 'L_PREVIEW' => $lang['Preview'], 'ARTICLE_TITLE' => $preview_title, 'ARTICLE_DESC' => $preview_desc, 'ARTICLE_BODY' => $preview_text, 'PREVIEW_MESSAGE' => $preview_text ) ); $template->assign_var_from_handle( 'KB_PREVIEW_BOX', 'preview' ); } // // show article form - MAIN // if ( $kb_post_mode == 'edit' ) { $s_hidden_vars = '<input type="hidden" name="k" value="' . $article_id . '"><input type="hidden" name="bbcode_uid" value="' . $bbcode_uid . '"><input type="hidden" name="author_id" value="' . $author_id . '">'; } else { $s_hidden_vars = '<input type="hidden" name="cat" value="' . $category_id . '">'; } if ( $bbcode_uid != '' ) { $kb_text = preg_replace('/\:(([a-z0-9]:)?)' . $bbcode_uid . '/s', '', $kb_text); } $kb_text = str_replace('<', '<', $kb_text); $kb_text = str_replace('>', '>', $kb_text); $kb_text = str_replace('<br />', "\n", $kb_text); // // Toggle selection // $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; $bbcode_status = ( $bbcode_on ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF']; $links_status = ( $links_on ) ? $lang['Links_are_ON'] : $lang['Links_are_OFF']; $images_status = ( $images_on ) ? $lang['Images_are_ON'] : $lang['Images_are_OFF']; // // Smilies toggle selection // if ( $smilies_on ) { $smilies_status = $lang['Smilies_are_ON']; mx_generate_smilies( 'inline', PAGE_POSTING ); } else { $smilies_status = $lang['Smilies_are_OFF']; } // // set up page // $template->set_filenames( array( 'body' => 'kb_post_body.tpl' ) ); if ( !$userdata['session_logged_in'] ) { $template->assign_block_vars( 'switch_name', array() ); } $kb_action_url = $kb_post_mode == 'add' ? this_kb_mxurl( 'mode=add' ) : this_kb_mxurl( 'mode=edit' ); $custom_data = $kb_post_mode == 'add' ? $mx_kb_custom_field->display_edit() : $mx_kb_custom_field->display_edit( $article_id ); if ( $custom_data ) { $template->assign_block_vars( 'custom_data_fields', array( 'L_ADDTIONAL_FIELD' => $lang['Addtional_field'] )); } $template->assign_vars( array( 'S_ACTION' => $kb_action_url, 'S_HIDDEN_FIELDS' => $s_hidden_vars, 'ARTICLE_TITLE' => $kb_title, 'ARTICLE_DESC' => $kb_desc, 'ARTICLE_BODY' => $kb_text, 'USERNAME' => $username, 'L_ADD_ARTICLE' => $lang['Add_article'], 'L_ARTICLE_TITLE' => $lang['Article_title'], 'L_ARTICLE_DESCRIPTION' => $lang['Article_description'], 'L_ARTICLE_TEXT' => $lang['Article_text'], 'L_ARTICLE_CATEGORY' => $lang['Category'], 'L_ARTICLE_TYPE' => $lang['Article_type'], 'L_SUBMIT' => $lang['Submit'], 'L_PREVIEW' => $lang['Preview'], 'L_SELECT_TYPE' => $lang['Select'], 'L_NAME' => $lang['Username'], 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf( $bbcode_status, '<a href="' . append_sid( "faq.$phpEx?mode=bbcode" ) . '" target="_phpbbcode">', '</a>' ), 'SMILIES_STATUS' => $smilies_status, 'LINKS_STATUS' => $links_status, 'IMAGES_STATUS' => $images_status, '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_EMPTY_ARTICLE_NAME' => $lang['Empty_article_name'], 'L_EMPTY_ARTICLE_DESC' => $lang['Empty_article_desc'], 'L_EMPTY_CAT' => $lang['Empty_category'], 'L_EMPTY_TYPE' => $lang['Empty_type'], '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_PAGES' => $lang['L_Pages'], 'L_PAGES_EXPLAIN' => $lang['L_Pages_explain'], 'L_TOC' => $lang['L_Toc'], 'L_TOC_EXPLAIN' => $lang['L_Toc_explain'], 'L_ABSTRACT' => $lang['L_Abstract'], 'L_ABSTRACT_EXPLAIN' => $lang['L_Abstract_explain'], 'L_TITLE_FORMAT' => $lang['L_Title_Format'], 'L_TITLE_FORMAT_EXPLAIN' => $lang['L_Title_Format_explain'], 'L_SUBTITLE_FORMAT' => $lang['L_Subtitle_Format'], 'L_SUBTITLE_FORMAT_EXPLAIN' => $lang['L_Subtitle_Format_explain'], 'L_SUBSUBTITLE_FORMAT' => $lang['L_Subsubtitle_Format'], 'L_SUBSUBTITLE_FORMAT_EXPLAIN' => $lang['L_Subsubtitle_Format_explain'], 'L_OPTIONS' => $lang['L_Options'], 'L_FORMATTING' => $lang['L_Formatting'], 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'] ) ); $this->get_kb_type_list( $type_id ); if ( $kb_post_mode == 'edit' ) { $template->assign_block_vars( 'switch_edit', array( 'CAT_LIST' => $this->generate_jumpbox( 'auth_edit', $category_id, $category_id, true ) )); } // =================================================== // assign var for top navigation // =================================================== $this->generate_navigation( $category_id ); // // User authorisation levels output // $this->auth_can($category_id); // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } ?> --- NEW FILE: kb_moderator.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_moderator.php,v 1.1 2005/12/08 15:06:46 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_moderator extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $phpEx, $kb_config, $board_config, $mx_request_vars, $userdata; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx; // // Include admin functions // include( $phpbb_root_path . 'includes/functions_admin.' . $phpEx ); // ********************************************************************** // Read language definition // ********************************************************************** if ( !file_exists( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_admin.' . $phpEx ); } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx ); } // // Request vars // $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); $category_id = $mx_request_vars->request('cat', MX_TYPE_INT, 0); $article_id = $mx_request_vars->request('a', MX_TYPE_INT, 0); $page_id = $mx_request_vars->request('page', MX_TYPE_INT, 0); $ref_stats = $mx_request_vars->is_request('ref'); if ( !( ($this->auth_user[$category_id]['auth_delete'] || $this->auth_user[$category_id]['auth_mod']) && $userdata['session_logged_in'] ) ) { $message = $lang['No_add'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } if ( $mx_request_vars->is_request('action') ) { $action = $mx_request_vars->request('action', MX_TYPE_NO_TAGS, ''); } else { if ( $approve && $this->auth_user[$category_id]['auth_mod']) { $action = 'approve'; } else if ( $unapprove && $this->auth_user[$category_id]['auth_mod']) { $action = 'unapprove'; } else if ( $delete && ( $this->auth_user[$category_id]['auth_mod'] || $this->auth_user[$category_id]['auth_delete']) ) { $action = 'delete'; } else { $action = ''; } } switch ( $action ) { case 'approve': $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = " . $article_id; if ( !( $results = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } $kb_row = $db->sql_fetchrow( $results ); $topic_sql = ''; /* $kb_comment = array(); // Populate the kb_comment variable $kb_comment = $this->kb_get_data($kb_row, $userdata ); // Compose post header $subject = $lang['KB_comment_prefix'] . $kb_comment['article_title']; $message_temp = $this->kb_compose_comment( $kb_comment ); $kb_message = $message_temp['message']; $kb_update_message = $message_temp['update_message']; if ( $kb_config['use_comments'] ) { if ( !$kb_row['topic_id'] ) { // Post $topic_data = kb_insert_post( $kb_message, $subject, $kb_comment['category_forum_id'], $kb_comment['article_editor_id'], $kb_comment['article_editor'], $kb_comment['article_editor_sig'], $kb_comment['topic_id'], $kb_update_message ); $topic_sql = ", topic_id = " . $topic_data['topic_id']; } } */ $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET approved = 1 " . $topic_sql . " WHERE article_id = " . $article_id; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not update article data", '', __LINE__, __FILE__, $sql ); } /* $this->kb_notify( $kb_config['notify'], $kb_message, $kb_config['admin_id'], $kb_comment['article_editor_id'], 'approved' ); */ $this->modified( true ); $this->_kb(); $message = $lang['Article_approved'] . '<br /><br />' . sprintf( $lang['Click_return_article_manager'], '<a href="' . append_sid( this_kb_mxurl( "page=$page_id&mode=cat&cat=$category_id&start=$start" ) ) . '">', '</a>' ) ; mx_message_die( GENERAL_MESSAGE, $message ); break; case 'unapprove': $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET approved = 0 WHERE article_id = " . $article_id; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not update article data", '', __LINE__, __FILE__, $sql ); } $this->modified( true ); $this->_kb(); $message = $lang['Article_unapproved'] . '<br /><br />' . sprintf( $lang['Click_return_article_manager'], '<a href="' . append_sid( this_kb_mxurl( "page=$page_id&mode=cat&cat=$category_id&start=$start") ) . '">', '</a>' ) ; mx_message_die( GENERAL_MESSAGE, $message ); break; case 'delete': if ( $mx_request_vars->get('c') == "yes" ) { $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = " . $article_id; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not obtain article category", '', __LINE__, __FILE__, $sql ); } $article_info = $db->sql_fetchrow( $result ); if ( $this->comments[$article_info['article_category_id']]['activated'] && !$this->comments[$article_info['article_category_id']]['internal_comments'] && $kb_config['del_topic'] && $article_info['topic_id'] ) { include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); $mx_kb_comments = new mx_kb_comments(); $mx_kb_comments->init( $article_info, 'phpbb' ); $mx_kb_comments->post('delete', $article_info['topic_id']); } $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = " . $article_id; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not delete article data", '', __LINE__, __FILE__, $sql ); } $message = $lang['Article_deleted'] . '<br /><br />' . sprintf( $lang['Click_return_article_manager'], '<a href="' . append_sid( this_kb_mxurl("page=$page_id&mode=cat&cat=$category_id&start=$start") ) . '">', '</a>' ) ; $this->modified( true ); $this->_kb(); mx_message_die( GENERAL_MESSAGE, $message ); } else { $category_id = ( $ref_stats ? 1 : $category_id ); $message = $lang['Confirm_art_delete'] . '<br /><br />' . sprintf( $lang['Confirm_art_delete_yes'], '<a href="' . append_sid( this_kb_mxurl( "mode=moderate&action=delete&page=$page_id&cat=$category_id&c=yes&a=$article_id&start=$start" ) ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Confirm_art_delete_no'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx?page=$page_id&mode=cat&cat=$category_id&start=$start" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } break; } // =================================================== // assign var for top navigation // =================================================== $this->generate_navigation( $category_id ); // // User authorisation levels output // $this->auth_can($category_id); // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } ?> --- NEW FILE: kb_main.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_main.php,v 1.1 2005/12/08 15:06:46 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. */ class mx_kb_main extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $board_config, $phpEx, $kb_config, $debug; $page_title = $category_name; $template->set_filenames( array( 'body' => 'kb_index_body.tpl' )); $template->assign_vars( array( 'L_CATEGORY' => $lang['Category'], 'L_ARTICLES' => $lang['Articles'] ) ); // =================================================== // Show the Category for the download database index // =================================================== $this->display_categories(); // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', 0, 0, true ); } } ?> --- NEW FILE: kb_search.php --- (This appears to be a binary file; contents omitted.) --- NEW FILE: kb_rate.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_rate.php,v 1.1 2005/12/08 15:06:47 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_rate extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $phpEx, $kb_config, $mx_request_vars, $userdata; global $mx_root_path, $module_root_path, $is_block, $phpEx; // // Request vars // $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); $article_id = $mx_request_vars->request('k', MX_TYPE_INT, 0); $rating = $mx_request_vars->request('rating', MX_TYPE_INT, 0); $rate = $mx_request_vars->request('rate', MX_TYPE_NO_TAGS, ''); if ( empty( $article_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Article_not_exsist'] ); } $template->set_filenames( array( 'body' => 'kb_rate_body.tpl' ) ); $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query Article info', '', __LINE__, __FILE__, $sql ); } if ( !$article = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Article_not_exsist'] ); } $db->sql_freeresult( $result ); $category_id = $article['article_category_id']; if ( !$this->auth_user[$category_id]['auth_rate'] || !$kb_config['use_ratings'] ) { // // The user is not authed to read this cat ... // $message = $lang['Not_authorized']; mx_message_die(GENERAL_MESSAGE, $message); } $ipaddy = getenv ( "REMOTE_ADDR" ); if ( $kb_config['votes_check_ip'] == 1 ) { $sql = "SELECT * FROM " . KB_VOTES_TABLE . " WHERE votes_ip = '" . $ipaddy . "' AND votes_file = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query rate ip', '', __LINE__, __FILE__, $sql ); } if ( $db->sql_numrows( $result ) > 0 ) { $template->assign_vars( array( "META" => '<meta http-equiv="refresh" content="3;url=' . append_sid( this_kb_mxurl( "action=url&k=" . $article_id ) ) . '">' ) ); $message = $lang['Rerror'] . "<br /><br />" . sprintf( $lang['Click_return_rate'], "<a href=\"" . append_sid( this_kb_mxurl( "mode=article&k=$article_id" ) ) . "\">", "</a>" ); mx_message_die( GENERAL_MESSAGE, $message ); } } if ( $kb_config['votes_check_userid'] == 1 ) { $sql = "SELECT * FROM " . KB_VOTES_TABLE . " WHERE votes_userid = '" . $userdata['user_id'] . "' AND votes_file = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query rate ip', '', __LINE__, __FILE__, $sql ); } if ( $db->sql_numrows( $result ) > 0 ) { $template->assign_vars( array( "META" => '<meta http-equiv="refresh" content="3;url=' . append_sid( this_kb_mxurl( "action=url&k=" . $article_id ) ) . '">' ) ); $message = $lang['Rerror'] . "<br /><br />" . sprintf( $lang['Click_return_rate'], "<a href=\"" . append_sid( this_kb_mxurl( "mode=article&k=$article_id" ) ) . "\">", "</a>" ); mx_message_die( GENERAL_MESSAGE, $message ); } } if ( $rate == 'dorate' ) { $conf = str_replace( "{filename}", $article['article_title'], $lang['Rconf'] ); $conf = str_replace( "{rate}", $rating, $conf ); if ( $article['article_totalvotes'] == 1 ) { $add = 0; } else { $add = 1; } $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET article_rating=article_rating+" . $rating . ", article_totalvotes=article_totalvotes+1 WHERE article_id = '" . $article_id . "'"; if ( !( $update = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Update rating table', '', __LINE__, __FILE__, $sql ); } $ipaddy = getenv ( "REMOTE_ADDR" ); $sql = "INSERT INTO " . KB_VOTES_TABLE . " VALUES('" . $ipaddy . "', '" . $userdata['user_id'] . "', '" . $article_id . "')"; if ( !( $insert = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Update rating table', '', __LINE__, __FILE__, $sql ); } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Update rating table', '', __LINE__, __FILE__, $sql ); } $article = $db->sql_fetchrow( $result ); if ( $article['article_rating'] == 0 or $article['article_totalvotes'] == 0 ) { $nrating = 0; } else { $nrating = round( $article['article_rating'] / ( $article['article_totalvotes'] ), 3 ); } $conf = str_replace( "{newrating}", $nrating, $conf ); $template->assign_vars( array( "META" => '<meta http-equiv="refresh" content="3;url=' . append_sid( this_kb_mxurl( "action=url&k=" . $article_id ) ) . '">' ) ); if ( !$reader_mode ) { $message = $conf . "<br /><br />" . sprintf( $lang['Click_return_rate'], "<a href=\"" . append_sid( this_kb_mxurl( "mode=article&k=$article_id" ) ) . "\">", "</a>" ) . "<br /><br />" . sprintf( $lang['Click_return_forum'], "<a href=\"" . append_sid( "index.$phpEx?page=$page_id&mode=cat&cat=$category_id" ) . "\">", "</a>" ); } else { $message = $conf . "<br /><br />" . sprintf( $lang['Click_return_rate'], "<a href=\"" . append_sid( this_kb_mxurl( "mode=article&k=$article_id" ) ) . "\">", "</a>" ); } mx_message_die( GENERAL_MESSAGE, $message ); } else { $rateinfo = str_replace( "{filename}", $article['article_title'], $lang['Rateinfo'] ); $template->assign_block_vars( "rate", array() ); // // Send variables to template (the associated *.tpl file) // /* $template->assign_vars( array( 'PATH' => $path_kb )); */ $template->assign_vars( array( 'S_RATE_ACTION' => append_sid( this_kb_mxurl( ) ), 'L_RATE' => $lang['Rate'], 'L_RERROR' => $lang['Rerror'], 'L_R1' => $lang['R1'], 'L_R2' => $lang['R2'], 'L_R3' => $lang['R3'], 'L_R4' => $lang['R4'], 'L_R5' => $lang['R5'], 'L_R6' => $lang['R6'], 'L_R7' => $lang['R7'], 'L_R8' => $lang['R8'], 'L_R9' => $lang['R9'], 'L_R10' => $lang['R10'], 'RATEINFO' => $rateinfo, 'ID' => $article_id ) ); } // =================================================== // assign var for top navigation // =================================================== $this->generate_navigation( $category_id ); // // User authorisation levels output // $this->auth_can($category_id); // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } ?> --- NEW FILE: kb_cat.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_cat.php,v 1.1 2005/12/08 15:06:46 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_cat extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $phpEx, $kb_config, $mx_request_vars, $userdata; global $mx_root_path, $module_root_path, $is_block, $phpEx; // // Request vars // $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); $category_id = $mx_request_vars->request('cat', MX_TYPE_INT, ''); if ( empty( $category_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Category_not_exsist'] ); } // ======================================================= // If user not allowed to view article listing (read) and there is no sub Category // or the user is not allowed to view these category we gave him a nice message. // ======================================================= $show_category = false; if ( isset( $this->subcat_rowset[$category_id] ) ) { foreach( $this->subcat_rowset[$category_id] as $sub_cat_id => $sub_cat_row ) { if ( $this->auth_user[$sub_cat_id]['auth_view'] ) { $show_category = true; break; } } } if ( ( !$this->auth_user[$category_id]['auth_mod'] ) && ( !$show_category ) ) { if ( !$userdata['session_logged_in'] ) { // mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=". pa_this_mxurl("action=category&cat_id=" . $cat_id, true), true)); } $message = $lang['Not_authorized']; mx_message_die( GENERAL_MESSAGE, $message ); } if ( !isset( $this->cat_rowset[$category_id] ) ) { $message = $lang['Category_not_exsist'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } // // Validate Comments Setup // if ( $this->comments[$category_id]['activated'] && !$this->comments[$category_id]['internal_comments'] && $this->cat_rowset[$category_id]['comments_forum_id'] < 1 ) { // // Commenting is enabled but no category forum id specified // $message = $lang['No_cat_comments_forum_id']; mx_message_die(GENERAL_MESSAGE, $message); } // // Vars // $category_name = $this->cat_rowset['category_name']; $this->page_title = $category_name; $template->set_filenames( array( 'body' => 'kb_cat_body.tpl' ) ); // // Pagination // $sql_pag = "SELECT count(article_id) AS total FROM " . KB_ARTICLES_TABLE . " WHERE "; $sql_pag .= " article_category_id = '$category_id'"; if ( !( $result = $db->sql_query( $sql_pag ) ) ) { mx_message_die( GENERAL_ERROR, 'Error getting total articles', '', __LINE__, __FILE__, $sql ); } if ( $total = $db->sql_fetchrow( $result ) ) { $total_articles = $total['total']; $pagination = generate_pagination( this_kb_mxurl( "mode=cat&cat=$category_id" ), $total_articles, $kb_config['pagination'], $start ) . ' '; } if ( $total_articles > 0 ) { $template->assign_block_vars( 'pagination', array() ); } $template->assign_vars( array( 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $kb_config['pagination'] ) + 1 ), ceil( $total_articles / $kb_config['pagination'] ) ), 'L_GOTO_PAGE' => $lang['Goto_page'], 'L_CATEGORY_NAME' => $category_name, 'L_ARTICLE' => $lang['Article'], 'L_ARTICLE_TYPE' => $lang['Article_type'], 'L_ARTICLE_CATEGORY' => $lang['Category'], 'L_ARTICLE_DATE' => $lang['Date'], 'L_ARTICLE_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_VOTES' => $lang['Votes'], 'L_CATEGORY' => $lang['Category_sub'], 'L_ARTICLES' => $lang['Articles'], 'U_CAT' => append_sid( this_kb_mxurl( 'mode=cat&cat=' . $category_id ) ) ) ); // =================================================== // assign var for top navigation // =================================================== $this->generate_navigation( $category_id ); // // User authorisation levels output // $this->auth_can($category_id); // // get sub-cats // if ( isset( $this->subcat_rowset[$category_id] ) ) { $this->display_categories( $category_id ); } // // Get articles // $this->display_articles( $category_id, '1', 'articlerow', $start, $kb_config['pagination'] ); // // Get footer quick dropdown jumpbox // $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } ?> --- NEW FILE: kb_article.php --- <?php /** ------------------------------------------------------------------------ * Subject : mxBB - a fully modular portal and CMS (for phpBB) * Author : Jon Ohlsson and the mxBB Team * Credits : The phpBB Group & Marc Morisette, wGeric * Copyright : (C) 2002-2005 mxBB Portal * Email : jo...@mx... * Project site : www.mxbb-portal.com * ------------------------------------------------------------------------- * * $Id: kb_article.php,v 1.1 2005/12/08 15:06:46 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 ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } class mx_kb_article extends mx_kb_public { function main( $action ) { global $template, $lang, $db, $phpEx, $kb_config, $mx_request_vars, $userdata; global $phpbb_root_path, $mx_root_path, $module_root_path, $is_block, $phpEx, $images; global $mx_kb_custom_field, $print_version, $reader_mode; // // Request vars // $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); $article_id = $mx_request_vars->request('k', MX_TYPE_INT, ''); $page_num = $mx_request_vars->request('page_num', MX_TYPE_INT, 1) - 1; if ( empty( $article_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Article_not_exsist'] ); } // // Instatiate text tools // $mx_kb_text_tools = new mx_kb_text_tools(); $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE article_id = $article_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } // =================================================== // article doesn't exist' // =================================================== if ( !$kb_row = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Article_not_exsist'] ); } $db->sql_freeresult( $result ); // =================================================== // KB auth for viewing article // =================================================== if ( ( !$this->auth_user[$kb_row['article_category_id']]['auth_view'] ) ) { /* if ( !$userdata['session_logged_in'] ) { mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=".pa_this_mxurl("action=file&file_id=" . $file_id), true)); } */ $message = $lang['Article_not_exsist'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( this_kb_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $phpbb_root_path . "index.$phpEx" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } // =================================================== // Prepare article info to display them // =================================================== $article_title = $kb_row['article_title']; $article_description = $kb_row['article_description']; $article_category_id = $kb_row['article_category_id']; $article_category_name = $this->cat_rowset[$article_category_id]['category_name']; $author_id = $kb_row['article_author_id']; $approved = $kb_row['approved']; $date = create_date( $board_config['default_dateformat'], $kb_row['article_date'], $board_config['board_timezone'] ); // // wysiwyg // if ( $kb_config['allow_wysiwyg'] && file_exists( $mx_root_path . 'modules/tinymce/jscripts/tiny_mce/blank.htm' )) { $bbcode_on = false; $html_on = true; $smilies_on = false; $html_entities_match = array( ); $html_entities_replace = array( ); } else { $bbcode_on = $kb_config['allow_bbcode'] ? true : false; $html_on = $kb_config['allow_html'] ? true : false; $smilies_on = $kb_config['allow_smilies'] ? true : false; $board_config['allow_html_tags'] = $kb_config['allowed_html_tags']; } // // Define censored word matches // $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); // // Get vars // $temp_url = append_sid( this_kb_mxurl( "mode=cat&cat=$article_category_id" ) ); $category = '<a href="' . $temp_url . '" class="gensmall">' . $article_category_name . '</a>'; if ( $author_id == -1 ) { $author_kb_art = ( $kb_row['username'] == '' ) ? $lang['Guest'] : $kb_row['username']; } else { $author_name = $this->get_kb_author( $author_id ); $temp_url = append_sid( $phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$author_id" ); $author_kb_art = '<a href="' . $temp_url . '" class="gensmall">' . $author_name . '</a>'; } $art_pages = explode( '[page]', stripslashes( $kb_row['article_body'] ) ); $article = trim( $art_pages[$page_num] ); $article = str_replace( '[toc]', '', $article ); $article = $this->article_formatting( $article ); $type_id = $kb_row['article_type']; $type = $this->get_kb_type( $type_id ); $new_views = $kb_row['views'] + 1; $views = '<b>' . $lang['Views'] . '</b> ' . $new_views; if ( $kb_row['article_rating'] == 0 || $kb_row['article_totalvotes'] == 0 ) { $rating = 0; $rating_votes = 0; $rating_message = $lang['No_votes'] ; $rate_message = '<b>' . $lang['Votes_label'] . '</b> ' . $rating_message; } else { $rating = round( $kb_row['article_rating'] / $kb_row['article_totalvotes'], 2 ); $rating_votes = $kb_row['article_totalvotes']; $rating_message = $rating . '/10, ' . $rating_votes . ' ' . $lang['Votes'] ; $rate_message = '<b>' . $lang['Votes_label'] . '</b> ' . $rating_message; } if ( $page_num == 0 ) { $sql = "UPDATE " . KB_ARTICLES_TABLE . " SET views = '" . $new_views . "' WHERE article_id = " . $article_id; } if ( !( $result2 = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not update article's views", '', __LINE__, __FILE__, $sql ); } // // Was a highlight request part of the URI? // $original_highlight = ''; $highlight_match = $highlight = ''; if (isset($HTTP_GET_VARS['highlight'])) { // // Split words and phrases // $original_highlight = '&highlight='.trim(htmlspecialchars($HTTP_GET_VARS['highlight'])); $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight']))); for($i = 0; $i < sizeof($words); $i++) { if (trim($words[$i]) != '') { $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#')); } } unset($words); $highlight = urlencode($HTTP_GET_VARS['highlight']); $highlight_match = phpbb_rtrim($highlight_match, "\\"); } if ( !$html_on ) { $article = preg_replace( '#(<)([\/]?.*?)(>)#is', "<\\2>", $article ); } // // Remove Images and/or links // if (!$kb_config['allow_images'] || !$kb_config['allow_inks']) { $article = $mx_kb_text_tools->remove_images_links( $article, $kb_config['allow_images'], $kb_config['no_image_message'], $kb_config['allow_links'], $kb_config['no_link_message'] ); } // // Parse message // $bbcode_uid = $kb_row['bbcode_uid']; if ( $bbcode_on ) { if ( $bbcode_uid != '' ) { $article = ( $bbcode_on ) ? bbencode_second_pass( $article, $bbcode_uid ) : preg_replace( '/\:[0-9a-z\:]+\]/si', ']', $article ); } } $article = make_clickable( $article ); // // Parse smilies // if ( $smilies_on ) { $article = mx_smilies_pass( $article ); } // // Highlight active words (primarily for search) // if ($highlight_match) { // // This was shamelessly 'borrowed' from volker at multiartstudio dot de // via php.net's annotated manual // $article = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . $highlight_match . ")\b#i', '<span ... [truncated message content] |