|
From: Jon O. <jon...@us...> - 2005-04-12 21:11:49
|
Update of /cvsroot/mxbb/mx_kb/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30151/modules/mx_kb/includes Modified Files: functions_kb_auth.php functions_kb_mx.php Log Message: i have renamed mx_auth_group_cache to mx_auth_group and removed old function with shorter name ;) ...to make it clearer Index: functions_kb_auth.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/includes/functions_kb_auth.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions_kb_auth.php 4 Feb 2005 23:44:31 -0000 1.1 --- functions_kb_auth.php 12 Apr 2005 21:11:31 -0000 1.2 *************** *** 1,278 **** ! <?php ! ! /** ------------------------------------------------------------------------ ! * subject : mx-portal module ! * begin : june, 2002 ! * copyright : (C) 2002-2005 MX-System ! * email : jon...@ho... ! * project site : www.mx-system.com ! * ! * description : ! * ! */ ! ! /** ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! */ ! ! if ( !defined( 'IN_PORTAL' ) ) ! { ! die( 'Hacking attempt' ); ! } ! ! function kb_auth( $type, $cat_id, $userdata, $f_access = '', $f_access_group = '' ) ! { ! global $db, $lang; ! ! switch ( $type ) ! { ! case AUTH_ALL: ! $a_sql = 'a.auth_view, a.auth_post, a.auth_rate, a.auth_comment, a.auth_edit, a.auth_delete, a.auth_approval, a.auth_approval_edit'; ! $a_sql_groups = 'a.auth_view_groups, a.auth_post_groups, a.auth_rate_groups, a.auth_comment_groups, a.auth_edit_groups, a.auth_delete_groups, a.auth_approval_groups, a.auth_approval_edit_groups'; ! $auth_fields = array( 'auth_view', 'auth_post', 'auth_rate', 'auth_comment', 'auth_edit', 'auth_delete', 'auth_approval', 'auth_approval_edit' ); ! $auth_fields_groups = array( 'auth_view_groups', 'auth_post_groups', 'auth_rate_groups', 'auth_comment_groups', 'auth_edit_groups', 'auth_delete_groups', 'auth_approval_groups', 'auth_approval_edit_groups' ); ! break; ! ! case AUTH_VIEW: ! $a_sql = 'a.auth_view'; ! $a_sql_groups = 'a.auth_view_groups'; ! $auth_fields = array( 'auth_view' ); ! $auth_fields_groups = array( 'auth_view_groups' ); ! break; ! ! case AUTH_POST: ! $a_sql = 'a.auth_post'; ! $a_sql_groups = 'a.auth_post_groups'; ! $auth_fields = array( 'auth_post' ); ! $auth_fields_groups = array( 'auth_post_groups' ); ! break; ! ! case AUTH_RATE: ! $a_sql = 'a.auth_rate'; ! $a_sql_groups = 'a.auth_rate_groups'; ! $auth_fields = array( 'auth_rate' ); ! $auth_fields_groups = array( 'auth_rate_groups' ); ! break; ! ! case AUTH_COMMENT: ! $a_sql = 'a.auth_comment'; ! $a_sql_groups = 'a.auth_comment_groups'; ! $auth_fields = array( 'auth_comment' ); ! $auth_fields_groups = array( 'auth_comment_groups' ); ! break; ! ! case AUTH_EDIT: ! $a_sql = 'a.auth_edit'; ! $a_sql_groups = 'a.auth_edit_groups'; ! $auth_fields = array( 'auth_edit' ); ! $auth_fields_groups = array( 'auth_edit_groups' ); ! break; ! ! case AUTH_DELETE: ! $a_sql = 'a.auth_delete'; ! $a_sql_groups = 'a.auth_delete_groups'; ! $auth_fields = array( 'auth_delete' ); ! $auth_fields_groups = array( 'auth_delete_groups' ); ! break; ! ! case AUTH_APPROVAL: ! $a_sql = 'a.auth_approval'; ! $a_sql_groups = 'a.auth_approval_groups'; ! $auth_fields = array( 'auth_approval' ); ! $auth_fields_groups = array( 'auth_approval_groups' ); ! break; ! ! case AUTH_APPROVAL_EDIT: ! $a_sql = 'a.auth_approval_edit'; ! $a_sql_groups = 'a.auth_approval_edit_groups'; ! $auth_fields = array( 'auth_approval_edit' ); ! $auth_fields_groups = array( 'auth_approval_edit_groups' ); ! break; ! ! default: ! break; ! } ! ! $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? true : 0; ! ! // ! // If f_access has not been passed, or auth is needed to return an array of forums ! // then we need to pull the auth information on the given forum (or all forums) ! // ! if ( empty($f_access) ) ! { ! $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; ! ! $sql = "SELECT a.category_id, $a_sql ! FROM " . KB_CATEGORIES_TABLE . " a ! $forum_match_sql"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); ! } ! ! $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; ! ! if ( !($f_access = $db->$sql_fetchrow($result)) ) ! { ! $db->sql_freeresult($result); ! return array(); ! } ! $db->sql_freeresult($result); ! } ! ! // ! // If f_access_group has not been passed, or auth is needed to return an array of forums ! // then we need to pull the auth information on the given forum (or all forums) ! // ! if ( empty($f_access_group) ) ! { ! $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; ! ! $sql = "SELECT a.category_id, $a_sql_groups, a.auth_moderator_groups ! FROM " . KB_CATEGORIES_TABLE . " a ! $forum_match_sql"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); ! } ! ! $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; ! ! if ( !($f_access_group = $db->$sql_fetchrow($result)) ) ! { ! $db->sql_freeresult($result); ! return array(); ! } ! $db->sql_freeresult($result); ! } ! ! $auth_user = array(); ! for( $i = 0; $i < count( $auth_fields ); $i++ ) ! { ! $key = $auth_fields[$i]; ! $key_groups = $auth_fields_groups[$i]; ! // If the user is logged on and the module 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 modules. We assume here that a moderator ! // and admin automatically have access to an ACL module, similarly we assume admins meet an ! // auth requirement of MOD ! ! if ( $cat_id != AUTH_LIST_ALL ) ! { ! $value = $f_access[$key]; ! $value_groups = $f_access_group[$key_groups]; ! ! switch ( $value ) ! { ! case AUTH_ALL: ! $auth_user[$key] = true; ! $auth_user[$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_ANONYMOUS: ! $auth_user[$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_ACL: // PRIVATE ! $auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $value_groups ) || $is_admin : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Users_granted_access']; ! break; ! ! case AUTH_MOD: ! $auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Moderators']; ! break; ! ! case AUTH_ADMIN: ! $auth_user[$key] = $is_admin; ! $auth_user[$key . '_type'] = $lang['Auth_Administrators']; ! break; ! ! default: ! $auth_user[$key] = 0; ! break; ! } ! } ! else ! { ! for($k = 0; $k < count($f_access); $k++) ! { ! $value = $f_access[$k][$key]; ! $value_groups = $f_access_group[$k][$key_groups]; ! ! $f_cat_id = $f_access[$k]['category_id']; ! ! ! switch ( $value ) ! { ! case AUTH_ALL: ! $auth_user[$f_cat_id][$key] = true; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_REG: ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Registered_Users']; ! break; ! ! case AUTH_ANONYMOUS: ! $auth_user[$f_cat_id][$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_ACL: // PRIVATE ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $value_groups ) || $is_admin : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Users_granted_access']; ! break; ! ! case AUTH_MOD: ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Moderators']; ! break; ! ! case AUTH_ADMIN: ! $auth_user[$f_cat_id][$key] = $is_admin; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Administrators']; ! break; ! ! default: ! $auth_user[$f_cat_id][$key] = 0; ! break; ! } ! } ! } ! } ! ! // ! // Is user a moderator? ! // ! if ( $cat_id != AUTH_LIST_ALL ) ! { ! $auth_user['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; ! } ! else ! { ! for($k = 0; $k < count($f_access); $k++) ! { ! $f_cat_id = $f_access[$k]['category_id']; ! ! $auth_user[$f_cat_id]['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_auth_group_cache( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; ! } ! } ! //die(var_export($auth_user)); ! return $auth_user; ! } ! ?> \ No newline at end of file --- 1,278 ---- ! <?php ! ! /** ------------------------------------------------------------------------ ! * subject : mx-portal module ! * begin : june, 2002 ! * copyright : (C) 2002-2005 MX-System ! * email : jon...@ho... ! * project site : www.mx-system.com ! * ! * description : ! * ! */ ! ! /** ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! */ ! ! if ( !defined( 'IN_PORTAL' ) ) ! { ! die( 'Hacking attempt' ); ! } ! ! function kb_auth( $type, $cat_id, $userdata, $f_access = '', $f_access_group = '' ) ! { ! global $db, $lang; ! ! switch ( $type ) ! { ! case AUTH_ALL: ! $a_sql = 'a.auth_view, a.auth_post, a.auth_rate, a.auth_comment, a.auth_edit, a.auth_delete, a.auth_approval, a.auth_approval_edit'; ! $a_sql_groups = 'a.auth_view_groups, a.auth_post_groups, a.auth_rate_groups, a.auth_comment_groups, a.auth_edit_groups, a.auth_delete_groups, a.auth_approval_groups, a.auth_approval_edit_groups'; ! $auth_fields = array( 'auth_view', 'auth_post', 'auth_rate', 'auth_comment', 'auth_edit', 'auth_delete', 'auth_approval', 'auth_approval_edit' ); ! $auth_fields_groups = array( 'auth_view_groups', 'auth_post_groups', 'auth_rate_groups', 'auth_comment_groups', 'auth_edit_groups', 'auth_delete_groups', 'auth_approval_groups', 'auth_approval_edit_groups' ); ! break; ! ! case AUTH_VIEW: ! $a_sql = 'a.auth_view'; ! $a_sql_groups = 'a.auth_view_groups'; ! $auth_fields = array( 'auth_view' ); ! $auth_fields_groups = array( 'auth_view_groups' ); ! break; ! ! case AUTH_POST: ! $a_sql = 'a.auth_post'; ! $a_sql_groups = 'a.auth_post_groups'; ! $auth_fields = array( 'auth_post' ); ! $auth_fields_groups = array( 'auth_post_groups' ); ! break; ! ! case AUTH_RATE: ! $a_sql = 'a.auth_rate'; ! $a_sql_groups = 'a.auth_rate_groups'; ! $auth_fields = array( 'auth_rate' ); ! $auth_fields_groups = array( 'auth_rate_groups' ); ! break; ! ! case AUTH_COMMENT: ! $a_sql = 'a.auth_comment'; ! $a_sql_groups = 'a.auth_comment_groups'; ! $auth_fields = array( 'auth_comment' ); ! $auth_fields_groups = array( 'auth_comment_groups' ); ! break; ! ! case AUTH_EDIT: ! $a_sql = 'a.auth_edit'; ! $a_sql_groups = 'a.auth_edit_groups'; ! $auth_fields = array( 'auth_edit' ); ! $auth_fields_groups = array( 'auth_edit_groups' ); ! break; ! ! case AUTH_DELETE: ! $a_sql = 'a.auth_delete'; ! $a_sql_groups = 'a.auth_delete_groups'; ! $auth_fields = array( 'auth_delete' ); ! $auth_fields_groups = array( 'auth_delete_groups' ); ! break; ! ! case AUTH_APPROVAL: ! $a_sql = 'a.auth_approval'; ! $a_sql_groups = 'a.auth_approval_groups'; ! $auth_fields = array( 'auth_approval' ); ! $auth_fields_groups = array( 'auth_approval_groups' ); ! break; ! ! case AUTH_APPROVAL_EDIT: ! $a_sql = 'a.auth_approval_edit'; ! $a_sql_groups = 'a.auth_approval_edit_groups'; ! $auth_fields = array( 'auth_approval_edit' ); ! $auth_fields_groups = array( 'auth_approval_edit_groups' ); ! break; ! ! default: ! break; ! } ! ! $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? true : 0; ! ! // ! // If f_access has not been passed, or auth is needed to return an array of forums ! // then we need to pull the auth information on the given forum (or all forums) ! // ! if ( empty($f_access) ) ! { ! $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; ! ! $sql = "SELECT a.category_id, $a_sql ! FROM " . KB_CATEGORIES_TABLE . " a ! $forum_match_sql"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); ! } ! ! $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; ! ! if ( !($f_access = $db->$sql_fetchrow($result)) ) ! { ! $db->sql_freeresult($result); ! return array(); ! } ! $db->sql_freeresult($result); ! } ! ! // ! // If f_access_group has not been passed, or auth is needed to return an array of forums ! // then we need to pull the auth information on the given forum (or all forums) ! // ! if ( empty($f_access_group) ) ! { ! $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; ! ! $sql = "SELECT a.category_id, $a_sql_groups, a.auth_moderator_groups ! FROM " . KB_CATEGORIES_TABLE . " a ! $forum_match_sql"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); ! } ! ! $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; ! ! if ( !($f_access_group = $db->$sql_fetchrow($result)) ) ! { ! $db->sql_freeresult($result); ! return array(); ! } ! $db->sql_freeresult($result); ! } ! ! $auth_user = array(); ! for( $i = 0; $i < count( $auth_fields ); $i++ ) ! { ! $key = $auth_fields[$i]; ! $key_groups = $auth_fields_groups[$i]; ! // If the user is logged on and the module 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 modules. We assume here that a moderator ! // and admin automatically have access to an ACL module, similarly we assume admins meet an ! // auth requirement of MOD ! ! if ( $cat_id != AUTH_LIST_ALL ) ! { ! $value = $f_access[$key]; ! $value_groups = $f_access_group[$key_groups]; ! ! switch ( $value ) ! { ! case AUTH_ALL: ! $auth_user[$key] = true; ! $auth_user[$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_ANONYMOUS: ! $auth_user[$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_ACL: // PRIVATE ! $auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $value_groups ) || $is_admin : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Users_granted_access']; ! break; ! ! case AUTH_MOD: ! $auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; ! $auth_user[$key . '_type'] = $lang['Auth_Moderators']; ! break; ! ! case AUTH_ADMIN: ! $auth_user[$key] = $is_admin; ! $auth_user[$key . '_type'] = $lang['Auth_Administrators']; ! break; ! ! default: ! $auth_user[$key] = 0; ! break; ! } ! } ! else ! { ! for($k = 0; $k < count($f_access); $k++) ! { ! $value = $f_access[$k][$key]; ! $value_groups = $f_access_group[$k][$key_groups]; ! ! $f_cat_id = $f_access[$k]['category_id']; ! ! ! switch ( $value ) ! { ! case AUTH_ALL: ! $auth_user[$f_cat_id][$key] = true; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_REG: ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Registered_Users']; ! break; ! ! case AUTH_ANONYMOUS: ! $auth_user[$f_cat_id][$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; ! break; ! ! case AUTH_ACL: // PRIVATE ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $value_groups ) || $is_admin : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Users_granted_access']; ! break; ! ! case AUTH_MOD: ! $auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Moderators']; ! break; ! ! case AUTH_ADMIN: ! $auth_user[$f_cat_id][$key] = $is_admin; ! $auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Administrators']; ! break; ! ! default: ! $auth_user[$f_cat_id][$key] = 0; ! break; ! } ! } ! } ! } ! ! // ! // Is user a moderator? ! // ! if ( $cat_id != AUTH_LIST_ALL ) ! { ! $auth_user['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; ! } ! else ! { ! for($k = 0; $k < count($f_access); $k++) ! { ! $f_cat_id = $f_access[$k]['category_id']; ! ! $auth_user[$f_cat_id]['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_auth_group( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; ! } ! } ! //die(var_export($auth_user)); ! return $auth_user; ! } ! ?> \ No newline at end of file Index: functions_kb_mx.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/includes/functions_kb_mx.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** functions_kb_mx.php 9 Apr 2005 21:41:28 -0000 1.3 --- functions_kb_mx.php 12 Apr 2005 21:11:32 -0000 1.4 *************** *** 1,469 **** ! <?php ! /** ------------------------------------------------------------------------ ! * subject : mx-portal, CMS & portal ! * begin : june, 2002 ! * copyright : (C) 2002-2005 MX-System ! * email : jon...@ho... ! * project site : www.mx-system.com ! * ! * description : ! * ------------------------------------------------------------------------- ! * ! * $Id$ ! */ ! ! /** ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License', or ! * ('at your option) any later version. ! */ ! ! if ( !function_exists( mx_smilies_pass ) ) ! { ! function mx_smilies_pass($message) ! { ! global $board_config; ! $smilies_path = $board_config['smilies_path']; ! $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; ! $message = smilies_pass($message); ! $board_config['smilies_path'] = $smilies_path; ! return $message; ! } ! } ! ! if ( !function_exists( mx_generate_smilies ) ) ! { ! function mx_generate_smilies($mode, $page_id) ! { ! global $board_config, $template, $phpEx; ! $smilies_path = $board_config['smilies_path']; ! $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; ! generate_smilies($mode, $page_id); ! $board_config['smilies_path'] = $smilies_path; ! $template->assign_vars(array( ! 'U_MORE_SMILIES' => append_sid(PHPBB_URL . "posting.$phpEx?mode=smilies")) ! ); ! } ! } ! ! if ( !function_exists( mx_message_die ) ) ! { ! ! function mx_message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '') ! { ! global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images; ! global $userdata, $user_ip, $session_length; ! global $starttime; ! ! message_die($msg_code, $msg_text, $msg_title, $err_line, $err_file, $sql); ! } ! ! } ! ! if ( !function_exists( mx_auth_group_cache ) ) ! { ! // Validates if user belongs to group included in group_ids list ! // Also, adds all usergroups to userdata array ! function mx_auth_group_cache( $group_ids = '', $group_mod_mode = false ) ! { ! global $userdata, $db; ! ! if ( $group_ids == '' ) ! { ! return false; ! } ! ! $group_ids_array = explode(",", $group_ids); ! ! // Try to reuse usergroups result. ! if ( $group_mod_mode ) ! { ! $userdata_key = 'mx_usergroups_mod' . $userdata['user_id']; ! ! if ( empty( $userdata[$userdata_key] ) ) ! { ! // Check if user is group moderator.. ! $sql = "SELECT gr.group_id ! FROM " . GROUPS_TABLE . " gr, ! " . USER_GROUP_TABLE . " ugr ! WHERE gr.group_id = ugr.group_id ! AND gr.group_moderator = '" . $userdata['user_id'] . "' ! AND ugr.user_pending = '0' "; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); ! } ! ! $group_row = $db->sql_fetchrowset( $result ); ! ! $userdata[$userdata_key_mod] = $group_row; ! } ! } ! else ! { ! $userdata_key = 'mx_usergroups' . $userdata['user_id']; ! ! if ( empty( $userdata[$userdata_key] ) ) ! { ! // Check if user is member of the proper group.. ! $sql = "SELECT group_id FROM " . USER_GROUP_TABLE . " WHERE user_id='" . $userdata['user_id'] . "' AND user_pending = 0"; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); ! } ! ! $group_row = $db->sql_fetchrowset( $result ); ! ! $userdata[$userdata_key] = $group_row; ! } ! } ! ! for ( $i = 0; $i < count( $userdata[$userdata_key] ); $i++ ) ! { ! if ( in_array( $userdata[$userdata_key][$i]['group_id'], $group_ids_array ) ) ! { ! $is_member = true; ! return $is_member; ! } ! } ! ! return false; ! } ! } ! ! if ( !function_exists( mx_add_search_words ) ) ! { ! // Add search words for blocks ! function mx_add_search_words($mode, $post_id, $post_text, $post_title = '', $mx_mode = 'mx') ! { ! global $db, $phpbb_root_path, $board_config, $lang; ! ! // $search_match_table = SEARCH_MATCH_TABLE; ! // $search_word_table = SEARCH_WORD_TABLE; ! ! switch ( $mx_mode ) ! { ! case 'mx': ! $search_match_table = MX_MATCH_TABLE; ! $search_word_table = MX_WORD_TABLE; ! $db_key = 'block_id'; ! break; ! case 'kb': ! $search_match_table = KB_MATCH_TABLE; ! $search_word_table = KB_WORD_TABLE; ! $db_key = 'article_id'; ! break; ! } ! ! $stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_stopwords.txt"); ! $synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_synonyms.txt"); ! ! $search_raw_words = array(); ! $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array)); ! $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array)); ! ! @set_time_limit(0); ! ! $word = array(); ! $word_insert_sql = array(); ! while ( list($word_in, $search_matches) = @each($search_raw_words) ) ! { ! $word_insert_sql[$word_in] = ''; ! if ( !empty($search_matches) ) ! { ! for ($i = 0; $i < count($search_matches); $i++) ! { ! $search_matches[$i] = trim($search_matches[$i]); ! ! if( $search_matches[$i] != '' ) ! { ! $word[] = $search_matches[$i]; ! if ( !strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'") ) ! { ! $word_insert_sql[$word_in] .= ( $word_insert_sql[$word_in] != "" ) ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'"; ! } ! } ! } ! } ! } ! ! if ( count($word) ) ! { ! sort($word); ! ! $prev_word = ''; ! $word_text_sql = ''; ! $temp_word = array(); ! for($i = 0; $i < count($word); $i++) ! { ! if ( $word[$i] != $prev_word ) ! { ! $temp_word[] = $word[$i]; ! $word_text_sql .= ( ( $word_text_sql != '' ) ? ', ' : '' ) . "'" . $word[$i] . "'"; ! } ! $prev_word = $word[$i]; ! } ! $word = $temp_word; ! ! $check_words = array(); ! switch( SQL_LAYER ) ! { ! case 'postgresql': ! case 'msaccess': ! case 'mssql-odbc': ! case 'oracle': ! case 'db2': ! $sql = "SELECT word_id, word_text ! FROM " . $search_word_table . " ! WHERE word_text IN ($word_text_sql)"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not select words', '', __LINE__, __FILE__, $sql); ! } ! ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $check_words[$row['word_text']] = $row['word_id']; ! } ! break; ! } ! ! $value_sql = ''; ! $match_word = array(); ! for ($i = 0; $i < count($word); $i++) ! { ! $new_match = true; ! if ( isset($check_words[$word[$i]]) ) ! { ! $new_match = false; ! } ! ! if ( $new_match ) ! { ! switch( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\', 0)'; ! break; ! case 'mssql': ! case 'mssql-odbc': ! $value_sql .= ( ( $value_sql != '' ) ? ' UNION ALL ' : '' ) . "SELECT '" . $word[$i] . "', 0"; ! break; ! default: ! $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) ! VALUES ('" . $word[$i] . "', 0)"; ! if( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); ! } ! break; ! } ! } ! } ! ! if ( $value_sql != '' ) ! { ! switch ( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $sql = "INSERT IGNORE INTO " . $search_word_table . " (word_text, word_common) ! VALUES $value_sql"; ! break; ! case 'mssql': ! case 'mssql-odbc': ! $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) ! $value_sql"; ! break; ! } ! ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! ! while( list($word_in, $match_sql) = @each($word_insert_sql) ) ! { ! $title_match = ( $word_in == 'title' ) ? 1 : 0; ! ! if ( $match_sql != '' ) ! { ! $sql = "INSERT INTO " . $search_match_table . " ($db_key, word_id, title_match) ! SELECT $post_id, word_id, $title_match ! FROM " . $search_word_table . " ! WHERE word_text IN ($match_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! ! if ($mode == 'single') ! { ! // remove_common('single', 4/10, $word); ! } ! ! return; ! } ! ! function mx_remove_search_post($post_id_sql, $mx_mode = 'mx') ! { ! global $db; ! ! // $search_match_table = SEARCH_MATCH_TABLE; ! // $search_word_table = SEARCH_WORD_TABLE; ! ! switch ( $mx_mode ) ! { ! case 'mx': ! $search_match_table = MX_MATCH_TABLE; ! $search_word_table = MX_WORD_TABLE; ! $db_key = 'block_id'; ! break; ! case 'kb': ! $search_match_table = KB_MATCH_TABLE; ! $search_word_table = KB_WORD_TABLE; ! $db_key = 'article_id'; ! break; ! } ! ! $words_removed = false; ! ! switch ( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $sql = "SELECT word_id ! FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql) ! GROUP BY word_id"; ! if ( $result = $db->sql_query($sql) ) ! { ! $word_id_sql = ''; ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; ! } ! ! $sql = "SELECT word_id ! FROM " . $search_match_table . " ! WHERE word_id IN ($word_id_sql) ! GROUP BY word_id ! HAVING COUNT(word_id) = 1"; ! if ( $result = $db->sql_query($sql) ) ! { ! $word_id_sql = ''; ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; ! } ! ! if ( $word_id_sql != '' ) ! { ! $sql = "DELETE FROM " . $search_word_table . " ! WHERE word_id IN ($word_id_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql); ! } ! ! $words_removed = $db->sql_affectedrows(); ! } ! } ! } ! break; ! ! default: ! $sql = "DELETE FROM " . $search_word_table . " ! WHERE word_id IN ( ! SELECT word_id ! FROM " . $search_match_table . " ! WHERE word_id IN ( ! SELECT word_id ! FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql) ! GROUP BY word_id ! ) ! GROUP BY word_id ! HAVING COUNT(word_id) = 1 ! )"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql); ! } ! ! $words_removed = $db->sql_affectedrows(); ! ! break; ! } ! ! $sql = "DELETE FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); ! } ! ! return $words_removed; ! } ! } ! ! if ( !function_exists(mx_do_install_upgrade) ) ! { ! // Generating output ! ! function mx_do_install_upgrade( $sql = '', $main_install = false ) ! { ! global $table_prefix, $mx_table_prefix, $userdata, $phpEx, $template, $lang, $db, $board_config, $HTTP_POST_VARS; ! ! $inst_error = false; ! $n = 0; ! $message = "<b>This is the result list of the SQL queries needed for the install/upgrade</b><br /><br />"; ! ! while ( $sql[$n] ) ! { ! if ( !$result = $db->sql_query( $sql[$n] ) ) ! { ! $message .= '<b><font color=#FF0000>[Error or Already added]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; ! $inst_error = true; ! } ! else ! { ! $message .= '<b><font color=#0000fF>[Added/Updated]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; ! } ! $n++; ! } ! $message .= '<br /> If you get some Errors, Already Added or Updated messages, relax, this is normal when updating modules'; ! ! if ( $main_install ) ! { ! if ( !$inst_error ) ! { ! $message .= '-> no db errors :-)<br /><br /><b>Portal installed successfully! </b><hr><br /><br />'; ! $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; ! $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; ! $message .= '3) Then (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; ! ! $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; ! } ! else ! { ! $message .= '<br /><br /><b>Portal installed successfully (with some warnings)! </b><hr><br /><br />'; ! $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; ! $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; ! $message .= '3) Now (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; ! ! $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; ! } ! } ! return $message; ! } ! } ?> \ No newline at end of file --- 1,469 ---- ! <?php ! /** ------------------------------------------------------------------------ ! * subject : mx-portal, CMS & portal ! * begin : june, 2002 ! * copyright : (C) 2002-2005 MX-System ! * email : jon...@ho... ! * project site : www.mx-system.com ! * ! * description : ! * ------------------------------------------------------------------------- ! * ! * $Id$ ! */ ! ! /** ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License', or ! * ('at your option) any later version. ! */ ! ! if ( !function_exists( mx_smilies_pass ) ) ! { ! function mx_smilies_pass($message) ! { ! global $board_config; ! $smilies_path = $board_config['smilies_path']; ! $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; ! $message = smilies_pass($message); ! $board_config['smilies_path'] = $smilies_path; ! return $message; ! } ! } ! ! if ( !function_exists( mx_generate_smilies ) ) ! { ! function mx_generate_smilies($mode, $page_id) ! { ! global $board_config, $template, $phpEx; ! $smilies_path = $board_config['smilies_path']; ! $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; ! generate_smilies($mode, $page_id); ! $board_config['smilies_path'] = $smilies_path; ! $template->assign_vars(array( ! 'U_MORE_SMILIES' => append_sid(PHPBB_URL . "posting.$phpEx?mode=smilies")) ! ); ! } ! } ! ! if ( !function_exists( mx_message_die ) ) ! { ! ! function mx_message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '') ! { ! global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images; ! global $userdata, $user_ip, $session_length; ! global $starttime; ! ! message_die($msg_code, $msg_text, $msg_title, $err_line, $err_file, $sql); ! } ! ! } ! ! if ( !function_exists( mx_auth_group ) ) ! { ! // Validates if user belongs to group included in group_ids list ! // Also, adds all usergroups to userdata array ! function mx_auth_group( $group_ids = '', $group_mod_mode = false ) ! { ! global $userdata, $db; ! ! if ( $group_ids == '' ) ! { ! return false; ! } ! ! $group_ids_array = explode(",", $group_ids); ! ! // Try to reuse usergroups result. ! if ( $group_mod_mode ) ! { ! $userdata_key = 'mx_usergroups_mod' . $userdata['user_id']; ! ! if ( empty( $userdata[$userdata_key] ) ) ! { ! // Check if user is group moderator.. ! $sql = "SELECT gr.group_id ! FROM " . GROUPS_TABLE . " gr, ! " . USER_GROUP_TABLE . " ugr ! WHERE gr.group_id = ugr.group_id ! AND gr.group_moderator = '" . $userdata['user_id'] . "' ! AND ugr.user_pending = '0' "; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); ! } ! ! $group_row = $db->sql_fetchrowset( $result ); ! ! $userdata[$userdata_key_mod] = $group_row; ! } ! } ! else ! { ! $userdata_key = 'mx_usergroups' . $userdata['user_id']; ! ! if ( empty( $userdata[$userdata_key] ) ) ! { ! // Check if user is member of the proper group.. ! $sql = "SELECT group_id FROM " . USER_GROUP_TABLE . " WHERE user_id='" . $userdata['user_id'] . "' AND user_pending = 0"; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); ! } ! ! $group_row = $db->sql_fetchrowset( $result ); ! ! $userdata[$userdata_key] = $group_row; ! } ! } ! ! for ( $i = 0; $i < count( $userdata[$userdata_key] ); $i++ ) ! { ! if ( in_array( $userdata[$userdata_key][$i]['group_id'], $group_ids_array ) ) ! { ! $is_member = true; ! return $is_member; ! } ! } ! ! return false; ! } ! } ! ! if ( !function_exists( mx_add_search_words ) ) ! { ! // Add search words for blocks ! function mx_add_search_words($mode, $post_id, $post_text, $post_title = '', $mx_mode = 'mx') ! { ! global $db, $phpbb_root_path, $board_config, $lang; ! ! // $search_match_table = SEARCH_MATCH_TABLE; ! // $search_word_table = SEARCH_WORD_TABLE; ! ! switch ( $mx_mode ) ! { ! case 'mx': ! $search_match_table = MX_MATCH_TABLE; ! $search_word_table = MX_WORD_TABLE; ! $db_key = 'block_id'; ! break; ! case 'kb': ! $search_match_table = KB_MATCH_TABLE; ! $search_word_table = KB_WORD_TABLE; ! $db_key = 'article_id'; ! break; ! } ! ! $stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_stopwords.txt"); ! $synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_synonyms.txt"); ! ! $search_raw_words = array(); ! $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array)); ! $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array)); ! ! @set_time_limit(0); ! ! $word = array(); ! $word_insert_sql = array(); ! while ( list($word_in, $search_matches) = @each($search_raw_words) ) ! { ! $word_insert_sql[$word_in] = ''; ! if ( !empty($search_matches) ) ! { ! for ($i = 0; $i < count($search_matches); $i++) ! { ! $search_matches[$i] = trim($search_matches[$i]); ! ! if( $search_matches[$i] != '' ) ! { ! $word[] = $search_matches[$i]; ! if ( !strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'") ) ! { ! $word_insert_sql[$word_in] .= ( $word_insert_sql[$word_in] != "" ) ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'"; ! } ! } ! } ! } ! } ! ! if ( count($word) ) ! { ! sort($word); ! ! $prev_word = ''; ! $word_text_sql = ''; ! $temp_word = array(); ! for($i = 0; $i < count($word); $i++) ! { ! if ( $word[$i] != $prev_word ) ! { ! $temp_word[] = $word[$i]; ! $word_text_sql .= ( ( $word_text_sql != '' ) ? ', ' : '' ) . "'" . $word[$i] . "'"; ! } ! $prev_word = $word[$i]; ! } ! $word = $temp_word; ! ! $check_words = array(); ! switch( SQL_LAYER ) ! { ! case 'postgresql': ! case 'msaccess': ! case 'mssql-odbc': ! case 'oracle': ! case 'db2': ! $sql = "SELECT word_id, word_text ! FROM " . $search_word_table . " ! WHERE word_text IN ($word_text_sql)"; ! if ( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not select words', '', __LINE__, __FILE__, $sql); ! } ! ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $check_words[$row['word_text']] = $row['word_id']; ! } ! break; ! } ! ! $value_sql = ''; ! $match_word = array(); ! for ($i = 0; $i < count($word); $i++) ! { ! $new_match = true; ! if ( isset($check_words[$word[$i]]) ) ! { ! $new_match = false; ! } ! ! if ( $new_match ) ! { ! switch( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\', 0)'; ! break; ! case 'mssql': ! case 'mssql-odbc': ! $value_sql .= ( ( $value_sql != '' ) ? ' UNION ALL ' : '' ) . "SELECT '" . $word[$i] . "', 0"; ! break; ! default: ! $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) ! VALUES ('" . $word[$i] . "', 0)"; ! if( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); ! } ! break; ! } ! } ! } ! ! if ( $value_sql != '' ) ! { ! switch ( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $sql = "INSERT IGNORE INTO " . $search_word_table . " (word_text, word_common) ! VALUES $value_sql"; ! break; ! case 'mssql': ! case 'mssql-odbc': ! $sql = "INSERT INTO " . $search_word_table . " (word_text, word_common) ! $value_sql"; ! break; ! } ! ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! ! while( list($word_in, $match_sql) = @each($word_insert_sql) ) ! { ! $title_match = ( $word_in == 'title' ) ? 1 : 0; ! ! if ( $match_sql != '' ) ! { ! $sql = "INSERT INTO " . $search_match_table . " ($db_key, word_id, title_match) ! SELECT $post_id, word_id, $title_match ! FROM " . $search_word_table . " ! WHERE word_text IN ($match_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! ! if ($mode == 'single') ! { ! // remove_common('single', 4/10, $word); ! } ! ! return; ! } ! ! function mx_remove_search_post($post_id_sql, $mx_mode = 'mx') ! { ! global $db; ! ! // $search_match_table = SEARCH_MATCH_TABLE; ! // $search_word_table = SEARCH_WORD_TABLE; ! ! switch ( $mx_mode ) ! { ! case 'mx': ! $search_match_table = MX_MATCH_TABLE; ! $search_word_table = MX_WORD_TABLE; ! $db_key = 'block_id'; ! break; ! case 'kb': ! $search_match_table = KB_MATCH_TABLE; ! $search_word_table = KB_WORD_TABLE; ! $db_key = 'article_id'; ! break; ! } ! ! $words_removed = false; ! ! switch ( SQL_LAYER ) ! { ! case 'mysql': ! case 'mysql4': ! $sql = "SELECT word_id ! FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql) ! GROUP BY word_id"; ! if ( $result = $db->sql_query($sql) ) ! { ! $word_id_sql = ''; ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; ! } ! ! $sql = "SELECT word_id ! FROM " . $search_match_table . " ! WHERE word_id IN ($word_id_sql) ! GROUP BY word_id ! HAVING COUNT(word_id) = 1"; ! if ( $result = $db->sql_query($sql) ) ! { ! $word_id_sql = ''; ! while ( $row = $db->sql_fetchrow($result) ) ! { ! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id']; ! } ! ! if ( $word_id_sql != '' ) ! { ! $sql = "DELETE FROM " . $search_word_table . " ! WHERE word_id IN ($word_id_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql); ! } ! ! $words_removed = $db->sql_affectedrows(); ! } ! } ! } ! break; ! ! default: ! $sql = "DELETE FROM " . $search_word_table . " ! WHERE word_id IN ( ! SELECT word_id ! FROM " . $search_match_table . " ! WHERE word_id IN ( ! SELECT word_id ! FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql) ! GROUP BY word_id ! ) ! GROUP BY word_id ! HAVING COUNT(word_id) = 1 ! )"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql); ! } ! ! $words_removed = $db->sql_affectedrows(); ! ! break; ! } ! ! $sql = "DELETE FROM " . $search_match_table . " ! WHERE $db_key IN ($post_id_sql)"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); ! } ! ! return $words_removed; ! } ! } ! ! if ( !function_exists(mx_do_install_upgrade) ) ! { ! // Generating output ! ! function mx_do_install_upgrade( $sql = '', $main_install = false ) ! { ! global $table_prefix, $mx_table_prefix, $userdata, $phpEx, $template, $lang, $db, $board_config, $HTTP_POST_VARS; ! ! $inst_error = false; ! $n = 0; ! $message = "<b>This is the result list of the SQL queries needed for the install/upgrade</b><br /><br />"; ! ! while ( $sql[$n] ) ! { ! if ( !$result = $db->sql_query( $sql[$n] ) ) ! { ! $message .= '<b><font color=#FF0000>[Error or Already added]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; ! $inst_error = true; ! } ! else ! { ! $message .= '<b><font color=#0000fF>[Added/Updated]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; ! } ! $n++; ! } ! $message .= '<br /> If you get some Errors, Already Added or Updated messages, relax, this is normal when updating modules'; ! ! if ( $main_install ) ! { ! if ( !$inst_error ) ! { ! $message .= '-> no db errors :-)<br /><br /><b>Portal installed successfully! </b><hr><br /><br />'; ! $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; ! $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; ! $message .= '3) Then (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; ! ! $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; ! } ! else ! { ! $message .= '<br /><br /><b>Portal installed successfully (with some warnings)! </b><hr><br /><br />'; ! $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; ! $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; ! $message .= '3) Now (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; ! ! $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; ! } ! } ! return $message; ! } ! } ?> \ No newline at end of file |