phpbbkb-checkins Mailing List for phpBB Knowledge Base (Page 2)
Status: Alpha
Brought to you by:
markthedaemon
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(1) |
Sep
|
Oct
(6) |
Nov
(10) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(10) |
Feb
(19) |
Mar
(5) |
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mar...@us...> - 2007-02-14 02:30:30
|
Revision: 46 http://svn.sourceforge.net/phpbbkb/?rev=46&view=rev Author: markthedaemon Date: 2007-02-13 18:30:25 -0800 (Tue, 13 Feb 2007) Log Message: ----------- I have no idea why these files aren't in here. They should be... Added Paths: ----------- main/trunk/kb/ main/trunk/kb/auth.php main/trunk/kb/constants.php main/trunk/kb/functions.php Added: main/trunk/kb/auth.php =================================================================== --- main/trunk/kb/auth.php (rev 0) +++ main/trunk/kb/auth.php 2007-02-14 02:30:25 UTC (rev 46) @@ -0,0 +1,188 @@ +<?php +/*************************************************************************** + * auth.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +// This file holds the kb auth functions, very similar to the phpBB auth functions, but differs certain places :) +// As of now, the articles auth is handles out from which category it is selected through, therefore an article +// can have different kinds of auth, all depending on through which category it is viewed. This solution might seem +// stupid, but it is the best I can come up with, and I think admins will just take that into consideration when creating +// category permissions. + +// +// This function returns info on whether the user is allowed to do the supplied argument(s) all dependant on the given category id +// +function kb_auth($type, $cat_id, $userdata) +{ + switch($type) + { + case "view": + $sql = "a.auth_view"; + $auth_fields = array('auth_view'); + break; + + case "add": + $sql = "a.auth_add"; + $auth_fields = array('auth_add'); + break; + + case "edit": + $sql = "a.auth_edit"; + $auth_fields = array('auth_edit'); + break; + + case "delete": + $sql = "a.auth_delete"; + $auth_fields = array('auth_delete'); + break; + + case "mod": + $sql = "a.auth_mod"; + $auth_fields = array('auth_mod'); + break; + + case "comment": + $sql = "a.auth_comment"; + $auth_fields = array('auth_comment'); + break; + + case "rate": + $sql = "a.auth_rate"; + $auth_fields = array('auth_rate'); + break; + + case "attach": + $sql = "a.auth_attach"; + $auth_fields = array('auth_attach'); + break; + + // Returns array containing everything above + case "all": + $sql = "a.auth_view, a.auth_add, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate', 'auth_attach'); + break; + + // Returns array containing article related auth + case "article": + $sql = "a.auth_view, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate"; + $auth_fields = array('auth_view', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate'); + break; + + // Returns array containing category related auth + case "cat": + $sql = "a.auth_view, a.auth_add, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_attach'); + break; + } + + $sql = "SELECT a.cat_id, $sql + FROM " . KB_CATEGORIES_TABLE . " a + WHERE a.cat_id = '" . $cat_id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_MESSAGE, 'Could not retrieve categorys auth info.', '', __LINE__, __FILE__, $sql); + } + + $f_access = $db->sql_fetchrow($result); + + // + // If user is logged in we need to see if he is in any usergroups that changes his auth info, else just return it + // + if($userdata['session_logged_in']) + { + // Check if the user is present in a group that changes his permissions + $sql = "SELECT a.cat_id, $sql, a.auth_mod + FROM " . KB_AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug + WHERE ug.user_id = ".$userdata['user_id']. " + AND ug.user_pending = 0 + AND a.group_id = ug.group_id + AND a.cat_id = '" . $cat_id . "'"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Failed obtaining category access control lists', '', __LINE__, __FILE__, $sql); + } + + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $u_access[] = $row; + } + while( $row = $db->sql_fetchrow($result) ); + } + $db->sql_freeresult($result); + } + + $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; + + $auth = array(); + for($i = 0; $i < count($auth_fields); $i++) + { + $key = $auth_fields[$i]; + + // + // If the user is logged on and the forum type is either ALL or REG then the user has access + // + // If the type if ACL, MOD or ADMIN then we need to see if the user has specific permissions + // to do whatever it is they want to do ... to do this we pull relevant information for the + // user (and any groups they belong to) + // + // Now we compare the users access level against the forums. We assume here that a moderator + // and admin automatically have access to an ACL forum, similarly we assume admins meet an + // auth requirement of MOD + // + $value = $f_access[$key]; + + switch( $value ) + { + case AUTH_ALL: + $auth[$key] = TRUE; + $auth[$key . '_type'] = $lang['Auth_Anonymous_Users']; + break; + + case AUTH_REG: + $auth_user[$key] = ( $userdata['session_logged_in'] ) ? TRUE : 0; + $auth_user[$key . '_type'] = $lang['Auth_Registered_Users']; + break; + + case AUTH_ACL: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_ACL, $key, $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Users_granted_access']; + break; + + case AUTH_MOD: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_MOD, 'auth_mod', $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Moderators']; + break; + + case AUTH_ADMIN: + $auth[$key] = $is_admin; + $auth[$key . '_type'] = $lang['Auth_Administrators']; + break; + + default: + $auth[$key] = 0; + break; + } + } + + return $auth; +} + +?> Added: main/trunk/kb/constants.php =================================================================== --- main/trunk/kb/constants.php (rev 0) +++ main/trunk/kb/constants.php 2007-02-14 02:30:25 UTC (rev 46) @@ -0,0 +1,40 @@ +<?php +/*************************************************************************** + * constants.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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_PHPBB')) +{ + die('Hacking attempt'); +} + +// All constants here +// DB Tables +define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); +define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); +define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats +define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access"); + +// Article Status +define('KB_STATUS_NOT_ASSIGNED', 0); +define('KB_STATUS_ASSIGNED', 1); +define('KB_STATUS_REVIEW_IN_PROGRESS', 3); +define('KB_STATUS_ACCEPTED', 4); +define('KB_STATUS_REJECTED', 5); + +?> \ No newline at end of file Added: main/trunk/kb/functions.php =================================================================== --- main/trunk/kb/functions.php (rev 0) +++ main/trunk/kb/functions.php 2007-02-14 02:30:25 UTC (rev 46) @@ -0,0 +1,966 @@ +<?php +/*************************************************************************** + * functions.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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_PHPBB')) +{ + die('Hacking attempt'); +} + +// This function creates the navigation line based on a few parameters +function create_navigation($type = "main", $id_ary = array()) +{ + global $db, $template, $lang, $board_config, $phpEx; + + switch($type) + { + case "ucp": + // Different kind of subcategories + switch($id_ary) + { + case "post_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article') . '">' . $lang['kb_ucp_articlepost'] .'</a></span>'; + break; + + case "edit_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article') . '">' . $lang['kb_ucp_articleedit'] .'</a></span>'; + break; + + default: + break; + } + break; + + case "viewcat": + // View category + // id = $cat_id::$cat_name + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + break; + + case "viewsubcat": + // View subcategory + // id = $cat_id::$cat_name::$maincat_id + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + break; + + case "viewarticle": + // Viewing an article + if($id_ary[2] == 0) + { + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } + else + { + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } + break; + + case "search": + // viewing search results or page + break; + + case "main": + default: + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; + break; + } + + $template->assign_vars(array( + 'NAVIGATION' => $navigation) + ); + + return; +} + +function get_cats_structure() +{ + global $db; + + $cats = array(); + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '0' + ORDER BY cat_order ASC"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cats.', '', __LINE__, __FILE__, $sql); + } + + $i = 0; + while($row = $db->sql_fetchrow($result)) + { + $cats[$i] = $row; + + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $row['cat_id'] . "' + ORDER BY cat_order ASC"; + if( !($subcat_result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcats.', '', __LINE__, __FILE__, $sql); + } + + $cats[$i]['subcats'] = array(); + while($row2 = $db->sql_fetchrow($subcat_result)) + { + $cats[$i]['subcats'][] = $row2; + } + $i++; + } + + return $cats; +} + +function get_kb_config() +{ + // Using normal db table with kb_prefix + global $db; + + $sql = "SELECT * + FROM " . CONFIG_TABLE; + if(!$result = $db->sql_query($sql)) + { + message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql); + } + + $config = array(); + while($row = $db->fetchrow($result)) + { + // Detect if it has a kb_ in it and strip it + if(strstr('kb_', $row['config_name'])) + { + $name = str_replace("kb_", "", $row['config_name']); + $config[$name] = $row['config_value']; + } + } + + return $config; +} + +//////////////////////////////////////// +/// UCP FUNCTIONS /// +//////////////////////////////////////// +function ucp_generate_page_title($action) +{ + global $lang; + + $title = $lang['kb_ucp']; + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + $title .= ": " . $lang['kb_ucp_articlepost']; + break; + + case "edit_article": + $title .= ": " . $lang['kb_ucp_articleedit']; + break; + + case "delete_article": + $title .= ": " . $lang['kb_ucp_articledelete']; + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + + return $title; +} + +// This is for posting articles, mostly cut out of the posting.php :) +function ucp_article_form($mode, $id, $preview) +{ + global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; + + $error_msg = ''; + $user_sig = $userdata['user_sig']; + + // Simple auth for Alpha 1 + if(!$userdata['session_logged_in']) + { + message_die(GENERAL_MESSAGE, 'Not authenticated!'); + } + + if(!empty($HTTP_POST_VARS['post'])) + { + if($mode == 'edit') + { + // Let's get the old article data + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; + if(!$article_id) + { + message_die(MESSAGE_DIE, 'No article id defined.'); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$article_id'"; + if (!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + // if user editing set status = 0, else set status = old status :) + if($userdata['user_id'] == $article['article_author']) + { + $article_status = "0"; + } + else + { + $article_status = $article['article_status']; + } + + // Simple Auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']); + } + } + + // Add the new article + // Make all the variables :) + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; + } + + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; + $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); + $bbcode_uid = ''; + $cat_id = $HTTP_POST_VARS['cats']; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; + + prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + + if ( $error_msg == '' ) + { + $current_time = time(); + + if($mode == 'post') + { + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + } + else + { + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; + if(!$article_id) + { + message_die(GENERAL_ERROR, 'No article to edit.'); + } + + // First update the article table + $sql = "UPDATE " . KB_ARTICLES_TABLE . " + SET article_title = '$article_title', + article_desc = '$article_desc', + article_author = '$article_author', + article_authorname = '$article_authorname', + article_edittime = '$current_time', + article_editby = '" . $userdata['user_id'] . "', + article_status = '$article_status', + enable_sig = '$attach_sig', + enable_html = '$html_on', + enable_bbcode = '$bbcode_on', + enable_smilies = '$smilies_on', + article_text = '$message' + WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); + } + + // Now delete all articlecats + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); + } + + // Last add them again doing the loop + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + // Message here somewhere + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + } + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); + } + } + + if($mode == "post" && !$preview && $error_msg == '') + { + $article_title = ''; + $article_text = ''; + $article_desc = ''; + $authorname = $userdata['username']; + $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); + $hidden_form_fields = ""; + $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; + + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); + } + } + elseif($preview || $error_msg != '') + { + $article_id = $HTTP_POST_VARS['id']; + $article_title = $HTTP_POST_VARS['title']; + $article_text = $HTTP_POST_VARS['message']; + $article_desc = $HTTP_POST_VARS['desc']; + $article_cats = $HTTP_POST_VARS['cats']; + $authorname = $HTTP_POST_VARS['authorname']; + + $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; + $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; + $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; + + if($mode == 'edit') + { + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + } + else + { + $hidden_form_fields = ""; + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + } + + if($error_msg != "") + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } + + if($preview) + { + // Create the preview box + $preview_article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $preview_article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $preview_message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; + + $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($preview_message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$html_on ) + { + $preview_message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $preview_message); + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($bbcode_uid != '') + { + $preview_message = ($bbcode_on) ? bbencode_second_pass($preview_message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $preview_message); + } + + $preview_message = make_clickable($preview_message); + + // + // Parse smilies + // + if ( $smilies_on ) + { + $preview_message = smilies_pass($preview_message); + } + + // + // Replace naughty words + // + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if (count($orig_word)) + { + $preview_article_title = preg_replace($orig_word, $replacement_word, $preview_article_title); + $preview_article_desc = preg_replace($orig_word, $replacement_word, $preview_article_desc); + $preview_message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $preview_message . '<'), 1, -1)); + } + + $preview_message = str_replace("\n", "\n<br />\n", $preview_message); + + + $template->set_filenames(array( + 'preview_box' => 'kb_previewarticle.tpl') + ); + + $template->assign_vars(array( + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_PREVIEW' => $lang['kb_articlepreview'], + 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, + 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, + 'MESSAGE' => $preview_message) + ); + + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview_box'); + } + } + else + { + if(empty($id)) + { + message_die(GENERAL_ERROR, "No article defined."); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); + } + + if($db->sql_numrows($result) == 1) + { + $article = $db->sql_fetchrow($result); + } + else + { + message_die(GENERAL_ERROR, "Article does not exist."); + } + + // Now make an array over the cats + $sql = "SELECT cat_id + FROM " . KB_ARTICLECATS_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); + } + + $article_cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $article_cats[] = $row; + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_desc = $article['article_desc']; + $authorname = $article['article_authorname']; + + $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $article['enable_html'] ) ? true : false; + $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; + $smilies_on = ( $article['enable_smilies'] ) ? true : false; + + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; + } + + if ( $article['bbcode_uid'] != '' ) + { + $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); + } + + $article_text = str_replace('<', '<', $article_text); + $article_text = str_replace('>', '>', $article_text); + $article_text = str_replace('<br />', "\n", $article_text); + + // + // Signature toggle selection + // + if( $user_sig != '' ) + { + $template->assign_block_vars('switch_signature_checkbox', array()); + } + + // + // HTML toggle selection + // + if ( $board_config['allow_html'] ) + { + $html_status = $lang['HTML_is_ON']; + $template->assign_block_vars('switch_html_checkbox', array()); + } + else + { + $html_status = $lang['HTML_is_OFF']; + } + + // + // BBCode toggle selection + // + if ( $board_config['allow_bbcode'] ) + { + $bbcode_status = $lang['BBCode_is_ON']; + $template->assign_block_vars('switch_bbcode_checkbox', array()); + } + else + { + $bbcode_status = $lang['BBCode_is_OFF']; + } + + // Obtain categories structure + $cats = get_cats_structure(); + + // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S + $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; + if($mode == "edit" || $preview) + { + for($i = 0; $i < count($cats); $i++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + else + { + for($i = 0; $i < count($cats); $i++) + { + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + + // + // Smilies toggle selection + // + if ( $board_config['allow_smilies'] ) + { + $smilies_status = $lang['Smilies_are_ON']; + $template->assign_block_vars('switch_smilies_checkbox', array()); + } + else + { + $smilies_status = $lang['Smilies_are_OFF']; + } + + $template->set_filenames(array( + 'body' => 'kb_article_posting.tpl') + ); + + create_navigation("ucp", $action); + $post_article = ($mode == 'edit') ? $lang['kb_edit_article'] : $lang['kb_post_article']; + + // This is the template stuff we need no matter what + $template->assign_vars(array( + 'AUTHORNAME' => $authorname, + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE' => $article_text, + 'DESC' => $article_desc, + 'HTML_STATUS' => $html_status, + 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + 'SMILIES_STATUS' => $smilies_status, + + 'L_POST_ARTICLE' => $post_article, + 'L_AUTHORNAME' => $lang['kb_authorname'], + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_ARTICLE_CATS' => $lang['kb_articlecats'], + 'L_ARTICLE_BODY' => $lang['kb_articletext'], + 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], + 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? + 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], + + 'L_OPTIONS' => $lang['Options'], + 'L_PREVIEW' => $lang['Preview'], + 'L_SUBMIT' => $lang['Submit'], + 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], + 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], + 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], + '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_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', + 'S_POST_ACTION' => $form_action, + 'CATS_HTML' => $s_cats, + 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) + ); +} + +// Delete an article +function ucp_article_delete($id, $confirm) +{ + global $lang, $db, $phpEx, $template; + + // Simple auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']); + } + + if(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="article_id" value="' . $id . '" />'; + $l_confirm = $lang['kb_confirm_deletearticle']; + + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete_article"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + } + elseif($confirm) // Double check they actually confirmed + { + $article_id = $HTTP_POST_VARS['article_id']; + + // Need lang vars for the error messages? + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articles table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + // Message + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); + } +} + +// +// Prepare an article for the database +// +function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) +{ + global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; + + // Check title + if (!empty($article_title)) + { + $article_title = htmlspecialchars(trim($article_title)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; + } + + // Check message + if(!empty($message)) + { + $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; + $message = prepare_article_text(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; + } + + // Check Desc + if (!empty($article_desc)) + { + $article_desc = htmlspecialchars(trim($article_desc)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; + } + + // Check categories + if(!is_array($cat_id)) + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; + } + return; +} + +function prepare_article_text($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) +{ + global $board_config, $phpEx; + + // + // Clean up the message + // + $message = trim($message); + $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + $html_entities_replace = array('&', '<', '>', '"'); + + if ($html_on) + { + // If HTML is on, we try to make it safe + // This approach is quite agressive and anything that does not look like a valid tag + // is going to get converted to HTML entities + $message = stripslashes($message); + $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; + $matches = array(); + + $message_split = preg_split($html_match, $message); + preg_match_all($html_match, $message, $matches); + + $message = ''; + + // Include functions_post for clean_html + include($phpbb_root_path . "includes/functions_post." . $phpEx); + + foreach ($message_split as $part) + { + $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); + $message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag); + } + + $message = addslashes($message); + $message = str_replace('"', '\"', $message); + } + else + { + $message = preg_replace($html_entities_match, $html_entities_replace, $message); + } + + if($bbcode_on && $bbcode_uid != '') + { + $message = bbencode_first_pass($message, $bbcode_uid); + } + + return $message; +} + +function unprepare_article_text($message) +{ + $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); + $unhtml_specialchars_replace = array('>', '<', '"', '&'); + + return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message); +} +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-02-12 15:46:24
|
Revision: 45 http://svn.sourceforge.net/phpbbkb/?rev=45&view=rev Author: markthedaemon Date: 2007-02-12 07:46:21 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Some changes that have been sitting in my sandbox for some time now, finally getting the chance to commit them. Modified Paths: -------------- main/trunk/includes/page_header.php main/trunk/kb.php main/trunk/language/lang_english/lang_main.php main/trunk/templates/subSilver/images/lang_english/Thumbs.db main/trunk/templates/subSilver/kb_main.tpl main/trunk/templates/subSilver/kb_viewcat.tpl main/trunk/templates/subSilver/overall_header.tpl main/trunk/templates/subSilver/subSilver.cfg Modified: main/trunk/includes/page_header.php =================================================================== --- main/trunk/includes/page_header.php 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/includes/page_header.php 2007-02-12 15:46:21 UTC (rev 45) @@ -378,6 +378,7 @@ 'L_SEARCH_SELF' => $lang['Search_your_posts'], 'L_WHOSONLINE_ADMIN' => sprintf($lang['Admin_online_color'], '<span style="color:#' . $theme['fontcolor3'] . '">', '</span>'), 'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'), + 'L_KB' => $lang['KB'], 'U_SEARCH_UNANSWERED' => append_sid('search.'.$phpEx.'?search_id=unanswered'), 'U_SEARCH_SELF' => append_sid('search.'.$phpEx.'?search_id=egosearch'), @@ -394,6 +395,7 @@ 'U_VIEWONLINE' => append_sid('viewonline.'.$phpEx), 'U_LOGIN_LOGOUT' => append_sid($u_login_logout), 'U_GROUP_CP' => append_sid('groupcp.'.$phpEx), + 'U_KB' => append_sid('kb.'.$phpEx), 'S_CONTENT_DIRECTION' => $lang['DIRECTION'], 'S_CONTENT_ENCODING' => $lang['ENCODING'], Modified: main/trunk/kb.php =================================================================== --- main/trunk/kb.php 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/kb.php 2007-02-12 15:46:21 UTC (rev 45) @@ -44,14 +44,9 @@ // search - the kb search engine... // More will come whenever i figure something out. Now i'll start coding. :D // Imladris include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_kb.' . $phpEx); + $pid = ( isset($HTTP_GET_VARS['pid']) ) ? $HTTP_GET_VARS['pid'] : "main"; -// Making sure the install file has been removed -if(file_exists($phpbb_root_path . "kb_install." . $phpEx)) -{ - message_die(GENERAL_MESSAGE, $lang['kb_remove_installfile']); -} - switch($pid) { case "main": @@ -87,8 +82,8 @@ $template->assign_vars(array( 'L_CATEGORIES' => $lang['kb_categories'], 'L_ARTICLES' => $lang['kb_articles'], - 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], - 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) + 'ADD_ARTICLE_IMG' => $images['kb_new_article'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) ); if($total_catrows = count($catrows)) Modified: main/trunk/language/lang_english/lang_main.php =================================================================== --- main/trunk/language/lang_english/lang_main.php 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/language/lang_english/lang_main.php 2007-02-12 15:46:21 UTC (rev 45) @@ -1020,6 +1020,9 @@ $lang['Session_invalid'] = 'Invalid Session. Please resubmit the form.'; +// phpBB Knowledge Base MOD :: Language Strings +$lang['KB'] = 'Knowledge Base'; + // // That's all, Folks! // ------------------------------------------------- Modified: main/trunk/templates/subSilver/images/lang_english/Thumbs.db =================================================================== (Binary files differ) Modified: main/trunk/templates/subSilver/kb_main.tpl =================================================================== --- main/trunk/templates/subSilver/kb_main.tpl 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/templates/subSilver/kb_main.tpl 2007-02-12 15:46:21 UTC (rev 45) @@ -1,7 +1,7 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> <!-- BEGIN switch_add_article --> - <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}"><img src="{ADD_ARTICLE_IMG}" border="0" alt="{L_ADD_ARTICLE}" /></a></td> <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> @@ -41,7 +41,7 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> <!-- BEGIN switch_add_article --> - <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}"><img src="{ADD_ARTICLE_IMG}" border="0" alt="{L_ADD_ARTICLE}" /></a></td> <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> Modified: main/trunk/templates/subSilver/kb_viewcat.tpl =================================================================== --- main/trunk/templates/subSilver/kb_viewcat.tpl 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/templates/subSilver/kb_viewcat.tpl 2007-02-12 15:46:21 UTC (rev 45) @@ -1,7 +1,7 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> <!-- BEGIN switch_add_article --> - <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}"><img src="{ADD_ARTICLE_IMG}" border="0" alt="{L_ADD_ARTICLE}" /></a></td> <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> Modified: main/trunk/templates/subSilver/overall_header.tpl =================================================================== --- main/trunk/templates/subSilver/overall_header.tpl 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/templates/subSilver/overall_header.tpl 2007-02-12 15:46:21 UTC (rev 45) @@ -232,7 +232,7 @@ <td align="center" width="100%" valign="middle"><span class="maintitle">{SITENAME}</span><br /><span class="gen">{SITE_DESCRIPTION}<br /> </span> <table cellspacing="0" cellpadding="2" border="0"> <tr> - <td align="center" valign="top" nowrap="nowrap"><span class="mainmenu"> <a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a> <a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a> <a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a> <a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a> + <td align="center" valign="top" nowrap="nowrap"><span class="mainmenu"> <a href="{U_KB}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_KB}" hspace="3" />{L_KB}</a> <a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a> <a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a> <a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a> <a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a> <!-- BEGIN switch_user_logged_out --> <a href="{U_REGISTER}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" alt="{L_REGISTER}" hspace="3" />{L_REGISTER}</a> <!-- END switch_user_logged_out --> Modified: main/trunk/templates/subSilver/subSilver.cfg =================================================================== --- main/trunk/templates/subSilver/subSilver.cfg 2007-01-26 18:24:11 UTC (rev 44) +++ main/trunk/templates/subSilver/subSilver.cfg 2007-02-12 15:46:21 UTC (rev 45) @@ -44,6 +44,7 @@ $images['icon_latest_reply'] = "$current_template_images/icon_latest_reply.gif"; $images['icon_newest_reply'] = "$current_template_images/icon_newest_reply.gif"; + $images['forum'] = "$current_template_images/folder_big.gif"; $images['forum_new'] = "$current_template_images/folder_new_big.gif"; $images['forum_locked'] = "$current_template_images/folder_locked_big.gif"; @@ -63,6 +64,7 @@ $images['post_locked'] = "$current_template_images/{LANG}/reply-locked.gif"; $images['reply_new'] = "$current_template_images/{LANG}/reply.gif"; $images['reply_locked'] = "$current_template_images/{LANG}/reply-locked.gif"; +$images['kb_new_article'] = "$current_template_images/{LANG}/new-article.gif"; $images['pm_inbox'] = "$current_template_images/msg_inbox.gif"; $images['pm_outbox'] = "$current_template_images/msg_outbox.gif"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-01-26 18:24:16
|
Revision: 44 http://svn.sourceforge.net/phpbbkb/?rev=44&view=rev Author: markthedaemon Date: 2007-01-26 10:24:11 -0800 (Fri, 26 Jan 2007) Log Message: ----------- Couple of minor changes to the install file Modified Paths: -------------- main/trunk/install/kb_install.php Modified: main/trunk/install/kb_install.php =================================================================== --- main/trunk/install/kb_install.php 2007-01-26 18:12:17 UTC (rev 43) +++ main/trunk/install/kb_install.php 2007-01-26 18:24:11 UTC (rev 44) @@ -19,7 +19,7 @@ ***************************************************************************/ define('IN_PHPBB', true); -$phpbb_root_path = './'; +$phpbb_root_path = './../'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.' . $phpEx); @@ -32,21 +32,8 @@ // End session management // - -if( !$userdata['session_logged_in'] ) -{ - $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; - header($header_location . append_sid($phpbb_root_path . "login.$phpEx?redirect=kb_install.$phpEx", true)); - exit; -} - -if( $userdata['user_level'] != ADMIN ) -{ - message_die(GENERAL_MESSAGE, 'You are not authorised to access this page'); -} - $page_title = 'phpBB Knowledge Base MOD'; -include('includes/page_header.' . $phpEx); +include($phpbb_root_path . 'includes/page_header.' . $phpEx); $sql = array(); $sql[] = "CREATE TABLE " . $table_prefix . "kb_categories ( @@ -134,5 +121,5 @@ '<a href="http://www.phpbbknowledgebase.com" target="_blank">phpBB Knowledge Base Forums</a> or the <a href="http://www.phpbb.com/phpBB/viewtopic.php?t=415458" target="_blank">phpBB.com topic</a> and ask someone for help.</span></td></tr>'; echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid($phpbb_root_path . "index.$phpEx") . '">Have a nice day, and thanks for using the phpBB Knowledge Base MODification!</a></span></td></table>'; -include('includes/page_tail.' . $phpEx); +include($phpbb_root_path . 'includes/page_tail.' . $phpEx); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-01-26 18:12:21
|
Revision: 43 http://svn.sourceforge.net/phpbbkb/?rev=43&view=rev Author: markthedaemon Date: 2007-01-26 10:12:17 -0800 (Fri, 26 Jan 2007) Log Message: ----------- A couple of changes including; - Moving the install schema into to install/schemas/kb_schema.sql. The current install is only a tempory solution and is a bit of a hack; it probably won't get fixed before Alpha 1 but it should be by at least the betas. - Adding a "Viewing KB" to both viewonline and the admin index. Modified Paths: -------------- main/trunk/admin/index.php main/trunk/viewonline.php Added Paths: ----------- main/trunk/install/schemas/kb_schema.sql main/trunk/templates/subSilver/images/lang_english/Thumbs.db Modified: main/trunk/admin/index.php =================================================================== --- main/trunk/admin/index.php 2007-01-26 18:02:51 UTC (rev 42) +++ main/trunk/admin/index.php 2007-01-26 18:12:17 UTC (rev 43) @@ -430,6 +430,10 @@ $location = $lang['Viewing_FAQ']; $location_url = "index.$phpEx?pane=right"; break; + case PAGE_KB: + $location = $lang['Viewing_KB']; + $location_url = "index.$phpEx?pane=right"; + break; default: $location = $lang['Forum_index']; $location_url = "index.$phpEx?pane=right"; @@ -522,6 +526,10 @@ $location = $lang['Viewing_FAQ']; $location_url = "index.$phpEx?pane=right"; break; + case PAGE_KB: + $location = $lang['Viewing_KB']; + $location_url = "index.$phpEx?pane=right"; + break; default: $location = $lang['Forum_index']; $location_url = "index.$phpEx?pane=right"; Added: main/trunk/install/schemas/kb_schema.sql =================================================================== --- main/trunk/install/schemas/kb_schema.sql (rev 0) +++ main/trunk/install/schemas/kb_schema.sql 2007-01-26 18:12:17 UTC (rev 43) @@ -0,0 +1,64 @@ +# +# phpBB2 Knowledge Base :: MySQL install schema +# +# $Id: Exp $ +# + +CREATE TABLE phpbb_kb_categories ( + cat_id mediumint(8) UNSIGNED NOT NULL auto_increment, + cat_main mediumint(8) UNSIGNED DEFAULT '0', + cat_title varchar(100) NOT NULL, + cat_desc varchar(255) NOT NULL, + cat_articles mediumint(8) UNSIGNED DEFAULT '0', + cat_order mediumint(8) UNSIGNED NOT NULL, + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + PRIMARY KEY (cat_id), + KEY cat_order (cat_order) +); + +CREATE TABLE phpbb_kb_articles ( + article_id mediumint(8) UNSIGNED NOT NULL auto_increment, + article_title varchar(100) NOT NULL, + article_desc varchar(255) NOT NULL, + article_author mediumint(8) UNSIGNED NOT NULL, + article_authorname varchar(50) NOT NULL, + article_time int(20) UNSIGNED DEFAULT '0', + article_edittime int(20) UNSIGNED DEFAULT '0', + article_hits mediumint(8) UNSIGNED DEFAULT '0', + article_editby mediumint(8) UNSIGNED DEFAULT '0', + article_status smallint(1) UNSIGNED DEFAULT '0', + bbcode_uid varchar(10) NOT NULL, + enable_sig smallint(1) UNSIGNED DEFAULT '0', + enable_html smallint(1) UNSIGNED DEFAULT '0', + enable_bbcode smallint(1) UNSIGNED DEFAULT '0', + enable_smilies smallint(1) UNSIGNED DEFAULT '0', + article_text text, + PRIMARY KEY (article_id) +); + +CREATE TABLE phpbb_kb_articlecats ( + article_id mediumint(8) NOT NULL DEFAULT '0', + cat_id mediumint(8) NOT NULL DEFAULT '0' +); + +CREATE TABLE phpbb_kb_auth_access ( + group_id mediumint(8) NOT NULL default '0', + cat_id smallint(5) unsigned NOT NULL default '0', + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + KEY group_id (group_id), + KEY cat_id (cat_id) +); \ No newline at end of file Added: main/trunk/templates/subSilver/images/lang_english/Thumbs.db =================================================================== (Binary files differ) Property changes on: main/trunk/templates/subSilver/images/lang_english/Thumbs.db ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: main/trunk/viewonline.php =================================================================== --- main/trunk/viewonline.php 2007-01-26 18:02:51 UTC (rev 42) +++ main/trunk/viewonline.php 2007-01-26 18:12:17 UTC (rev 43) @@ -195,6 +195,10 @@ $location = $lang['Viewing_FAQ']; $location_url = "faq.$phpEx"; break; + case PAGE_KB: + $location = $lang['Viewing_KB']; + $location_url = "kb.$phpEx"; + break; default: $location = $lang['Forum_index']; $location_url = "index.$phpEx"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-01-26 18:02:51
|
Revision: 42 http://svn.sourceforge.net/phpbbkb/?rev=42&view=rev Author: markthedaemon Date: 2007-01-26 10:02:51 -0800 (Fri, 26 Jan 2007) Log Message: ----------- Adding the KB files as well as commiting a updated lang_kb.php file which includes some initial changes for the language side of things. Added Paths: ----------- main/trunk/admin/admin_kb.php main/trunk/install/kb_install.php main/trunk/kb.php main/trunk/language/lang_english/lang_kb.php main/trunk/templates/subSilver/admin/kb_cats.tpl main/trunk/templates/subSilver/admin/kb_editcat.tpl main/trunk/templates/subSilver/images/Thumbs.db main/trunk/templates/subSilver/images/new-article.gif main/trunk/templates/subSilver/kb_article_posting.tpl main/trunk/templates/subSilver/kb_main.tpl main/trunk/templates/subSilver/kb_previewarticle.tpl main/trunk/templates/subSilver/kb_viewarticle.tpl main/trunk/templates/subSilver/kb_viewcat.tpl Added: main/trunk/admin/admin_kb.php =================================================================== --- main/trunk/admin/admin_kb.php (rev 0) +++ main/trunk/admin/admin_kb.php 2007-01-26 18:02:51 UTC (rev 42) @@ -0,0 +1,727 @@ +<?php +/*************************************************************************** + * admin_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +define('IN_PHPBB', 1); + +if( !empty($setmodules) ) +{ + $file = basename(__FILE__); + $module['KB']['Categories'] = "$file?mode=cats"; + return; +} + +$phpbb_root_path = "./../"; +require($phpbb_root_path . 'extension.inc'); +require('./pagestart.' . $phpEx); + +// Get constants and functions +include($phpbb_root_path . "kb/constants." . $phpEx); +include($phpbb_root_path . "kb/functions." . $phpEx); + +// And language +include($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/lang_kb." . $phpEx); +$mode = $HTTP_GET_VARS['mode']; + +switch($mode) +{ + /* + NOTE: All article editing, deleting, approving and so on will be featured in the ucp for the admin as well, + might integrate it here later but i like it better in ucp. + case "articles": + break; + */ + + case "cats": + $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; + $delete = isset($HTTP_GET_VARS['delete']) ? $HTTP_GET_VARS['delete'] : false; + $add = isset($HTTP_POST_VARS['add']) ? true : false; + if(!$add) + { + $add = isset($HTTP_GET_VARS['add']) ? true : false; + } + $sort = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : false; + + if($edit != false) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'DESCRIPTION' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) + ); + + $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; + } + else + { + $error_msg = ''; + + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'DESCRIPTION' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) + ); + + $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_main = '" . $parent . "', + cat_title = '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', + cat_desc = '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "' + WHERE cat_id = '" . $edit . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't edit category.", "", __LINE__, __FILE__, $sql); + } + + if($HTTP_POST_VARS['oldparent'] != $HTTP_POST_VARS['parent']) + { + // Parent category changed, alter the order + sort_cats("edit", $edit, 0, array(0 => $HTTP_POST_VARS['parent'], 1 => $HTTP_POST_VARS['oldparent'])); + } + + // And a message here somewhere + $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); + } + } + } + + if($delete != false) + { + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + $cancel = isset($HTTP_POST_VARS['cancel']) ? true : false; + if($cancel) + { + // Redirect back to cat page + + } + elseif(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $delete . '" />'; + $l_confirm = $lang['kbadm_confirm_deletecat']; + + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=true"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + + include('./page_footer_admin.'.$phpEx); + exit; + } + elseif($confirm) // Double check user confirmed + { + $cat_id = $HTTP_POST_VARS['cat_id']; + + // Need lang vars for the errors? + $sql = "DELETE FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from categories table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + // Delete subcats + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE cat_main = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete subcategories from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? + message_die(GENERAL_MESSAGE, $message); + } + } + + if($add) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_addcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_addcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) + ); + + $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; + } + else + { + $error_msg = ''; + + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($HTTP_POST_VARS['parent']); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $HTTP_POST_VARS['title'], + 'DESCRIPTION' => $HTTP_POST_VARS['desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) + ); + + $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "INSERT INTO " . KB_CATEGORIES_TABLE . " (cat_id, cat_main, cat_title, cat_desc, cat_articles, cat_order) + VALUES ('', '" . $parent . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "', '0', '9999');"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't insert new category.", "", __LINE__, __FILE__, $sql); + } + + sort_cats("add", $db->sql_nextid(), 0, $parent); + + // And a message here somewhere + $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); + } + } + } + + if($sort != false) + { + $sort = explode("|", $sort); + + // ok so ?sort=id|up/down|level + sort_cats("", $sort[0], $sort[1], $sort[2]); // Put id2 in the level argument, nvm that :) + + // And yes yet another message here + $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); + } + + // Show categories as list + $cats = get_cats_structure(); + + $template->set_filenames(array( + 'body' => 'admin/kb_cats.tpl') + ); + + $template->assign_vars(array( + 'L_CATEGORIES' => $lang['kb_categories'], + 'L_EDITCAT' => $lang['kbadm_editcat'], + 'L_DELCAT' => $lang['kbadm_delcat'], + 'L_HEADER' => $lang['Categories'], + 'L_EXPLAIN' => $lang['kbadm_maincat_explain']) + ); + + if($total_catrows = count($cats)) + { + for($i = 0; $i < $total_catrows; $i++) + { + // Check if the cat is at the top and therefore cant be moved up + if(($cats[$i - 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i - 1]['cat_id']) == 0)) + { + $movecat_up = $lang['kbadm_movecatup']; + } + else + { + $movecat_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|up|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatup'] . '</a>'; + } + + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i + 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i + 1]['cat_id']) == 0)) + { + $movecat_down = $lang['kbadm_movecatdown']; + } + else + { + $movecat_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|down|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Ok display one cat here + $template->assign_block_vars('catrow', array( + // Name 'nd stuff + 'CAT_TITLE' => $cats[$i]['cat_title'], + 'CAT_DESC' => $cats[$i]['cat_desc'], + + // Links + 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), + 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), + // sort=id,id2|up/down|level + 'MOVECAT_UP' => $movecat_up, + 'MOVECAT_DOWN' => $movecat_down, + + // Image + 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D + ); + + if($total_subcats = count($cats[$i]['subcats'])) + { + // Contains subcats, show them + //$template->assign_block_vars('catrow.switch_subcat', array( + //'L_SUBCATS' => $lang['kb_subcats']) + //); + + for($j = 0; $j < $total_subcats; $j++) + { + if(($cats[$i]['subcats'][$j - 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j - 1]['cat_id']) == 0)) + { + $subcatmove_up = $lang['kbadm_movecatup']; + } + else + { + $subcatmove_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|up') . '">' . $lang['kbadm_movecatup'] . '</a>'; + } + + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i]['subcats'][$j + 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j + 1]['cat_id']) == 0)) + { + $subcatmove_down = $lang['kbadm_movecatdown']; + } + else + { + $subcatmove_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|down') . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Show the subcat + $template->assign_block_vars('catrow.subcatrow', array( + 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], + 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], + + // Links + 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), + 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), + // sort=id,id2|up/down|level + 'MOVESUBCAT_UP' => $subcatmove_up, + 'MOVESUBCAT_DOWN' => $subcatmove_down, + + 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D + ); + } // for subcats + + //$template->assign_block_vars('catrow.switch_subcat_close', array()); + } // if subcats + } // for cats + + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_CAT_SETTINGS' => $lang['kbadm_addcat'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) + ); + + $template->pparse('body'); + }// total cats + else + { + message_die(GENERAL_MESSAGE, sprintf($lang['No_kbadm_cats'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats&add=1") . '">', '</a>')); + } + + include('./page_footer_admin.'.$phpEx); + exit; + break; + + case "auth": // For later use + break; + + case "files": // For later use + break; + + default: // General settings here + break; +} + + +////////////////// +/// FUNCTIONS /// +////////////////// +function generate_cat_parents($selected = false) +{ + global $db, $lang; + + $sql = "SELECT cat_id, cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '0' + ORDER BY cat_order ASC"; // At the moment only one level of subcats + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); + } + + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + } + + if(!$selected) + { + $parent = '<select name="parent">\n<option value="0" selected="selected">' . $lang['kb_main'] . '</option>\n'; + } + else + { + $parent = '<select name="parent">\n<option value="0">' . $lang['kb_main'] . '</option>\n'; + } + + for($i = 0; $i < count($cats); $i++) + { + if(!$selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + if($cats[$i]['cat_id'] == $selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '" selected="selected">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + } + } + + $parent .= "</select>"; + + return $parent; +} + +function sort_cats($type = "", $id = 0, $dir = 0, $level = 0) +{ + global $db; + + if($type == "add") + { + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + elseif($type == "edit") + { + // First clean up in the old level where it is gone from + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[1] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $sql = ""; + $i = 0; + while($old_cat = $db->sql_fetchrow($result)) + { + $i++; + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $i . "' + WHERE cat_id = '" . $old_cat['cat_id'] . "';\n"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); + } + } + + // Ok insert it in the back of the new one :) + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[0] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + else + { + $sql = "SELECT cat_order, cat_main + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); + } + + $cat = $db->sql_fetchrow($result); + + if($dir == "up") + { + $num = $cat['cat_order'] - 1; + + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); + } + + $cat2 = $db->sql_fetchrow($result); + } + elseif($dir == "down") + { + $num = $cat['cat_order'] + 1; + + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); + } + + $cat2 = $db->sql_fetchrow($result); + } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat2['cat_order'] . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat['cat_order'] . "' + WHERE cat_id = '" . $cat2['cat_id'] . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + + return; + } +} +?> Added: main/trunk/install/kb_install.php =================================================================== --- main/trunk/install/kb_install.php (rev 0) +++ main/trunk/install/kb_install.php 2007-01-26 18:02:51 UTC (rev 42) @@ -0,0 +1,138 @@ +<?php +/*************************************************************************** + * kb_install.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +define('IN_PHPBB', true); +$phpbb_root_path = './'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'common.' . $phpEx); + +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_INDEX); +init_userprefs($userdata); +// +// End session management +// + + +if( !$userdata['session_logged_in'] ) +{ + $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; + header($header_location . append_sid($phpbb_root_path . "login.$phpEx?redirect=kb_install.$phpEx", true)); + exit; +} + +if( $userdata['user_level'] != ADMIN ) +{ + message_die(GENERAL_MESSAGE, 'You are not authorised to access this page'); +} + +$page_title = 'phpBB Knowledge Base MOD'; +include('includes/page_header.' . $phpEx); + +$sql = array(); +$sql[] = "CREATE TABLE " . $table_prefix . "kb_categories ( + cat_id mediumint(8) UNSIGNED NOT NULL auto_increment, + cat_main mediumint(8) UNSIGNED DEFAULT '0', + cat_title varchar(100) NOT NULL, + cat_desc varchar(255) NOT NULL, + cat_articles mediumint(8) UNSIGNED DEFAULT '0', + cat_order mediumint(8) UNSIGNED NOT NULL, + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + PRIMARY KEY (cat_id), + KEY cat_order (cat_order) +)"; + +$sql[] = "CREATE TABLE " . $table_prefix . "kb_articles ( + article_id mediumint(8) UNSIGNED NOT NULL auto_increment, + article_title varchar(100) NOT NULL, + article_desc varchar(255) NOT NULL, + article_author mediumint(8) UNSIGNED NOT NULL, + article_authorname varchar(50) NOT NULL, + article_time int(20) UNSIGNED DEFAULT '0', + article_edittime int(20) UNSIGNED DEFAULT '0', + article_hits mediumint(8) UNSIGNED DEFAULT '0', + article_editby mediumint(8) UNSIGNED DEFAULT '0', + article_status smallint(1) UNSIGNED DEFAULT '0', + bbcode_uid varchar(10) NOT NULL, + enable_sig smallint(1) UNSIGNED DEFAULT '0', + enable_html smallint(1) UNSIGNED DEFAULT '0', + enable_bbcode smallint(1) UNSIGNED DEFAULT '0', + enable_smilies smallint(1) UNSIGNED DEFAULT '0', + article_text text, + PRIMARY KEY (article_id) +)"; + +$sql[] = "CREATE TABLE " . $table_prefix . "kb_articlecats ( + article_id mediumint(8) NOT NULL DEFAULT '0', + cat_id mediumint(8) NOT NULL DEFAULT '0' +)"; + +$sql[] = "CREATE TABLE " . $table_prefix . "kb_auth_access ( + group_id mediumint(8) NOT NULL default '0', + cat_id smallint(5) unsigned NOT NULL default '0', + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + KEY group_id (group_id), + KEY cat_id (cat_id) +)"; + +echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; +echo '<tr><th>Updating the database</th></tr>'; + +for( $i = 0; $i < count($sql); $i++ ) +{ + $msg = '<tr><td class="catLeft" height="28"><span class="forumlink">'; + + if( !$result = $db->sql_query($sql[$i]) ) + { + $error = $db->sql_error(); + $msg .= '<font color="#FF0000"><b>Error:</b></font> ' . $error['message']; + } + else + { + $msg .= '<font color="#00AA00"><b>Successfull</b></font>'; + } + + $msg .= '</span></td><tr><td class="row1"><pre class="genmed">' . $sql[$i] . '</pre></td></tr>'; + echo $msg; +} + +echo '<tr><th height="28">End</th></tr><tr><td class="row1"><span class="genmed">Installation is now finished. Please be sure to delete this file now.<br />'; +echo 'If you have run into any errors, please visit the '. + '<a href="http://www.phpbbknowledgebase.com" target="_blank">phpBB Knowledge Base Forums</a> or the <a href="http://www.phpbb.com/phpBB/viewtopic.php?t=415458" target="_blank">phpBB.com topic</a> and ask someone for help.</span></td></tr>'; +echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid($phpbb_root_path . "index.$phpEx") . '">Have a nice day, and thanks for using the phpBB Knowledge Base MODification!</a></span></td></table>'; + +include('includes/page_tail.' . $phpEx); +?> \ No newline at end of file Added: main/trunk/kb.php =================================================================== --- main/trunk/kb.php (rev 0) +++ main/trunk/kb.php 2007-01-26 18:02:51 UTC (rev 42) @@ -0,0 +1,624 @@ +<?php +/*************************************************************************** + * kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ +define('IN_PHPBB', true); +$phpbb_root_path = './'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'common.' . $phpEx); +include($phpbb_root_path . 'kb/constants.' . $phpEx); // Added these two files, yes i could just add the 10-15 lines it will end with in +include($phpbb_root_path . 'kb/functions.' . $phpEx); // the existing files, but this makes it a lot easier to install/uninstall. +include($phpbb_root_path . 'includes/bbcode.'.$phpEx); + +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_KB); +init_userprefs($userdata); +// +// End session management +// + +// File takes care of the following action set via $pid ($HTTP_GET_VARS['pid']): +// main - views categories, with subcategories listed +// view_cat - views a category, either lists subcategories or articles contained, or both ofc. +// view_article - views an article +// ucp - My idea of this is that it should be the complete possibility for users here. If they are normal users, they can see their own +// articles and if they get approved or not. They can also view their comments, and wether they are approved or not. This should +// also include mod options for admins. Approving/disapproving comments or articles, editing them, so on... +// search - the kb search engine... +// More will come whenever i figure something out. Now i'll start coding. :D // Imladris +include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_kb.' . $phpEx); +$pid = ( isset($HTTP_GET_VARS['pid']) ) ? $HTTP_GET_VARS['pid'] : "main"; + +// Making sure the install file has been removed +if(file_exists($phpbb_root_path . "kb_install." . $phpEx)) +{ + message_die(GENERAL_MESSAGE, $lang['kb_remove_installfile']); +} + +switch($pid) +{ + case "main": + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '0' + ORDER BY c.cat_order ASC"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); + } + + $catrows = array(); + while ($row = $db->sql_fetchrow($result)) + { + $catrows[] = $row; + } + + // Start Page output + $page_title = $lang['kb_main']; + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + create_navigation(); + + $template->set_filenames(array( + 'body' => 'kb_main.tpl') + ); + + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + + $template->assign_vars(array( + 'L_CATEGORIES' => $lang['kb_categories'], + 'L_ARTICLES' => $lang['kb_articles'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) + ); + + if($total_catrows = count($catrows)) + { + for($i = 0; $i < $total_catrows; $i++) + { + //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Ok display one cat here + $template->assign_block_vars('catrow', array( + 'CAT_TITLE' => $catrows[$i]['cat_title'], + 'CAT_DESC' => $catrows[$i]['cat_desc'], + 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'L_SUBCATS' => $lang['kb_subcats'], + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); + + // Now let's look at subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' + ORDER BY c.cat_order ASC"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while ($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; + } + + if($total_subcats = count($subcats)) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcats', array()); + + for($j = 0; $j < $total_subcats; $j++) + { + //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Show the subcat + $k = $j + 1; + $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; + $template->assign_block_vars('catrow.subcatrow', array( + 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], + 'SUBCAT_COMMA' => $subcat_comma) + ); + //} // if auth view + } // for subcats + } // if subcats + //} // auth view + } // for cats + }// total cats + else + { + message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + } + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + break; + + case "view_cat": + $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; + if(!$cat_id) + { + message_die(GENERAL_MESSAGE, $lang['kb_cat_noexist']); + } + + // Store the main cat in a variable + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $cat_id . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query the main category', '', __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + // Let's find subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '$cat_id' + ORDER BY c.cat_order ASC"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; + } + + // Now articles, the LIKE handles multiple cats + // First handle the sorting + // default is by edit time, other options: -rating, -author, -title + if(isset($HTTP_GET_VARS['sort'])) + { + switch($HTTP_GET_VARS['sort']) + { + case "rating": + // Later + $sort = "ORDER BY a.article_edittime DESC"; + break; + + case "author": + // Later + $sort = "ORDER BY a.article_edittime DESC"; + break; + + case "title": + $sort = "ORDER BY a.article_title"; + break; + + case "time": + default: + $sort = "ORDER BY a.article_edittime DESC"; + break; + } + } + else + { + $sort = "ORDER BY a.article_edittime DESC"; + } + + $sql = "SELECT a.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_ARTICLES_TABLE . " a + WHERE c.cat_id = '$cat_id' + AND c.article_id = a.article_id + $sort"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query articles.', '', __LINE__, __FILE__, $sql); + } + + $articles = array(); + while($row = $db->sql_fetchrow($result)) + { + $articles[] = $row; + } + + // Start Page output + $page_title = $lang['kb_viewcat'] . ": " . $cat['cat_title']; + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + if($cat['cat_main'] == "0") + { + create_navigation("viewcat", array( + 0 => $cat['cat_id'], + 1 => $cat['cat_title']) + ); + } + else + { + create_navigation("viewsubcat", array( + 0 => $cat_id, + 1 => $cat['cat_title'], + 2 => $cat['cat_main']) + ); + } + + $template->set_filenames(array( + 'body' => 'kb_viewcat.tpl') + ); + + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + + // Process the whole thing + $template->assign_vars(array( + 'L_VIEWS' => $lang['Views'], + 'L_AUTHOR' => $lang['Author'], + 'L_ARTICLES' => $lang['kb_articles'], + 'L_SUBCATS' => sprintf($lang['kb_viewcat_subcats'], $cat['cat_title']), + 'L_LAST_ACTION' => $lang['kb_last_action'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) + ); + + if( $total_subcats = count($subcats) ) + { + $template->assign_block_vars('switch_subcats', array()); + + // Ok it contains subcats, let's build them. + for($i = 0; $i < $total_subcats; $i++) + { + // Ok display one cat here + $template->assign_block_vars('switch_subcats.catrow', array( + 'CAT_TITLE' => $subcats[$i]['cat_title'], + 'CAT_DESC' => $subcats[$i]['cat_desc'], + 'CAT_ARTICLES' => $subcats[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$i]['cat_id']), + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); + } + } + + if( $total_articles = count($articles) ) + { + $template->assign_block_vars('switch_articles', array()); + + // Contains articles + for($i = 0; $i < $total_articles; $i++) + { + if($articles[$i]['article_authorname'] == "") + { + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE user_id = '" . $articles[$i]['article_author']; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query authorname', '', __LINE__, __FILE__, $sql); + } + + $user = $db->sql_fetchrow($result); + $authorname = $user['username']; + } + else + { + $authorname = $articles[$i]['article_authorname']; + } + $author = "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE user_id = '" . $articles[$i]['article_editby'] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query last edited by\'s username.', '', __LINE__, __FILE__, $sql); + } + + $user = $db->sql_fetchrow($result); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + + $template->assign_block_vars('switch_articles.articlerow', array( + 'TOPIC_FOLDER_IMG' => $images['folder'], + 'ARTICLE_TITLE' => $articles[$i]['article_title'], + 'ARTICLE_DESC' => $articles[$i]['article_desc'], + 'ARTICLE_AUTHOR' => $author, + 'ARTICLE_HITS' => $articles[$i]['article_hits'], + 'ARTICLE_LAST_ACTION' => $last_action, + 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=view_article&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) + ); + } + } + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + break; + + case "view_article": + $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; + $id = ( empty($HTTP_GET_VARS['id']) ) ? false : $HTTP_GET_VARS['id']; + + // Get naughty words :) + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + + $sql = "SELECT a.*, u.* + FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u + WHERE a.article_id = '$id' + AND a.article_author = u.user_id"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + $sql = "SELECT c.*, ca.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_CATEGORIES_TABLE . " ca + WHERE c.article_id = '$id' + AND ca.cat_id = c.cat_id"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article categories.', '', __LINE__, __FILE__, $sql); + } + + // + // These vars are for later use + // + $in_cat = false; + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + + if($row['cat_id'] == $cid) + { + $in_cat = true; + $current_cat['cat_title'] = $row['cat_title']; + $current_cat['cat_id'] = $row['cat_id']; + $current_cat['cat_main'] = $row['cat_main']; + } + } + + // + // Check that the given category is true + // + if(!$in_cat) + { + message_die(GENERAL_MESSAGE, "The category specified in GET variables did not exist along with this article in the database."); + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_bbcode_uid = $article['bbcode_uid']; + + $user_sig = ( $article['enable_sig'] && $article['user_sig'] != '' && $board_config['allow_sig'] ) ? $article['user_sig'] : ''; + $user_sig_bbcode_uid = $article['user_sig_bbcode_uid']; + + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$board_config['allow_html'] || !$userdata['user_allowhtml']) + { + if ( $user_sig != '' ) + { + $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); + } + + if ( $article['enable_html'] ) + { + $article_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $article_text); + } + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($user_sig != '' && $user_sig_bbcode_uid != '') + { + $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig); + } + + if ($article_bbcode_uid != '') + { + $article_text = ($board_config['allow_bbcode']) ? bbencode_second_pass($article_text, $article_bbcode_uid) : preg_replace("/\:$article_bbcode_uid/si", '', $article_text); + } + + if ( $user_sig != '' ) + { + $user_sig = make_clickable($user_sig); + } + $article_text = make_clickable($article_text); + + // + // Parse smilies + // + if ( $board_config['allow_smilies'] ) + { + if ( $article['user_allowsmile'] && $user_sig != '' ) + { + $user_sig = smilies_pass($user_sig); + } + + if ( $article['enable_smilies'] ) + { + $article_text = smilies_pass($article_text); + } + } + + // + // Replace naughty words + // + if (count($orig_word)) + { + $article_title = preg_replace($orig_word, $replacement_word, $article_title); + $article_desc = preg_replace($orig_word, $replacement_word, $article_desc); + + if ($user_sig != '') + { + $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); + } + + $article_text = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $article_text . '<'), 1, -1)); + } + + // + // Replace newlines (we use this rather than nl2br because + // till recently it wasn't XHTML compliant) + // + if ( $user_sig != '' ) + { + $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig); + } + + $article_text = str_replace("\n", "\n<br />\n", $article_text); + + // Start Page output + $page_title = $lang['kb_viewarticle'] . " : " . $article_title; + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + $template->set_filenames(array( + 'body' => 'kb_viewarticle.tpl') + ); + + create_navigation("viewarticle", array( + 0 => $current_cat['cat_id'], + 1 => $current_cat['cat_title'], + 2 => $current_cat['cat_main'], + 3 => $article['article_id'], + 4 => $article_title) + ); + + $posted_by = sprintf($lang['kb_posted_by'], '<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&u=' . $article['article_author']) . '">' . $article['article_authorname'] . '</a>', create_date($board_config['default_dateformat'], $article['article_time'], $board_config['board_timezone']), create_date($board_config['default_dateformat'], $article['article_edittime'], $board_config['board_timezone'])); + + $template->assign_vars(array( + 'U_VIEW_ARTICLE' => append_sid('kb.' . $phpEx . '?pid=view_article&cid=' . $cid . '&id=' . $article['article_id']), + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE_TEXT' => $article_text, + 'POSTED_BY' => $posted_by, + 'SIGNATURE' => $user_sig, + 'L_EDITARTICLE' => $lang['kb_ucp_articleedit'], + 'L_DELETEARTICLE' => $lang['kb_ucp_articledelete'], + + 'U_EDITARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article&id=' . $id), + 'U_DELETEARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=delete_article&id=' . $id)) + ); + + if(($userdata['user_level'] == ADMIN) || ($userdata['user_id'] == $article['article_author'])) + { + $template->assign_block_vars('switch_mod', array()); + } + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + break; + + case "ucp": + $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; + /*include($phpbb_root_path . "kb/ucp_class." . $phpEx); + $ucp = new ucp; + + // Start Page output + $page_title = $ucp->generate_page_title($action); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); + */ + // The above have been removed and changed to functions.php + $id = isset($HTTP_GET_VARS['id']) ? $HTTP_GET_VARS['id'] : 0; + $preview = isset($HTTP_POST_VARS['preview']) ? true : false; + + $page_title = ucp_generate_page_title($action); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + ucp_article_form("post", false, $preview); + break; + + case "edit_article": + ucp_article_form("edit", $id, $preview); + break; + + case "delete_article": + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + ucp_article_delete($id, $confirm); + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + + // + // Generate the page + // + if($action != "delete_article") + { + $template->pparse('body'); + } + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + break; + + case "search": + break; + + case "comment": + // For Adding, deleting and editing comments, this includes rating. + break; + + default: + message_die(GENERAL_MESSAGE, 'Wrong page id defined. No page shown.'); + break; +} +?> \ No newline at end of file Added: main/trunk/language/lang_english/lang_kb.php =================================================================== --- main/trunk/language/lang_english/lang_kb.php (rev 0) +++ main/trunk/language/lang_english/lang_kb.php 2007-01-26 18:02:51 UTC (rev 42) @@ -0,0 +1,97 @@ +<?php +/*************************************************************************** + * lang_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +// Page titles +$lang['kb_main'] = "Knowledge Base Home"; +$lang['kb_viewcat'] = "Viewing Category"; +$lang['kb_viewarticle'] = "Viewing Article"; +$lang['kb_ucp'] = "KB User Control Panel"; +$lang['kb_ucp_articlepost'] = "Post new article"; +$lang['kb_ucp_articleedit'] = "Edit article"; +$lang['kb_ucp_articledelete'] = "Delete article"; + +// Normal Page +$lang['kb_categories'] = "Knowledge Base Categories"; +$lang['kb_articles'] = "Articles"; +$lang['kb_subcats'] = "Subcategories"; +$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. The Knowledge Base Modification <strong>will not</strong> work before the file is removed."; +$lang['No_kb_cats'] = "No Knowledge Base categories have been added."; +$lang['kb_cat_noexist'] = "The category you have chosen does not exist."; + +$lang['kb_viewcat_subcats'] = "Subcategories in %s"; +$lang['kb_last_action'] = "Last action"; +$lang['kb_last_action_row'] = "Last action for this article was comitted by %s on the %s"; + +// Posting Page +$lang['kb_post_article'] = "Post New Article"; +$lang['kb_edit_article'] = "Edit Article"; +$lang['kb_authorname'] = "Author Name"; +$lang['kb_authorname_desc'] = "This is the name that will be displayed, you can leave your forum username here if you require, or replace it with another name."; +$lang['kb_articlename'] = "Article Name"; +$lang['kb_articledesc'] = "Article Description"; +$lang['kb_articlecats'] = "Article Categories"; +$lang['kb_articletext'] = "Article Content"; +$lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; +$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use Ctrl & Click for multiple."; +$lang['kb_empty_article'] = "The article content you have submitted was empty."; +$lang['kb_empty_article_title'] = "The article title you submitted was empty."; +$lang['kb_empty_cats'] = "The article you submitted had no category defined."; +$lang['kb_empty_article_desc'] = "The article has to contain an article description."; +$lang['kb_added'] = "Your article has been submitted and is awaiting approval."; +$lang['kb_deleted'] = "Your article has been deleted and is now nonexistant."; +$lang['kb_edited'] = "Your article has been edited and is awaiting reapproval."; +$lang['kb_click_view_article'] = "Click %shere%s to view you article."; // Change this later on, they can't view the article yet. +$lang['kb_click_return_ucp'] = "Click %shere%s to go back to the user control panel"; +$lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; +$lang['kb_confirm_deletearticle'] = "Are you sure you want to delete this article?"; +$lang['kb_articlepreview'] = "Article Preview"; + +// Auth +$lang['kb_edit_noauth'] = "You are not allowed to edit this article."; +$lang['kb_delete_noauth'] = "You are not allowed to delete this article."; + +// Admin +$lang['kbadm_header_editcat'] = "Edit Category"; +$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category and description."; +$lang['kbadm_cat_settings'] = "Category Properties"; +$lang['kbadm_cat_title'] = "Category Title"; +$lang['kbadm_cat_desc'] = "Category Description"; +$lang['kbadm_cat_parent'] = "Parent Category"; +$lang['kbadm_empty_cat_title'] = "The Category Title submitted was empty."; +$lang['kbadm_empty_cat_desc'] = "The Category Description submitted was empty."; +$lang['kbadm_confirm_deletecat'] = "Are you sure you want to delete this category?"; +$lang['kbadm_Click_return_catadmin'] = "Click %shere%s to return to category administration."; +$lang['kbadm_header_addcat'] = "Add Category"; +$lang['kbadm_explain_addcat'] = "From here you can add a new category."; +$lang['kbadm_addcat'] = "Add"; +$lang['kbadm_editcat'] = "Edit"; + +$lang['kbadm_movecatup'] = "Move Up"; +$lang['kbadm_movecatdown'] = "Move Down"; +$lang['kbadm_delcat'] = "Delete"; +$lang['kbadm_maincat_explain'] = "This is the place where you can move categories up and down, create new ones and edit the already existant."; + +$lang['kbadm_delcat_success'] = "The category has been deleted successfully."; +$lang['kbadm_editcat_success'] = "The category has been edited successfully."; +$lang['kbadm_addcat_success'] = "Your new category has been added."; +$lang['kbadm_sortcat_success'] = "The category has been moved as specified."; + +$lang['No_kbadm_cats'] = "No knowledge base categories has been added. Click %shere%s to create a new one."; +?> \ No newline at end of file Added: main/trunk/templates/subSilver/admin/kb_cats.tpl =================================================================== --- main/trunk/templates/subSilver/admin/kb_cats.tpl (rev 0) +++ main/trunk/templates/subSilver/admin/kb_cats.tpl 2007-01-26 18:02:51 UTC (rev 42) @@ -0,0 +1,66 @@ +<h1>{L_HEADER}</h1> + +<p>{L_EXPLAIN}</p> + +<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> + <tr> + <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_CATEGORIES} </th> + <th class="thCornerR" colspan="4" nowrap="nowrap"> </th> + </tr> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle"> </span></td> + <td class="rowpic" colspan="4" align="right"> </td> + </tr> + <!-- BEGIN catrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> + <td class="row1" width="100%" height="50">{catrow.CAT_TITLE}<br /> + </span> <span class="genmed">{catrow.CAT_DESC}</td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_UP}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_DOWN}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- BEGIN subcatrow --> + <tr> + <td class="row2" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row2" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> + <span class="genmed">{catrow.subcatrow.SUBCAT_DESC}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_EDITSUBCAT}">{L_EDITCAT}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_UP}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_DOWN}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_DELSUBCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- END subcatrow --> + <!-- END catrow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> + </tr> +</table> + +<br clear="all" /> + +<form action="{S_FORUM_ACTION}" method="post"> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">{L_CAT_SETTINGS}</th> + </tr> + <tr> + <td class="row1">{L_CAT_TITLE}</td> + <td class="row2"><input type="text" size="25" name="title" value="" class="post" /></td> + </tr> + <tr> + <td class="row1">{L_CAT_DESCRIPTION}</td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="desc" class="post"></textarea></td> + </tr> + <tr> + <td class="row1">{L_CAT_PARENT}</td> + <td class="row2">{S_PARENT}</td> + </tr> + <tr> + <td cl... [truncated message content] |
From: <mar...@us...> - 2007-01-26 17:49:48
|
Revision: 41 http://svn.sourceforge.net/phpbbkb/?rev=41&view=rev Author: markthedaemon Date: 2007-01-26 09:49:48 -0800 (Fri, 26 Jan 2007) Log Message: ----------- We decided it would be better if we worked from a phpBB2 install, so we could modify files et cetera. Thus, here it is :D Added Paths: ----------- main/ main/branches/ main/etc/ main/tags/ main/trunk/ main/trunk/admin/ main/trunk/admin/admin_board.php main/trunk/admin/admin_db_utilities.php main/trunk/admin/admin_disallow.php main/trunk/admin/admin_forum_prune.php main/trunk/admin/admin_forumauth.php main/trunk/admin/admin_forums.php main/trunk/admin/admin_groups.php main/trunk/admin/admin_mass_email.php main/trunk/admin/admin_ranks.php main/trunk/admin/admin_smilies.php main/trunk/admin/admin_styles.php main/trunk/admin/admin_ug_auth.php main/trunk/admin/admin_user_ban.php main/trunk/admin/admin_users.php main/trunk/admin/admin_words.php main/trunk/admin/index.php main/trunk/admin/page_footer_admin.php main/trunk/admin/page_header_admin.php main/trunk/admin/pagestart.php main/trunk/cache/ main/trunk/cache/.htaccess main/trunk/cache/index.htm main/trunk/common.php main/trunk/config.php main/trunk/contrib/ main/trunk/contrib/README.html main/trunk/contrib/dbinformer.php main/trunk/contrib/fixfiles.sh main/trunk/contrib/template_db_cache.php main/trunk/contrib/template_file_cache.php main/trunk/db/ main/trunk/db/db2.php main/trunk/db/index.htm main/trunk/db/msaccess.php main/trunk/db/mssql-odbc.php main/trunk/db/mssql.php main/trunk/db/mysql.php main/trunk/db/mysql4.php main/trunk/db/postgres7.php main/trunk/docs/ main/trunk/docs/AUTHORS main/trunk/docs/CHANGELOG.html main/trunk/docs/COPYING main/trunk/docs/FAQ.html main/trunk/docs/INSTALL.html main/trunk/docs/README.html main/trunk/docs/coding-guidelines.txt main/trunk/docs/codingstandards.htm main/trunk/extension.inc main/trunk/faq.php main/trunk/groupcp.php main/trunk/images/ main/trunk/images/avatars/ main/trunk/images/avatars/gallery/ main/trunk/images/avatars/gallery/index.htm main/trunk/images/avatars/index.htm main/trunk/images/index.htm main/trunk/images/smiles/ main/trunk/images/smiles/icon_arrow.gif main/trunk/images/smiles/icon_biggrin.gif main/trunk/images/smiles/icon_confused.gif main/trunk/images/smiles/icon_cool.gif main/trunk/images/smiles/icon_cry.gif main/trunk/images/smiles/icon_eek.gif main/trunk/images/smiles/icon_evil.gif main/trunk/images/smiles/icon_exclaim.gif main/trunk/images/smiles/icon_frown.gif main/trunk/images/smiles/icon_idea.gif main/trunk/images/smiles/icon_lol.gif main/trunk/images/smiles/icon_mad.gif main/trunk/images/smiles/icon_mrgreen.gif main/trunk/images/smiles/icon_neutral.gif main/trunk/images/smiles/icon_question.gif main/trunk/images/smiles/icon_razz.gif main/trunk/images/smiles/icon_redface.gif main/trunk/images/smiles/icon_rolleyes.gif main/trunk/images/smiles/icon_sad.gif main/trunk/images/smiles/icon_smile.gif main/trunk/images/smiles/icon_surprised.gif main/trunk/images/smiles/icon_twisted.gif main/trunk/images/smiles/icon_wink.gif main/trunk/images/spacer.gif main/trunk/includes/ main/trunk/includes/auth.php main/trunk/includes/bbcode.php main/trunk/includes/constants.php main/trunk/includes/db.php main/trunk/includes/emailer.php main/trunk/includes/functions.php main/trunk/includes/functions_admin.php main/trunk/includes/functions_post.php main/trunk/includes/functions_search.php main/trunk/includes/functions_selects.php main/trunk/includes/functions_validate.php main/trunk/includes/index.htm main/trunk/includes/page_header.php main/trunk/includes/page_tail.php main/trunk/includes/prune.php main/trunk/includes/sessions.php main/trunk/includes/smtp.php main/trunk/includes/sql_parse.php main/trunk/includes/template.php main/trunk/includes/topic_review.php main/trunk/includes/usercp_activate.php main/trunk/includes/usercp_avatar.php main/trunk/includes/usercp_confirm.php main/trunk/includes/usercp_email.php main/trunk/includes/usercp_register.php main/trunk/includes/usercp_sendpasswd.php main/trunk/includes/usercp_viewprofile.php main/trunk/index.php main/trunk/install/ main/trunk/install/index.htm main/trunk/install/install.php main/trunk/install/schemas/ main/trunk/install/schemas/index.htm main/trunk/install/schemas/ms_access_primer.zip main/trunk/install/schemas/mssql_basic.sql main/trunk/install/schemas/mssql_schema.sql main/trunk/install/schemas/mysql_basic.sql main/trunk/install/schemas/mysql_schema.sql main/trunk/install/schemas/postgres_basic.sql main/trunk/install/schemas/postgres_schema.sql main/trunk/install/update_to_latest.php main/trunk/install/upgrade.php main/trunk/language/ main/trunk/language/index.htm main/trunk/language/lang_english/ main/trunk/language/lang_english/email/ main/trunk/language/lang_english/email/admin_activate.tpl main/trunk/language/lang_english/email/admin_send_email.tpl main/trunk/language/lang_english/email/admin_welcome_activated.tpl main/trunk/language/lang_english/email/admin_welcome_inactive.tpl main/trunk/language/lang_english/email/coppa_welcome_inactive.tpl main/trunk/language/lang_english/email/group_added.tpl main/trunk/language/lang_english/email/group_approved.tpl main/trunk/language/lang_english/email/group_request.tpl main/trunk/language/lang_english/email/index.htm main/trunk/language/lang_english/email/privmsg_notify.tpl main/trunk/language/lang_english/email/profile_send_email.tpl main/trunk/language/lang_english/email/topic_notify.tpl main/trunk/language/lang_english/email/user_activate.tpl main/trunk/language/lang_english/email/user_activate_passwd.tpl main/trunk/language/lang_english/email/user_welcome.tpl main/trunk/language/lang_english/email/user_welcome_inactive.tpl main/trunk/language/lang_english/index.htm main/trunk/language/lang_english/lang_admin.php main/trunk/language/lang_english/lang_bbcode.php main/trunk/language/lang_english/lang_faq.php main/trunk/language/lang_english/lang_main.php main/trunk/language/lang_english/search_stopwords.txt main/trunk/language/lang_english/search_synonyms.txt main/trunk/login.php main/trunk/memberlist.php main/trunk/modcp.php main/trunk/posting.php main/trunk/privmsg.php main/trunk/profile.php main/trunk/search.php main/trunk/templates/ main/trunk/templates/index.htm main/trunk/templates/subSilver/ main/trunk/templates/subSilver/admin/ main/trunk/templates/subSilver/admin/admin_message_body.tpl main/trunk/templates/subSilver/admin/auth_forum_body.tpl main/trunk/templates/subSilver/admin/auth_select_body.tpl main/trunk/templates/subSilver/admin/auth_ug_body.tpl main/trunk/templates/subSilver/admin/board_config_body.tpl main/trunk/templates/subSilver/admin/category_edit_body.tpl main/trunk/templates/subSilver/admin/confirm_body.tpl main/trunk/templates/subSilver/admin/db_utils_backup_body.tpl main/trunk/templates/subSilver/admin/db_utils_restore_body.tpl main/trunk/templates/subSilver/admin/disallow_body.tpl main/trunk/templates/subSilver/admin/forum_admin_body.tpl main/trunk/templates/subSilver/admin/forum_delete_body.tpl main/trunk/templates/subSilver/admin/forum_edit_body.tpl main/trunk/templates/subSilver/admin/forum_prune_body.tpl main/trunk/templates/subSilver/admin/forum_prune_result_body.tpl main/trunk/templates/subSilver/admin/forum_prune_select_body.tpl main/trunk/templates/subSilver/admin/group_edit_body.tpl main/trunk/templates/subSilver/admin/group_select_body.tpl main/trunk/templates/subSilver/admin/index.htm main/trunk/templates/subSilver/admin/index_body.tpl main/trunk/templates/subSilver/admin/index_frameset.tpl main/trunk/templates/subSilver/admin/index_navigate.tpl main/trunk/templates/subSilver/admin/page_footer.tpl main/trunk/templates/subSilver/admin/page_header.tpl main/trunk/templates/subSilver/admin/ranks_edit_body.tpl main/trunk/templates/subSilver/admin/ranks_list_body.tpl main/trunk/templates/subSilver/admin/smile_edit_body.tpl main/trunk/templates/subSilver/admin/smile_import_body.tpl main/trunk/templates/subSilver/admin/smile_list_body.tpl main/trunk/templates/subSilver/admin/styles_addnew_body.tpl main/trunk/templates/subSilver/admin/styles_edit_body.tpl main/trunk/templates/subSilver/admin/styles_exporter.tpl main/trunk/templates/subSilver/admin/styles_list_body.tpl main/trunk/templates/subSilver/admin/user_avatar_gallery.tpl main/trunk/templates/subSilver/admin/user_ban_body.tpl main/trunk/templates/subSilver/admin/user_edit_body.tpl main/trunk/templates/subSilver/admin/user_email_body.tpl main/trunk/templates/subSilver/admin/user_select_body.tpl main/trunk/templates/subSilver/admin/words_edit_body.tpl main/trunk/templates/subSilver/admin/words_list_body.tpl main/trunk/templates/subSilver/agreement.tpl main/trunk/templates/subSilver/bbcode.tpl main/trunk/templates/subSilver/confirm_body.tpl main/trunk/templates/subSilver/error_body.tpl main/trunk/templates/subSilver/faq_body.tpl main/trunk/templates/subSilver/formIE.css main/trunk/templates/subSilver/groupcp_info_body.tpl main/trunk/templates/subSilver/groupcp_pending_info.tpl main/trunk/templates/subSilver/groupcp_user_body.tpl main/trunk/templates/subSilver/images/ main/trunk/templates/subSilver/images/cellpic.gif main/trunk/templates/subSilver/images/cellpic1.gif main/trunk/templates/subSilver/images/cellpic2.jpg main/trunk/templates/subSilver/images/cellpic3.gif main/trunk/templates/subSilver/images/created_by.jpg main/trunk/templates/subSilver/images/folder.gif main/trunk/templates/subSilver/images/folder_announce.gif main/trunk/templates/subSilver/images/folder_announce_new.gif main/trunk/templates/subSilver/images/folder_big.gif main/trunk/templates/subSilver/images/folder_hot.gif main/trunk/templates/subSilver/images/folder_lock.gif main/trunk/templates/subSilver/images/folder_lock_new.gif main/trunk/templates/subSilver/images/folder_locked_big.gif main/trunk/templates/subSilver/images/folder_new.gif main/trunk/templates/subSilver/images/folder_new_big.gif main/trunk/templates/subSilver/images/folder_new_hot.gif main/trunk/templates/subSilver/images/folder_sticky.gif main/trunk/templates/subSilver/images/folder_sticky_new.gif main/trunk/templates/subSilver/images/icon_delete.gif main/trunk/templates/subSilver/images/icon_latest_reply.gif main/trunk/templates/subSilver/images/icon_mini_faq.gif main/trunk/templates/subSilver/images/icon_mini_groups.gif main/trunk/templates/subSilver/images/icon_mini_login.gif main/trunk/templates/subSilver/images/icon_mini_members.gif main/trunk/templates/subSilver/images/icon_mini_message.gif main/trunk/templates/subSilver/images/icon_mini_profile.gif main/trunk/templates/subSilver/images/icon_mini_register.gif main/trunk/templates/subSilver/images/icon_mini_search.gif main/trunk/templates/subSilver/images/icon_minipost.gif main/trunk/templates/subSilver/images/icon_minipost_new.gif main/trunk/templates/subSilver/images/icon_newest_reply.gif main/trunk/templates/subSilver/images/index.htm main/trunk/templates/subSilver/images/lang_english/ main/trunk/templates/subSilver/images/lang_english/icon_aim.gif main/trunk/templates/subSilver/images/lang_english/icon_edit.gif main/trunk/templates/subSilver/images/lang_english/icon_email.gif main/trunk/templates/subSilver/images/lang_english/icon_icq_add.gif main/trunk/templates/subSilver/images/lang_english/icon_ip.gif main/trunk/templates/subSilver/images/lang_english/icon_msnm.gif main/trunk/templates/subSilver/images/lang_english/icon_pm.gif main/trunk/templates/subSilver/images/lang_english/icon_profile.gif main/trunk/templates/subSilver/images/lang_english/icon_quote.gif main/trunk/templates/subSilver/images/lang_english/icon_search.gif main/trunk/templates/subSilver/images/lang_english/icon_www.gif main/trunk/templates/subSilver/images/lang_english/icon_yim.gif main/trunk/templates/subSilver/images/lang_english/msg_newpost.gif main/trunk/templates/subSilver/images/lang_english/post.gif main/trunk/templates/subSilver/images/lang_english/reply-locked.gif main/trunk/templates/subSilver/images/lang_english/reply.gif main/trunk/templates/subSilver/images/logo_phpBB.gif main/trunk/templates/subSilver/images/logo_phpBB_med.gif main/trunk/templates/subSilver/images/msg_inbox.gif main/trunk/templates/subSilver/images/msg_outbox.gif main/trunk/templates/subSilver/images/msg_savebox.gif main/trunk/templates/subSilver/images/msg_sentbox.gif main/trunk/templates/subSilver/images/spacer.gif main/trunk/templates/subSilver/images/topic_delete.gif main/trunk/templates/subSilver/images/topic_lock.gif main/trunk/templates/subSilver/images/topic_move.gif main/trunk/templates/subSilver/images/topic_split.gif main/trunk/templates/subSilver/images/topic_unlock.gif main/trunk/templates/subSilver/images/vote_lcap.gif main/trunk/templates/subSilver/images/vote_rcap.gif main/trunk/templates/subSilver/images/voting_bar.gif main/trunk/templates/subSilver/images/whosonline.gif main/trunk/templates/subSilver/index.htm main/trunk/templates/subSilver/index_body.tpl main/trunk/templates/subSilver/jumpbox.tpl main/trunk/templates/subSilver/login_body.tpl main/trunk/templates/subSilver/memberlist_body.tpl main/trunk/templates/subSilver/message_body.tpl main/trunk/templates/subSilver/modcp_body.tpl main/trunk/templates/subSilver/modcp_move.tpl main/trunk/templates/subSilver/modcp_split.tpl main/trunk/templates/subSilver/modcp_viewip.tpl main/trunk/templates/subSilver/overall_footer.tpl main/trunk/templates/subSilver/overall_header.tpl main/trunk/templates/subSilver/posting_body.tpl main/trunk/templates/subSilver/posting_poll_body.tpl main/trunk/templates/subSilver/posting_preview.tpl main/trunk/templates/subSilver/posting_smilies.tpl main/trunk/templates/subSilver/posting_topic_review.tpl main/trunk/templates/subSilver/privmsgs_body.tpl main/trunk/templates/subSilver/privmsgs_popup.tpl main/trunk/templates/subSilver/privmsgs_preview.tpl main/trunk/templates/subSilver/privmsgs_read_body.tpl main/trunk/templates/subSilver/profile_add_body.tpl main/trunk/templates/subSilver/profile_avatar_gallery.tpl main/trunk/templates/subSilver/profile_send_email.tpl main/trunk/templates/subSilver/profile_send_pass.tpl main/trunk/templates/subSilver/profile_view_body.tpl main/trunk/templates/subSilver/search_body.tpl main/trunk/templates/subSilver/search_results_posts.tpl main/trunk/templates/subSilver/search_results_topics.tpl main/trunk/templates/subSilver/search_username.tpl main/trunk/templates/subSilver/simple_footer.tpl main/trunk/templates/subSilver/simple_header.tpl main/trunk/templates/subSilver/subSilver.cfg main/trunk/templates/subSilver/subSilver.css main/trunk/templates/subSilver/theme_info.cfg main/trunk/templates/subSilver/viewforum_body.tpl main/trunk/templates/subSilver/viewonline_body.tpl main/trunk/templates/subSilver/viewtopic_body.tpl main/trunk/templates/subSilver/viewtopic_poll_ballot.tpl main/trunk/templates/subSilver/viewtopic_poll_result.tpl main/trunk/viewforum.php main/trunk/viewonline.php main/trunk/viewtopic.php package/ package/branches/ package/etc/ package/tags/ package/trunk/ Added: main/trunk/admin/admin_board.php =================================================================== --- main/trunk/admin/admin_board.php (rev 0) +++ main/trunk/admin/admin_board.php 2007-01-26 17:49:48 UTC (rev 41) @@ -0,0 +1,366 @@ +<?php +/*************************************************************************** + * admin_board.php + * ------------------- + * begin : Thursday, Jul 12, 2001 + * copyright : (C) 2001 The phpBB Group + * email : su...@ph... + * + * $Id: admin_board.php,v 1.51.2.16 2006/12/16 13:11:24 acydburn Exp $ + * + * + ***************************************************************************/ + +define('IN_PHPBB', 1); + +if( !empty($setmodules) ) +{ + $file = basename(__FILE__); + $module['General']['Configuration'] = $file; + return; +} + +// +// Let's set the root dir for phpBB +// +$phpbb_root_path = "./../"; +require($phpbb_root_path . 'extension.inc'); +require('./pagestart.' . $phpEx); +include($phpbb_root_path . 'includes/functions_selects.'.$phpEx); + +// +// Pull all config data +// +$sql = "SELECT * + FROM " . CONFIG_TABLE; +if(!$result = $db->sql_query($sql)) +{ + message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql); +} +else +{ + while( $row = $db->sql_fetchrow($result) ) + { + $config_name = $row['config_name']; + $config_value = $row['config_value']; + $default_config[$config_name] = isset($HTTP_POST_VARS['submit']) ? str_replace("'", "\'", $config_value) : $config_value; + + $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; + + if ($config_name == 'cookie_name') + { + $new['cookie_name'] = str_replace('.', '_', $new['cookie_name']); + } + + // Attempt to prevent a common mistake with this value, + // http:// is the protocol and not part of the server name + if ($config_name == 'server_name') + { + $new['server_name'] = str_replace('http://', '', $new['server_name']); + } + + // Attempt to prevent a mistake with this value. + if ($config_name == 'avatar_path') + { + $new['avatar_path'] = trim($new['avatar_path']); + if (strstr($new['avatar_path'], "\0") || !is_dir($phpbb_root_path . $new['avatar_path']) || !is_writable($phpbb_root_path . $new['avatar_path'])) + { + $new['avatar_path'] = $default_config['avatar_path']; + } + } + + if( isset($HTTP_POST_VARS['submit']) ) + { + $sql = "UPDATE " . CONFIG_TABLE . " SET + config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' + WHERE config_name = '$config_name'"; + if( !$db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql); + } + } + } + + if( isset($HTTP_POST_VARS['submit']) ) + { + $message = $lang['Config_updated'] . "<br /><br />" . sprintf($lang['Click_return_config'], "<a href=\"" . append_sid("admin_board.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); + + message_die(GENERAL_MESSAGE, $message); + } +} + +$style_select = style_select($new['default_style'], 'default_style', "../templates"); +$lang_select = language_select($new['default_lang'], 'default_lang', "language"); +$timezone_select = tz_select($new['board_timezone'], 'board_timezone'); + +$disable_board_yes = ( $new['board_disable'] ) ? "checked=\"checked\"" : ""; +$disable_board_no = ( !$new['board_disable'] ) ? "checked=\"checked\"" : ""; + +$cookie_secure_yes = ( $new['cookie_secure'] ) ? "checked=\"checked\"" : ""; +$cookie_secure_no = ( !$new['cookie_secure'] ) ? "checked=\"checked\"" : ""; + +$html_tags = $new['allow_html_tags']; + +$override_user_style_yes = ( $new['override_user_style'] ) ? "checked=\"checked\"" : ""; +$override_user_style_no = ( !$new['override_user_style'] ) ? "checked=\"checked\"" : ""; + +$html_yes = ( $new['allow_html'] ) ? "checked=\"checked\"" : ""; +$html_no = ( !$new['allow_html'] ) ? "checked=\"checked\"" : ""; + +$bbcode_yes = ( $new['allow_bbcode'] ) ? "checked=\"checked\"" : ""; +$bbcode_no = ( !$new['allow_bbcode'] ) ? "checked=\"checked\"" : ""; + +$activation_none = ( $new['require_activation'] == USER_ACTIVATION_NONE ) ? "checked=\"checked\"" : ""; +$activation_user = ( $new['require_activation'] == USER_ACTIVATION_SELF ) ? "checked=\"checked\"" : ""; +$activation_admin = ( $new['require_activation'] == USER_ACTIVATION_ADMIN ) ? "checked=\"checked\"" : ""; + +$confirm_yes = ($new['enable_confirm']) ? 'checked="checked"' : ''; +$confirm_no = (!$new['enable_confirm']) ? 'checked="checked"' : ''; + +$allow_autologin_yes = ($new['allow_autologin']) ? 'checked="checked"' : ''; +$allow_autologin_no = (!$new['allow_autologin']) ? 'checked="checked"' : ''; + +$board_email_form_yes = ( $new['board_email_form'] ) ? "checked=\"checked\"" : ""; +$board_email_form_no = ( !$new['board_email_form'] ) ? "checked=\"checked\"" : ""; + +$gzip_yes = ( $new['gzip_compress'] ) ? "checked=\"checked\"" : ""; +$gzip_no = ( !$new['gzip_compress'] ) ? "checked=\"checked\"" : ""; + +$privmsg_on = ( !$new['privmsg_disable'] ) ? "checked=\"checked\"" : ""; +$privmsg_off = ( $new['privmsg_disable'] ) ? "checked=\"checked\"" : ""; + +$prune_yes = ( $new['prune_enable'] ) ? "checked=\"checked\"" : ""; +$prune_no = ( !$new['prune_enable'] ) ? "checked=\"checked\"" : ""; + +$smile_yes = ( $new['allow_smilies'] ) ? "checked=\"checked\"" : ""; +$smile_no = ( !$new['allow_smilies'] ) ? "checked=\"checked\"" : ""; + +$sig_yes = ( $new['allow_sig'] ) ? "checked=\"checked\"" : ""; +$sig_no = ( !$new['allow_sig'] ) ? "checked=\"checked\"" : ""; + +$namechange_yes = ( $new['allow_namechange'] ) ? "checked=\"checked\"" : ""; +$namechange_no = ( !$new['allow_namechange'] ) ? "checked=\"checked\"" : ""; + +$avatars_local_yes = ( $new['allow_avatar_local'] ) ? "checked=\"checked\"" : ""; +$avatars_local_no = ( !$new['allow_avatar_local'] ) ? "checked=\"checked\"" : ""; +$avatars_remote_yes = ( $new['allow_avatar_remote'] ) ? "checked=\"checked\"" : ""; +$avatars_remote_no = ( !$new['allow_avatar_remote'] ) ? "checked=\"checked\"" : ""; +$avatars_upload_yes = ( $new['allow_avatar_upload'] ) ? "checked=\"checked\"" : ""; +$avatars_upload_no = ( !$new['allow_avatar_upload'] ) ? "checked=\"checked\"" : ""; + +$smtp_yes = ( $new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; +$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; + +$template->set_filenames(array( + "body" => "admin/board_config_body.tpl") +); + +// +// Escape any quotes in the site description for proper display in the text +// box on the admin page +// +$new['site_desc'] = str_replace('"', '"', $new['site_desc']); +$new['sitename'] = str_replace('"', '"', strip_tags($new['sitename'])); +$template->assign_vars(array( + "S_CONFIG_ACTION" => append_sid("admin_board.$phpEx"), + + "L_YES" => $lang['Yes'], + "L_NO" => $lang['No'], + "L_CONFIGURATION_TITLE" => $lang['General_Config'], + "L_CONFIGURATION_EXPLAIN" => $lang['Config_explain'], + "L_GENERAL_SETTINGS" => $lang['General_settings'], + "L_SERVER_NAME" => $lang['Server_name'], + "L_SERVER_NAME_EXPLAIN" => $lang['Server_name_explain'], + "L_SERVER_PORT" => $lang['Server_port'], + "L_SERVER_PORT_EXPLAIN" => $lang['Server_port_explain'], + "L_SCRIPT_PATH" => $lang['Script_path'], + "L_SCRIPT_PATH_EXPLAIN" => $lang['Script_path_explain'], + "L_SITE_NAME" => $lang['Site_name'], + "L_SITE_DESCRIPTION" => $lang['Site_desc'], + "L_DISABLE_BOARD" => $lang['Board_disable'], + "L_DISABLE_BOARD_EXPLAIN" => $lang['Board_disable_explain'], + "L_ACCT_ACTIVATION" => $lang['Acct_activation'], + "L_NONE" => $lang['Acc_None'], + "L_USER" => $lang['Acc_User'], + "L_ADMIN" => $lang['Acc_Admin'], + "L_VISUAL_CONFIRM" => $lang['Visual_confirm'], + "L_VISUAL_CONFIRM_EXPLAIN" => $lang['Visual_confirm_explain'], + "L_ALLOW_AUTOLOGIN" => $lang['Allow_autologin'], + "L_ALLOW_AUTOLOGIN_EXPLAIN" => $lang['Allow_autologin_explain'], + "L_AUTOLOGIN_TIME" => $lang['Autologin_time'], + "L_AUTOLOGIN_TIME_EXPLAIN" => $lang['Autologin_time_explain'], + "L_COOKIE_SETTINGS" => $lang['Cookie_settings'], + "L_COOKIE_SETTINGS_EXPLAIN" => $lang['Cookie_settings_explain'], + "L_COOKIE_DOMAIN" => $lang['Cookie_domain'], + "L_COOKIE_NAME" => $lang['Cookie_name'], + "L_COOKIE_PATH" => $lang['Cookie_path'], + "L_COOKIE_SECURE" => $lang['Cookie_secure'], + "L_COOKIE_SECURE_EXPLAIN" => $lang['Cookie_secure_explain'], + "L_SESSION_LENGTH" => $lang['Session_length'], + "L_PRIVATE_MESSAGING" => $lang['Private_Messaging'], + "L_INBOX_LIMIT" => $lang['Inbox_limits'], + "L_SENTBOX_LIMIT" => $lang['Sentbox_limits'], + "L_SAVEBOX_LIMIT" => $lang['Savebox_limits'], + "L_DISABLE_PRIVATE_MESSAGING" => $lang['Disable_privmsg'], + "L_ENABLED" => $lang['Enabled'], + "L_DISABLED" => $lang['Disabled'], + "L_ABILITIES_SETTINGS" => $lang['Abilities_settings'], + "L_MAX_POLL_OPTIONS" => $lang['Max_poll_options'], + "L_FLOOD_INTERVAL" => $lang['Flood_Interval'], + "L_FLOOD_INTERVAL_EXPLAIN" => $lang['Flood_Interval_explain'], + "L_SEARCH_FLOOD_INTERVAL" => $lang['Search_Flood_Interval'], + "L_SEARCH_FLOOD_INTERVAL_EXPLAIN" => $lang['Search_Flood_Interval_explain'], + + 'L_MAX_LOGIN_ATTEMPTS' => $lang['Max_login_attempts'], + 'L_MAX_LOGIN_ATTEMPTS_EXPLAIN' => $lang['Max_login_attempts_explain'], + 'L_LOGIN_RESET_TIME' => $lang['Login_reset_time'], + 'L_LOGIN_RESET_TIME_EXPLAIN' => $lang['Login_reset_time_explain'], + 'MAX_LOGIN_ATTEMPTS' => $new['max_login_attempts'], + 'LOGIN_RESET_TIME' => $new['login_reset_time'], + + "L_BOARD_EMAIL_FORM" => $lang['Board_email_form'], + "L_BOARD_EMAIL_FORM_EXPLAIN" => $lang['Board_email_form_explain'], + "L_TOPICS_PER_PAGE" => $lang['Topics_per_page'], + "L_POSTS_PER_PAGE" => $lang['Posts_per_page'], + "L_HOT_THRESHOLD" => $lang['Hot_threshold'], + "L_DEFAULT_STYLE" => $lang['Default_style'], + "L_OVERRIDE_STYLE" => $lang['Override_style'], + "L_OVERRIDE_STYLE_EXPLAIN" => $lang['Override_style_explain'], + "L_DEFAULT_LANGUAGE" => $lang['Default_language'], + "L_DATE_FORMAT" => $lang['Date_format'], + "L_SYSTEM_TIMEZONE" => $lang['System_timezone'], + "L_ENABLE_GZIP" => $lang['Enable_gzip'], + "L_ENABLE_PRUNE" => $lang['Enable_prune'], + "L_ALLOW_HTML" => $lang['Allow_HTML'], + "L_ALLOW_BBCODE" => $lang['Allow_BBCode'], + "L_ALLOWED_TAGS" => $lang['Allowed_tags'], + "L_ALLOWED_TAGS_EXPLAIN" => $lang['Allowed_tags_explain'], + "L_ALLOW_SMILIES" => $lang['Allow_smilies'], + "L_SMILIES_PATH" => $lang['Smilies_path'], + "L_SMILIES_PATH_EXPLAIN" => $lang['Smilies_path_explain'], + "L_ALLOW_SIG" => $lang['Allow_sig'], + "L_MAX_SIG_LENGTH" => $lang['Max_sig_length'], + "L_MAX_SIG_LENGTH_EXPLAIN" => $lang['Max_sig_length_explain'], + "L_ALLOW_NAME_CHANGE" => $lang['Allow_name_change'], + "L_AVATAR_SETTINGS" => $lang['Avatar_settings'], + "L_ALLOW_LOCAL" => $lang['Allow_local'], + "L_ALLOW_REMOTE" => $lang['Allow_remote'], + "L_ALLOW_REMOTE_EXPLAIN" => $lang['Allow_remote_explain'], + "L_ALLOW_UPLOAD" => $lang['Allow_upload'], + "L_MAX_FILESIZE" => $lang['Max_filesize'], + "L_MAX_FILESIZE_EXPLAIN" => $lang['Max_filesize_explain'], + "L_MAX_AVATAR_SIZE" => $lang['Max_avatar_size'], + "L_MAX_AVATAR_SIZE_EXPLAIN" => $lang['Max_avatar_size_explain'], + "L_AVATAR_STORAGE_PATH" => $lang['Avatar_storage_path'], + "L_AVATAR_STORAGE_PATH_EXPLAIN" => $lang['Avatar_storage_path_explain'], + "L_AVATAR_GALLERY_PATH" => $lang['Avatar_gallery_path'], + "L_AVATAR_GALLERY_PATH_EXPLAIN" => $lang['Avatar_gallery_path_explain'], + "L_COPPA_SETTINGS" => $lang['COPPA_settings'], + "L_COPPA_FAX" => $lang['COPPA_fax'], + "L_COPPA_MAIL" => $lang['COPPA_mail'], + "L_COPPA_MAIL_EXPLAIN" => $lang['COPPA_mail_explain'], + "L_EMAIL_SETTINGS" => $lang['Email_settings'], + "L_ADMIN_EMAIL" => $lang['Admin_email'], + "L_EMAIL_SIG" => $lang['Email_sig'], + "L_EMAIL_SIG_EXPLAIN" => $lang['Email_sig_explain'], + "L_USE_SMTP" => $lang['Use_SMTP'], + "L_USE_SMTP_EXPLAIN" => $lang['Use_SMTP_explain'], + "L_SMTP_SERVER" => $lang['SMTP_server'], + "L_SMTP_USERNAME" => $lang['SMTP_username'], + "L_SMTP_USERNAME_EXPLAIN" => $lang['SMTP_username_explain'], + "L_SMTP_PASSWORD" => $lang['SMTP_password'], + "L_SMTP_PASSWORD_EXPLAIN" => $lang['SMTP_password_explain'], + "L_SUBMIT" => $lang['Submit'], + "L_RESET" => $lang['Reset'], + + "SERVER_NAME" => $new['server_name'], + "SCRIPT_PATH" => $new['script_path'], + "SERVER_PORT" => $new['server_port'], + "SITENAME" => $new['sitename'], + "SITE_DESCRIPTION" => $new['site_desc'], + "S_DISABLE_BOARD_YES" => $disable_board_yes, + "S_DISABLE_BOARD_NO" => $disable_board_no, + "ACTIVATION_NONE" => USER_ACTIVATION_NONE, + "ACTIVATION_NONE_CHECKED" => $activation_none, + "ACTIVATION_USER" => USER_ACTIVATION_SELF, + "ACTIVATION_USER_CHECKED" => $activation_user, + "ACTIVATION_ADMIN" => USER_ACTIVATION_ADMIN, + "ACTIVATION_ADMIN_CHECKED" => $activation_admin, + "CONFIRM_ENABLE" => $confirm_yes, + "CONFIRM_DISABLE" => $confirm_no, + 'ALLOW_AUTOLOGIN_YES' => $allow_autologin_yes, + 'ALLOW_AUTOLOGIN_NO' => $allow_autologin_no, + 'AUTOLOGIN_TIME' => (int) $new['max_autologin_time'], + "BOARD_EMAIL_FORM_ENABLE" => $board_email_form_yes, + "BOARD_EMAIL_FORM_DISABLE" => $board_email_form_no, + "MAX_POLL_OPTIONS" => $new['max_poll_options'], + "FLOOD_INTERVAL" => $new['flood_interval'], + "SEARCH_FLOOD_INTERVAL" => $new['search_flood_interval'], + "TOPICS_PER_PAGE" => $new['topics_per_page'], + "POSTS_PER_PAGE" => $new['posts_per_page'], + "HOT_TOPIC" => $new['hot_threshold'], + "STYLE_SELECT" => $style_select, + "OVERRIDE_STYLE_YES" => $override_user_style_yes, + "OVERRIDE_STYLE_NO" => $override_user_style_no, + "LANG_SELECT" => $lang_select, + "L_DATE_FORMAT_EXPLAIN" => $lang['Date_format_explain'], + "DEFAULT_DATEFORMAT" => $new['default_dateformat'], + "TIMEZONE_SELECT" => $timezone_select, + "S_PRIVMSG_ENABLED" => $privmsg_on, + "S_PRIVMSG_DISABLED" => $privmsg_off, + "INBOX_LIMIT" => $new['max_inbox_privmsgs'], + "SENTBOX_LIMIT" => $new['max_sentbox_privmsgs'], + "SAVEBOX_LIMIT" => $new['max_savebox_privmsgs'], + "COOKIE_DOMAIN" => $new['cookie_domain'], + "COOKIE_NAME" => $new['cookie_name'], + "COOKIE_PATH" => $new['cookie_path'], + "SESSION_LENGTH" => $new['session_length'], + "S_COOKIE_SECURE_ENABLED" => $cookie_secure_yes, + "S_COOKIE_SECURE_DISABLED" => $cookie_secure_no, + "GZIP_YES" => $gzip_yes, + "GZIP_NO" => $gzip_no, + "PRUNE_YES" => $prune_yes, + "PRUNE_NO" => $prune_no, + "HTML_TAGS" => $html_tags, + "HTML_YES" => $html_yes, + "HTML_NO" => $html_no, + "BBCODE_YES" => $bbcode_yes, + "BBCODE_NO" => $bbcode_no, + "SMILE_YES" => $smile_yes, + "SMILE_NO" => $smile_no, + "SIG_YES" => $sig_yes, + "SIG_NO" => $sig_no, + "SIG_SIZE" => $new['max_sig_chars'], + "NAMECHANGE_YES" => $namechange_yes, + "NAMECHANGE_NO" => $namechange_no, + "AVATARS_LOCAL_YES" => $avatars_local_yes, + "AVATARS_LOCAL_NO" => $avatars_local_no, + "AVATARS_REMOTE_YES" => $avatars_remote_yes, + "AVATARS_REMOTE_NO" => $avatars_remote_no, + "AVATARS_UPLOAD_YES" => $avatars_upload_yes, + "AVATARS_UPLOAD_NO" => $avatars_upload_no, + "AVATAR_FILESIZE" => $new['avatar_filesize'], + "AVATAR_MAX_HEIGHT" => $new['avatar_max_height'], + "AVATAR_MAX_WIDTH" => $new['avatar_max_width'], + "AVATAR_PATH" => $new['avatar_path'], + "AVATAR_GALLERY_PATH" => $new['avatar_gallery_path'], + "SMILIES_PATH" => $new['smilies_path'], + "INBOX_PRIVMSGS" => $new['max_inbox_privmsgs'], + "SENTBOX_PRIVMSGS" => $new['max_sentbox_privmsgs'], + "SAVEBOX_PRIVMSGS" => $new['max_savebox_privmsgs'], + "EMAIL_FROM" => $new['board_email'], + "EMAIL_SIG" => $new['board_email_sig'], + "SMTP_YES" => $smtp_yes, + "SMTP_NO" => $smtp_no, + "SMTP_HOST" => $new['smtp_host'], + "SMTP_USERNAME" => $new['smtp_username'], + "SMTP_PASSWORD" => $new['smtp_password'], + "COPPA_MAIL" => $new['coppa_mail'], + "COPPA_FAX" => $new['coppa_fax']) +); + +$template->pparse("body"); + +include('./page_footer_admin.'.$phpEx); + +?> Added: main/trunk/admin/admin_db_utilities.php =================================================================== --- main/trunk/admin/admin_db_utilities.php (rev 0) +++ main/trunk/admin/admin_db_utilities.php 2007-01-26 17:49:48 UTC (rev 41) @@ -0,0 +1,1008 @@ +<?php +/*************************************************************************** +* admin_db_utilities.php +* ------------------- +* begin : Thu May 31, 2001 +* copyright : (C) 2001 The phpBB Group +* email : su...@ph... +* +* $Id: admin_db_utilities.php,v 1.42.2.14 2006/02/10 20:35:40 grahamje 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. + * + ***************************************************************************/ + +/*************************************************************************** +* We will attempt to create a file based backup of all of the data in the +* users phpBB database. The resulting file should be able to be imported by +* the db_restore.php function, or by using the mysql command_line +* +* Some functions are adapted from the upgrade_20.php script and others +* adapted from the unoficial phpMyAdmin 2.2.0. +***************************************************************************/ + +define('IN_PHPBB', 1); + +if( !empty($setmodules) ) +{ + $filename = basename(__FILE__); + $module['General']['Backup_DB'] = $filename . "?perform=backup"; + + $file_uploads = (@phpversion() >= '4.0.0') ? @ini_get('file_uploads') : @get_cfg_var('file_uploads'); + + if( (empty($file_uploads) || $file_uploads != 0) && (strtolower($file_uploads) != 'off') && (@phpversion() != '4.0.4pl1') ) + { + $module['General']['Restore_DB'] = $filename . "?perform=restore"; + } + + return; +} + +// +// Load default header +// +$no_page_header = TRUE; +$phpbb_root_path = "./../"; +require($phpbb_root_path . 'extension.inc'); +require('./pagestart.' . $phpEx); +include($phpbb_root_path . 'includes/sql_parse.'.$phpEx); + +// +// Set VERBOSE to 1 for debugging info.. +// +define("VERBOSE", 0); + +// +// Increase maximum execution time, but don't complain about it if it isn't +// allowed. +// +@set_time_limit(1200); + +// ----------------------- +// The following functions are adapted from phpMyAdmin and upgrade_20.php +// +function gzip_PrintFourChars($Val) +{ + for ($i = 0; $i < 4; $i ++) + { + $return .= chr($Val % 256); + $Val = floor($Val / 256); + } + return $return; +} + + + +// +// This function is used for grabbing the sequences for postgres... +// +function pg_get_sequences($crlf, $backup_type) +{ + global $db; + + $get_seq_sql = "SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' + AND relkind = 'S' ORDER BY relname"; + + $seq = $db->sql_query($get_seq_sql); + + if( !$num_seq = $db->sql_numrows($seq) ) + { + + $return_val = "# No Sequences Found $crlf"; + + } + else + { + $return_val = "# Sequences $crlf"; + $i_seq = 0; + + while($i_seq < $num_seq) + { + $row = $db->sql_fetchrow($seq); + $sequence = $row['relname']; + + $get_props_sql = "SELECT * FROM $sequence"; + $seq_props = $db->sql_query($get_props_sql); + + if($db->sql_numrows($seq_props) > 0) + { + $row1 = $db->sql_fetchrow($seq_props); + + if($backup_type == 'structure') + { + $row['last_value'] = 1; + } + + $return_val .= "CREATE SEQUENCE $sequence start " . $row['last_value'] . ' increment ' . $row['increment_by'] . ' maxvalue ' . $row['max_value'] . ' minvalue ' . $row['min_value'] . ' cache ' . $row['cache_value'] . "; $crlf"; + + } // End if numrows > 0 + + if(($row['last_value'] > 1) && ($backup_type != 'structure')) + { + $return_val .= "SELECT NEXTVALE('$sequence'); $crlf"; + unset($row['last_value']); + } + + $i_seq++; + + } // End while.. + + } // End else... + + return $returnval; + +} // End function... + +// +// The following functions will return the "CREATE TABLE syntax for the +// varying DBMS's +// +// This function returns, will return the table def's for postgres... +// +function get_table_def_postgresql($table, $crlf) +{ + global $drop, $db; + + $schema_create = ""; + // + // Get a listing of the fields, with their associated types, etc. + // + + $field_query = "SELECT a.attnum, a.attname AS field, t.typname as type, a.attlen AS length, a.atttypmod as lengthvar, a.attnotnull as notnull + FROM pg_class c, pg_attribute a, pg_type t + WHERE c.relname = '$table' + AND a.attnum > 0 + AND a.attrelid = c.oid + AND a.atttypid = t.oid + ORDER BY a.attnum"; + $result = $db->sql_query($field_query); + + if(!$result) + { + message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query); + } // end if.. + + if ($drop == 1) + { + $schema_create .= "DROP TABLE $table;$crlf"; + } // end if + + // + // Ok now we actually start building the SQL statements to restore the tables + // + + $schema_create .= "CREATE TABLE $table($crlf"; + + while ($row = $db->sql_fetchrow($result)) + { + // + // Get the data from the table + // + $sql_get_default = "SELECT d.adsrc AS rowdefault + FROM pg_attrdef d, pg_class c + WHERE (c.relname = '$table') + AND (c.oid = d.adrelid) + AND d.adnum = " . $row['attnum']; + $def_res = $db->sql_query($sql_get_default); + + if (!$def_res) + { + unset($row['rowdefault']); + } + else + { + $row['rowdefault'] = @pg_result($def_res, 0, 'rowdefault'); + } + + if ($row['type'] == 'bpchar') + { + // Internally stored as bpchar, but isn't accepted in a CREATE TABLE statement. + $row['type'] = 'char'; + } + + $schema_create .= ' ' . $row['field'] . ' ' . $row['type']; + + if (eregi('char', $row['type'])) + { + if ($row['lengthvar'] > 0) + { + $schema_create .= '(' . ($row['lengthvar'] -4) . ')'; + } + } + + if (eregi('numeric', $row['type'])) + { + $schema_create .= '('; + $schema_create .= sprintf("%s,%s", (($row['lengthvar'] >> 16) & 0xffff), (($row['lengthvar'] - 4) & 0xffff)); + $schema_create .= ')'; + } + + if (!empty($row['rowdefault'])) + { + $schema_create .= ' DEFAULT ' . $row['rowdefault']; + } + + if ($row['notnull'] == 't') + { + $schema_create .= ' NOT NULL'; + } + + $schema_create .= ",$crlf"; + + } + // + // Get the listing of primary keys. + // + + $sql_pri_keys = "SELECT ic.relname AS index_name, bc.relname AS tab_name, ta.attname AS column_name, i.indisunique AS unique_key, i.indisprimary AS primary_key + FROM pg_class bc, pg_class ic, pg_index i, pg_attribute ta, pg_attribute ia + WHERE (bc.oid = i.indrelid) + AND (ic.oid = i.indexrelid) + AND (ia.attrelid = i.indexrelid) + AND (ta.attrelid = bc.oid) + AND (bc.relname = '$table') + AND (ta.attrelid = i.indrelid) + AND (ta.attnum = i.indkey[ia.attnum-1]) + ORDER BY index_name, tab_name, column_name "; + $result = $db->sql_query($sql_pri_keys); + + if(!$result) + { + message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_pri_keys); + } + + while ( $row = $db->sql_fetchrow($result)) + { + if ($row['primary_key'] == 't') + { + if (!empty($primary_key)) + { + $primary_key .= ', '; + } + + $primary_key .= $row['column_name']; + $primary_key_name = $row['index_name']; + + } + else + { + // + // We have to store this all this info because it is possible to have a multi-column key... + // we can loop through it again and build the statement + // + $index_rows[$row['index_name']]['table'] = $table; + $index_rows[$row['index_name']]['unique'] = ($row['unique_key'] == 't') ? ' UNIQUE ' : ''; + $index_rows[$row['index_name']]['column_names'] .= $row['column_name'] . ', '; + } + } + + if (!empty($index_rows)) + { + while(list($idx_name, $props) = each($index_rows)) + { + $props['column_names'] = ereg_replace(", $", "" , $props['column_names']); + $index_create .= 'CREATE ' . $props['unique'] . " INDEX $idx_name ON $table (" . $props['column_names'] . ");$crlf"; + } + } + + if (!empty($primary_key)) + { + $schema_create .= " CONSTRAINT $primary_key_name PRIMARY KEY ($primary_key),$crlf"; + } + + // + // Generate constraint clauses for CHECK constraints + // + $sql_checks = "SELECT rcname as index_name, rcsrc + FROM pg_relcheck, pg_class bc + WHERE rcrelid = bc.oid + AND bc.relname = '$table' + AND NOT EXISTS ( + SELECT * + FROM pg_relcheck as c, pg_inherits as i + WHERE i.inhrelid = pg_relcheck.rcrelid + AND c.rcname = pg_relcheck.rcname + AND c.rcsrc = pg_relcheck.rcsrc + AND c.rcrelid = i.inhparent + )"; + $result = $db->sql_query($sql_checks); + + if (!$result) + { + message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_checks); + } + + // + // Add the constraints to the sql file. + // + while ($row = $db->sql_fetchrow($result)) + { + $schema_create .= ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['rcsrc'] . ",$crlf"; + } + + $schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create); + $index_create = ereg_replace(',' . $crlf . '$', '', $index_create); + + $schema_create .= "$crlf);$crlf"; + + if (!empty($index_create)) + { + $schema_create .= $index_create; + } + + // + // Ok now we've built all the sql return it to the calling function. + // + return (stripslashes($schema_create)); + +} + +// +// This function returns the "CREATE TABLE" syntax for mysql dbms... +// +function get_table_def_mysql($table, $crlf) +{ + global $drop, $db; + + $schema_create = ""; + $field_query = "SHOW FIELDS FROM $table"; + $key_query = "SHOW KEYS FROM $table"; + + // + // If the user has selected to drop existing tables when doing a restore. + // Then we add the statement to drop the tables.... + // + if ($drop == 1) + { + $schema_create .= "DROP TABLE IF EXISTS $table;$crlf"; + } + + $schema_create .= "CREATE TABLE $table($crlf"; + + // + // Ok lets grab the fields... + // + $result = $db->sql_query($field_query); + if(!$result) + { + message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query); + } + + while ($row = $db->sql_fetchrow($result)) + { + $schema_create .= ' ' . $row['Field'] . ' ' . $row['Type']; + + if(!empty($row['Default'])) + { + $schema_create .= ' DEFAULT \'' . $row['Default'] . '\''; + } + + if($row['Null'] != "YES") + { + $schema_create .= ' NOT NULL'; + } + + if($row['Extra'] != "") + { + $schema_create .= ' ' . $row['Extra']; + } + + $schema_create .= ",$crlf"; + } + // + // Drop the last ',$crlf' off ;) + // + $schema_create = ereg_replace(',' . $crlf . '$', "", $schema_create); + + // + // Get any Indexed fields from the database... + // + $result = $db->sql_query($key_query); + if(!$result) + { + message_die(GENERAL_ERROR, "FAILED IN get_table_def (show keys)", "", __LINE__, __FILE__, $key_query); + } + + while($row = $db->sql_fetchrow($result)) + { + $kname = $row['Key_name']; + + if(($kname != 'PRIMARY') && ($row['Non_unique'] == 0)) + { + $kname = "UNIQUE|$kname"; + } + + if(!is_array($index[$kname])) + { + $index[$kname] = array(); + } + + $index[$kname][] = $row['Column_name']; + } + + while(list($x, $columns) = @each($index)) + { + $schema_create .= ", $crlf"; + + if($x == 'PRIMARY') + { + $schema_create .= ' PRIMARY KEY (' . implode($columns, ', ') . ')'; + } + elseif (substr($x,0,6) == 'UNIQUE') + { + $schema_create .= ' UNIQUE ' . substr($x,7) . ' (' . implode($columns, ', ') . ')'; + } + else + { + $schema_create .= " KEY $x (" . implode($columns, ', ') . ')'; + } + } + + $schema_create .= "$crlf);"; + + if(get_magic_quotes_runtime()) + { + return(stripslashes($schema_create)); + } + else + { + return($schema_create); + } + +} // End get_table_def_mysql + + +// +// This fuction will return a tables create definition to be used as an sql +// statement. +// +// +// The following functions Get the data from the tables and format it as a +// series of INSERT statements, for each different DBMS... +// After every row a custom callback function $handler gets called. +// $handler must accept one parameter ($sql_insert); +// +// +// Here is the function for postgres... +// +function get_table_content_postgresql($table, $handler) +{ + global $db; + + // + // Grab all of the data from current table. + // + + $result = $db->sql_query("SELECT * FROM $table"); + + if (!$result) + { + message_die(GENERAL_ERROR, "Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table"); + } + + $i_num_fields = $db->sql_numfields($result); + + for ($i = 0; $i < $i_num_fields; $i++) + { + $aryType[] = $db->sql_fieldtype($i, $result); + $aryName[] = $db->sql_fieldname($i, $result); + } + + $iRec = 0; + + while($row = $db->sql_fetchrow($result)) + { + $schema_vals = ''; + $schema_fields = ''; + $schema_insert = ''; + // + // Build the SQL statement to recreate the data. + // + for($i = 0; $i < $i_num_fields; $i++) + { + $strVal = $row[$aryName[$i]]; + if (eregi("char|text|bool", $aryType[$i])) + { + $strQuote = "'"; + $strEmpty = ""; + $strVal = addslashes($strVal); + } + elseif (eregi("date|timestamp", $aryType[$i])) + { + if (empty($strVal)) + { + $strQuote = ""; + } + else + { + $strQuote = "'"; + } + } + else + { + $strQuote = ""; + $strEmpty = "NULL"; + } + + if (empty($strVal) && $strVal != "0") + { + $strVal = $strEmpty; + } + + $schema_vals .= " $strQuote$strVal$strQuote,"; + $schema_fields .= " $aryName[$i],"; + + } + + $schema_vals = ereg_replace(",$", "", $schema_vals); + $schema_vals = ereg_replace("^ ", "", $schema_vals); + $schema_fields = ereg_replace(",$", "", $schema_fields); + $schema_fields = ereg_replace("^ ", "", $schema_fields); + + // + // Take the ordered fields and their associated data and build it + // into a valid sql statement to recreate that field in the data. + // + $schema_insert = "INSERT INTO $table ($schema_fields) VALUES($schema_vals);"; + + $handler(trim($schema_insert)); + } + + return(true); + +}// end function get_table_content_postgres... + +// +// This function is for getting the data from a mysql table. +// + +function get_table_content_mysql($table, $handler) +{ + global $db; + + // Grab the data from the table. + if (!($result = $db->sql_query("SELECT * FROM $table"))) + { + message_die(GENERAL_ERROR, "Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table"); + } + + // Loop through the resulting rows and build the sql statement. + if ($row = $db->sql_fetchrow($result)) + { + $handler("\n#\n# Table Data for $table\n#\n"); + $field_names = array(); + + // Grab the list of field names. + $num_fields = $db->sql_numfields($result); + $table_list = '('; + for ($j = 0; $j < $num_fields; $j++) + { + $field_names[$j] = $db->sql_fieldname($j, $result); + $table_list .= (($j > 0) ? ', ' : '') . $field_names[$j]; + + } + $table_list .= ')'; + + do + { + // Start building the SQL statement. + $schema_insert = "INSERT INTO $table $table_list VALUES("; + + // Loop through the rows and fill in data for each column + for ($j = 0; $j < $num_fields; $j++) + { + $schema_insert .= ($j > 0) ? ', ' : ''; + + if(!isset($row[$field_names[$j]])) + { + // + // If there is no data for the column set it to null. + // There was a problem here with an extra space causing the + // sql file not to reimport if the last column was null in + // any table. Should be fixed now :) JLH + // + $schema_insert .= 'NULL'; + } + elseif ($row[$field_names[$j]] != '') + { + $schema_insert .= '\'' . addslashes($row[$field_names[$j]]) . '\''; + } + else + { + $schema_insert .= '\'\''; + } + } + + $schema_insert .= ');'; + + // Go ahead and send the insert statement to the handler function. + $handler(trim($schema_insert)); + + } + while ($row = $db->sql_fetchrow($result)); + } + + return(true); +} + +function output_table_content($content) +{ + global $tempfile; + + //fwrite($tempfile, $content . "\n"); + //$backup_sql .= $content . "\n"; + echo $content ."\n"; + return; +} +// +// End Functions +// ------------- + + +// +// Begin program proper +// +if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) +{ + $perform = (isset($HTTP_POST_VARS['perform'])) ? $HTTP_POST_VARS['perform'] : $HTTP_GET_VARS['perform']; + + switch($perform) + { + case 'backup': + + $error = false; + switch(SQL_LAYER) + { + case 'oracle': + $error = true; + break; + case 'db2': + $error = true; + break; + case 'msaccess': + $error = true; + break; + case 'mssql': + case 'mssql-odbc': + $error = true; + break; + } + + if ($error) + { + include('./page_header_admin.'.$phpEx); + + $template->set_filenames(array( + "body" => "admin/admin_message_body.tpl") + ); + + $template->assign_vars(array( + "MESSAGE_TITLE" => $lang['Information'], + "MESSAGE_TEXT" => $lang['Backups_not_supported']) + ); + + $template->pparse("body"); + + include('./page_footer_admin.'.$phpEx); + } + + $tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'forum_prune', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'search_results', 'search_wordlist', 'search_wordmatch', 'sessions', 'smilies', 'themes', 'themes_name', 'topics', 'topics_watch', 'user_group', 'users', 'vote_desc', 'vote_results', 'vote_voters', 'words', 'confirm', 'sessions_keys'); + + $additional_tables = (isset($HTTP_POST_VARS['additional_tables'])) ? $HTTP_POST_VARS['additional_tables'] : ( (isset($HTTP_GET_VARS['additional_tables'])) ? $HTTP_GET_VARS['additional_tables'] : "" ); + + $backup_type = (isset($HTTP_POST_VARS['backup_type'])) ? $HTTP_POST_VARS['backup_type'] : ( (isset($HTTP_GET_VARS['backup_type'])) ? $HTTP_GET_VARS['backup_type'] : "" ); + + $gzipcompress = (!empty($HTTP_POST_VARS['gzipcompress'])) ? $HTTP_POST_VARS['gzipcompress'] : ( (!empty($HTTP_GET_VARS['gzipcompress'])) ? $HTTP_GET_VARS['gzipcompress'] : 0 ); + + $drop = (!empty($HTTP_POST_VARS['drop'])) ? intval($HTTP_POST_VARS['drop']) : ( (!empty($HTTP_GET_VARS['drop'])) ? intval($HTTP_GET_VARS['drop']) : 0 ); + + if(!empty($additional_tables)) + { + if(ereg(",", $additional_tables)) + { + $additional_tables = split(",", $additional_tables); + + for($i = 0; $i < count($additional_tables); $i++) + { + $tables[] = trim($additional_tables[$i]); + } + + } + else + { + $tables[] = trim($additional_tables); + } + } + + if( !isset($HTTP_POST_VARS['backupstart']) && !isset($HTTP_GET_VARS['backupstart'])) + { + include('./page_header_admin.'.$phpEx); + + $template->set_filenames(array( + "body" => "admin/db_utils_backup_body.tpl") + ); + $s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"backup\" /><input type=\"hidden\" name=\"drop\" value=\"1\" /><input type=\"hidden\" name=\"perform\" value=\"$perform\" />"; + + $template->assign_vars(array( + "L_DATABASE_BACKUP" => $lang['Database_Utilities'] . " : " . $lang['Backup'], + "L_BACKUP_EXPLAIN" => $lang['Backup_explain'], + "L_FULL_BACKUP" => $lang['Full_backup'], + "L_STRUCTURE_BACKUP" => $lang['Structure_backup'], + "L_DATA_BACKUP" => $lang['Data_backup'], + "L_ADDITIONAL_TABLES" => $lang['Additional_tables'], + "L_START_BACKUP" => $lang['Start_backup'], + "L_BACKUP_OPTIONS" => $lang['Backup_options'], + "L_GZIP_COMPRESS" => $lang['Gzip_compress'], + "L_NO" => $lang['No'], + "L_YES" => $lang['Yes'], + + "S_HIDDEN_FIELDS" => $s_hidden_fields, + "S_DBUTILS_ACTION" => append_sid("admin_db_utilities.$phpEx")) + ); + $template->pparse("body"); + + break; + + } + else if( !isset($HTTP_POST_VARS['startdownload']) && !isset($HTTP_GET_VARS['startdownload']) ) + { + if(is_array($additional_tables)) + { + $additional_tables = implode(',', $additional_tables); + } + $template->set_filenames(array( + "body" => "admin/admin_message_body.tpl") + ); + + $template->assign_vars(array( + "META" => '<meta http-equiv="refresh" content="2;url=' . append_sid("admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1") . '">', + + "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Backup'], + "MESSAGE_TEXT" => $lang['Backup_download']) + ); + + include('./page_header_admin.'.$phpEx); + + $template->pparse("body"); + + include('./page_footer_admin.'.$phpEx); + + } + header("Pragma: no-cache"); + $do_gzip_compress = FALSE; + if( $gzipcompress ) + { + $phpver = phpversion(); + + if($phpver >= "4.0") + { + if(extension_loaded("zlib")) + { + $do_gzip_compress = TRUE; + } + } + } + if($do_gzip_compress) + { + @ob_start(); + @ob_implicit_flush(0); + header("Content-Type: application/x-gzip; name=\"phpbb_db_backup.sql.gz\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz"); + } + else + { + header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql"); + } + + // + // Build the sql script file... + // + echo "#\n"; + echo "# phpBB Backup Script\n"; + echo "# Dump of tables for $dbname\n"; + echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; + echo "#\n"; + + if(SQL_LAYER == 'postgresql') + { + echo "\n" . pg_get_sequences("\n", $backup_type); + } + for($i = 0; $i < count($tables); $i++) + { + $table_name = $tables[$i]; + + switch (SQL_LAYER) + { + case 'postgresql': + $table_def_function = "get_table_def_postgresql"; + $table_content_function = "get_table_content_postgresql"; + break; + + case 'mysql': + case 'mysql4': + $table_def_function = "get_table_def_mysql"; + $table_content_function = "get_table_content_mysql"; + break; + } + + if($backup_type != 'data') + { + echo "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n"; + echo $table_def_function($table_prefix . $table_name, "\n") . "\n"; + } + + if($backup_type != 'structure') + { + $table_content_function($table_prefix . $table_name, "output_table_content"); + } + } + + if($do_gzip_compress) + { + $Size = ob_get_length(); + $Crc = crc32(ob_get_contents()); + $contents = gzcompress(ob_get_contents()); + ob_end_clean(); + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00".substr($contents, 0, strlen($contents) - 4).gzip_PrintFourChars($Crc).gzip_PrintFourChars($Size); + } + exit; + + break; + + case 'restore': + if(!isset($HTTP_POST_VARS['restore_start'])) + { + // + // Define Template files... + // + include('./page_header_admin.'.$phpEx); + + $template->set_filenames(array( + "body" => "admin/db_utils_restore_body.tpl") + ); + + $s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"restore\" /><input type=\"hidden\" name=\"perform\" value=\"$perform\" />"; + + $template->assign_vars(array( + "L_DATABASE_RESTORE" => $lang['Database_Utilities'] . " : " . $lang['Restore'], + "L_RESTORE_EXPLAIN" => $lang['Restore_explain'], + "L_SELECT_FILE" => $lang['Select_file'], + "L_START_RESTORE" => $lang['Start_Restore'], + + "S_DBUTILS_ACTION" => append_sid("admin_db_utilities.$phpEx"), + "S_HIDDEN_FIELDS" => $s_hidden_fields) + ); + $template->pparse("body"); + + break; + + } + else + { + // + // Handle the file upload .... + // If no file was uploaded report an error... + // + $backup_file_name = (!empty($HTTP_POST_FILES['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : ""; + $backup_file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != "none") ? $HTTP_POST_FILES['backup_file']['tmp_name'] : ""; + $backup_file_type = (!empty($HTTP_POST_FILES['backup_file']['type'])) ? $HTTP_POST_FILES['backup_file']['type'] : ""; + + if($backup_file_tmpname == "" || $backup_file_name == "") + { + message_die(GENERAL_MESSAGE, $lang['Restore_Error_no_file']); + } + // + // If I file was actually uploaded, check to make sure that we + // are actually passed the name of an uploaded file, and not + // a hackers attempt at getting us to process a local system + // file. + // + if( file_exists(phpbb_realpath($backup_file_tmpname)) ) + { + if( preg_match("/^(text\/[a-zA-Z]+)|(application\/(x\-)?gzip(\-compressed)?)|(application\/octet-stream)$/is", $backup_file_type) ) + { + if( preg_match("/\.gz$/is",$backup_file_name) ) + { + $do_gzip_compress = FALSE; + $phpver = phpversion(); + if($phpver >= "4.0") + { + if(extension_loaded("zlib")) + { + $do_gzip_compress = TRUE; + } + } + + if($do_gzip_compress) + { + $gz_ptr = gzopen($backup_file_tmpname, 'rb'); + $sql_query = ""; + while( !gzeof($gz_ptr) ) + { + $sql_query .= gzgets($gz_ptr, 100000); + } + } + else + { + message_die(GENERAL_ERROR, $lang['Restore_Error_decompress']); + } + } + else + { + $sql_query = fread(fopen($backup_file_tmpname, 'r'), filesize($backup_file_tmpname)); + } + // + // Comment this line out to see if this fixes the stuff... + // + //$sql_query = stripslashes($sql_query); + } + else + { + message_die(GENERAL_ERROR, $lang['Restore_Error_filename'] ." $backup_file_type $backup_file_name"); + } + } + else + { + message_die(GENERAL_ERROR, $lang['Restore_Error_uploading']); + } + + if($sql_query != "") + { + // Strip out sql comments... + $sql_query = remove_remarks($sql_query); + $pieces = split_sql_file($sql_query, ";"); + + $sql_count = count($pieces); + for($i = 0; $i < $sql_count; $i++) + { + $sql = trim($pieces[$i]); + + if(!empty($sql) and $sql[0] != "#") + { + if(VERBOSE == 1) + { + echo "Executing: $sql\n<br>"; + flush(); + } + + $result = $db->sql_query($sql); + + if(!$result && ( !(SQL_LAYER == 'postgresql' && eregi("drop table", $sql) ) ) ) + { + message_die(GENERAL_ERROR, "Error importing backup file", "", __LINE__, __FILE__, $sql); + } + } + } + } + + include('./page_header_admin.'.$phpEx); + + $template->set_filenames(array( + "body" => "admin/admin_message_body.tpl") + ); + + $message = $lang['Restore_success']; + + $template->assign_vars(array( + "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Restore'], + "MESSAGE_TEXT" => $message) + ); + + $template->pparse("body"); + break; + } + break; + } +} + +include('./page_footer_admin.'.$phpEx); + +?> Added: main/trunk/admin/admin_disallow.php =================================================================== --- main/trunk/admin/admin_disallow.php (rev 0) +++ main/trunk/admin/admin_disallow.php 2007-01-26 17:49:48 UTC (rev 41) @@ -0,0 +1,146 @@ +<?php +/*************************************************************************** + * admin_disallow.php + * ------------------- + * begin : Tuesday, Oct 05, 2001 + * copyright : (C) 2001 The p... [truncated message content] |
From: <mar...@us...> - 2007-01-26 17:42:31
|
Revision: 40 http://svn.sourceforge.net/phpbbkb/?rev=40&view=rev Author: markthedaemon Date: 2007-01-26 09:42:20 -0800 (Fri, 26 Jan 2007) Log Message: ----------- A re-arrangement of the current svn layout Removed Paths: ------------- LICENSE.txt contrib/ develop/ docs/ install.xml modx.subsilver.en.xsl root/ Deleted: LICENSE.txt =================================================================== --- LICENSE.txt 2007-01-24 18:24:34 UTC (rev 39) +++ LICENSE.txt 2007-01-26 17:42:20 UTC (rev 40) @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. Deleted: install.xml =================================================================== --- install.xml 2007-01-24 18:24:34 UTC (rev 39) +++ install.xml 2007-01-26 17:42:20 UTC (rev 40) @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<?xml-stylesheet type="text/xsl" href="modx.subsilver.en.xsl"?> -<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/--> -<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.0.xsd"> - <header> - <license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license> - <title lang="en-gb">phpBB Knowledge Base</title> - <description lang="en-gb">This MOD aims to provide a Knowledge Base for phpBB2</description> - <author-notes lang="en-gb">The lines that are provided for the edits are from a default phpBB 2.0.22 installation and may vary depending on how modified your board is.</author-notes> - <author-group> - <author> - <realname>Mark Barnes</realname> - <email>mar...@us...</email> - <username>MarkTheDaemon</username> - <homepage>http://www.markthedaemon.com</homepage> - <contributions /> - </author> - <author> - <username>AcousticJames</username> - <homepage>http://www.bootlegdreams.net/</homepage> - <contributions /> - </author> - <author> - <username>Prince of phpBB</username> - <contributions /> - </author> - <author> - <username>ToonArmy</username> - <contributions /> - </author> - <author> - <realname>Andreas Nielsen</realname> - <email>Lor...@ho...</email> - <username>Imladris</username> - <homepage>http://blog.softphp.dk</homepage> - <contributions /> - </author> - </author-group> - <mod-version> - <major>0</major> - <minor>0</minor> - <revision>1</revision> - </mod-version> - <installation> - <level>intermediate</level> - <time>270</time> - <target-version> - <target-primary>2.0</target-primary> - <target-major allow="exact">2</target-major> - <target-minor allow="exact">0</target-minor> - </target-version> - </installation> - <meta name="generator" content="Phpbb.ModTeam.Tools (c#)" /> - </header> - <action-group> - <open src="language/lang_english/lang_admin.php"> - <edit> - <find><![CDATA[// -// That's all Folks! -// ------------------------------------------------- - -?>]]></find> - <action type="before-add">$lang['KB'] = "Knowledge Base"; -$lang['Categories'] = "Category Management";</action> - </edit> - </open> - <open src="includes/constants.php"> - <edit> - <find>define('AUTH_ATTACH', 11);</find> - <action type="after-add">define('KB_STATUS_NOT_ASSIGNED', 0); -define('KB_STATUS_ASSIGNED', 1); -define('KB_STATUS_REVIEW_IN_PROGRESS', 3); -define('KB_STATUS_ACCEPTED', 4); -define('KB_STATUS_REJECTED', 5);</action> - <comment lang="en-gb">Line 147</comment> - </edit> - <edit> - <find>define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');</find> - <action type="after-add">define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); -define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); -define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); -define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access");</action> - <comment lang="en-gb">Line 181</comment> - </edit> - </open> - </action-group> -</mod> \ No newline at end of file Deleted: modx.subsilver.en.xsl =================================================================== --- modx.subsilver.en.xsl 2007-01-24 18:24:34 UTC (rev 39) +++ modx.subsilver.en.xsl 2007-01-26 17:42:20 UTC (rev 40) @@ -1,771 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- MODX by the phpBB MOD Team XSL file v1.0 copyright 2005-2006 the phpBB MOD Team. - $Id: modx.subsilver.en.xsl,v 1.3 2006/05/08 22:29:29 wgeric Exp $ --> -<!DOCTYPE xsl:stylesheet[ - <!ENTITY nbsp " "> -]> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:mod="http://www.phpbb.com/mods/xml/modx-1.0.xsd"> - <xsl:output method="html" omit-xml-declaration="no" indent="yes" /> -<xsl:variable name="title" select="mod:mod/mod:header/mod:title" /> -<xsl:variable name="version"> -<xsl:for-each select="mod:mod/mod:header/mod:mod-version"> - <xsl:call-template name="give-version"> - </xsl:call-template> - </xsl:for-each> -</xsl:variable> - <xsl:template match="mod:mod"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta http-equiv="Content-Language" content="en-GB" /> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <style> - -/* Style for a "Recommendation" */ - -/* - Copyright 1997-2003 W3C (MIT, ERCIM, Keio). All Rights Reserved. - The following software licensing rules apply: - http://www.w3.org/Consortium/Legal/copyright-software */ - -/* $Id: modx.subsilver.en.xsl,v 1.3 2006/05/08 22:29:29 wgeric Exp $ */ - -/* Updated by Jon Stanley for use in phpBB XML MOD */ - -/* Updated by David Smith to look subSilvery for phpBB */ - -html, body { - font-family: Verdana, Arial, Helvetica, sans-serif; - color: black; - background: #E5E5E5; - background-position: top left; - background-attachment: fixed; - background-repeat: no-repeat; - } -:link { color : #006699; background: transparent } -:visited { color : #006699; background: transparent } -a:active { color : #006699; background: transparent } -a:hover { text-decoration: underline; color : #DD6900; } - -a:link img, a:visited img { border-style: none } /* no border on img links */ - -a img { color: white; } /* trick to hide the border in Netscape 4 */ -@media all { /* hide the next rule from Netscape 4 */ - a img { color: inherit; } /* undo the color change above */ -} - -th, td { /* ns 4 */ - font-family: sans-serif; -} - -h1, h2, h3, h4, h5, h6 { text-align: left } -/* background should be transparent, but WebTV has a bug */ -h1, h2, h3 { color: #006699 } -h1 { font: 170% sans-serif } -h2 { font: 140% sans-serif } -h3 { font: 120% sans-serif } -h4 { font: bold 100% sans-serif } -h5 { font: italic 100% sans-serif } -h6 { font: small-caps 100% sans-serif } - -.hide { display: none } - -div.head { margin-bottom: 1em } -div.head h1 { margin-top: 2em; clear: both } -div.head table { margin-left: 2em; margin-top: 2em } - -p.copyright { font-size: small } -p.copyright small { font-size: small } - -@media screen { /* hide from IE3 */ -a[href]:hover { background: #ffa } -} - -pre { margin-left: 2em } -/* -p { - margin-top: 0.6em; - margin-bottom: 0.6em; -} -*/ -dt, dd { margin-top: 0; margin-bottom: 0 } /* opera 3.50 */ -dt { font-weight: bold } - -pre, code { font-family: monospace } /* navigator 4 requires this */ - -ul.toc { - list-style: disc; /* Mac NS has problem with 'none' */ - list-style: none; -} - -@media aural { - h1, h2, h3 { stress: 20; richness: 90 } - .hide { speak: none } - p.copyright { volume: x-soft; speech-rate: x-fast } - dt { pause-before: 20% } - pre { speak-punctuation: code } -} - -/* Additional styles */ - -div.editFile {border: 2px solid #333333; margin: 0em 0em 2em; padding: 1em 1em; background: #D1D7DC;} -div.editFile h2 { font-size: 170%; margin: 0.4em 0em; } -div.action { border: 2px solid #DD6900; padding: 1em; background: #DEE3E7; margin: 1em 0em; } -div.action p { font-weight: normal; margin-top: 0px; margin-bottom: 0px; font-size: 0.8em; } -div.action h3 { margin-top: 0px; margin-bottom: 0px; } -div.action pre { padding: 0.2em; background: #EFEFEF; border: 2px solid #006699; overflow: scroll; width: 95%; } -div.editFile pre { padding: 0.2em; background: #EFEFEF; border: 2px solid #006699; overflow: scroll; width: 95%; } - -#pageBody { background-color: #FFFFFF; border: 1px #98AAB1 solid; padding: 1em 1em;} - -hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;} - -strong.red { color: red; } - -</style> - -<script type="text/javascript"><![CDATA[<!--]]> -var i = 0; -var box = new Array(); -<xsl:for-each select="mod:action-group/mod:open/mod:edit"> - <xsl:for-each select="mod:find|mod:action"> - box[i] = '<xsl:value-of select="generate-id()"/>'; - i += 1; - </xsl:for-each> - <xsl:for-each select="mod:inline-edit"> - <xsl:for-each select="mod:inline-find|mod:inline-action"> - box[i] = '<xsl:value-of select="generate-id()"/>'; - i += 1; - </xsl:for-each> - </xsl:for-each> -</xsl:for-each> - -<![CDATA[ -var selectedElement = -1; -var boxes = box.length; -var pre_count = 0; - -// The following line from http://www.ryancooper.com/resources/keycode.asp -document.onkeydown = mod_doKeyPress; - -function SXBB_IsIEMac() -{ - // Any better way to detect IEMac? - var ua = String(navigator.userAgent).toLowerCase(); - if( document.all && ua.indexOf("mac") >= 0 ) - { - return true; - } - return false; -} - -function select_text(id) -{ - var o = document.getElementById(id); - if( !o ) - { - return; - } - var r, s; - if( document.selection && !SXBB_IsIEMac() ) - { - // Works on: IE5+ - // To be confirmed: IE4? / IEMac fails? - r = document.body.createTextRange(); - r.moveToElementText(o); - r.select(); - } - else if( document.createRange && (document.getSelection || window.getSelection) ) - { - // Works on: Netscape/Mozilla/Konqueror/Safari - // To be confirmed: Konqueror/Safari use window.getSelection ? - r = document.createRange(); - r.selectNodeContents(o); - s = window.getSelection ? window.getSelection() : document.getSelection(); - s.removeAllRanges(); - s.addRange(r); - } - - find_selected(id); - return o; -} - -function find_selected(id) -{ - for( x = 0; x < box.length; x++ ) - { - if ( box[x] == id ) - { - selectedElement = x; - } - } -} - -// function findPosY taken from http://www.quirksmode.org/js/findpos.html -function findPosY(obj) -{ - var curtop = 0; - if (obj.offsetParent) - { - while (obj.offsetParent) - { - curtop += obj.offsetTop - obj = obj.offsetParent; - } - } - else if (obj.y) - { - curtop += obj.y; - } - return curtop; -} - -function selectNextBox() -{ - selectedElement += 1; - if (selectedElement >= boxes) selectedElement = 0; - obj = select_text(box[selectedElement]); - window.scrollTo(0, findPosY(obj) - 100); -} - -function selectPrevBox() -{ - selectedElement -= 1; - if (selectedElement < 0) selectedElement = boxes - 1; - obj = select_text(box[selectedElement]); - window.scrollTo(0, findPosY(obj) - 100); -} - -function selectFirstBox() -{ - selectedElement = 0; - obj = select_text(box[selectedElement]); - window.scrollTo(0, findPosY(obj) - 100); -} - -function mod_doKeyPress(e) -{ - /* section from w3 schools starts here http://www.w3schools.com/jsref/jsref_onkeypress.asp */ - var keynum; - /* section from w3 schools ends here */ - - // The following line from http://www.ryancooper.com/resources/keycode.asp - if (window.event) keynum = window.event.keyCode; - else if (e) keynum = e.which; - - if (keynum == 84) selectNextBox(); - //if (keynum == 9) selectNextBox(); //tab - //if (keynum == 13) selectNextBox(); //enter/return - //if (keynum == 32) selectNextBox(); //space - if (keynum == 40) selectNextBox(); //down key - if (keynum == 38) selectPrevBox(); //up key - if (keynum == 83 || keynum == 37) - { - selectFirstBox(); - } - return false; -} -//-->]]></script> - <title>phpBB MOD » <xsl:value-of select="$title" /></title> - </head> - <body> - <div id="pageBody"> - <div id="modInfo"> - <xsl:for-each select="mod:header"> - <xsl:call-template name="give-header"></xsl:call-template> - </xsl:for-each> - <div id="modInstructions"> - <xsl:for-each select="mod:action-group"> - <xsl:call-template name="give-actions"></xsl:call-template> - </xsl:for-each> - </div> - <hr /> - <div class="endMOD"> - <h1>Save all files. End of MOD.</h1> - <p>You have finished the installation for this MOD. Upload all changed files to your website. If the installation went bad, simply restore your backed up files.</p> - </div> - </div> - </div> - <p class="copyright" style="text-align: center; font-size: 10px;">MOD UA XSLT File Copyright © 2006 The phpBB Group, this MOD is copyright to the author<xsl:if test="count(author) > 1">s</xsl:if> listed above.</p> - </body> - </html> - </xsl:template> - <xsl:template name="give-header"> - <h1>Installation instructions for '<xsl:value-of select="$title" />' Version <xsl:value-of select="$version" /></h1> - <h2>About this MOD</h2> - <dl> - <dt>Title:</dt> - <dd> - <xsl:if test="count(mod:title) > 1"> - <dl id="title"> - <xsl:for-each select="mod:title"> - <dl id="{generate-id()}"> - <dt> - <xsl:value-of select="@lang" /> - </dt> - <dd style='white-space:pre;'> - <xsl:value-of select="current()" /> - </dd> - </dl> - </xsl:for-each> - </dl> - </xsl:if> - <xsl:if test="count(mod:title) = 1"> - <xsl:value-of select="mod:title" /> - </xsl:if> - </dd> - <dt>Description:</dt> - <dd> - <xsl:if test="count(mod:description) > 1"> - <dl id="description"> - <xsl:for-each select="mod:description"> - <dl id="{generate-id()}"> - <dt> - <xsl:value-of select="@lang" /> - </dt> - <dd> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string"> - <xsl:value-of select="current()" /> - </xsl:with-param> - </xsl:call-template> - </dd> - </dl> - </xsl:for-each> - </dl> - </xsl:if> - <xsl:if test="count(mod:description) = 1"> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string"> - <xsl:value-of select="mod:description" /> - </xsl:with-param> - </xsl:call-template> - </xsl:if> - </dd> - <dt>Version:</dt> - <dd> - <xsl:for-each select="mod:mod-version"> - <xsl:call-template name="give-version"></xsl:call-template> - </xsl:for-each> - </dd> - <xsl:for-each select="mod:installation"> - <xsl:call-template name="give-installation"></xsl:call-template> - </xsl:for-each> - </dl> - <xsl:for-each select="mod:author-group"> - <h2>Author<xsl:if test="count(mod:author) > 1">s</xsl:if></h2> - <xsl:call-template name="give-authors"></xsl:call-template> - </xsl:for-each> - <h2>Files To Edit</h2> - <xsl:for-each select="../mod:action-group"> - <xsl:call-template name="give-files-to-edit"></xsl:call-template> - </xsl:for-each> - <h2>Included Files</h2> - <xsl:if test="count(../mod:action-group/mod:copy/mod:file) = 0"> - <p>No files have been included with this MOD.</p> - </xsl:if> - <xsl:for-each select="../mod:action-group"> - <xsl:call-template name="give-files-included"></xsl:call-template> - </xsl:for-each> - <hr /> - <div id="modDisclaimer"> - <h1>Disclaimer</h1> - <p>For Security Purposes, Please Check: <a href="http://www.phpbb.com/mods/">http://www.phpbb.com/mods/</a> for the latest version of this MOD. Downloading this MOD from other sites could cause malicious code to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered in our MOD-Database, located at: <a href="http://www.phpbb.com/mods/">http://www.phpbb.com/mods/</a></p> - <h2>Author Notes</h2> - <xsl:if test="count(mod:author-notes) > 1"> - <dl id="author-notes"> - <xsl:for-each select="mod:author-notes"> - <dl id="{generate-id()}"> - <dt> - <xsl:value-of select="@lang" /> - </dt> - <dd> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string"> - <xsl:value-of select="current()" /> - </xsl:with-param> - </xsl:call-template> - </dd> - </dl> - </xsl:for-each> - </dl> - </xsl:if> - <xsl:if test="count(mod:author-notes) = 1"> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string"> - <xsl:value-of select="mod:author-notes" /> - </xsl:with-param> - </xsl:call-template> - </xsl:if> - <xsl:for-each select="mod:history"> - <xsl:call-template name="give-mod-history"></xsl:call-template> - </xsl:for-each> - <h3>License</h3> - <p>This MOD has been licensed under the following license:</p> - <p style='white-space:pre;'> - <xsl:value-of select="mod:license" /> - </p> - <h3>Other Notes</h3> - <p>Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD</p> - <p>This MOD was designed for phpBB<xsl:value-of select="mod:installation/mod:target-version/mod:target-primary" /> and may not function as stated on other phpBB versions. MODs for phpBB3.0 will <strong>not</strong> work on phpBB2.0 and vice versa.</p> - <xsl:if test="./mod:mod-version/mod:minor mod 2 != 0 or ./mod:mod-version/mod:major = 0"> - <p> - <strong class="red">This MOD is development quality. It is not recommended that you install it on a live forum.</strong> - </p> - </xsl:if> - </div> - <hr /> - </xsl:template> - <xsl:template name="give-authors"> - <xsl:for-each select="mod:author"> - <xsl:call-template name="give-author"></xsl:call-template> - </xsl:for-each> - </xsl:template> - <xsl:template name="give-author"> - <dl> - <dt>Username:</dt> - <dd> - <a href="http://www.phpbb.com/phpBB/profile.php?mode=viewprofile&u={mod:username}"> - <xsl:value-of select="mod:username" /> - </a> - </dd> - <xsl:if test="mod:email != 'N/A' and mod:email != 'n/a' and mod:email != ''"> - <dt>Email:</dt> - <dd> - <a href="mailto:{mod:email}"> - <xsl:value-of select="mod:email" /> - </a> - </dd> - </xsl:if> - <dt>Realname:</dt> - <dd> - <xsl:value-of select="mod:realname" /> - </dd> - <xsl:if test="mod:homepage != 'N/A' and mod:homepage != 'n/a' and mod:homepage!=''"> - <dt>WWW:</dt> - <dd> - <a href="{mod:homepage}"> - <xsl:value-of select="mod:homepage" /> - </a> - </dd> - </xsl:if> - </dl> - <br /> - </xsl:template> - <xsl:template name="give-version"><xsl:value-of select="concat(mod:major, '.', mod:minor, '.', mod:revision, mod:release)" /></xsl:template> - <xsl:template name="give-installation"> - <dt>Installation Level:</dt> - <dd> - <xsl:if test="mod:level='easy'">Easy</xsl:if> - <xsl:if test="mod:level='intermediate'">Intermediate</xsl:if> - <xsl:if test="mod:level='hard'">Hard</xsl:if> - </dd> - <dt>Installation Time:</dt> - <dd>~<xsl:value-of select="floor(mod:time div 60)" /> minutes</dd> - </xsl:template> - <xsl:template name="give-mod-history"> - <xsl:if test="count(mod:entry)>1"> - <h2>MOD History</h2> - <dl> - <xsl:for-each select="mod:entry"> - <xsl:call-template name="give-history-entry"></xsl:call-template> - </xsl:for-each> - </dl> - </xsl:if> - </xsl:template> - <xsl:template name="give-history-entry"> - <dt><xsl:value-of select="substring(mod:date,1,10)" /> - Version - <xsl:for-each select="mod:rev-version"> - <xsl:call-template name="give-version"></xsl:call-template> - </xsl:for-each></dt> - <dd> - <xsl:if test="count(mod:changelog) > 1"> - <xsl:for-each select="mod:changelog"> - <xsl:call-template name="give-history-entry-changelog"></xsl:call-template> - </xsl:for-each> - </xsl:if> - <xsl:if test="count(mod:changelog) = 1"> - <xsl:for-each select="mod:changelog"> - <xsl:call-template name="give-history-entry-changelog-single"></xsl:call-template> - </xsl:for-each> - </xsl:if> - </dd> - </xsl:template> - <xsl:template name="give-history-entry-changelog"> - <dl> - <dt> - <xsl:value-of select="@lang" /> - </dt> - <dd> - <ul> - <xsl:for-each select="mod:change"> - <li> - <xsl:value-of select="current()" /> - </li> - </xsl:for-each> - </ul> - </dd> - </dl> - </xsl:template> - <xsl:template name="give-history-entry-changelog-single"> - <ul> - <xsl:for-each select="mod:change"> - <li> - <xsl:value-of select="current()" /> - </li> - </xsl:for-each> - </ul> - </xsl:template> - <xsl:template name="give-files-to-edit"> - <ul> - <xsl:for-each select="mod:open"> - <xsl:call-template name="give-file"></xsl:call-template> - </xsl:for-each> - </ul> - </xsl:template> - <xsl:template name="give-files-included"> - <ul> - <xsl:for-each select="mod:copy"> - <xsl:call-template name="give-file-copy"></xsl:call-template> - </xsl:for-each> - </ul> - </xsl:template> - <xsl:template name="give-file"> - <li> - <xsl:value-of select="@src" /> - <xsl:if test="position()!=last()">,</xsl:if> - </li> - </xsl:template> - <xsl:template name="give-file-copy"> - <xsl:for-each select="mod:file"> - <li> - <xsl:value-of select="@from" /> - <xsl:if test="position()!=last()">,</xsl:if> - </li> - </xsl:for-each> - </xsl:template> - <xsl:template name="give-actions"> - <xsl:if test="count(mod:sql) > 0"> - <h1 onclick="select_text('sql');">SQL</h1> - </xsl:if> - <div id="sql"> - <xsl:for-each select="mod:sql"> - <xsl:call-template name="give-sql"></xsl:call-template> - </xsl:for-each> - </div> - <xsl:if test="count(mod:copy) > 0"> - <h1>File Copy</h1> - </xsl:if> - <xsl:for-each select="mod:copy"> - <xsl:call-template name="give-filez"></xsl:call-template> - </xsl:for-each> - <h1>Edits</h1> - <p>Click on the action name or in the code box to select the code. You may also hit '<em>s</em>' on your keyboard to go to the first code box and the <em>up</em> and <em>down</em> arrows to scroll through the code boxes.</p> - <xsl:for-each select="mod:open"> - <xsl:call-template name="give-fileo"></xsl:call-template> - </xsl:for-each> - <xsl:call-template name="give-manual"></xsl:call-template> - </xsl:template> - <xsl:template name="give-sql"> - <div class="action"> - <pre> - <xsl:value-of select="current()" /> - </pre> - </div> - </xsl:template> - <xsl:template name="give-manual"> - <xsl:for-each select="mod:diy-instructions"> - <div class="editFile"> - <h2 onClick="select_text('{generate-id()}')">DIY Instructions<xsl:if test="count(../mod:diy-instructions) > 1"> (<xsl:value-of select="@lang" />)</xsl:if></h2> - <p>These are manual instructions that cannot be performed automatically. You should follow these instructions carefully.</p> - <pre id="{generate-id()}"> - <xsl:value-of select="current()" /> - </pre> - </div> - </xsl:for-each> - </xsl:template> - <xsl:template name="give-fileo"> - <div class="editFile"> - <h2>Open: <xsl:value-of select="@src" /></h2> - <xsl:for-each select="mod:edit"> - <div class="action"> - <xsl:for-each select="mod:find|mod:action|mod:inline-edit|mod:comment"> - <xsl:if test="name() = 'find'"> - <h3 onClick="select_text('{generate-id()}')">Find</h3> - <p><strong>Tip:</strong> This may be a partial find and not the whole line. -<xsl:if test="@type = 'regex'"> - <br /> - <em>This find contains an advanced feature known as regular expressions, click here to learn more.</em> - </xsl:if> -</p> - <pre id="{generate-id()}"> - <xsl:value-of select="current()" /> - </pre> - </xsl:if> - <xsl:if test="name() = 'action'"> - <xsl:if test="@type = 'after-add'"> - <h3 onClick="select_text('{generate-id()}')">Add after</h3> - <p><strong>Tip:</strong> Add these lines on a new blank line after the preceding line(s) to find.</p> - </xsl:if> - <xsl:if test="@type = 'before-add'"> - <h3 onClick="select_text('{generate-id()}')">Add before</h3> - <p><strong>Tip:</strong> Add these lines on a new blank line before the preceding line(s) to find.</p> - </xsl:if> - <xsl:if test="@type = 'replace-with'"> - <h3 onClick="select_text('{generate-id()}')">Replace With</h3> - <p><strong>Tip:</strong> Replace the preceding line(s) to find with the following lines.</p> - </xsl:if> - <xsl:if test="@type = 'operation'"> - <h3 onClick="select_text('{generate-id()}')">Increment</h3> - <p><strong>Tip:</strong> This allows you to alter integers. For help on what each operator means, click here.</p> - </xsl:if> - <pre id="{generate-id()}"> - <xsl:value-of select="current()" /> - </pre> - </xsl:if> - <xsl:if test="name() = 'comment'"> - <dl> - <dt>Comment:<xsl:if test="count(../mod:comment) > 1"> (<xsl:value-of select="@lang" />)</xsl:if></dt> - <dd> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string"> - <xsl:value-of select="current()" /> - </xsl:with-param> - </xsl:call-template> - </dd> - </dl> - </xsl:if> - <xsl:if test="name() = 'inline-edit'"> - <div class="action"> - <xsl:for-each select="mod:inline-find|mod:inline-action|mod:inline-comment"> - <xsl:if test="name() = 'inline-find'"> - <h3 onClick="select_text('{generate-id()}')">In-line Find</h3> - <p><strong>Tip:</strong> This is a partial match of a line for in-line operations. -<xsl:if test="@type = 'regex'"> - <br /> - <em>This find contains an advanced feature known as regular expressions, click here to learn more.</em> - </xsl:if> -</p> - <pre id="{generate-id()}"> - <xsl:value-of select="current()" /> - </pre> - </xsl:if> - <xsl:if test="name() = 'inline-action'"> - <xsl:if test="@type = 'after-add'"> - <h3 onClick="select_text('{generate-id()}')">In-line Add after</h3> - </xsl:if> - <xsl:if test="@type = 'before-add'"> - <h3 onClick="select_text('{generate-id()}')">In-line Add before</h3> - </xsl:if> - <xsl:if test="@type = 'replace-with'"> - <h3 onClick="select_text('{generate-id()}')">In-line Replace With</h3> - </xsl:if> - <xsl:if test="@type = 'operation'"> - <h3 onClick="select_text('{generate-id()}')">In-line Increment</h3> - <p><strong>Tip:</strong> This allows you to alter integers. For help on what each operator means, click here.</p> - </xsl:if> - <pre id="{generate-id()}"> - <xsl:value-of select="current()" /> - </pre> - </xsl:if> - <xsl:if test="name() = 'inline-comment'"> - <p> - <strong>Comment:</strong> - <em> - <xsl:value-of select="current()" /> - </em> - </p> - </xsl:if> - </xsl:for-each> - </div> - </xsl:if> - </xsl:for-each> - </div> - </xsl:for-each> - </div> - </xsl:template> - <xsl:template name="give-filez"> - <dl> - <xsl:for-each select="mod:file"> - <dt>Copy: <xsl:value-of select="@from" /></dt> - <dd>To: <xsl:value-of select="@to" /></dd> - </xsl:for-each> - </dl> - </xsl:template> - <xsl:template name="give-sub-action-find"> - <p>Find</p> - <pre> - <xsl:value-of select="find-string" /> - </pre> - <xsl:if test="count(in-line) > 0"> - <div class="action"> - <xsl:for-each select="in-line"> - <xsl:for-each select="find-in-line|edit-in-line"> - <xsl:if test="name() = 'find-in-line'"> - <xsl:call-template name="give-sub-action-in-line-find"></xsl:call-template> - </xsl:if> - <xsl:if test="name() = 'edit-in-line'"> - <xsl:call-template name="give-sub-action-in-line-edit"></xsl:call-template> - </xsl:if> - </xsl:for-each> - </xsl:for-each> - </div> - </xsl:if> - </xsl:template> - <xsl:template name="give-sub-action-in-line-find"> - <p>In-line, Find</p> - <pre> - <xsl:value-of select="find-string-in-line" /> - </pre> - </xsl:template> - <xsl:template name="give-sub-action-edit"> - <xsl:if test="@action = 'replace'"> - <p>Replace, Add</p> - </xsl:if> - <xsl:if test="@action = 'add' and @where = 'after'"> - <p>After, Add</p> - </xsl:if> - <xsl:if test="@action = 'add' and @where = 'before'"> - <p>Before, Add</p> - </xsl:if> - <pre> - <xsl:value-of select="current()" /> - </pre> - </xsl:template> - <xsl:template name="give-sub-action-in-line-edit"> - <xsl:if test="@action = 'replace'"> - <p>In-line, Replace With</p> - </xsl:if> - <xsl:if test="@action = 'add' and @where = 'after'"> - <p>In-line, After, Add</p> - </xsl:if> - <xsl:if test="@action = 'add' and @where = 'before'"> - <p>In-line, Before, Add</p> - </xsl:if> - <xsl:if test="@action = 'operation'"> - <p>In-line, perform the following mathematical operation</p> - <xsl:variable name="oper_body" select="@operation" /> - <pre> - <xsl:value-of select="$oper_body" /> - </pre> - </xsl:if> - <pre> - <xsl:value-of select="current()" /> - </pre> - </xsl:template> - <!-- add-line-breaks borrowed from http://www.stylusstudio.com/xsllist/200103/post40180.html --> - <xsl:template name="add-line-breaks"> - <xsl:param name="string" select="." /> - <xsl:choose> - <xsl:when test="contains($string, '
')"> - <xsl:value-of select="substring-before($string, '
')" /> - <br /> - <xsl:call-template name="add-line-breaks"> - <xsl:with-param name="string" select="substring-after($string, '
')" /> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$string" /> - </xsl:otherwise> - </xsl:choose> - </xsl:template> -</xsl:stylesheet> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-01-24 18:24:37
|
Revision: 39 http://svn.sourceforge.net/phpbbkb/?rev=39&view=rev Author: markthedaemon Date: 2007-01-24 10:24:34 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Rather than having a seperate constants.php file they would be better suited in includes/constants.php. The constant numbers need changing, as they are already taken by other things. Modified Paths: -------------- install.xml Modified: install.xml =================================================================== --- install.xml 2007-01-09 06:31:38 UTC (rev 38) +++ install.xml 2007-01-24 18:24:34 UTC (rev 39) @@ -4,9 +4,9 @@ <mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.0.xsd"> <header> <license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license> - <title lang="en-gb">phpbb Knowledge Base</title> + <title lang="en-gb">phpBB Knowledge Base</title> <description lang="en-gb">This MOD aims to provide a Knowledge Base for phpBB2</description> - <author-notes lang="en-gb">TODO: Write author(s) notes</author-notes> + <author-notes lang="en-gb">The lines that are provided for the edits are from a default phpBB 2.0.22 installation and may vary depending on how modified your board is.</author-notes> <author-group> <author> <realname>Mark Barnes</realname> @@ -21,27 +21,14 @@ <contributions /> </author> <author> - <username>drathbun</username> - <homepage>http://www.phpbbdoctor.com/</homepage> - <contributions /> - </author> - <author> - <username>Peter VDD</username> - <contributions /> - </author> - <author> <username>Prince of phpBB</username> <contributions /> </author> <author> - <username>Sphenn</username> + <username>ToonArmy</username> <contributions /> </author> <author> - <username>ToonArmy</username> - <contributions /> - </author> - <author> <realname>Andreas Nielsen</realname> <email>Lor...@ho...</email> <username>Imladris</username> @@ -56,7 +43,7 @@ </mod-version> <installation> <level>intermediate</level> - <time>126</time> + <time>270</time> <target-version> <target-primary>2.0</target-primary> <target-major allow="exact">2</target-major> @@ -66,16 +53,35 @@ <meta name="generator" content="Phpbb.ModTeam.Tools (c#)" /> </header> <action-group> - <open src="language/lang_english/lang_admin.php"> - <edit> - <find>// + <open src="language/lang_english/lang_admin.php"> + <edit> + <find><![CDATA[// // That's all Folks! // ------------------------------------------------- -?></find> - <action type="before-add">$lang['KB'] = "Knowledge Base"; +?>]]></find> + <action type="before-add">$lang['KB'] = "Knowledge Base"; $lang['Categories'] = "Category Management";</action> - </edit> - </open> + </edit> + </open> + <open src="includes/constants.php"> + <edit> + <find>define('AUTH_ATTACH', 11);</find> + <action type="after-add">define('KB_STATUS_NOT_ASSIGNED', 0); +define('KB_STATUS_ASSIGNED', 1); +define('KB_STATUS_REVIEW_IN_PROGRESS', 3); +define('KB_STATUS_ACCEPTED', 4); +define('KB_STATUS_REJECTED', 5);</action> + <comment lang="en-gb">Line 147</comment> + </edit> + <edit> + <find>define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');</find> + <action type="after-add">define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); +define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); +define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); +define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access");</action> + <comment lang="en-gb">Line 181</comment> + </edit> + </open> </action-group> </mod> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-09 06:31:42
|
Revision: 38 http://svn.sourceforge.net/phpbbkb/?rev=38&view=rev Author: softphp Date: 2007-01-08 22:31:38 -0800 (Mon, 08 Jan 2007) Log Message: ----------- - Corrected various bugs Modified Paths: -------------- root/kb/constants.php root/kb/functions.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb/constants.php 2007-01-09 06:31:38 UTC (rev 38) @@ -30,4 +30,11 @@ define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access"); +// Article Status +define('KB_STATUS_NOT_ASSIGNED', 0); +define('KB_STATUS_ASSIGNED', 1); +define('KB_STATUS_REVIEW_IN_PROGRESS', 3); +define('KB_STATUS_ACCEPTED', 4); +define('KB_STATUS_REJECTED', 5); + ?> \ No newline at end of file Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb/functions.php 2007-01-09 06:31:38 UTC (rev 38) @@ -1,4 +1,4 @@ - <?php +<?php /*************************************************************************** * functions.php * ------------------- @@ -144,6 +144,32 @@ return $cats; } +function get_kb_config() +{ + // Using normal db table with kb_prefix + global $db; + + $sql = "SELECT * + FROM " . CONFIG_TABLE; + if(!$result = $db->sql_query($sql)) + { + message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql); + } + + $config = array(); + while($row = $db->fetchrow($result)) + { + // Detect if it has a kb_ in it and strip it + if(strstr('kb_', $row['config_name'])) + { + $name = str_replace("kb_", "", $row['config_name']); + $config[$name] = $row['config_value']; + } + } + + return $config; +} + //////////////////////////////////////// /// UCP FUNCTIONS /// //////////////////////////////////////// @@ -189,7 +215,7 @@ } // This is for posting articles, mostly cut out of the posting.php :) -function ucp_article_form($mode, $id, $review) +function ucp_article_form($mode, $id, $preview) { global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; @@ -207,7 +233,11 @@ if($mode == 'edit') { // Let's get the old article data - $article_id = $id; + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; + if(!$article_id) + { + message_die(MESSAGE_DIE, 'No article id defined.'); + } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " @@ -232,7 +262,7 @@ // Simple Auth for alpha 1 if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) { - message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']; + message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']); } } @@ -308,10 +338,11 @@ } $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } else { + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; if(!$article_id) { message_die(GENERAL_ERROR, 'No article to edit.'); @@ -330,7 +361,8 @@ enable_html = '$html_on', enable_bbcode = '$bbcode_on', enable_smilies = '$smilies_on', - article_text = '$message';"; + article_text = '$message' + WHERE article_id = '$article_id'"; if (!$db->sql_query($sql)) { @@ -364,7 +396,7 @@ // Message here somewhere $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } $template->assign_vars(array( @@ -375,7 +407,6 @@ } } - $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; if($mode == "post" && !$preview && $error_msg == '') { $article_title = ''; @@ -415,6 +446,7 @@ } elseif($preview || $error_msg != '') { + $article_id = $HTTP_POST_VARS['id']; $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; $article_desc = $HTTP_POST_VARS['desc']; @@ -457,31 +489,78 @@ $preview_message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; - $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($preview_message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$html_on ) + { + $preview_message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $preview_message); + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($bbcode_uid != '') + { + $preview_message = ($bbcode_on) ? bbencode_second_pass($preview_message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $preview_message); + } + + $preview_message = make_clickable($preview_message); + + // + // Parse smilies + // + if ( $smilies_on ) + { + $preview_message = smilies_pass($preview_message); + } + + // + // Replace naughty words + // + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if (count($orig_word)) + { + $preview_article_title = preg_replace($orig_word, $replacement_word, $preview_article_title); + $preview_article_desc = preg_replace($orig_word, $replacement_word, $preview_article_desc); + $preview_message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $preview_message . '<'), 1, -1)); + } + + $preview_message = str_replace("\n", "\n<br />\n", $preview_message); + + $template->set_filenames(array( - 'preview_box' => 'kb_articlepreview.tpl') + 'preview_box' => 'kb_previewarticle.tpl') ); $template->assign_vars(array( + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_PREVIEW' => $lang['kb_articlepreview'], 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, 'MESSAGE' => $preview_message) ); - $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview'); + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview_box'); } } else { - if(empty($article_id)) + if(empty($id)) { message_die(GENERAL_ERROR, "No article defined."); } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$article_id'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); @@ -499,7 +578,7 @@ // Now make an array over the cats $sql = "SELECT cat_id FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$article_id'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); @@ -523,7 +602,7 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; } if ( $article['bbcode_uid'] != '' ) @@ -635,6 +714,7 @@ ); create_navigation("ucp", $action); + $post_article = ($mode == 'edit') ? $lang['kb_edit_article'] : $lang['kb_post_article']; // This is the template stuff we need no matter what $template->assign_vars(array( @@ -646,7 +726,7 @@ 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, - 'L_POST_ARTICLE' => $lang['kb_post_article'], + 'L_POST_ARTICLE' => $post_article, 'L_AUTHORNAME' => $lang['kb_authorname'], 'L_ARTICLE_NAME' => $lang['kb_articlename'], 'L_ARTICLE_DESC' => $lang['kb_articledesc'], @@ -723,7 +803,7 @@ // Simple auth for alpha 1 if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) { - message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']; + message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']); } if(!$confirm) @@ -770,7 +850,7 @@ // Message $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); $template->assign_vars(array( 'META' => $meta) Modified: root/kb.php =================================================================== --- root/kb.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb.php 2007-01-09 06:31:38 UTC (rev 38) @@ -363,7 +363,7 @@ case "view_article": $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; - $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + $id = ( empty($HTTP_GET_VARS['id']) ) ? false : $HTTP_GET_VARS['id']; // Get naughty words :) $orig_word = array(); @@ -482,6 +482,7 @@ if (count($orig_word)) { $article_title = preg_replace($orig_word, $replacement_word, $article_title); + $article_desc = preg_replace($orig_word, $replacement_word, $article_desc); if ($user_sig != '') { Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb_install.php 2007-01-09 06:31:38 UTC (rev 38) @@ -79,7 +79,7 @@ article_hits mediumint(8) UNSIGNED DEFAULT '0', article_editby mediumint(8) UNSIGNED DEFAULT '0', article_status smallint(1) UNSIGNED DEFAULT '0', - bbcode_uid varcharr(10) NOT NULL, + bbcode_uid varchar(10) NOT NULL, enable_sig smallint(1) UNSIGNED DEFAULT '0', enable_html smallint(1) UNSIGNED DEFAULT '0', enable_bbcode smallint(1) UNSIGNED DEFAULT '0', Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/language/lang_english/lang_kb.php 2007-01-09 06:31:38 UTC (rev 38) @@ -41,6 +41,7 @@ // Posting Page $lang['kb_post_article'] = "Post New Article"; +$lang['kb_edit_article'] = "Edit Article"; $lang['kb_authorname'] = "Author Name"; $lang['kb_authorname_desc'] = "This is the name that will be displayed, just leave your username there if you want, but you might wanted to change it."; $lang['kb_articlename'] = "Article Name"; @@ -56,10 +57,11 @@ $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; $lang['kb_deleted'] = "Your article has been deleted and is now nonexistant."; $lang['kb_edited'] = "Your article has been edited and is awaiting reapproval."; -$lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. -$lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; +$lang['kb_click_view_article'] = "Click %shere%s to view you article."; // Change this later on, they can't view the article yet. +$lang['kb_click_return_ucp'] = "Click %shere%s to go back to the user control panel"; $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; $lang['kb_confirm_deletearticle'] = "Are you sure you want to delete this article?"; +$lang['kb_articlepreview'] = "Article Preview"; // Auth $lang['kb_edit_noauth'] = "You are not allowed to edit this article."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-07 22:19:24
|
Revision: 37 http://svn.sourceforge.net/phpbbkb/?rev=37&view=rev Author: softphp Date: 2007-01-07 14:19:22 -0800 (Sun, 07 Jan 2007) Log Message: ----------- - Another quick commit, added the preview function, which means, testing, correcting my english and we're ready for Alpha 1. Modified Paths: -------------- root/kb/functions.php Added Paths: ----------- root/templates/subSilver/kb_previewarticle.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-07 01:09:59 UTC (rev 36) +++ root/kb/functions.php 2007-01-07 22:19:22 UTC (rev 37) @@ -1,4 +1,4 @@ -<?php + <?php /*************************************************************************** * functions.php * ------------------- @@ -207,7 +207,7 @@ if($mode == 'edit') { // Let's get the old article data - $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + $article_id = $id; $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " @@ -412,17 +412,13 @@ { $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); } - - if($preview) - { - // Do funny preview stuff - } } elseif($preview || $error_msg != '') { $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; $article_desc = $HTTP_POST_VARS['desc']; + $article_cats = $HTTP_POST_VARS['cats']; $authorname = $HTTP_POST_VARS['authorname']; $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; @@ -431,8 +427,17 @@ $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; + if($mode == 'edit') + { + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + } + else + { + $hidden_form_fields = ""; + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + } + if($error_msg != "") { $template->set_filenames(array( @@ -443,17 +448,40 @@ ); $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); } + + if($preview) + { + // Create the preview box + $preview_article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $preview_article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $preview_message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; + + $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + + $template->set_filenames(array( + 'preview_box' => 'kb_articlepreview.tpl') + ); + + $template->assign_vars(array( + 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, + 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, + 'MESSAGE' => $preview_message) + ); + + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview'); + } } else { - if(empty($id)) + if(empty($article_id)) { message_die(GENERAL_ERROR, "No article defined."); } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); @@ -471,7 +499,7 @@ // Now make an array over the cats $sql = "SELECT cat_id FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); @@ -495,7 +523,7 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; } if ( $article['bbcode_uid'] != '' ) @@ -546,7 +574,7 @@ // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($mode == "edit") + if($mode == "edit" || $preview) { for($i = 0; $i < count($cats); $i++) { @@ -848,7 +876,7 @@ return $message; } -function unprepare_message($message) +function unprepare_article_text($message) { $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); $unhtml_specialchars_replace = array('>', '<', '"', '&'); Added: root/templates/subSilver/kb_previewarticle.tpl =================================================================== --- root/templates/subSilver/kb_previewarticle.tpl (rev 0) +++ root/templates/subSilver/kb_previewarticle.tpl 2007-01-07 22:19:22 UTC (rev 37) @@ -0,0 +1,23 @@ + +<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0"> + <tr> + <th height="25" class="thHead">{L_PREVIEW}</th> + </tr> + <tr> + <td class="row1"><img src="templates/subSilver/images/icon_minipost.gif" alt="{L_POST}" /><span class="postdetails">{L_ARTICLE_NAME}: {PREVIEW_ARTICLE_TITLE} {L_ARTICLE_DESC}: {PREVIEW_ARTICLE_DESC}</span></td> + </tr> + <tr> + <td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> + <span class="postbody">{MESSAGE}</span> + </td> + </tr> + </table></td> + </tr> + <tr> + <td class="spaceRow" height="1"><img src="templates/subSilver/images/spacer.gif" width="1" height="1" /></td> + </tr> +</table> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-07 01:10:02
|
Revision: 36 http://svn.sourceforge.net/phpbbkb/?rev=36&view=rev Author: softphp Date: 2007-01-06 17:09:59 -0800 (Sat, 06 Jan 2007) Log Message: ----------- - Added the viewarticle tpl file, that i apparently had forgotten. - Added some basic auth that will work for Alpha 1. - Corrected minor language vars here and there, and other minor bugs. Modified Paths: -------------- root/kb/functions.php root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/templates/subSilver/kb_viewarticle.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/kb/functions.php 2007-01-07 01:09:59 UTC (rev 36) @@ -169,6 +169,7 @@ break; case "delete_article": + $title .= ": " . $lang['kb_ucp_articledelete']; break; case "post_comment": // Only input @@ -195,7 +196,7 @@ $error_msg = ''; $user_sig = $userdata['user_sig']; - // This is instead of authentication which will be featured after alpha + // Simple auth for Alpha 1 if(!$userdata['session_logged_in']) { message_die(GENERAL_MESSAGE, 'Not authenticated!'); @@ -219,7 +220,7 @@ $article = $db->sql_fetchrow($result); // if user editing set status = 0, else set status = old status :) - if($userdata['user_id'] == $article_author) + if($userdata['user_id'] == $article['article_author']) { $article_status = "0"; } @@ -227,6 +228,12 @@ { $article_status = $article['article_status']; } + + // Simple Auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']; + } } // Add the new article @@ -356,8 +363,15 @@ } // Message here somewhere + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } - return; + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); } } @@ -678,6 +692,12 @@ { global $lang, $db, $phpEx, $template; + // Simple auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']; + } + if(!$confirm) { $s_hidden_fields = '<input type="hidden" name="article_id" value="' . $id . '" />'; @@ -697,7 +717,7 @@ 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], - 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete"), + 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete_article"), 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); @@ -721,6 +741,14 @@ } // Message + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); } } Modified: root/kb.php =================================================================== --- root/kb.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/kb.php 2007-01-07 01:09:59 UTC (rev 36) @@ -525,9 +525,19 @@ 'ARTICLE_TITLE' => $article_title, 'ARTICLE_TEXT' => $article_text, 'POSTED_BY' => $posted_by, - 'SIGNATURE' => $user_sig) + 'SIGNATURE' => $user_sig, + 'L_EDITARTICLE' => $lang['kb_ucp_articleedit'], + 'L_DELETEARTICLE' => $lang['kb_ucp_articledelete'], + + 'U_EDITARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article&id=' . $id), + 'U_DELETEARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=delete_article&id=' . $id)) ); + if(($userdata['user_level'] == ADMIN) || ($userdata['user_id'] == $article['article_author'])) + { + $template->assign_block_vars('switch_mod', array()); + } + // // Generate the page // @@ -591,7 +601,10 @@ // // Generate the page // - $template->pparse('body'); + if($action != "delete_article") + { + $template->pparse('body'); + } include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/language/lang_english/lang_kb.php 2007-01-07 01:09:59 UTC (rev 36) @@ -25,6 +25,7 @@ $lang['kb_ucp'] = "KB User Control Panel"; $lang['kb_ucp_articlepost'] = "Post new article"; $lang['kb_ucp_articleedit'] = "Edit article"; +$lang['kb_ucp_articledelete'] = "Delete article"; // Normal Page $lang['kb_categories'] = "Knowledge Base Categories"; @@ -53,10 +54,17 @@ $lang['kb_empty_cats'] = "The article you submitted had no category defined."; $lang['kb_empty_article_desc'] = "The article has to contain an article description."; $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; +$lang['kb_deleted'] = "Your article has been deleted and is now nonexistant."; +$lang['kb_edited'] = "Your article has been edited and is awaiting reapproval."; $lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. $lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; +$lang['kb_confirm_deletearticle'] = "Are you sure you want to delete this article?"; +// Auth +$lang['kb_edit_noauth'] = "You are not allowed to edit this article."; +$lang['kb_delete_noauth'] = "You are not allowed to delete this article."; + // Admin $lang['kbadm_header_editcat'] = "Edit Category"; $lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category and description."; Added: root/templates/subSilver/kb_viewarticle.tpl =================================================================== --- root/templates/subSilver/kb_viewarticle.tpl (rev 0) +++ root/templates/subSilver/kb_viewarticle.tpl 2007-01-07 01:09:59 UTC (rev 36) @@ -0,0 +1,39 @@ +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"> </td> + </tr> +</table> + +<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> + <tr> + <th colspan="2" class="thRight" nowrap="nowrap"><a class="maintitle" href="{U_VIEW_ARTICLE}">{ARTICLE_TITLE}</a></th> + </tr> + <tr> + <td align="left" class="catHead" height="28"><span class="gensmall">{POSTED_BY}</span></td> + <td align="right" class="catHead" height="28"><span class="gensmall"> + <!-- switch_mod BEGIN --> + <a href="{U_EDITARTICLE}">{L_EDITARTICLE}</a> <a href="{U_DELETEARTICLE}">{L_DELETEARTICLE}</a> + <!-- switch_mod END --> + </span></td> + </tr> + <tr> + <td colspan="2" class="row1" width="100%" height="28"><span class="postbody">{ARTICLE_TEXT}{SIGNATURE}</span></td> + </tr> + <tr> + <td colspan="2" class="row1" width="150" align="left" valign="middle"><span class="nav"><a href="#top" class="nav">{L_BACK_TO_TOP}</a></span></td> + </tr> + <tr> + <td colspan="2" class="spaceRow" height="1"><img src="templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td> + </tr> + <tr> + <td colspan="2" class="catBottom" height="28"></td> + </tr> +</table> + +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> + </tr> +</table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-06 11:14:44
|
Revision: 35 http://svn.sourceforge.net/phpbbkb/?rev=35&view=rev Author: softphp Date: 2007-01-06 03:14:40 -0800 (Sat, 06 Jan 2007) Log Message: ----------- - ACP now thoroughly tested and should be working 100%. - Alpha 1 is almost ready, need to implement some links here and there, and insert some auth here and there. Also preview function isn't coded yet. Besides that some native englishman just needs to look through the lang files and it's ready to go. Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php root/language/lang_english/lang_kb.php root/templates/subSilver/admin/kb_cats.tpl root/templates/subSilver/kb_main.tpl root/templates/subSilver/kb_viewcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/admin/admin_kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -52,6 +52,10 @@ $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; $delete = isset($HTTP_GET_VARS['delete']) ? $HTTP_GET_VARS['delete'] : false; $add = isset($HTTP_POST_VARS['add']) ? true : false; + if(!$add) + { + $add = isset($HTTP_GET_VARS['add']) ? true : false; + } $sort = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : false; if($edit != false) @@ -192,8 +196,14 @@ if($delete != false) { $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; - if(!$confirm) + $cancel = isset($HTTP_POST_VARS['cancel']) ? true : false; + if($cancel) { + // Redirect back to cat page + + } + elseif(!$confirm) + { $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $delete . '" />'; $l_confirm = $lang['kbadm_confirm_deletecat']; @@ -237,6 +247,13 @@ message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); } + // Delete subcats + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE cat_main = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete subcategories from articlecats table.", "", __LINE__, __FILE__, $sql); + } + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? @@ -266,7 +283,7 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "mode=cats")) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) ); $template->pparse('body'); @@ -294,8 +311,8 @@ 'body' => 'admin/kb_editcat.tpl') ); - $parent = generate_cat_parents($cat['cat_main']); - $s_hidden_fields = ""; + $parent = generate_cat_parents($HTTP_POST_VARS['parent']); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; $template->set_filenames(array( 'reg_header' => 'error_body.tpl') @@ -321,7 +338,7 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) ); $template->pparse('body'); @@ -355,7 +372,7 @@ { $sort = explode("|", $sort); - // ok so ?sort=id,id2|up/down|level + // ok so ?sort=id|up/down|level sort_cats("", $sort[0], $sort[1], $sort[2]); // Put id2 in the level argument, nvm that :) // And yes yet another message here @@ -374,8 +391,6 @@ $template->assign_vars(array( 'L_CATEGORIES' => $lang['kb_categories'], 'L_EDITCAT' => $lang['kbadm_editcat'], - 'L_MOVECAT_UP' => $lang['kbadm_movecatup'], - 'L_MOVECAT_DOWN' => $lang['kbadm_movecatdown'], 'L_DELCAT' => $lang['kbadm_delcat'], 'L_HEADER' => $lang['Categories'], 'L_EXPLAIN' => $lang['kbadm_maincat_explain']) @@ -385,69 +400,111 @@ { for($i = 0; $i < $total_catrows; $i++) { - //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + // Check if the cat is at the top and therefore cant be moved up + if(($cats[$i - 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i - 1]['cat_id']) == 0)) + { + $movecat_up = $lang['kbadm_movecatup']; + } + else + { + $movecat_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|up|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatup'] . '</a>'; + } - // auth not included in alpha - //if($auth['auth_view']) - //{ - // Ok display one cat here - $template->assign_block_vars('catrow', array( - // Name 'nd stuff - 'CAT_TITLE' => $cats[$i]['cat_title'], - 'CAT_DESC' => $cats[$i]['cat_desc'], - - // Links - 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), - 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), - // sort=id,id2|up/down|level - 'U_MOVECAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i - 1]['cat_id'] . "|up|" . $cats[$i]['cat_main']), - 'U_MOVECAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i + 1]['cat_id'] . "|down|" . $cats[$i]['cat_main']), - - // Image - 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D - ); + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i + 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i + 1]['cat_id']) == 0)) + { + $movecat_down = $lang['kbadm_movecatdown']; + } + else + { + $movecat_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|down|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Ok display one cat here + $template->assign_block_vars('catrow', array( + // Name 'nd stuff + 'CAT_TITLE' => $cats[$i]['cat_title'], + 'CAT_DESC' => $cats[$i]['cat_desc'], - if($total_subcats = count($cats[$i]['subcats'])) + // Links + 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), + 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), + // sort=id,id2|up/down|level + 'MOVECAT_UP' => $movecat_up, + 'MOVECAT_DOWN' => $movecat_down, + + // Image + 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D + ); + + if($total_subcats = count($cats[$i]['subcats'])) + { + // Contains subcats, show them + //$template->assign_block_vars('catrow.switch_subcat', array( + //'L_SUBCATS' => $lang['kb_subcats']) + //); + + for($j = 0; $j < $total_subcats; $j++) { - // Contains subcats, show them - $template->assign_block_vars('catrow.switch_subcat', array( - 'L_SUBCATS' => $lang['kb_subcats']) - ); + if(($cats[$i]['subcats'][$j - 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j - 1]['cat_id']) == 0)) + { + $subcatmove_up = $lang['kbadm_movecatup']; + } + else + { + $subcatmove_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|up') . '">' . $lang['kbadm_movecatup'] . '</a>'; + } - for($j = 0; $j < $total_subcats; $j++) + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i]['subcats'][$j + 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j + 1]['cat_id']) == 0)) { - //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + $subcatmove_down = $lang['kbadm_movecatdown']; + } + else + { + $subcatmove_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|down') . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Show the subcat + $template->assign_block_vars('catrow.subcatrow', array( + 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], + 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], - // auth not included in alpha - //if($auth['auth_view']) - //{ - // Show the subcat - $template->assign_block_vars('catrow.subcatrow', array( - 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], - 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], - - // Links - 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), - 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), - // sort=id,id2|up/down|level - 'U_MOVESUBCAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j - 1]['cat_id'] . "|up|" . $cats[$i]['subcats'][$j]['cat_main']), - 'U_MOVESUBCAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j + 1]['cat_id'] . "|down|" . $cats[$i]['subcats'][$j]['cat_main']), - - 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D - ); - //} // if auth view - } // for subcats - - $template->assign_block_vars('catrow.switch_subcat_close', array()); - } // if subcats - //} // auth view + // Links + 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), + 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), + // sort=id,id2|up/down|level + 'MOVESUBCAT_UP' => $subcatmove_up, + 'MOVESUBCAT_DOWN' => $subcatmove_down, + + 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D + ); + } // for subcats + + //$template->assign_block_vars('catrow.switch_subcat_close', array()); + } // if subcats } // for cats + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_CAT_SETTINGS' => $lang['kbadm_addcat'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) + ); + $template->pparse('body'); }// total cats else { - message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + message_die(GENERAL_MESSAGE, sprintf($lang['No_kbadm_cats'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats&add=1") . '">', '</a>')); } include('./page_footer_admin.'.$phpEx); @@ -474,7 +531,8 @@ $sql = "SELECT cat_id, cat_title FROM " . KB_CATEGORIES_TABLE . " - WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + WHERE cat_main = '0' + ORDER BY cat_order ASC"; // At the moment only one level of subcats if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); @@ -537,8 +595,8 @@ $cat_number = $db->sql_numrows($result); - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = '" . $cat_number + 1 . "' + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number . "' WHERE cat_id = '" . $id . "'"; if(!$db->sql_query($sql)) @@ -566,16 +624,15 @@ while($old_cat = $db->sql_fetchrow($result)) { $i++; - $sql .= "UPDATE " . KB_CATEGORIES_TABLE . " + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = '" . $i . "' WHERE cat_id = '" . $old_cat['cat_id'] . "';\n"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); + } } - if(!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); - } - // Ok insert it in the back of the new one :) $sql = "SELECT cat_id FROM " . KB_CATEGORIES_TABLE . " @@ -590,7 +647,7 @@ $cat_number = $db->sql_numrows($result); $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = '" . $cat_number + 1 . "' + SET cat_order = '" . $cat_number . "' WHERE cat_id = '" . $id . "'"; if(!$db->sql_query($sql)) @@ -602,52 +659,68 @@ } else { + $sql = "SELECT cat_order, cat_main + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); + } + + $cat = $db->sql_fetchrow($result); + if($dir == "up") { - $ids = explode(",", $id); + $num = $cat['cat_order'] - 1; - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order - 1 - WHERE cat_id = '" . $ids[0] . "';"; - - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order + 1 - WHERE cat_id = '" . $ids[1] . "' - AND cat_main = '" . $level . "';"; // to ensure they are in the same level. - - if(!$db->sql_query($sql)) + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; + + if(!$result = $db->sql_query($sql)) { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); } - if(!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); - } + $cat2 = $db->sql_fetchrow($result); } elseif($dir == "down") { - $ids = explode(",", $id); + $num = $cat['cat_order'] + 1; - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order + 1 - WHERE cat_id = '" . $ids[0] . "';"; + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order - 1 - WHERE cat_id = '" . $ids[1] . "' - AND cat_main = '" . $level . "';"; // to ensure they are in the same level - - if(!$db->sql_query($sql)) + if(!$result = $db->sql_query($sql)) { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); } - if(!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); - } + $cat2 = $db->sql_fetchrow($result); } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat2['cat_order'] . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat['cat_order'] . "' + WHERE cat_id = '" . $cat2['cat_id'] . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + return; } } Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/kb/functions.php 2007-01-06 11:14:40 UTC (rev 35) @@ -113,7 +113,7 @@ $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' - ORDER BY cat_order"; + ORDER BY cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query cats.', '', __LINE__, __FILE__, $sql); @@ -127,7 +127,7 @@ $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '" . $row['cat_id'] . "' - ORDER BY cat_order"; + ORDER BY cat_order ASC"; if( !($subcat_result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcats.', '', __LINE__, __FILE__, $sql); @@ -147,10 +147,45 @@ //////////////////////////////////////// /// UCP FUNCTIONS /// //////////////////////////////////////// -$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); -$html_entities_replace = array('&', '<', '>', '"'); -$unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); -$unhtml_specialchars_replace = array('>', '<', '"', '&'); +function ucp_generate_page_title($action) +{ + global $lang; + + $title = $lang['kb_ucp']; + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + $title .= ": " . $lang['kb_ucp_articlepost']; + break; + + case "edit_article": + $title .= ": " . $lang['kb_ucp_articleedit']; + break; + + case "delete_article": + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + + return $title; +} // This is for posting articles, mostly cut out of the posting.php :) function ucp_article_form($mode, $id, $review) @@ -160,6 +195,12 @@ $error_msg = ''; $user_sig = $userdata['user_sig']; + // This is instead of authentication which will be featured after alpha + if(!$userdata['session_logged_in']) + { + message_die(GENERAL_MESSAGE, 'Not authenticated!'); + } + if(!empty($HTTP_POST_VARS['post'])) { if($mode == 'edit') @@ -737,6 +778,8 @@ // Clean up the message // $message = trim($message); + $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + $html_entities_replace = array('&', '<', '>', '"'); if ($html_on) { @@ -779,6 +822,9 @@ function unprepare_message($message) { + $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); + $unhtml_specialchars_replace = array('>', '<', '"', '&'); + return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message); } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -58,7 +58,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '0' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); @@ -79,9 +79,16 @@ 'body' => 'kb_main.tpl') ); + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + $template->assign_vars(array( 'L_CATEGORIES' => $lang['kb_categories'], - 'L_ARTICLES' => $lang['kb_articles']) + 'L_ARTICLES' => $lang['kb_articles'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) ); if($total_catrows = count($catrows)) @@ -107,7 +114,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); @@ -179,7 +186,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '$cat_id' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); @@ -263,13 +270,20 @@ 'body' => 'kb_viewcat.tpl') ); + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + // Process the whole thing $template->assign_vars(array( 'L_VIEWS' => $lang['Views'], 'L_AUTHOR' => $lang['Author'], 'L_ARTICLES' => $lang['kb_articles'], 'L_SUBCATS' => sprintf($lang['kb_viewcat_subcats'], $cat['cat_title']), - 'L_LAST_ACTION' => $lang['kb_last_action']) + 'L_LAST_ACTION' => $lang['kb_last_action'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) ); if( $total_subcats = count($subcats) ) Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/language/lang_english/lang_kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -59,7 +59,7 @@ // Admin $lang['kbadm_header_editcat'] = "Edit Category"; -$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category adn description."; +$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category and description."; $lang['kbadm_cat_settings'] = "Category Properties"; $lang['kbadm_cat_title'] = "Category Title"; $lang['kbadm_cat_desc'] = "Category Description"; @@ -82,4 +82,6 @@ $lang['kbadm_editcat_success'] = "The category has been edited successfully."; $lang['kbadm_addcat_success'] = "Your new category has been added."; $lang['kbadm_sortcat_success'] = "The category has been moved as specified."; + +$lang['No_kbadm_cats'] = "No knowledge base categories has been added. Click %shere%s to create a new one."; ?> \ No newline at end of file Modified: root/templates/subSilver/admin/kb_cats.tpl =================================================================== --- root/templates/subSilver/admin/kb_cats.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/admin/kb_cats.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -16,37 +16,51 @@ <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> <td class="row1" width="100%" height="50">{catrow.CAT_TITLE}<br /> </span> <span class="genmed">{catrow.CAT_DESC}</td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_UP}">{L_MOVECAT_UP}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_UP}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_DOWN}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> </tr> - <!-- BEGIN switch_subcat --> - <tr> - <td class="catLeft" colspan="2" height="28"><span class="cattitle">{catrow.switch_subcat.L_SUBCATS}</span></td> - <td class="rowpic" colspan="4" align="right"> </td> - </tr> - <!-- END switch_subcat --> <!-- BEGIN subcatrow --> <tr> - <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> - <td class="row1" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> + <td class="row2" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row2" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> <span class="genmed">{catrow.subcatrow.SUBCAT_DESC}</span></td> <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_EDITSUBCAT}">{L_EDITCAT}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_UP}">{L_MOVECAT_UP}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_UP}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_DOWN}</span></td> <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_DELSUBCAT}">{L_DELCAT}</a></span></td> </tr> <!-- END subcatrow --> - <!-- BEGIN switch_subcat_close --> - <tr> - <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> - </tr> - <!-- END switch_subcat_close --> <!-- END catrow --> <tr> <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> </tr> </table> +<br clear="all" /> + +<form action="{S_FORUM_ACTION}" method="post"> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">{L_CAT_SETTINGS}</th> + </tr> + <tr> + <td class="row1">{L_CAT_TITLE}</td> + <td class="row2"><input type="text" size="25" name="title" value="" class="post" /></td> + </tr> + <tr> + <td class="row1">{L_CAT_DESCRIPTION}</td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="desc" class="post"></textarea></td> + </tr> + <tr> + <td class="row1">{L_CAT_PARENT}</td> + <td class="row2">{S_PARENT}</td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td> + </tr> + </table> +</form> + <br clear="all" /> \ No newline at end of file Modified: root/templates/subSilver/kb_main.tpl =================================================================== --- root/templates/subSilver/kb_main.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/kb_main.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -1,5 +1,8 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> </tr> @@ -36,7 +39,10 @@ </table> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> Modified: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/kb_viewcat.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -1,5 +1,8 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> </tr> @@ -52,7 +55,10 @@ <!-- END switch_articles --> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-29 23:45:12
|
Revision: 34 http://svn.sourceforge.net/phpbbkb/?rev=34&view=rev Author: softphp Date: 2006-12-29 15:45:05 -0800 (Fri, 29 Dec 2006) Log Message: ----------- - Added more to the acp, still buggy though, especially the sort function - Gotta fix some bbcode, some links here and there, need a native englishman to look the lang vars over and we're ready to go alpha. Modified Paths: -------------- install.xml root/admin/admin_kb.php root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/templates/subSilver/admin/kb_cats.tpl Modified: install.xml =================================================================== --- install.xml 2006-12-28 01:47:23 UTC (rev 33) +++ install.xml 2006-12-29 23:45:05 UTC (rev 34) @@ -41,6 +41,13 @@ <username>ToonArmy</username> <contributions /> </author> + <author> + <realname>Andreas Nielsen</realname> + <email>Lor...@ho...</email> + <username>Imladris</username> + <homepage>http://blog.softphp.dk</homepage> + <contributions /> + </author> </author-group> <mod-version> <major>0</major> @@ -58,5 +65,17 @@ </installation> <meta name="generator" content="Phpbb.ModTeam.Tools (c#)" /> </header> - <action-group /> + <action-group> + <open src="language/lang_english/lang_admin.php"> + <edit> + <find>// +// That's all Folks! +// ------------------------------------------------- + +?></find> + <action type="before-add">$lang['KB'] = "Knowledge Base"; +$lang['Categories'] = "Category Management";</action> + </edit> + </open> + </action-group> </mod> \ No newline at end of file Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/admin/admin_kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -27,6 +27,10 @@ return; } +$phpbb_root_path = "./../"; +require($phpbb_root_path . 'extension.inc'); +require('./pagestart.' . $phpEx); + // Get constants and functions include($phpbb_root_path . "kb/constants." . $phpEx); include($phpbb_root_path . "kb/functions." . $phpEx); @@ -79,15 +83,18 @@ 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], 'CAT_TITLE' => $cat['cat_title'], - 'CAT_DESC' => $cat['cat_desc'], + 'DESCRIPTION' => $cat['cat_desc'], 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -140,15 +147,18 @@ 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], 'CAT_TITLE' => $cat['cat_title'], - 'CAT_DESC' => $cat['cat_desc'], + 'DESCRIPTION' => $cat['cat_desc'], 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -172,7 +182,7 @@ } // And a message here somewhere - $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } @@ -201,11 +211,14 @@ 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], - 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?delete=true"), + 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=true"), 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); $template->pparse('confirm_body'); + + include('./page_footer_admin.'.$phpEx); + exit; } elseif($confirm) // Double check user confirmed { @@ -224,7 +237,7 @@ message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); } - $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? message_die(GENERAL_MESSAGE, $message); @@ -253,10 +266,13 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "mode=cats")) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -299,13 +315,19 @@ 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + 'CAT_TITLE' => $HTTP_POST_VARS['title'], + 'DESCRIPTION' => $HTTP_POST_VARS['desc'], + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -322,7 +344,7 @@ sort_cats("add", $db->sql_nextid(), 0, $parent); // And a message here somewhere - $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } @@ -333,16 +355,103 @@ { $sort = explode("|", $sort); - // ok so ?sort=id|id2|up/down - sort_cats("", $sort[0], $sort[2], $sort[1]); // Put id2 in the level argument, nvm that :) + // ok so ?sort=id,id2|up/down|level + sort_cats("", $sort[0], $sort[1], $sort[2]); // Put id2 in the level argument, nvm that :) // And yes yet another message here - $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } // Show categories as list + $cats = get_cats_structure(); + + $template->set_filenames(array( + 'body' => 'admin/kb_cats.tpl') + ); + + $template->assign_vars(array( + 'L_CATEGORIES' => $lang['kb_categories'], + 'L_EDITCAT' => $lang['kbadm_editcat'], + 'L_MOVECAT_UP' => $lang['kbadm_movecatup'], + 'L_MOVECAT_DOWN' => $lang['kbadm_movecatdown'], + 'L_DELCAT' => $lang['kbadm_delcat'], + 'L_HEADER' => $lang['Categories'], + 'L_EXPLAIN' => $lang['kbadm_maincat_explain']) + ); + + if($total_catrows = count($cats)) + { + for($i = 0; $i < $total_catrows; $i++) + { + //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Ok display one cat here + $template->assign_block_vars('catrow', array( + // Name 'nd stuff + 'CAT_TITLE' => $cats[$i]['cat_title'], + 'CAT_DESC' => $cats[$i]['cat_desc'], + + // Links + 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), + 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), + // sort=id,id2|up/down|level + 'U_MOVECAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i - 1]['cat_id'] . "|up|" . $cats[$i]['cat_main']), + 'U_MOVECAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i + 1]['cat_id'] . "|down|" . $cats[$i]['cat_main']), + + // Image + 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D + ); + + if($total_subcats = count($cats[$i]['subcats'])) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcat', array( + 'L_SUBCATS' => $lang['kb_subcats']) + ); + + for($j = 0; $j < $total_subcats; $j++) + { + //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Show the subcat + $template->assign_block_vars('catrow.subcatrow', array( + 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], + 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], + + // Links + 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), + 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), + // sort=id,id2|up/down|level + 'U_MOVESUBCAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j - 1]['cat_id'] . "|up|" . $cats[$i]['subcats'][$j]['cat_main']), + 'U_MOVESUBCAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j + 1]['cat_id'] . "|down|" . $cats[$i]['subcats'][$j]['cat_main']), + + 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D + ); + //} // if auth view + } // for subcats + + $template->assign_block_vars('catrow.switch_subcat_close', array()); + } // if subcats + //} // auth view + } // for cats + + $template->pparse('body'); + }// total cats + else + { + message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + } + + include('./page_footer_admin.'.$phpEx); + exit; break; case "auth": // For later use @@ -412,6 +521,8 @@ function sort_cats($type = "", $id = 0, $dir = 0, $level = 0) { + global $db; + if($type == "add") { $sql = "SELECT cat_id @@ -493,31 +604,49 @@ { if($dir == "up") { + $ids = explode(",", $id); + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order - 1 - WHERE cat_id = '" . $id . "'; - UPDATE " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $ids[0] . "';"; + + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order + 1 - WHERE cat_id = '" . $dir . "';"; + WHERE cat_id = '" . $ids[1] . "' + AND cat_main = '" . $level . "';"; // to ensure they are in the same level. if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); } + + if(!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } } elseif($dir == "down") { + $ids = explode(",", $id); + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order + 1 - WHERE cat_id = '" . $id . "'; - UPDATE " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $ids[0] . "';"; + + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order - 1 - WHERE cat_id = '" . $dir . "';"; + WHERE cat_id = '" . $ids[1] . "' + AND cat_main = '" . $level . "';"; // to ensure they are in the same level if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); } + + if(!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } } return; } Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -88,10 +88,11 @@ { for($i = 0; $i < $total_catrows; $i++) { - $auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); - if($auth['auth_view']) - { + // auth not included in alpha + //if($auth['auth_view']) + //{ // Ok display one cat here $template->assign_block_vars('catrow', array( 'CAT_TITLE' => $catrows[$i]['cat_title'], @@ -125,10 +126,11 @@ for($j = 0; $j < $total_subcats; $j++) { - $auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); - if($auth['auth_view']) - { + // auth not included in alpha + //if($auth['auth_view']) + //{ // Show the subcat $k = $j + 1; $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; @@ -137,10 +139,10 @@ 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], 'SUBCAT_COMMA' => $subcat_comma) ); - } // if auth view + //} // if auth view } // for subcats } // if subcats - } // auth view + //} // auth view } // for cats }// total cats else Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/language/lang_english/lang_kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -29,7 +29,7 @@ // Normal Page $lang['kb_categories'] = "Knowledge Base Categories"; $lang['kb_articles'] = "Articles"; -$lang['kb_subcats'] = "Sub categories"; +$lang['kb_subcats'] = "Subcategories"; $lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; $lang['No_kb_cats'] = "No knowledge base categories has been added."; $lang['kb_cat_noexist'] = "The category you chose does not exist."; @@ -58,22 +58,28 @@ $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; // Admin -$lang['kbadm_header_editcat'] -$lang['kbadm_explain_editcat'] -$lang['kbadm_cat_settings'] -$lang['kbadm_cat_title'] -$lang['kbadm_cat_desc'] -$lang['kbadm_cat_parent'] -$lang['kbadm_empty_cat_title'] -$lang['kbadm_empty_cat_desc'] -$lang['kbadm_confirm_deletecat'] -$lang['kbadm_Click_return_catadmin'] -$lang['kbadm_header_addcat'] -$lang['kbadm_explain_addcat'] -$lang['kbadm_addcat'] +$lang['kbadm_header_editcat'] = "Edit Category"; +$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category adn description."; +$lang['kbadm_cat_settings'] = "Category Properties"; +$lang['kbadm_cat_title'] = "Category Title"; +$lang['kbadm_cat_desc'] = "Category Description"; +$lang['kbadm_cat_parent'] = "Parent Category"; +$lang['kbadm_empty_cat_title'] = "The Category Title submitted was empty."; +$lang['kbadm_empty_cat_desc'] = "The Category Description submitted was empty."; +$lang['kbadm_confirm_deletecat'] = "Are you sure you want to delete this category?"; +$lang['kbadm_Click_return_catadmin'] = "Click %shere%s to return to category administration."; +$lang['kbadm_header_addcat'] = "Add Category"; +$lang['kbadm_explain_addcat'] = "From here you can add a new category."; +$lang['kbadm_addcat'] = "Add"; +$lang['kbadm_editcat'] = "Edit"; -$lang['kbadm_delcat_success'] -$lang['kbadm_editcat_success'] -$lang['kbadm_addcat_success'] -$lang['kbadm_sortcat_success'] +$lang['kbadm_movecatup'] = "Move Up"; +$lang['kbadm_movecatdown'] = "Move Down"; +$lang['kbadm_delcat'] = "Delete"; +$lang['kbadm_maincat_explain'] = "This is the place where you can move categories up and down, create new ones and edit the already existant."; + +$lang['kbadm_delcat_success'] = "The category has been deleted successfully."; +$lang['kbadm_editcat_success'] = "The category has been edited successfully."; +$lang['kbadm_addcat_success'] = "Your new category has been added."; +$lang['kbadm_sortcat_success'] = "The category has been moved as specified."; ?> \ No newline at end of file Added: root/templates/subSilver/admin/kb_cats.tpl =================================================================== --- root/templates/subSilver/admin/kb_cats.tpl (rev 0) +++ root/templates/subSilver/admin/kb_cats.tpl 2006-12-29 23:45:05 UTC (rev 34) @@ -0,0 +1,52 @@ +<h1>{L_HEADER}</h1> + +<p>{L_EXPLAIN}</p> + +<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> + <tr> + <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_CATEGORIES} </th> + <th class="thCornerR" colspan="4" nowrap="nowrap"> </th> + </tr> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle"> </span></td> + <td class="rowpic" colspan="4" align="right"> </td> + </tr> + <!-- BEGIN catrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> + <td class="row1" width="100%" height="50">{catrow.CAT_TITLE}<br /> + </span> <span class="genmed">{catrow.CAT_DESC}</td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_UP}">{L_MOVECAT_UP}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- BEGIN switch_subcat --> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle">{catrow.switch_subcat.L_SUBCATS}</span></td> + <td class="rowpic" colspan="4" align="right"> </td> + </tr> + <!-- END switch_subcat --> + <!-- BEGIN subcatrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row1" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> + <span class="genmed">{catrow.subcatrow.SUBCAT_DESC}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_EDITSUBCAT}">{L_EDITCAT}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_UP}">{L_MOVECAT_UP}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_DELSUBCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- END subcatrow --> + <!-- BEGIN switch_subcat_close --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> + </tr> + <!-- END switch_subcat_close --> + <!-- END catrow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> + </tr> +</table> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-28 01:47:25
|
Revision: 33 http://svn.sourceforge.net/phpbbkb/?rev=33&view=rev Author: softphp Date: 2006-12-27 17:47:23 -0800 (Wed, 27 Dec 2006) Log Message: ----------- - Introduced the auth system, haven't implemented it completely into the kb.php, but I'm working on it, still waiting to be tested. Along with the admin panel and a lot of other stuff. Modified Paths: -------------- root/kb/auth.php root/kb/constants.php root/kb.php root/kb_install.php Modified: root/kb/auth.php =================================================================== --- root/kb/auth.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb/auth.php 2006-12-28 01:47:23 UTC (rev 33) @@ -18,10 +18,170 @@ * ***************************************************************************/ -// This file holds the kb_auth functions, very similar to the phpBB auth functions, but differs certain places :) +// This file holds the kb auth functions, very similar to the phpBB auth functions, but differs certain places :) +// As of now, the articles auth is handles out from which category it is selected through, therefore an article +// can have different kinds of auth, all depending on through which category it is viewed. This solution might seem +// stupid, but it is the best I can come up with, and I think admins will just take that into consideration when creating +// category permissions. + +// +// This function returns info on whether the user is allowed to do the supplied argument(s) all dependant on the given category id +// function kb_auth($type, $cat_id, $userdata) { + switch($type) + { + case "view": + $sql = "a.auth_view"; + $auth_fields = array('auth_view'); + break; + + case "add": + $sql = "a.auth_add"; + $auth_fields = array('auth_add'); + break; + + case "edit": + $sql = "a.auth_edit"; + $auth_fields = array('auth_edit'); + break; + + case "delete": + $sql = "a.auth_delete"; + $auth_fields = array('auth_delete'); + break; + + case "mod": + $sql = "a.auth_mod"; + $auth_fields = array('auth_mod'); + break; + + case "comment": + $sql = "a.auth_comment"; + $auth_fields = array('auth_comment'); + break; + + case "rate": + $sql = "a.auth_rate"; + $auth_fields = array('auth_rate'); + break; + + case "attach": + $sql = "a.auth_attach"; + $auth_fields = array('auth_attach'); + break; + + // Returns array containing everything above + case "all": + $sql = "a.auth_view, a.auth_add, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate', 'auth_attach'); + break; + + // Returns array containing article related auth + case "article": + $sql = "a.auth_view, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate"; + $auth_fields = array('auth_view', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate'); + break; + + // Returns array containing category related auth + case "cat": + $sql = "a.auth_view, a.auth_add, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_attach'); + break; + } + $sql = "SELECT a.cat_id, $sql + FROM " . KB_CATEGORIES_TABLE . " a + WHERE a.cat_id = '" . $cat_id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_MESSAGE, 'Could not retrieve categorys auth info.', '', __LINE__, __FILE__, $sql); + } + + $f_access = $db->sql_fetchrow($result); + + // + // If user is logged in we need to see if he is in any usergroups that changes his auth info, else just return it + // + if($userdata['session_logged_in']) + { + // Check if the user is present in a group that changes his permissions + $sql = "SELECT a.cat_id, $sql, a.auth_mod + FROM " . KB_AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug + WHERE ug.user_id = ".$userdata['user_id']. " + AND ug.user_pending = 0 + AND a.group_id = ug.group_id + AND a.cat_id = '" . $cat_id . "'"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Failed obtaining category access control lists', '', __LINE__, __FILE__, $sql); + } + + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $u_access[] = $row; + } + while( $row = $db->sql_fetchrow($result) ); + } + $db->sql_freeresult($result); + } + + $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; + + $auth = array(); + for($i = 0; $i < count($auth_fields); $i++) + { + $key = $auth_fields[$i]; + + // + // If the user is logged on and the forum type is either ALL or REG then the user has access + // + // If the type if ACL, MOD or ADMIN then we need to see if the user has specific permissions + // to do whatever it is they want to do ... to do this we pull relevant information for the + // user (and any groups they belong to) + // + // Now we compare the users access level against the forums. We assume here that a moderator + // and admin automatically have access to an ACL forum, similarly we assume admins meet an + // auth requirement of MOD + // + $value = $f_access[$key]; + + switch( $value ) + { + case AUTH_ALL: + $auth[$key] = TRUE; + $auth[$key . '_type'] = $lang['Auth_Anonymous_Users']; + break; + + case AUTH_REG: + $auth_user[$key] = ( $userdata['session_logged_in'] ) ? TRUE : 0; + $auth_user[$key . '_type'] = $lang['Auth_Registered_Users']; + break; + + case AUTH_ACL: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_ACL, $key, $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Users_granted_access']; + break; + + case AUTH_MOD: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_MOD, 'auth_mod', $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Moderators']; + break; + + case AUTH_ADMIN: + $auth[$key] = $is_admin; + $auth[$key . '_type'] = $lang['Auth_Administrators']; + break; + + default: + $auth[$key] = 0; + break; + } + } + return $auth; } Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb/constants.php 2006-12-28 01:47:23 UTC (rev 33) @@ -28,5 +28,6 @@ define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats +define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access"); ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb.php 2006-12-28 01:47:23 UTC (rev 33) @@ -88,51 +88,61 @@ { for($i = 0; $i < $total_catrows; $i++) { - // Ok display one cat here - $template->assign_block_vars('catrow', array( - 'CAT_TITLE' => $catrows[$i]['cat_title'], - 'CAT_DESC' => $catrows[$i]['cat_desc'], - 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), - 'L_SUBCATS' => $lang['kb_subcats'], - 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D - ); + $auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); - // Now let's look at subcats - $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order - FROM " . KB_CATEGORIES_TABLE . " c - WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' - ORDER BY c.cat_order"; - if( !($result = $db->sql_query($sql)) ) + if($auth['auth_view']) { - message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); - } - - $subcats = array(); - while ($row = $db->sql_fetchrow($result)) - { - $subcats[] = $row; - } - - if($total_subcats = count($subcats)) - { - // Contains subcats, show them - $template->assign_block_vars('catrow.switch_subcats', array()); + // Ok display one cat here + $template->assign_block_vars('catrow', array( + 'CAT_TITLE' => $catrows[$i]['cat_title'], + 'CAT_DESC' => $catrows[$i]['cat_desc'], + 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'L_SUBCATS' => $lang['kb_subcats'], + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); - for($j = 0; $j < $total_subcats; $j++) + // Now let's look at subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' + ORDER BY c.cat_order"; + if( !($result = $db->sql_query($sql)) ) { - // Show the subcat - $k = $j + 1; - $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; - $template->assign_block_vars('catrow.subcatrow', array( - 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), - 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], - 'SUBCAT_COMMA' => $subcat_comma) - ); + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while ($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; } - } - } - } + + if($total_subcats = count($subcats)) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcats', array()); + + for($j = 0; $j < $total_subcats; $j++) + { + $auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + + if($auth['auth_view']) + { + // Show the subcat + $k = $j + 1; + $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; + $template->assign_block_vars('catrow.subcatrow', array( + 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], + 'SUBCAT_COMMA' => $subcat_comma) + ); + } // if auth view + } // for subcats + } // if subcats + } // auth view + } // for cats + }// total cats else { message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); @@ -367,6 +377,7 @@ // // These vars are for later use // + $in_cat = false; $cats = array(); while($row = $db->sql_fetchrow($result)) { @@ -374,12 +385,21 @@ if($row['cat_id'] == $cid) { + $in_cat = true; $current_cat['cat_title'] = $row['cat_title']; $current_cat['cat_id'] = $row['cat_id']; $current_cat['cat_main'] = $row['cat_main']; } } + // + // Check that the given category is true + // + if(!$in_cat) + { + message_die(GENERAL_MESSAGE, "The category specified in GET variables did not exist along with this article in the database."); + } + $article_title = $article['article_title']; $article_text = $article['article_text']; $article_bbcode_uid = $article['bbcode_uid']; Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb_install.php 2006-12-28 01:47:23 UTC (rev 33) @@ -56,6 +56,14 @@ cat_desc varchar(255) NOT NULL, cat_articles mediumint(8) UNSIGNED DEFAULT '0', cat_order mediumint(8) UNSIGNED NOT NULL, + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', PRIMARY KEY (cat_id), KEY cat_order (cat_order) )"; @@ -86,20 +94,18 @@ )"; $sql[] = "CREATE TABLE " . $table_prefix . "kb_auth_access ( - `group_id` mediumint(8) NOT NULL default '0', - `cat_id` smallint(5) unsigned NOT NULL default '0', - `auth_view` tinyint(1) NOT NULL default '0', - `auth_add` tinyint(1) NOT NULL default '0', - `auth_edit` tinyint(1) NOT NULL default '0', - `auth_delete` tinyint(1) NOT NULL default '0', - `auth_mod` tinyint(1) NOT NULL default '0', - `auth_comment` tinyint(1) NOT NULL default '0', - `auth_rate` tinyint(1) NOT NULL default '0', - `auth_a` tinyint(1) NOT NULL default '0', - `auth_attachments` tinyint(1) NOT NULL default '0', - KEY `group_id` (`group_id`), - KEY `cat_id` (`cat_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + group_id mediumint(8) NOT NULL default '0', + cat_id smallint(5) unsigned NOT NULL default '0', + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + KEY group_id (group_id), + KEY cat_id (cat_id) )"; echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-19 20:14:57
|
Revision: 32 http://svn.sourceforge.net/phpbbkb/?rev=32&view=rev Author: softphp Date: 2006-12-19 12:14:53 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/kb/auth.php Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/admin/admin_kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -37,8 +37,12 @@ switch($mode) { + /* + NOTE: All article editing, deleting, approving and so on will be featured in the ucp for the admin as well, + might integrate it here later but i like it better in ucp. case "articles": break; + */ case "cats": $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; @@ -91,12 +95,12 @@ if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; } if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; } if($error_msg != '') @@ -168,13 +172,63 @@ } // And a message here somewhere + $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } } } if($delete != false) { + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + if(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $delete . '" />'; + $l_confirm = $lang['kbadm_confirm_deletecat']; + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?delete=true"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + } + elseif($confirm) // Double check user confirmed + { + $cat_id = $HTTP_POST_VARS['cat_id']; + + // Need lang vars for the errors? + $sql = "DELETE FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from categories table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? + message_die(GENERAL_MESSAGE, $message); + } } if($add) @@ -210,12 +264,12 @@ if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; } if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; } if($error_msg != '') @@ -245,7 +299,7 @@ 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], - 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) @@ -268,6 +322,9 @@ sort_cats("add", $db->sql_nextid(), 0, $parent); // And a message here somewhere + $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } } } @@ -276,16 +333,19 @@ { $sort = explode("|", $sort); - // ok so ?sort=id|up(1)/down(-1) - sort_cats("", $sort[0], $sort[1]); + // ok so ?sort=id|id2|up/down + sort_cats("", $sort[0], $sort[2], $sort[1]); // Put id2 in the level argument, nvm that :) // And yes yet another message here + $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } // Show categories as list break; - case "permissions": // For later use + case "auth": // For later use break; case "files": // For later use @@ -431,6 +491,34 @@ } else { + if($dir == "up") + { + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order - 1 + WHERE cat_id = '" . $id . "'; + UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order + 1 + WHERE cat_id = '" . $dir . "';"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + } + elseif($dir == "down") + { + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order + 1 + WHERE cat_id = '" . $id . "'; + UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order - 1 + WHERE cat_id = '" . $dir . "';"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + } return; } } Added: root/kb/auth.php =================================================================== --- root/kb/auth.php (rev 0) +++ root/kb/auth.php 2006-12-19 20:14:53 UTC (rev 32) @@ -0,0 +1,28 @@ +<?php +/*************************************************************************** + * auth.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +// This file holds the kb_auth functions, very similar to the phpBB auth functions, but differs certain places :) +function kb_auth($type, $cat_id, $userdata) +{ + + return $auth; +} + +?> Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb/functions.php 2006-12-19 20:14:53 UTC (rev 32) @@ -632,6 +632,57 @@ ); } +// Delete an article +function ucp_article_delete($id, $confirm) +{ + global $lang, $db, $phpEx, $template; + + if(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="article_id" value="' . $id . '" />'; + $l_confirm = $lang['kb_confirm_deletearticle']; + + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + } + elseif($confirm) // Double check they actually confirmed + { + $article_id = $HTTP_POST_VARS['article_id']; + + // Need lang vars for the error messages? + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articles table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + // Message + } +} + // // Prepare an article for the database // Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -535,7 +535,8 @@ break; case "delete_article": - ucp_article_delete(); + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + ucp_article_delete($id, $confirm); break; case "post_comment": // Only input Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb_install.php 2006-12-19 20:14:53 UTC (rev 32) @@ -85,6 +85,23 @@ cat_id mediumint(8) NOT NULL DEFAULT '0' )"; +$sql[] = "CREATE TABLE " . $table_prefix . "kb_auth_access ( + `group_id` mediumint(8) NOT NULL default '0', + `cat_id` smallint(5) unsigned NOT NULL default '0', + `auth_view` tinyint(1) NOT NULL default '0', + `auth_add` tinyint(1) NOT NULL default '0', + `auth_edit` tinyint(1) NOT NULL default '0', + `auth_delete` tinyint(1) NOT NULL default '0', + `auth_mod` tinyint(1) NOT NULL default '0', + `auth_comment` tinyint(1) NOT NULL default '0', + `auth_rate` tinyint(1) NOT NULL default '0', + `auth_a` tinyint(1) NOT NULL default '0', + `auth_attachments` tinyint(1) NOT NULL default '0', + KEY `group_id` (`group_id`), + KEY `cat_id` (`cat_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +)"; + echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; echo '<tr><th>Updating the database</th></tr>'; Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/language/lang_english/lang_kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -56,4 +56,24 @@ $lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. $lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; + +// Admin +$lang['kbadm_header_editcat'] +$lang['kbadm_explain_editcat'] +$lang['kbadm_cat_settings'] +$lang['kbadm_cat_title'] +$lang['kbadm_cat_desc'] +$lang['kbadm_cat_parent'] +$lang['kbadm_empty_cat_title'] +$lang['kbadm_empty_cat_desc'] +$lang['kbadm_confirm_deletecat'] +$lang['kbadm_Click_return_catadmin'] +$lang['kbadm_header_addcat'] +$lang['kbadm_explain_addcat'] +$lang['kbadm_addcat'] + +$lang['kbadm_delcat_success'] +$lang['kbadm_editcat_success'] +$lang['kbadm_addcat_success'] +$lang['kbadm_sortcat_success'] ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-16 00:23:57
|
Revision: 31 http://svn.sourceforge.net/phpbbkb/?rev=31&view=rev Author: softphp Date: 2006-12-15 16:23:56 -0800 (Fri, 15 Dec 2006) Log Message: ----------- - Added some sorting code, and finished editing and adding categories, all needs testing of course. Modified Paths: -------------- root/admin/admin_kb.php root/templates/subSilver/admin/kb_editcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-15 14:33:32 UTC (rev 30) +++ root/admin/admin_kb.php 2006-12-16 00:23:56 UTC (rev 31) @@ -50,7 +50,9 @@ { if(!isset($HTTP_POST_VARS['submit'])) { - $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $edit . "'"; + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); @@ -62,7 +64,7 @@ ); $parent = generate_cat_parents($cat['cat_main']); - $s_hidden_fields = ""; + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; $template->assign_vars(array( 'L_HEADER' => $lang['kbadm_header_editcat'], @@ -85,7 +87,88 @@ } else { + $error_msg = ''; + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'CAT_DESC' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_main = '" . $parent . "', + cat_title = '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', + cat_desc = '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "' + WHERE cat_id = '" . $edit . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't edit category.", "", __LINE__, __FILE__, $sql); + } + + if($HTTP_POST_VARS['oldparent'] != $HTTP_POST_VARS['parent']) + { + // Parent category changed, alter the order + sort_cats("edit", $edit, 0, array(0 => $HTTP_POST_VARS['parent'], 1 => $HTTP_POST_VARS['oldparent'])); + } + + // And a message here somewhere + } } } @@ -123,13 +206,80 @@ } else { + $error_msg = ''; + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = ""; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "INSERT INTO " . KB_CATEGORIES_TABLE . " (cat_id, cat_main, cat_title, cat_desc, cat_articles, cat_order) + VALUES ('', '" . $parent . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "', '0', '9999');"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't insert new category.", "", __LINE__, __FILE__, $sql); + } + + sort_cats("add", $db->sql_nextid(), 0, $parent); + + // And a message here somewhere + } } } if($sort != false) { + $sort = explode("|", $sort); + // ok so ?sort=id|up(1)/down(-1) + sort_cats("", $sort[0], $sort[1]); + + // And yes yet another message here } // Show categories as list @@ -199,4 +349,89 @@ return $parent; } + +function sort_cats($type = "", $id = 0, $dir = 0, $level = 0) +{ + if($type == "add") + { + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number + 1 . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + elseif($type == "edit") + { + // First clean up in the old level where it is gone from + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[1] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $sql = ""; + $i = 0; + while($old_cat = $db->sql_fetchrow($result)) + { + $i++; + $sql .= "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $i . "' + WHERE cat_id = '" . $old_cat['cat_id'] . "';\n"; + } + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); + } + + // Ok insert it in the back of the new one :) + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[0] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number + 1 . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + else + { + return; + } +} ?> Modified: root/templates/subSilver/admin/kb_editcat.tpl =================================================================== --- root/templates/subSilver/admin/kb_editcat.tpl 2006-12-15 14:33:32 UTC (rev 30) +++ root/templates/subSilver/admin/kb_editcat.tpl 2006-12-16 00:23:56 UTC (rev 31) @@ -3,6 +3,7 @@ <p>{L_EXPLAIN}</p> +{ERROR_BOX} <form action="{S_FORUM_ACTION}" method="post"> <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> <tr> @@ -10,11 +11,11 @@ </tr> <tr> <td class="row1">{L_CAT_TITLE}</td> - <td class="row2"><input type="text" size="25" name="forumname" value="{CAT_TITLE}" class="post" /></td> + <td class="row2"><input type="text" size="25" name="title" value="{CAT_TITLE}" class="post" /></td> </tr> <tr> <td class="row1">{L_CAT_DESCRIPTION}</td> - <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="forumdesc" class="post">{DESCRIPTION}</textarea></td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="desc" class="post">{DESCRIPTION}</textarea></td> </tr> <tr> <td class="row1">{L_CAT_PARENT}</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-15 14:33:37
|
Revision: 30 http://svn.sourceforge.net/phpbbkb/?rev=30&view=rev Author: softphp Date: 2006-12-15 06:33:32 -0800 (Fri, 15 Dec 2006) Log Message: ----------- -Removed the ucp class and just using functions.php now. Further things added in admin_kb.php. Hoping to work more on it sunday or later tonight. Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php Removed Paths: ------------- root/kb/ucp_class.php Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/admin/admin_kb.php 2006-12-15 14:33:32 UTC (rev 30) @@ -151,9 +151,11 @@ ////////////////// function generate_cat_parents($selected = false) { - global $db; + global $db, $lang; - $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + $sql = "SELECT cat_id, cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); @@ -165,6 +167,36 @@ $cats[] = $row; } - $parent = ""; + if(!$selected) + { + $parent = '<select name="parent">\n<option value="0" selected="selected">' . $lang['kb_main'] . '</option>\n'; + } + else + { + $parent = '<select name="parent">\n<option value="0">' . $lang['kb_main'] . '</option>\n'; + } + + for($i = 0; $i < count($cats); $i++) + { + if(!$selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + if($cats[$i]['cat_id'] == $selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '" selected="selected">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + } + } + + $parent .= "</select>"; + + return $parent; } ?> Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb/functions.php 2006-12-15 14:33:32 UTC (rev 30) @@ -144,10 +144,494 @@ return $cats; } -// These vars we need for making html safe +//////////////////////////////////////// +/// UCP FUNCTIONS /// +//////////////////////////////////////// $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); $html_entities_replace = array('&', '<', '>', '"'); -/* +$unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); +$unhtml_specialchars_replace = array('>', '<', '"', '&'); + +// This is for posting articles, mostly cut out of the posting.php :) +function ucp_article_form($mode, $id, $review) +{ + global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; + + $error_msg = ''; + $user_sig = $userdata['user_sig']; + + if(!empty($HTTP_POST_VARS['post'])) + { + if($mode == 'edit') + { + // Let's get the old article data + $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$article_id'"; + if (!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + // if user editing set status = 0, else set status = old status :) + if($userdata['user_id'] == $article_author) + { + $article_status = "0"; + } + else + { + $article_status = $article['article_status']; + } + } + + // Add the new article + // Make all the variables :) + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; + } + + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; + $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); + $bbcode_uid = ''; + $cat_id = $HTTP_POST_VARS['cats']; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; + + prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + + if ( $error_msg == '' ) + { + $current_time = time(); + + if($mode == 'post') + { + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + } + else + { + if(!$article_id) + { + message_die(GENERAL_ERROR, 'No article to edit.'); + } + + // First update the article table + $sql = "UPDATE " . KB_ARTICLES_TABLE . " + SET article_title = '$article_title', + article_desc = '$article_desc', + article_author = '$article_author', + article_authorname = '$article_authorname', + article_edittime = '$current_time', + article_editby = '" . $userdata['user_id'] . "', + article_status = '$article_status', + enable_sig = '$attach_sig', + enable_html = '$html_on', + enable_bbcode = '$bbcode_on', + enable_smilies = '$smilies_on', + article_text = '$message';"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); + } + + // Now delete all articlecats + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); + } + + // Last add them again doing the loop + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + // Message here somewhere + } + return; + } + } + + $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; + if($mode == "post" && !$preview && $error_msg == '') + { + $article_title = ''; + $article_text = ''; + $article_desc = ''; + $authorname = $userdata['username']; + $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); + $hidden_form_fields = ""; + $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; + + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); + } + + if($preview) + { + // Do funny preview stuff + } + } + elseif($preview || $error_msg != '') + { + $article_title = $HTTP_POST_VARS['title']; + $article_text = $HTTP_POST_VARS['message']; + $article_desc = $HTTP_POST_VARS['desc']; + $authorname = $HTTP_POST_VARS['authorname']; + + $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; + $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; + $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; + + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $hidden_form_fields = ""; + if($error_msg != "") + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } + } + else + { + if(empty($id)) + { + message_die(GENERAL_ERROR, "No article defined."); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); + } + + if($db->sql_numrows($result) == 1) + { + $article = $db->sql_fetchrow($result); + } + else + { + message_die(GENERAL_ERROR, "Article does not exist."); + } + + // Now make an array over the cats + $sql = "SELECT cat_id + FROM " . KB_ARTICLECATS_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); + } + + $article_cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $article_cats[] = $row; + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_desc = $article['article_desc']; + $authorname = $article['article_authorname']; + + $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $article['enable_html'] ) ? true : false; + $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; + $smilies_on = ( $article['enable_smilies'] ) ? true : false; + + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; + } + + if ( $article['bbcode_uid'] != '' ) + { + $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); + } + + $article_text = str_replace('<', '<', $article_text); + $article_text = str_replace('>', '>', $article_text); + $article_text = str_replace('<br />', "\n", $article_text); + + // + // Signature toggle selection + // + if( $user_sig != '' ) + { + $template->assign_block_vars('switch_signature_checkbox', array()); + } + + // + // HTML toggle selection + // + if ( $board_config['allow_html'] ) + { + $html_status = $lang['HTML_is_ON']; + $template->assign_block_vars('switch_html_checkbox', array()); + } + else + { + $html_status = $lang['HTML_is_OFF']; + } + + // + // BBCode toggle selection + // + if ( $board_config['allow_bbcode'] ) + { + $bbcode_status = $lang['BBCode_is_ON']; + $template->assign_block_vars('switch_bbcode_checkbox', array()); + } + else + { + $bbcode_status = $lang['BBCode_is_OFF']; + } + + // Obtain categories structure + $cats = get_cats_structure(); + + // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S + $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; + if($mode == "edit") + { + for($i = 0; $i < count($cats); $i++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + else + { + for($i = 0; $i < count($cats); $i++) + { + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + + // + // Smilies toggle selection + // + if ( $board_config['allow_smilies'] ) + { + $smilies_status = $lang['Smilies_are_ON']; + $template->assign_block_vars('switch_smilies_checkbox', array()); + } + else + { + $smilies_status = $lang['Smilies_are_OFF']; + } + + $template->set_filenames(array( + 'body' => 'kb_article_posting.tpl') + ); + + create_navigation("ucp", $action); + + // This is the template stuff we need no matter what + $template->assign_vars(array( + 'AUTHORNAME' => $authorname, + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE' => $article_text, + 'DESC' => $article_desc, + 'HTML_STATUS' => $html_status, + 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + 'SMILIES_STATUS' => $smilies_status, + + 'L_POST_ARTICLE' => $lang['kb_post_article'], + 'L_AUTHORNAME' => $lang['kb_authorname'], + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_ARTICLE_CATS' => $lang['kb_articlecats'], + 'L_ARTICLE_BODY' => $lang['kb_articletext'], + 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], + 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? + 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], + + 'L_OPTIONS' => $lang['Options'], + 'L_PREVIEW' => $lang['Preview'], + 'L_SUBMIT' => $lang['Submit'], + 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], + 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], + 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], + '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_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', + 'S_POST_ACTION' => $form_action, + 'CATS_HTML' => $s_cats, + 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) + ); +} + // // Prepare an article for the database // @@ -156,7 +640,6 @@ global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; // Check title - $article_title = "BLABLA"; if (!empty($article_title)) { $article_title = htmlspecialchars(trim($article_title)); @@ -170,7 +653,7 @@ if(!empty($message)) { $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; - $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + $message = prepare_article_text(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); } else { @@ -188,21 +671,16 @@ } // Check categories - if(is_array($cat_id)) + if(!is_array($cat_id)) { - print_r($cat_id); - $cat_id = implode(",", $cat_id); - } - else - { $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; } return; } -function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) +function prepare_article_text($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) { - global $board_config, $html_entities_match, $html_entities_replace; + global $board_config, $phpEx; // // Clean up the message @@ -223,6 +701,9 @@ $message = ''; + // Include functions_post for clean_html + include($phpbb_root_path . "includes/functions_post." . $phpEx); + foreach ($message_split as $part) { $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); @@ -244,5 +725,9 @@ return $message; } -*/ + +function unprepare_message($message) +{ + return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message); +} ?> \ No newline at end of file Deleted: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb/ucp_class.php 2006-12-15 14:33:32 UTC (rev 30) @@ -1,693 +0,0 @@ -<?php -/*************************************************************************** - * ucp_class.php - * ------------------- - * - * copyright: phpBB KB Group - * site: http://www.phpbbknowledgebase.com - * SF Project Page: http://www.sourceforge.net/projects/phpbbkb - * - ***************************************************************************/ - -/*************************************************************************** - * - * 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_PHPBB')) -{ - die('Hacking attempt'); -} - -// This contains the entire ucp class, so it's seperated from the rest of kb.php -class ucp -{ - var $action = ""; - var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); - var $html_entities_replace = array('&', '<', '>', '"'); - var $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); - var $unhtml_specialchars_replace = array('>', '<', '"', '&'); - - function generate_page($action, $id=0, $preview=false) - { - $this->action = $action; - switch($this->action) - { - case "articles": - break; - - case "comments": - break; - - case "post_article": - $this->article_form("post", false, $preview); - break; - - case "edit_article": - $this->article_form("edit", $id, $preview); - break; - - case "delete_article": - $this->article_delete(); - break; - - case "post_comment": // Only input - break; - - case "edit_comment": - break; - - case "delete_comment": - break; - - default: - break; - } - } - - function generate_page_title($action) - { - global $lang; - - $title = $lang['kb_ucp']; - - switch($action) - { - case "articles": - break; - - case "comments": - break; - - case "post_article": - $title .= ": " . $lang['kb_ucp_articlepost']; - break; - - case "edit_article": - $title .= ": " . $lang['kb_ucp_articleedit']; - break; - - case "delete_article": - - break; - - case "post_comment": // Only input - break; - - case "edit_comment": - break; - - case "delete_comment": - break; - - default: - break; - } - - return $title; - } - - // This is for posting articles, mostly cut out of the posting.php :) - function article_form($mode, $id, $review) - { - global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; - - $error_msg = ''; - $user_sig = $userdata['user_sig']; - - if(!empty($HTTP_POST_VARS['post'])) - { - if($mode == 'edit') - { - // Let's get the old article data - $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; - - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$article_id'"; - if (!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); - } - - $article = $db->sql_fetchrow($result); - - // if user editing set status = 0, else set status = old status :) - if($userdata['user_id'] == $article_author) - { - $article_status = "0"; - } - else - { - $article_status = $article['article_status']; - } - } - - // Add the new article - // Make all the variables :) - if ( !$board_config['allow_html'] ) - { - $html_on = 0; - } - else - { - $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; - } - - if ( !$board_config['allow_bbcode'] ) - { - $bbcode_on = 0; - } - else - { - $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; - } - - if ( !$board_config['allow_smilies'] ) - { - $smilies_on = 0; - } - else - { - $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; - } - - $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; - $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; - $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; - $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; - $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); - $bbcode_uid = ''; - $cat_id = $HTTP_POST_VARS['cats']; - $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; - - $this->prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); - - if ( $error_msg == '' ) - { - $current_time = time(); - - if($mode == 'post') - { - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); - } - - $article_id = $db->sql_nextid(); - // Now make the categories - foreach($cat_id as $i => $cat) - { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); - } - - if (!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); - } - } - - $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); - } - else - { - if(!$article_id) - { - message_die(GENERAL_ERROR, 'No article to edit.'); - } - - // First update the article table - $sql = "UPDATE " . KB_ARTICLES_TABLE . " - SET article_title = '$article_title', - article_desc = '$article_desc', - article_author = '$article_author', - article_authorname = '$article_authorname', - article_edittime = '$current_time', - article_editby = '" . $userdata['user_id'] . "', - article_status = '$article_status', - enable_sig = '$attach_sig', - enable_html = '$html_on', - enable_bbcode = '$bbcode_on', - enable_smilies = '$smilies_on', - article_text = '$message';"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); - } - - // Now delete all articlecats - $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); - } - - // Last add them again doing the loop - foreach($cat_id as $i => $cat) - { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); - } - - if (!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); - } - } - - // Message here somewhere - } - return; - } - } - - $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; - if($mode == "post" && !$preview && $error_msg == '') - { - $article_title = ''; - $article_text = ''; - $article_desc = ''; - $authorname = $userdata['username']; - $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); - $hidden_form_fields = ""; - $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; - - if ( !$board_config['allow_html'] ) - { - $html_on = 0; - } - else - { - $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); - } - - if ( !$board_config['allow_bbcode'] ) - { - $bbcode_on = 0; - } - else - { - $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); - } - - if ( !$board_config['allow_smilies'] ) - { - $smilies_on = 0; - } - else - { - $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); - } - - if($preview) - { - // Do funny preview stuff - } - } - elseif($preview || $error_msg != '') - { - $article_title = $HTTP_POST_VARS['title']; - $article_text = $HTTP_POST_VARS['message']; - $article_desc = $HTTP_POST_VARS['desc']; - $authorname = $HTTP_POST_VARS['authorname']; - - $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; - - $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; - $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; - $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; - if($error_msg != "") - { - $template->set_filenames(array( - 'reg_header' => 'error_body.tpl') - ); - $template->assign_vars(array( - 'ERROR_MESSAGE' => $error_msg) - ); - $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); - } - } - else - { - if(empty($id)) - { - message_die(GENERAL_ERROR, "No article defined."); - } - - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); - } - - if($db->sql_numrows($result) == 1) - { - $article = $db->sql_fetchrow($result); - } - else - { - message_die(GENERAL_ERROR, "Article does not exist."); - } - - // Now make an array over the cats - $sql = "SELECT cat_id - FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$id'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); - } - - $article_cats = array(); - while($row = $db->sql_fetchrow($result)) - { - $article_cats[] = $row; - } - - $article_title = $article['article_title']; - $article_text = $article['article_text']; - $article_desc = $article['article_desc']; - $authorname = $article['article_authorname']; - - $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; - - $html_on = ( $article['enable_html'] ) ? true : false; - $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; - $smilies_on = ( $article['enable_smilies'] ) ? true : false; - - $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; - } - - if ( $article['bbcode_uid'] != '' ) - { - $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); - } - - $article_text = str_replace('<', '<', $article_text); - $article_text = str_replace('>', '>', $article_text); - $article_text = str_replace('<br />', "\n", $article_text); - - // - // Signature toggle selection - // - if( $user_sig != '' ) - { - $template->assign_block_vars('switch_signature_checkbox', array()); - } - - // - // HTML toggle selection - // - if ( $board_config['allow_html'] ) - { - $html_status = $lang['HTML_is_ON']; - $template->assign_block_vars('switch_html_checkbox', array()); - } - else - { - $html_status = $lang['HTML_is_OFF']; - } - - // - // BBCode toggle selection - // - if ( $board_config['allow_bbcode'] ) - { - $bbcode_status = $lang['BBCode_is_ON']; - $template->assign_block_vars('switch_bbcode_checkbox', array()); - } - else - { - $bbcode_status = $lang['BBCode_is_OFF']; - } - - // Obtain categories structure - $cats = get_cats_structure(); - - // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S - $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($mode == "edit") - { - for($i = 0; $i < count($cats); $i++) - { - $selected = ''; - for($k = 0; $k < count($article_cats); $k++) - { - if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) - { - $selected = ' selected="selected"'; - } - } - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; - - // Sort subcats - for($j = 0; $j < count($cats[$i]['subcats']); $j++) - { - $selected = ''; - for($k = 0; $k < count($article_cats); $k++) - { - if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) - { - $selected = ' selected="selected"'; - } - } - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; - } - } - } - else - { - for($i = 0; $i < count($cats); $i++) - { - $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; - - // Sort subcats - for($j = 0; $j < count($cats[$i]['subcats']); $j++) - { - $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; - } - } - } - - // - // Smilies toggle selection - // - if ( $board_config['allow_smilies'] ) - { - $smilies_status = $lang['Smilies_are_ON']; - $template->assign_block_vars('switch_smilies_checkbox', array()); - } - else - { - $smilies_status = $lang['Smilies_are_OFF']; - } - - $template->set_filenames(array( - 'body' => 'kb_article_posting.tpl') - ); - - create_navigation("ucp", $this->action); - - // This is the template stuff we need no matter what - $template->assign_vars(array( - 'AUTHORNAME' => $authorname, - 'ARTICLE_TITLE' => $article_title, - 'ARTICLE' => $article_text, - 'DESC' => $article_desc, - 'HTML_STATUS' => $html_status, - 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), - 'SMILIES_STATUS' => $smilies_status, - - 'L_POST_ARTICLE' => $lang['kb_post_article'], - 'L_AUTHORNAME' => $lang['kb_authorname'], - 'L_ARTICLE_NAME' => $lang['kb_articlename'], - 'L_ARTICLE_DESC' => $lang['kb_articledesc'], - 'L_ARTICLE_CATS' => $lang['kb_articlecats'], - 'L_ARTICLE_BODY' => $lang['kb_articletext'], - 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], - 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? - 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], - - 'L_OPTIONS' => $lang['Options'], - 'L_PREVIEW' => $lang['Preview'], - 'L_SUBMIT' => $lang['Submit'], - 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], - 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], - 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], - '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_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', - 'S_POST_ACTION' => $form_action, - 'CATS_HTML' => $s_cats, - 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) - ); - } - - // - // Prepare an article for the database - // - function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) - { - global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; - - // Check title - if (!empty($article_title)) - { - $article_title = htmlspecialchars(trim($article_title)); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; - } - - // Check message - if(!empty($message)) - { - $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; - $message = $this->prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; - } - - // Check Desc - if (!empty($article_desc)) - { - $article_desc = htmlspecialchars(trim($article_desc)); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; - } - - // Check categories - if(!is_array($cat_id)) - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; - } - return; - } - - function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) - { - global $board_config, $phpEx; - - // - // Clean up the message - // - $message = trim($message); - - if ($html_on) - { - // If HTML is on, we try to make it safe - // This approach is quite agressive and anything that does not look like a valid tag - // is going to get converted to HTML entities - $message = stripslashes($message); - $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; - $matches = array(); - - $message_split = preg_split($html_match, $message); - preg_match_all($html_match, $message, $matches); - - $message = ''; - - // Include functions_post for clean_html - include($phpbb_root_path . "includes/functions_post." . $phpEx); - - foreach ($message_split as $part) - { - $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); - $message .= preg_replace($this->html_entities_match, $this->html_entities_replace, $part) . clean_html($tag); - } - - $message = addslashes($message); - $message = str_replace('"', '\"', $message); - } - else - { - $message = preg_replace($this->html_entities_match, $this->html_entities_replace, $message); - } - - if($bbcode_on && $bbcode_uid != '') - { - $message = bbencode_first_pass($message, $bbcode_uid); - } - - return $message; - } - - function unprepare_message($message) - { - return preg_replace($this->unhtml_specialchars_match, $this->unhtml_specialchars_replace, $message); - } -} -?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb.php 2006-12-15 14:33:32 UTC (rev 30) @@ -502,7 +502,7 @@ case "ucp": $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; - include($phpbb_root_path . "kb/ucp_class." . $phpEx); + /*include($phpbb_root_path . "kb/ucp_class." . $phpEx); $ucp = new ucp; // Start Page output @@ -510,7 +510,47 @@ include($phpbb_root_path . 'includes/page_header.' . $phpEx); $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); + */ + // The above have been removed and changed to functions.php + $id = isset($HTTP_GET_VARS['id']) ? $HTTP_GET_VARS['id'] : 0; + $preview = isset($HTTP_POST_VARS['preview']) ? true : false; + $page_title = ucp_generate_page_title($action); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + ucp_article_form("post", false, $preview); + break; + + case "edit_article": + ucp_article_form("edit", $id, $preview); + break; + + case "delete_article": + ucp_article_delete(); + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + // // Generate the page // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-14 00:13:55
|
Revision: 29 http://svn.sourceforge.net/phpbbkb/?rev=29&view=rev Author: softphp Date: 2006-12-13 16:13:52 -0800 (Wed, 13 Dec 2006) Log Message: ----------- -Added acp structure for categories and did a bit of untested code :) Please note that I'm probably restructuring the ucp_class very shortly, so it's not a class, due to several problems I've encountered. Modified Paths: -------------- root/admin/admin_kb.php Added Paths: ----------- root/templates/subSilver/admin/ root/templates/subSilver/admin/kb_editcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-12 22:17:54 UTC (rev 28) +++ root/admin/admin_kb.php 2006-12-14 00:13:52 UTC (rev 29) @@ -27,6 +27,12 @@ return; } +// Get constants and functions +include($phpbb_root_path . "kb/constants." . $phpEx); +include($phpbb_root_path . "kb/functions." . $phpEx); + +// And language +include($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/lang_kb." . $phpEx); $mode = $HTTP_GET_VARS['mode']; switch($mode) @@ -35,6 +41,98 @@ break; case "cats": + $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; + $delete = isset($HTTP_GET_VARS['delete']) ? $HTTP_GET_VARS['delete'] : false; + $add = isset($HTTP_POST_VARS['add']) ? true : false; + $sort = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : false; + + if($edit != false) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = ""; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'CAT_DESC' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + + } + } + + if($delete != false) + { + + } + + if($add) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_addcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_addcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx) + ); + + $template->pparse('body'); + } + else + { + + } + } + + if($sort != false) + { + + } + + // Show categories as list break; case "permissions": // For later use @@ -47,3 +145,26 @@ break; } + +////////////////// +/// FUNCTIONS /// +////////////////// +function generate_cat_parents($selected = false) +{ + global $db; + + $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); + } + + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + } + + $parent = ""; +} +?> Added: root/templates/subSilver/admin/kb_editcat.tpl =================================================================== --- root/templates/subSilver/admin/kb_editcat.tpl (rev 0) +++ root/templates/subSilver/admin/kb_editcat.tpl 2006-12-14 00:13:52 UTC (rev 29) @@ -0,0 +1,29 @@ + +<h1>{L_HEADER}</h1> + +<p>{L_EXPLAIN}</p> + +<form action="{S_FORUM_ACTION}" method="post"> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">{L_CAT_SETTINGS}</th> + </tr> + <tr> + <td class="row1">{L_CAT_TITLE}</td> + <td class="row2"><input type="text" size="25" name="forumname" value="{CAT_TITLE}" class="post" /></td> + </tr> + <tr> + <td class="row1">{L_CAT_DESCRIPTION}</td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="forumdesc" class="post">{DESCRIPTION}</textarea></td> + </tr> + <tr> + <td class="row1">{L_CAT_PARENT}</td> + <td class="row2">{S_PARENT}</td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td> + </tr> + </table> +</form> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-12 22:17:59
|
Revision: 28 http://svn.sourceforge.net/phpbbkb/?rev=28&view=rev Author: softphp Date: 2006-12-12 14:17:54 -0800 (Tue, 12 Dec 2006) Log Message: ----------- - Just some small changes and the introduction of an acp file. I don't know if Prince of PhpBB already has begun his work? If so... commit away! Modified Paths: -------------- root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/admin/ root/admin/admin_kb.php Added: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php (rev 0) +++ root/admin/admin_kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -0,0 +1,49 @@ +<?php +/*************************************************************************** + * admin_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +define('IN_PHPBB', 1); + +if( !empty($setmodules) ) +{ + $file = basename(__FILE__); + $module['KB']['Categories'] = "$file?mode=cats"; + return; +} + +$mode = $HTTP_GET_VARS['mode']; + +switch($mode) +{ + case "articles": + break; + + case "cats": + break; + + case "permissions": // For later use + break; + + case "files": // For later use + break; + + default: // General settings here + break; +} + Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-12 03:04:25 UTC (rev 27) +++ root/kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -150,7 +150,7 @@ $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; if(!$cat_id) { - message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); // this needs to be in a $lang entry + message_die(GENERAL_MESSAGE, $lang['kb_cat_noexist']); } // Store the main cat in a variable @@ -211,18 +211,6 @@ $sort = "ORDER BY a.article_edittime DESC"; } - // This has been removed due to probably not working - /* - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE cat_id LIKE '$cat_id' - $sort"; - if( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql); - } - */ - $sql = "SELECT a.* FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_ARTICLES_TABLE . " a WHERE c.cat_id = '$cat_id' @@ -314,7 +302,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; //hardcoded PHP extension. + $author = "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; $sql = "SELECT username FROM " . USERS_TABLE . " @@ -325,7 +313,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); // hardcoded PHP extension. + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -356,11 +344,6 @@ $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); - if(!$cid || !$id) - { - message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); // Hmm, is this a error that is worthy of being a hardcoded one? - } - $sql = "SELECT a.*, u.* FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u WHERE a.article_id = '$id' Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-12 03:04:25 UTC (rev 27) +++ root/language/lang_english/lang_kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -32,6 +32,7 @@ $lang['kb_subcats'] = "Sub categories"; $lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; $lang['No_kb_cats'] = "No knowledge base categories has been added."; +$lang['kb_cat_noexist'] = "The category you chose does not exist."; $lang['kb_viewcat_subcats'] = "Subcategories in %s"; $lang['kb_last_action'] = "Last action"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-12-12 03:04:26
|
Revision: 27 http://svn.sourceforge.net/phpbbkb/?rev=27&view=rev Author: markthedaemon Date: 2006-12-11 19:04:25 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Few changes, nothing major. Added some notes to kb.php as i was reading through it with possible changes. Code looks good thus far, Alpha 1 here we come :-D Modified Paths: -------------- root/kb/constants.php root/kb.php root/language/lang_english/lang_kb.php Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/kb/constants.php 2006-12-12 03:04:25 UTC (rev 27) @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * lang_kb.php + * constants.php * ------------------- * * copyright: phpBB KB Group Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/kb.php 2006-12-12 03:04:25 UTC (rev 27) @@ -150,7 +150,7 @@ $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; if(!$cat_id) { - message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); + message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); // this needs to be in a $lang entry } // Store the main cat in a variable @@ -314,7 +314,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; //hardcoded PHP extension. $sql = "SELECT username FROM " . USERS_TABLE . " @@ -325,7 +325,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); // hardcoded PHP extension. $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -358,7 +358,7 @@ if(!$cid || !$id) { - message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); + message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); // Hmm, is this a error that is worthy of being a hardcoded one? } $sql = "SELECT a.*, u.* Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/language/lang_english/lang_kb.php 2006-12-12 03:04:25 UTC (rev 27) @@ -19,7 +19,7 @@ ***************************************************************************/ // Page titles -$lang['kb_main'] = "KnowledgeBase Home"; +$lang['kb_main'] = "Knowledge Base Home"; $lang['kb_viewcat'] = "Viewing Category"; $lang['kb_viewarticle'] = "Viewing Article"; $lang['kb_ucp'] = "KB User Control Panel"; @@ -27,11 +27,11 @@ $lang['kb_ucp_articleedit'] = "Edit article"; // Normal Page -$lang['kb_categories'] = "KnowledgeBase Categories"; +$lang['kb_categories'] = "Knowledge Base Categories"; $lang['kb_articles'] = "Articles"; -$lang['kb_subcats'] = "Subcategories"; -$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. KnowledgeBase won't work before that has been done!"; -$lang['No_kb_cats'] = "No knowledgebase categories has been added."; +$lang['kb_subcats'] = "Sub categories"; +$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; +$lang['No_kb_cats'] = "No knowledge base categories has been added."; $lang['kb_viewcat_subcats'] = "Subcategories in %s"; $lang['kb_last_action'] = "Last action"; @@ -46,7 +46,7 @@ $lang['kb_articlecats'] = "Article Categories"; $lang['kb_articletext'] = "Article Content"; $lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; -$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use ctrl + click for multiple."; +$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use Ctrl & Click for multiple."; $lang['kb_empty_article'] = "The article content you have submitted was empty."; $lang['kb_empty_article_title'] = "The article title you submitted was empty."; $lang['kb_empty_cats'] = "The article you submitted had no category defined."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-29 23:28:50
|
Revision: 26 http://svn.sourceforge.net/phpbbkb/?rev=26&view=rev Author: softphp Date: 2006-11-29 15:28:36 -0800 (Wed, 29 Nov 2006) Log Message: ----------- -- Added a very simple page for viewing articles -- Fixed a bug that made the author id delete when you edited an article. Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/language/lang_english/lang_kb.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/functions.php 2006-11-29 23:28:36 UTC (rev 26) @@ -69,6 +69,23 @@ case "viewarticle": // Viewing an article + if($id_ary[2] == 0) + { + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } + else + { + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } break; case "search": Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/ucp_class.php 2006-11-29 23:28:36 UTC (rev 26) @@ -128,7 +128,7 @@ $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -351,19 +351,170 @@ $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + // Get naughty words :) + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if(!$cid || !$id) { message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); } - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + $sql = "SELECT a.*, u.* + FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u + WHERE a.article_id = '$id' + AND a.article_author = u.user_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); } + $article = $db->sql_fetchrow($result); + + $sql = "SELECT c.*, ca.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_CATEGORIES_TABLE . " ca + WHERE c.article_id = '$id' + AND ca.cat_id = c.cat_id"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article categories.', '', __LINE__, __FILE__, $sql); + } + + // + // These vars are for later use + // + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + + if($row['cat_id'] == $cid) + { + $current_cat['cat_title'] = $row['cat_title']; + $current_cat['cat_id'] = $row['cat_id']; + $current_cat['cat_main'] = $row['cat_main']; + } + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_bbcode_uid = $article['bbcode_uid']; + + $user_sig = ( $article['enable_sig'] && $article['user_sig'] != '' && $board_config['allow_sig'] ) ? $article['user_sig'] : ''; + $user_sig_bbcode_uid = $article['user_sig_bbcode_uid']; + + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$board_config['allow_html'] || !$userdata['user_allowhtml']) + { + if ( $user_sig != '' ) + { + $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); + } + + if ( $article['enable_html'] ) + { + $article_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $article_text); + } + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($user_sig != '' && $user_sig_bbcode_uid != '') + { + $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig); + } + + if ($article_bbcode_uid != '') + { + $article_text = ($board_config['allow_bbcode']) ? bbencode_second_pass($article_text, $article_bbcode_uid) : preg_replace("/\:$article_bbcode_uid/si", '', $article_text); + } + + if ( $user_sig != '' ) + { + $user_sig = make_clickable($user_sig); + } + $article_text = make_clickable($article_text); + + // + // Parse smilies + // + if ( $board_config['allow_smilies'] ) + { + if ( $article['user_allowsmile'] && $user_sig != '' ) + { + $user_sig = smilies_pass($user_sig); + } + + if ( $article['enable_smilies'] ) + { + $article_text = smilies_pass($article_text); + } + } + + // + // Replace naughty words + // + if (count($orig_word)) + { + $article_title = preg_replace($orig_word, $replacement_word, $article_title); + + if ($user_sig != '') + { + $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); + } + + $article_text = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $article_text . '<'), 1, -1)); + } + + // + // Replace newlines (we use this rather than nl2br because + // till recently it wasn't XHTML compliant) + // + if ( $user_sig != '' ) + { + $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig); + } + + $article_text = str_replace("\n", "\n<br />\n", $article_text); + + // Start Page output + $page_title = $lang['kb_viewarticle'] . " : " . $article_title; + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + $template->set_filenames(array( + 'body' => 'kb_viewarticle.tpl') + ); + + create_navigation("viewarticle", array( + 0 => $current_cat['cat_id'], + 1 => $current_cat['cat_title'], + 2 => $current_cat['cat_main'], + 3 => $article['article_id'], + 4 => $article_title) + ); + + $posted_by = sprintf($lang['kb_posted_by'], '<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&u=' . $article['article_author']) . '">' . $article['article_authorname'] . '</a>', create_date($board_config['default_dateformat'], $article['article_time'], $board_config['board_timezone']), create_date($board_config['default_dateformat'], $article['article_edittime'], $board_config['board_timezone'])); + + $template->assign_vars(array( + 'U_VIEW_ARTICLE' => append_sid('kb.' . $phpEx . '?pid=view_article&cid=' . $cid . '&id=' . $article['article_id']), + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE_TEXT' => $article_text, + 'POSTED_BY' => $posted_by, + 'SIGNATURE' => $user_sig) + ); + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; case "ucp": Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/language/lang_english/lang_kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -21,6 +21,7 @@ // Page titles $lang['kb_main'] = "KnowledgeBase Home"; $lang['kb_viewcat'] = "Viewing Category"; +$lang['kb_viewarticle'] = "Viewing Article"; $lang['kb_ucp'] = "KB User Control Panel"; $lang['kb_ucp_articlepost'] = "Post new article"; $lang['kb_ucp_articleedit'] = "Edit article"; @@ -53,4 +54,5 @@ $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; $lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. $lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; +$lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-27 15:50:12
|
Revision: 25 http://svn.sourceforge.net/phpbbkb/?rev=25&view=rev Author: softphp Date: 2006-11-27 07:50:04 -0800 (Mon, 27 Nov 2006) Log Message: ----------- - Edit article now works as intended - Added navigation to the 2 ucp pages - Started on view article. Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/kb_install.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb/functions.php 2006-11-27 15:50:04 UTC (rev 25) @@ -32,6 +32,19 @@ { case "ucp": // Different kind of subcategories + switch($id_ary) + { + case "post_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article') . '">' . $lang['kb_ucp_articlepost'] .'</a></span>'; + break; + + case "edit_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article') . '">' . $lang['kb_ucp_articleedit'] .'</a></span>'; + break; + + default: + break; + } break; case "viewcat": Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb/ucp_class.php 2006-11-27 15:50:04 UTC (rev 25) @@ -29,6 +29,8 @@ var $action = ""; var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); var $html_entities_replace = array('&', '<', '>', '"'); + var $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); + var $unhtml_specialchars_replace = array('>', '<', '"', '&'); function generate_page($action, $id=0, $preview=false) { @@ -86,7 +88,7 @@ break; case "edit_article": - + $title .= ": " . $lang['kb_ucp_articleedit']; break; case "delete_article": @@ -119,6 +121,32 @@ if(!empty($HTTP_POST_VARS['post'])) { + if($mode == 'edit') + { + // Let's get the old article data + $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if (!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + // if user editing set status = 0, else set status = old status :) + if($userdata['user_id'] == $article_author) + { + $article_status = "0"; + } + else + { + $article_status = $article['article_status']; + } + } + // Add the new article // Make all the variables :) if ( !$board_config['allow_html'] ) @@ -151,8 +179,8 @@ $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; - $article_author = $userdata['user_id']; - $article_authorname = ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname']; + $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; + $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); $bbcode_uid = ''; $cat_id = $HTTP_POST_VARS['cats']; $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; @@ -162,35 +190,91 @@ if ( $error_msg == '' ) { $current_time = time(); - - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; - if (!$db->sql_query($sql)) + + if($mode == 'post') { - message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } - - $article_id = $db->sql_nextid(); - // Now make the categories - foreach($cat_id as $i => $cat) + else { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + if(!$article_id) + { + message_die(GENERAL_ERROR, 'No article to edit.'); + } + // First update the article table + $sql = "UPDATE " . KB_ARTICLES_TABLE . " + SET article_title = '$article_title', + article_desc = '$article_desc', + article_author = '$article_author', + article_authorname = '$article_authorname', + article_edittime = '$current_time', + article_editby = '" . $userdata['user_id'] . "', + article_status = '$article_status', + enable_sig = '$attach_sig', + enable_html = '$html_on', + enable_bbcode = '$bbcode_on', + enable_smilies = '$smilies_on', + article_text = '$message';"; + if (!$db->sql_query($sql)) { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); } - if (!$db->sql_query($sql2)) + // Now delete all articlecats + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); } + + // Last add them again doing the loop + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + // Message here somewhere } - - $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); - return; } } @@ -252,16 +336,7 @@ $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - - if($mode == "edit") - { - $hidden_form_fields = ""; - } - else - { - $hidden_form_fields = ""; - } - + $hidden_form_fields = ""; if($error_msg != "") { $template->set_filenames(array( @@ -288,7 +363,14 @@ message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); } - $article = $db->sql_fetchrow($result); + if($db->sql_numrows($result) == 1) + { + $article = $db->sql_fetchrow($result); + } + else + { + message_die(GENERAL_ERROR, "Article does not exist."); + } // Now make an array over the cats $sql = "SELECT cat_id @@ -317,9 +399,14 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = ""; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; } + if ( $article['bbcode_uid'] != '' ) + { + $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); + } + $article_text = str_replace('<', '<', $article_text); $article_text = str_replace('>', '>', $article_text); $article_text = str_replace('<br />', "\n", $article_text); @@ -423,6 +510,8 @@ 'body' => 'kb_article_posting.tpl') ); + create_navigation("ucp", $this->action); + // This is the template stuff we need no matter what $template->assign_vars(array( 'AUTHORNAME' => $authorname, @@ -550,7 +639,7 @@ function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) { - global $board_config, $html_entities_match, $html_entities_replace; + global $board_config, $phpEx; // // Clean up the message @@ -571,6 +660,9 @@ $message = ''; + // Include functions_post for clean_html + include($phpbb_root_path . "includes/functions_post." . $phpEx); + foreach ($message_split as $part) { $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); @@ -592,5 +684,10 @@ return $message; } + + function unprepare_message($message) + { + return preg_replace($this->unhtml_specialchars_match, $this->unhtml_specialchars_replace, $message); + } } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb.php 2006-11-27 15:50:04 UTC (rev 25) @@ -334,7 +334,7 @@ 'ARTICLE_AUTHOR' => $author, 'ARTICLE_HITS' => $articles[$i]['article_hits'], 'ARTICLE_LAST_ACTION' => $last_action, - 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) + 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=view_article&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) ); } } @@ -348,6 +348,22 @@ break; case "view_article": + $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; + $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + + if(!$cid || !$id) + { + message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); + } + break; case "ucp": Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb_install.php 2006-11-27 15:50:04 UTC (rev 25) @@ -71,6 +71,7 @@ article_hits mediumint(8) UNSIGNED DEFAULT '0', article_editby mediumint(8) UNSIGNED DEFAULT '0', article_status smallint(1) UNSIGNED DEFAULT '0', + bbcode_uid varcharr(10) NOT NULL, enable_sig smallint(1) UNSIGNED DEFAULT '0', enable_html smallint(1) UNSIGNED DEFAULT '0', enable_bbcode smallint(1) UNSIGNED DEFAULT '0', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-26 02:49:30
|
Revision: 24 http://svn.sourceforge.net/phpbbkb/?rev=24&view=rev Author: softphp Date: 2006-11-25 18:49:26 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Fairly big commit here: - Recoded the multiple categories part, and introducing a new database table. It works nice. - Corrected minor template mistake. - Corrected some other stuff in ucp_class.php, especially the categories part, now including a lot of loops, could it be done easier? TODO: - Edit Article <-- Yes I worked on it now, and the user interface part works, but the db works hasn't been done, so no testing has commenced. - Preview when posting <-- I'll add this after I've added the view article part I think. - View Article <-- Not a single line has been coded Modified Paths: -------------- root/kb/constants.php root/kb/ucp_class.php root/kb.php root/kb_install.php root/templates/subSilver/kb_viewcat.tpl Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb/constants.php 2006-11-26 02:49:26 UTC (rev 24) @@ -27,5 +27,6 @@ // DB Tables define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); +define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats ?> \ No newline at end of file Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb/ucp_class.php 2006-11-26 02:49:26 UTC (rev 24) @@ -163,15 +163,31 @@ { $current_time = time(); - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); } - + $article_id = $db->sql_nextid(); - + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); @@ -236,8 +252,16 @@ $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; + if($mode == "edit") + { + $hidden_form_fields = ""; + } + else + { + $hidden_form_fields = ""; + } + if($error_msg != "") { $template->set_filenames(array( @@ -251,15 +275,36 @@ } else { + if(empty($id)) + { + message_die(GENERAL_ERROR, "No article defined."); + } + $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE id = '" . $id . "'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); } + $article = $db->sql_fetchrow($result); + // Now make an array over the cats + $sql = "SELECT cat_id + FROM " . KB_ARTICLECATS_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); + } + + $article_cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $article_cats[] = $row; + } + $article_title = $article['article_title']; $article_text = $article['article_text']; $article_desc = $article['article_desc']; @@ -316,34 +361,47 @@ // Obtain categories structure $cats = get_cats_structure(); - // First lets sort main cats + // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($preview || $mode == "edit") + if($mode == "edit") { for($i = 0; $i < count($cats); $i++) { - $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; // Sort subcats for($j = 0; $j < count($cats[$i]['subcats']); $j++) { - $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; } } } else { - $var = ( $preview ) ? $HTTP_POST_VARS['cats'] : $article['cat_id']; for($i = 0; $i < count($cats); $i++) { - $selected = ( strstr($var, "," . $cats[$i]['cat_id'] . ",") ) ? ' selected' : ''; - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; // Sort subcats for($j = 0; $j < count($cats[$i]['subcats']); $j++) { - $selected = ( strstr($var, "," . $cats[$i]['subcats'][$j]['cat_id'] . ",") ) ? ' selected' : ''; - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; } } } @@ -483,12 +541,8 @@ } // Check categories - if(is_array($cat_id)) + if(!is_array($cat_id)) { - $cat_id = implode(",", $cat_id); - } - else - { $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; } return; Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb.php 2006-11-26 02:49:26 UTC (rev 24) @@ -188,29 +188,31 @@ { case "rating": // Later - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; case "author": // Later - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; case "title": - $sort = "ORDER BY article_title"; + $sort = "ORDER BY a.article_title"; break; case "time": default: - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; } } else { - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; } + // This has been removed due to probably not working + /* $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE cat_id LIKE '$cat_id' @@ -219,10 +221,21 @@ { message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql); } + */ + $sql = "SELECT a.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_ARTICLES_TABLE . " a + WHERE c.cat_id = '$cat_id' + AND c.article_id = a.article_id + $sort"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query articles.', '', __LINE__, __FILE__, $sql); + } + $articles = array(); while($row = $db->sql_fetchrow($result)) - { + { $articles[] = $row; } @@ -305,7 +318,7 @@ $sql = "SELECT username FROM " . USERS_TABLE . " - WHERE user_id = '" . $articles[$i]['article_editby']; + WHERE user_id = '" . $articles[$i]['article_editby'] . "'"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query last edited by\'s username.', '', __LINE__, __FILE__, $sql); Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb_install.php 2006-11-26 02:49:26 UTC (rev 24) @@ -62,7 +62,6 @@ $sql[] = "CREATE TABLE " . $table_prefix . "kb_articles ( article_id mediumint(8) UNSIGNED NOT NULL auto_increment, - cat_id varcharr(20) NOT NULL, article_title varchar(100) NOT NULL, article_desc varchar(255) NOT NULL, article_author mediumint(8) UNSIGNED NOT NULL, @@ -77,10 +76,14 @@ enable_bbcode smallint(1) UNSIGNED DEFAULT '0', enable_smilies smallint(1) UNSIGNED DEFAULT '0', article_text text, - PRIMARY KEY (article_id), - KEY cat_id (cat_id) + PRIMARY KEY (article_id) )"; +$sql[] = "CREATE TABLE " . $table_prefix . "kb_articlecats ( + article_id mediumint(8) NOT NULL DEFAULT '0', + cat_id mediumint(8) NOT NULL DEFAULT '0' +)"; + echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; echo '<tr><th>Updating the database</th></tr>'; Modified: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl 2006-11-24 14:46:46 UTC (rev 23) +++ root/templates/subSilver/kb_viewcat.tpl 2006-11-26 02:49:26 UTC (rev 24) @@ -46,7 +46,7 @@ </tr> <!-- END articlerow --> <tr> - <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td> + <td class="catBottom" align="center" valign="middle" colspan="5" height="28"> </td> </tr> </table> <!-- END switch_articles --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-24 14:46:51
|
Revision: 23 http://svn.sourceforge.net/phpbbkb/?rev=23&view=rev Author: softphp Date: 2006-11-24 06:46:46 -0800 (Fri, 24 Nov 2006) Log Message: ----------- - Added a lot of missing lang vars - Finished correcting the errors Mark pointed out - Posting articles now works, not completely though TODO: - Make cat_articles go one up when you create an article - Code support for edit article & preview article NOTE: - Still no permissions at all Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php root/templates/subSilver/kb_article_posting.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb/functions.php 2006-11-24 14:46:46 UTC (rev 23) @@ -37,7 +37,7 @@ case "viewcat": // View category // id = $cat_id::$cat_name - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewsubcat": @@ -51,7 +51,7 @@ message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); } $maincat = $db->sql_fetchrow($result); - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'$phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewarticle": @@ -64,7 +64,7 @@ case "main": default: - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; break; } @@ -117,7 +117,7 @@ // These vars we need for making html safe $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); $html_entities_replace = array('&', '<', '>', '"'); - +/* // // Prepare an article for the database // @@ -126,6 +126,7 @@ global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; // Check title + $article_title = "BLABLA"; if (!empty($article_title)) { $article_title = htmlspecialchars(trim($article_title)); @@ -146,9 +147,20 @@ $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; } + // Check Desc + if (!empty($article_desc)) + { + $article_desc = htmlspecialchars(trim($article_desc)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; + } + // Check categories - if(!empty($cat_id) && count($cat_id) > 0) + if(is_array($cat_id)) { + print_r($cat_id); $cat_id = implode(",", $cat_id); } else @@ -202,4 +214,5 @@ return $message; } +*/ ?> \ No newline at end of file Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb/ucp_class.php 2006-11-24 14:46:46 UTC (rev 23) @@ -27,6 +27,8 @@ class ucp { var $action = ""; + var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + var $html_entities_replace = array('&', '<', '>', '"'); function generate_page($action, $id=0, $preview=false) { @@ -113,6 +115,7 @@ global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; $error_msg = ''; + $user_sig = $userdata['user_sig']; if(!empty($HTTP_POST_VARS['post'])) { @@ -124,7 +127,7 @@ } else { - $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE; + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; } if ( !$board_config['allow_bbcode'] ) @@ -133,7 +136,7 @@ } else { - $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE; + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; } if ( !$board_config['allow_smilies'] ) @@ -142,26 +145,26 @@ } else { - $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE; + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; } - $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? $HTTP_POST_VARS['desc'] : ''; + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; $article_author = $userdata['user_id']; $article_authorname = ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname']; $bbcode_uid = ''; $cat_id = $HTTP_POST_VARS['cats']; - $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; - prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); - + $this->prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + if ( $error_msg == '' ) { $current_time = time(); - $sql = "INSERT INTO" . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbode, enable_smilies, article_text) VALUES - ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$enable_sig', '$enable_html', '$enable_bbcode', '$enable_smilies', '$message');"; + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); @@ -169,19 +172,21 @@ $article_id = $db->sql_nextid(); - $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.'.$phpEx.'?pid=view_article&id=' . $article_id) . '>"'; - $message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.'.$phpEx.'?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.'.$phpEx.'?pid=ucp') . '">', '</a>'); + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + + return; } } $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; - if($mode == "post" && !$preview) + if($mode == "post" && !$preview && $error_msg == '') { $article_title = ''; $article_text = ''; $article_desc = ''; $authorname = $userdata['username']; - $form_action = append_sid('kb.'.$phpEx.'?pid=ucp&action=post_article'); + $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); $hidden_form_fields = ""; $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; @@ -217,7 +222,7 @@ // Do funny preview stuff } } - elseif($preview) + elseif($preview || $error_msg != '') { $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; @@ -230,8 +235,19 @@ $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); $hidden_form_fields = ""; + + if($error_msg != "") + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } } else { @@ -255,7 +271,7 @@ $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; $smilies_on = ( $article['enable_smilies'] ) ? true : false; - $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); $hidden_form_fields = ""; } @@ -354,8 +370,9 @@ 'AUTHORNAME' => $authorname, 'ARTICLE_TITLE' => $article_title, 'ARTICLE' => $article_text, + 'DESC' => $article_desc, 'HTML_STATUS' => $html_status, - 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_POST_ARTICLE' => $lang['kb_post_article'], @@ -426,5 +443,100 @@ 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) ); } + + // + // Prepare an article for the database + // + function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) + { + global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; + + // Check title + if (!empty($article_title)) + { + $article_title = htmlspecialchars(trim($article_title)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; + } + + // Check message + if(!empty($message)) + { + $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; + $message = $this->prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; + } + + // Check Desc + if (!empty($article_desc)) + { + $article_desc = htmlspecialchars(trim($article_desc)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; + } + + // Check categories + if(is_array($cat_id)) + { + $cat_id = implode(",", $cat_id); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; + } + return; + } + + function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) + { + global $board_config, $html_entities_match, $html_entities_replace; + + // + // Clean up the message + // + $message = trim($message); + + if ($html_on) + { + // If HTML is on, we try to make it safe + // This approach is quite agressive and anything that does not look like a valid tag + // is going to get converted to HTML entities + $message = stripslashes($message); + $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; + $matches = array(); + + $message_split = preg_split($html_match, $message); + preg_match_all($html_match, $message, $matches); + + $message = ''; + + foreach ($message_split as $part) + { + $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); + $message .= preg_replace($this->html_entities_match, $this->html_entities_replace, $part) . clean_html($tag); + } + + $message = addslashes($message); + $message = str_replace('"', '\"', $message); + } + else + { + $message = preg_replace($this->html_entities_match, $this->html_entities_replace, $message); + } + + if($bbcode_on && $bbcode_uid != '') + { + $message = bbencode_first_pass($message, $bbcode_uid); + } + + return $message; + } } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb.php 2006-11-24 14:46:46 UTC (rev 23) @@ -23,6 +23,7 @@ include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'kb/constants.' . $phpEx); // Added these two files, yes i could just add the 10-15 lines it will end with in include($phpbb_root_path . 'kb/functions.' . $phpEx); // the existing files, but this makes it a lot easier to install/uninstall. +include($phpbb_root_path . 'includes/bbcode.'.$phpEx); // // Start session management @@ -71,7 +72,7 @@ // Start Page output $page_title = $lang['kb_main']; - include($phpbb_root_path . 'includes/page_header.'.$phpEx); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); create_navigation(); $template->set_filenames(array( @@ -92,7 +93,7 @@ 'CAT_TITLE' => $catrows[$i]['cat_title'], 'CAT_DESC' => $catrows[$i]['cat_desc'], 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), 'L_SUBCATS' => $lang['kb_subcats'], 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D ); @@ -124,7 +125,7 @@ $k = $j + 1; $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; $template->assign_block_vars('catrow.subcatrow', array( - 'U_SUBCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], 'SUBCAT_COMMA' => $subcat_comma) ); @@ -270,7 +271,7 @@ 'CAT_TITLE' => $subcats[$i]['cat_title'], 'CAT_DESC' => $subcats[$i]['cat_desc'], 'CAT_ARTICLES' => $subcats[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$i]['cat_id']), + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$i]['cat_id']), 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D ); } @@ -300,7 +301,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; $sql = "SELECT username FROM " . USERS_TABLE . " @@ -311,7 +312,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -320,7 +321,7 @@ 'ARTICLE_AUTHOR' => $author, 'ARTICLE_HITS' => $articles[$i]['article_hits'], 'ARTICLE_LAST_ACTION' => $last_action, - 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) + 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) ); } } @@ -338,12 +339,12 @@ case "ucp": $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; - include($phpbb_root_path . "kb/ucp_class.$phpEx"); + include($phpbb_root_path . "kb/ucp_class." . $phpEx); $ucp = new ucp; // Start Page output $page_title = $ucp->generate_page_title($action); - include($phpbb_root_path . 'includes/page_header.'.$phpEx); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb_install.php 2006-11-24 14:46:46 UTC (rev 23) @@ -62,7 +62,7 @@ $sql[] = "CREATE TABLE " . $table_prefix . "kb_articles ( article_id mediumint(8) UNSIGNED NOT NULL auto_increment, - cat_id mediumint(8) UNSIGNED DEFAULT '0', + cat_id varcharr(20) NOT NULL, article_title varchar(100) NOT NULL, article_desc varchar(255) NOT NULL, article_author mediumint(8) UNSIGNED NOT NULL, Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/language/lang_english/lang_kb.php 2006-11-24 14:46:46 UTC (rev 23) @@ -46,4 +46,11 @@ $lang['kb_articletext'] = "Article Content"; $lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; $lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use ctrl + click for multiple."; +$lang['kb_empty_article'] = "The article content you have submitted was empty."; +$lang['kb_empty_article_title'] = "The article title you submitted was empty."; +$lang['kb_empty_cats'] = "The article you submitted had no category defined."; +$lang['kb_empty_article_desc'] = "The article has to contain an article description."; +$lang['kb_added'] = "Your article has been submitted and is awaiting approval."; +$lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. +$lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; ?> \ No newline at end of file Modified: root/templates/subSilver/kb_article_posting.tpl =================================================================== --- root/templates/subSilver/kb_article_posting.tpl 2006-11-24 03:21:02 UTC (rev 22) +++ root/templates/subSilver/kb_article_posting.tpl 2006-11-24 14:46:46 UTC (rev 23) @@ -265,7 +265,7 @@ </tr> <tr> <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_CATS}</b></span><br /><span class="gensmall">{L_ARTICLECATS_DESC}</span></td> - <td class="row2" width="78%"><select name="cats" size="4" multiple="multiple" id="cats"> + <td class="row2" width="78%"><select name="cats[]" size="4" multiple="multiple" id="cats"> {CATS_HTML} </select> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-11-24 03:21:03
|
Revision: 22 http://svn.sourceforge.net/phpbbkb/?rev=22&view=rev Author: markthedaemon Date: 2006-11-23 19:21:02 -0800 (Thu, 23 Nov 2006) Log Message: ----------- Couple of cleanup points: - Replaced & with & - Changed ("kb.$phpEx"); to ('kb'.$phpEx); (the proper syntax. TODO: - Need to check SQL injection in the ucp_class.php page. - Need to finish cleaning up the & and $phpEx. - Anything else i can think of... Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-24 00:27:20 UTC (rev 21) +++ root/kb/functions.php 2006-11-24 03:21:02 UTC (rev 22) @@ -37,7 +37,7 @@ case "viewcat": // View category // id = $cat_id::$cat_name - $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewsubcat": @@ -51,7 +51,7 @@ message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); } $maincat = $db->sql_fetchrow($result); - $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.'$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'$phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewarticle": @@ -64,7 +64,7 @@ case "main": default: - $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; break; } @@ -154,7 +154,7 @@ else { $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; - + } return; } Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-24 00:27:20 UTC (rev 21) +++ root/kb/ucp_class.php 2006-11-24 03:21:02 UTC (rev 22) @@ -169,8 +169,8 @@ $article_id = $db->sql_nextid(); - $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("kb.$phpEx?pid=view_article&id=" . $article_id) . '>"'; - $message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid("kb.$phpEx?pid=view_article&id=" . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid("kb.$phpEx?pid=ucp") . '">', '</a>'); + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.'.$phpEx.'?pid=view_article&id=' . $article_id) . '>"'; + $message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.'.$phpEx.'?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.'.$phpEx.'?pid=ucp') . '">', '</a>'); } } @@ -181,7 +181,7 @@ $article_text = ''; $article_desc = ''; $authorname = $userdata['username']; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $form_action = append_sid('kb.'.$phpEx.'?pid=ucp&action=post_article'); $hidden_form_fields = ""; $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |