|
From: Jon O. <jon...@us...> - 2005-10-12 15:37:47
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15763/includes Modified Files: mx_functions.php mx_functions_admincp.php mx_functions_blockcp.php mx_functions_core.php mx_functions_phpbb.php Log Message: Adding IP filter for pages Merged module_def panels and parameters, now usable at the same time Menu navigation fixes for highlights Index: mx_functions_blockcp.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_blockcp.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mx_functions_blockcp.php 1 Oct 2005 14:10:45 -0000 1.5 --- mx_functions_blockcp.php 12 Oct 2005 15:37:32 -0000 1.6 *************** *** 434,441 **** // Load and display additional blockcp panels (if any) // ! $this->load_block_panels($block_id); // ! // Load and display additional blockcp parameters (if any) // if (!empty($this->block_parameters)) --- 434,441 ---- // Load and display additional blockcp panels (if any) // ! //$this->load_block_panels($block_id); // ! // Load and display additional blockcp parameters or panels (if any) // if (!empty($this->block_parameters)) Index: mx_functions_core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_core.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mx_functions_core.php 2 Oct 2005 21:24:30 -0000 1.11 --- mx_functions_core.php 12 Oct 2005 15:37:32 -0000 1.12 *************** *** 419,422 **** --- 419,423 ---- pag.auth_view_group AS pag_auth_view_group, pag.auth_moderator_group AS pag_auth_moderator_group, + pag.ip_filter, bct.column_id, col.column_title, *************** *** 460,464 **** "page_auth_view" => $row['page_auth_view'], "page_auth_view_group" => $row['page_auth_view_group'], ! "page_auth_moderator_group" => $row['page_auth_moderator_group'] ); --- 461,466 ---- "page_auth_view" => $row['page_auth_view'], "page_auth_view_group" => $row['page_auth_view_group'], ! "page_auth_moderator_group" => $row['page_auth_moderator_group'], ! "ip_filter" => $row['ip_filter'] ); *************** *** 726,730 **** function _is_dynamic( $block_id ) { ! global $HTTP_POST_VARS, $HTTP_GET_VARS; $is_dynamic = ( ( $this->block_file == 'mx_dynamic.php' ) ? true : false ); --- 728,732 ---- function _is_dynamic( $block_id ) { ! global $mx_request_vars; $is_dynamic = ( ( $this->block_file == 'mx_dynamic.php' ) ? true : false ); *************** *** 732,743 **** if ( $is_dynamic ) { ! if ( isset( $HTTP_POST_VARS['dynamic_block'] ) || isset( $HTTP_GET_VARS['dynamic_block'] ) ) ! { ! $this->dynamic_block_id = ( isset( $HTTP_POST_VARS['dynamic_block'] ) ) ? intval( $HTTP_POST_VARS['dynamic_block'] ) : intval( $HTTP_GET_VARS['dynamic_block'] ); ! } ! else ! { ! $this->dynamic_block_id = $this->block_parameters['default_block_id']['parameter_value']; ! } if ( $this->dynamic_block_id == 0 || empty( $this->dynamic_block_id ) ) --- 734,738 ---- if ( $is_dynamic ) { ! $this->dynamic_block_id = $mx_request_vars->request('dynamic_block', MX_TYPE_INT, $this->block_parameters['default_block_id']['parameter_value']); if ( $this->dynamic_block_id == 0 || empty( $this->dynamic_block_id ) ) *************** *** 981,984 **** --- 976,981 ---- } } + + return $mx_module_defs->is_panel; } *************** *** 1177,1181 **** //$template = new mx_Template($template->root, $board_config); $template = new mx_Template($mx_root_path . 'templates/'. $theme['template_name'], $board_config); ! $this->_get_custom_module_panels($parameter_data, $block_id); $block_panels = ob_get_contents(); ob_end_clean(); --- 1174,1178 ---- //$template = new mx_Template($template->root, $board_config); $template = new mx_Template($mx_root_path . 'templates/'. $theme['template_name'], $board_config); ! $this->_get_custom_module_panels($this->block_parameters, $block_id); $block_panels = ob_get_contents(); ob_end_clean(); *************** *** 1199,1207 **** $return = false; if ( $this->_parameter_data_exist() ) { - ob_start(); foreach( $this->block_parameters as $parameter_name => $parameter_data ) { $this->is_panel = false; //$template = new mx_Template($template->root, $board_config); --- 1196,1206 ---- $return = false; + $block_panel_data = $block_parameter_data = ''; + if ( $this->_parameter_data_exist() ) { foreach( $this->block_parameters as $parameter_name => $parameter_data ) { + ob_start(); $this->is_panel = false; //$template = new mx_Template($template->root, $board_config); *************** *** 1249,1266 **** break; default: ! $this->_get_custom_module_parameters($parameter_data, $block_id); break; } $return = true; } ! $block_parameters = ob_get_contents(); ! ob_end_clean(); ! // // Now send all parameter data to main blockcp template // $blockcptemplate->assign_vars(array( ! 'BLOCKCP_PARAMETERS' => ( !empty($block_parameters) ) ? $block_parameters : '' )); } --- 1248,1277 ---- break; default: ! $this->is_panel = $this->_get_custom_module_parameters($parameter_data, $block_id); break; } + $block_output_data = ob_get_contents(); + ob_end_clean(); + + if ($this->is_panel) + { + $blockcptemplate->assign_block_vars('blockcp_panel', array( + 'BLOCKCP_PANELS' => ( !empty($block_output_data) ) ? $block_output_data : '' + )); + } + else + { + $block_parameter_data .= $block_output_data; + } + $return = true; } ! // // Now send all parameter data to main blockcp template // $blockcptemplate->assign_vars(array( ! 'BLOCKCP_PARAMETERS' => ( !empty($block_parameter_data) ) ? $block_parameter_data : '' )); } *************** *** 1660,1664 **** var $total_block = ''; ! var $auth_view = ''; var $block_border_graphics = false; --- 1671,1676 ---- var $total_block = ''; ! var $auth_view = false; ! var $auth_ip = false; var $block_border_graphics = false; *************** *** 1685,1691 **** $this->info = $this->page_config[$page_id]['page_info']; $mx_is_auth_ary = array(); $mx_is_auth_ary = page_auth( AUTH_VIEW, $userdata, $this->info['page_auth_view'], $this->info['page_auth_view_group'] ); ! $this->auth_view = $mx_is_auth_ary['auth_view']; $this->columns = $this->page_config[$page_id]['columns']; --- 1697,1716 ---- $this->info = $this->page_config[$page_id]['page_info']; + // + // View auth check + // $mx_is_auth_ary = array(); $mx_is_auth_ary = page_auth( AUTH_VIEW, $userdata, $this->info['page_auth_view'], $this->info['page_auth_view_group'] ); ! ! // ! // IP filter ! // ! $mx_ip = new mx_ip; ! ! // ! // Set the public view auth ! // ! $this->auth_view = $mx_is_auth_ary['auth_view']; ! $this->auth_ip = $mx_ip->auth($this->info['ip_filter']); $this->columns = $this->page_config[$page_id]['columns']; *************** *** 1782,1785 **** --- 1807,1884 ---- } // class mx_page + class mx_ip + { + + function mx_getip() + { + if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) + { + $ip = getenv("HTTP_CLIENT_IP"); + } + else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) + { + $ip = getenv("HTTP_X_FORWARDED_FOR"); + } + else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) + { + $ip = getenv("REMOTE_ADDR"); + } + else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) + { + $ip = $_SERVER['REMOTE_ADDR']; + } + else + { + $ip = "unknown"; + } + + return($ip); + } + + function auth( $mx_page_allowed_ips = '' ) + { + // + // Turn the serialized data into an array + // + $mx_page_allowed_ips = !empty($mx_page_allowed_ips) ? unserialize( stripslashes( $mx_page_allowed_ips )) : array(); + + // + // If no IP filtering is defined, return valid + // + if (count($mx_page_allowed_ips) == 0 || $mx_page_allowed_ips[0] == '') + { + return true; + } + + // + // If IP filter is set, go thorugh the filters + // + $mx_client_ip = $this->mx_getip(); + $mx_client_ip_subs = explode('.', $mx_client_ip); + + foreach($mx_page_allowed_ips as $key => $mx_page_allowed_ip) + { + $mx_page_allowed_ip_subs = explode('.', $mx_page_allowed_ip); + + $valid = true; + for( $i=0; $i < count($mx_client_ip_subs); $i++) + { + if ($mx_client_ip_subs[$i] != $mx_page_allowed_ip_subs[$i] && $mx_page_allowed_ip_subs[$i] != '*') + { + $valid = false; + continue; + } + } + + if ($valid) + { + return $valid; + } + } + + return false; + } + } + // // ------------------------------------------------------------------------------------------------------------- *************** *** 1793,1797 **** if ( empty( $mx_block->block_config[$block_id] ) ) { ! $block_config_temp = $mx_cache->read( $block_id, MX_BLOCK, !$cache ); $block_config_temp[$block_id] = array_merge($block_config_temp[$block_id]['block_info'], $block_config_temp[$block_id]['block_parameters']); return $block_config_temp; --- 1892,1896 ---- if ( empty( $mx_block->block_config[$block_id] ) ) { ! $block_config_temp = $mx_cache->read( $block_id, MX_CACHE_BLOCK_TYPE, $cache ); $block_config_temp[$block_id] = array_merge($block_config_temp[$block_id]['block_info'], $block_config_temp[$block_id]['block_parameters']); return $block_config_temp; Index: mx_functions_phpbb.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_phpbb.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mx_functions_phpbb.php 1 Oct 2005 14:10:45 -0000 1.13 --- mx_functions_phpbb.php 12 Oct 2005 15:37:32 -0000 1.14 *************** *** 502,506 **** --- 502,562 ---- } + // -------------------------------------------------------------------------------- + // Hook into some phpBB functions to append phpBB path to URLs... + // -------------------------------------------------------------------------------- + function mx_append_sid( $url, $non_html_amp = false ) + { + // + // Is mod_rewrite enabled? If so, do some url rewrites... + // + if ($mx_mod_rewrite || true) + { + + } + + // + // Replaces same function in sessions.php + // + return append_sid( $url, $non_html_amp ); + } + + function _mx_get_all_get_vars() + { + // + // Does this url have GET vars? If not this is NOT a portal url. Do nothing! + // + if ( ( $pos = strpos( $url, '?' ) ) === false ) + { + return array(); + } + // + // Reformat all unicode to plain & + // + $url = substr( $url, $pos + 1 ); + + if ( ( $pos = strpos( $url, '&' ) ) !== false ) + { + $url = str_replace( '&', '&', $url ); + } + + // + // Not collect all GET vars in an array + // + $query_array = array(); + $query_string = explode( '&', $url ); + + // + // First get page_id + // + for( $i = 0; $i < count( $query_string ); $i++ ) + { + $keyval = explode( '=', $query_string[$i] ); + $query_array[$keyval[0]] = $keyval[1]; + } + + return $query_array; + } + function mx_redirect($url, $redirect_msg = '', $redirect_link = '') { Index: mx_functions_admincp.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_admincp.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** mx_functions_admincp.php 1 Oct 2005 14:10:45 -0000 1.9 --- mx_functions_admincp.php 12 Oct 2005 15:37:32 -0000 1.10 *************** *** 357,361 **** --- 357,374 ---- $page_graph_border = $mx_request_vars->post('page_graph_border', MX_TYPE_NO_TAGS | MX_TYPE_SQL_QUOTED, ''); $auth_view = $mx_request_vars->post('auth_view', MX_TYPE_INT, 0); + + $ipfilter = $mx_request_vars->post('ip_filter', MX_TYPE_POST_VARS, ''); + + // + // Format the mod_rewrite array + // + $ipfilter = explode( "\n", htmlspecialchars( trim( $ipfilter ) ) ); + foreach( $ipfilter as $key => $value ) + { + $ipfilter[$key] = trim( $value ); + } + $ipfilter = addslashes( serialize( $ipfilter ) ); + $sql = "SELECT MAX(page_id) AS next_id FROM " . PAGE_TABLE; if( !($result = $db->sql_query($sql)) ) *************** *** 372,376 **** } ! $sql = "INSERT INTO " . PAGE_TABLE . " ( page_id, page_name, page_desc, page_icon, page_graph_border, auth_view, page_header ) VALUES ( '" . $page_id_new . "', '" . $page_name . "', --- 385,389 ---- } ! $sql = "INSERT INTO " . PAGE_TABLE . " ( page_id, page_name, page_desc, page_icon, page_graph_border, auth_view, page_header, ip_filter ) VALUES ( '" . $page_id_new . "', '" . $page_name . "', *************** *** 379,383 **** '" . $page_graph_border . "', '" . $auth_view . "', ! '" . $page_header . "' )"; if( !($result = $db->sql_query($sql)) ) --- 392,397 ---- '" . $page_graph_border . "', '" . $auth_view . "', ! '" . $page_header . "', ! '" . $ipfilter . "' )"; if( !($result = $db->sql_query($sql)) ) *************** *** 692,695 **** --- 706,713 ---- $data = addslashes( serialize( $data ) ); } + else + { + $data = addslashes( $data ); + } // *************** *** 913,917 **** $page_graph_border = $mx_request_vars->post('page_graph_border', MX_TYPE_NO_TAGS | MX_TYPE_SQL_QUOTED, ''); $auth_view = $mx_request_vars->post('auth_view', MX_TYPE_INT, 0); ! $sql = "UPDATE " . PAGE_TABLE . " SET page_name = '$page_name', --- 931,947 ---- $page_graph_border = $mx_request_vars->post('page_graph_border', MX_TYPE_NO_TAGS | MX_TYPE_SQL_QUOTED, ''); $auth_view = $mx_request_vars->post('auth_view', MX_TYPE_INT, 0); ! $ipfilter = $mx_request_vars->post('ip_filter', MX_TYPE_POST_VARS, ''); ! ! // ! // Format the mod_rewrite array ! // ! $ipfilter = explode( "\n", htmlspecialchars( trim( $ipfilter ) ) ); ! ! foreach( $ipfilter as $key => $value ) ! { ! $ipfilter[$key] = trim( $value ); ! } ! $ipfilter = addslashes( serialize( $ipfilter ) ); ! $sql = "UPDATE " . PAGE_TABLE . " SET page_name = '$page_name', *************** *** 920,924 **** page_header = '$page_header', page_graph_border = '$page_graph_border', ! auth_view = '$auth_view' WHERE page_id = $page_id"; if( !($result = $db->sql_query($sql)) ) --- 950,955 ---- page_header = '$page_header', page_graph_border = '$page_graph_border', ! auth_view = '$auth_view', ! ip_filter = '$ipfilter' WHERE page_id = $page_id"; if( !($result = $db->sql_query($sql)) ) Index: mx_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** mx_functions.php 1 Oct 2005 14:10:45 -0000 1.47 --- mx_functions.php 12 Oct 2005 15:37:32 -0000 1.48 *************** *** 156,160 **** | \********************************************************************************/ ! function get_list_multiple($name_select, $table, $idfield, $namefield, $id_list, $select) { global $db; --- 156,160 ---- | \********************************************************************************/ ! function get_list_multiple($name_select, $table, $idfield, $namefield, $id_list, $select, $namefield2 = '') { global $db; *************** *** 182,187 **** while( $row = $db->sql_fetchrow($result) ) { $selected = ( in_array($row[$idfield], $id_list) ) ? ' selected="selected"' : ''; ! $column_list .= '<option value="' . $row[$idfield] . '"' . $selected . '>' . $row[$namefield] . "</option>\n"; } --- 182,188 ---- while( $row = $db->sql_fetchrow($result) ) { + $namefield_desc = !empty($row[$namefield2]) ? ' (' . $row[$namefield2] . ')' : ''; $selected = ( in_array($row[$idfield], $id_list) ) ? ' selected="selected"' : ''; ! $column_list .= '<option value="' . $row[$idfield] . '"' . $selected . '>' . $row[$namefield] . $namefield_desc . "</option>\n"; } *************** *** 201,205 **** | $function_file: for filtering blocklists \********************************************************************************/ ! function get_list_formatted($type, $id, $name_select = '', $function_file = '') { global $db, $lang; --- 202,206 ---- | $function_file: for filtering blocklists \********************************************************************************/ ! function get_list_formatted($type, $id, $name_select = '', $function_file = '', $multiple_select = false) { global $db, $lang; *************** *** 278,282 **** } ! $column_list = '<select name="' . $name_select . '">'; if( $type == 'page_list' ) --- 279,288 ---- } ! if ($multiple_select) ! { ! $multiple_select_option = 'multiple="multiple"'; ! } ! ! $column_list = '<select name="' . $name_select . '" '.$multiple_select_option.'>'; if( $type == 'page_list' ) |