|
From: Markus P. <mar...@us...> - 2005-04-03 16:45:52
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10908/includes Modified Files: mx_cache.php Log Message: Bug #60 - Fix mx_cache() db2xml function using propietary MySQL code. Also, revised the whole admin_mx_gen_cache.php script: code cleanup, use of mx_request_vars class, moved db2xml_all to includes/mx_cache.php, fixed several problems, including $lang usage, etc. Index: mx_cache.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_cache.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mx_cache.php 9 Mar 2005 22:46:36 -0000 1.2 --- mx_cache.php 3 Apr 2005 16:45:15 -0000 1.3 *************** *** 283,362 **** } ! function db2xml( $host, $user, $password, $database, $sql, $xml_file ) { ! $create_xml = fopen( $xml_file, "w" ); ! fwrite( $create_xml, "<xml>\r\n<table>\r\n" ); ! $req = mysql_db_query( $database, $sql ); ! while ( $row = mysql_fetch_array( $req ) ) { ! fwrite( $create_xml, "<item>\r\n" ); ! for( $j = 0;$line = each( $row );$j++ ) { if ( $j % 2 ) { ! fwrite( $create_xml, "<$line[0]>" . to_text( $line[1] ) . "</$line[0]>\r\n" ); } } ! fwrite( $create_xml, "</item>\r\n" ); } ! fwrite( $create_xml, "</table>\r\n</xml>" ); ! fclose( $create_xml ); ! mysql_free_result( $req ); } ! function write_cache_config( $block_id = '' ) { ! global $db, $mx_root_path, $dbhost, $dbuser, $dbpasswd, $dbname, $HTTP_SESSION_VARS; $HTTP_SESSION_VARS['cache_read'] = false; $cache_dir = $mx_root_path . 'cache/'; ! @mkdir( $cache_dir, 0777 ); ! @chmod( $cache_dir, 0777 ); ! if ( !is_writable( $cache_dir ) ) { ! $message = !empty( $lang['Cache_dir_write_protect'] ) ? $lang['Cache_dir_write_protect'] : "Your cache directory is write-protected, unable to generate the cache file"; ! mx_message_die( GENERAL_MESSAGE, $message, '' ); exit; } /* ! $sql = "SELECT blk.block_id ! , blk.block_title ! , blk.block_desc ! , blk.show_block ! , blk.show_title ! , blk.show_stats ! , blk.block_time ! , blk.block_editor_id ! , blk.function_id ! , blk.auth_view ! , blk.auth_edit ! , blk.auth_delete ! , blk.auth_view_group ! , blk.auth_edit_group ! , blk.auth_moderator_group FROM " . BLOCK_TABLE . " blk" ; ! db2xml( $dbhost, $dbuser, $dbpasswd, $dbname, $sql, $cache_dir . "block_config.xml" ); */ - - $sql = "SELECT sys.parameter_id - , sys.block_id - , par.parameter_name - , sys.parameter_value - , sys.bbcode_uid - FROM " . BLOCK_SYSTEM_PARAMETER_TABLE . " sys, - " . PARAMETER_TABLE . " par - WHERE sys.parameter_id = par.parameter_id - AND sys.block_id = '" . $block_id . "'"; ! db2xml( $dbhost, $dbuser, $dbpasswd, $dbname, $sql, $cache_dir . "block_" . $block_id .".xml" ); /* // Generate page_blocks data ! $sql = "SELECT col.page_id, pag.page_name, pag.page_icon, pag.page_header, pag.page_graph_border, pag.auth_view AS pag_auth_view, pag.auth_view_group AS pag_auth_view_group, pag.auth_moderator_group AS pag_auth_moderator_group, bct.column_id, col.column_title, col.column_order, col.column_size, blk.block_id, blk.auth_view, blk.auth_view_group, blk.auth_edit, blk.auth_edit_group, blk.show_block, blk.show_title, blk.show_stats, blk.block_time, blk.block_editor_id, bct.column_id AS block_col_id, module_path, function_file, function_admin FROM " . COLUMN_BLOCK_TABLE . " bct, " . BLOCK_TABLE . " blk, --- 283,416 ---- } ! function db2xml($sql, $xml_file) { ! global $db; ! if ( !( $result = $db->sql_query($sql) ) ) { ! return; ! } ! ! if( !( $create_xml = fopen($xml_file, 'w') ) ) ! { ! return; ! } ! ! fwrite($create_xml, "<xml>\r\n<table>\r\n"); ! ! while( $row = $db->sql_fetchrow($result) ) ! { ! fwrite($create_xml, "<item>\r\n"); ! for( $j=0; $line = each($row); $j++ ) { if ( $j % 2 ) { ! fwrite($create_xml, "<$line[0]>" . to_text($line[1]) . "</$line[0]>\r\n"); } } ! fwrite($create_xml, "</item>\r\n"); } ! ! fwrite($create_xml, "</table>\r\n</xml>"); ! fclose($create_xml); } ! function db2xml_all($sql, $xml_file) { ! global $db; ! ! if ( !( $result = $db->sql_query($sql) ) ) ! { ! return; ! } ! ! $block_id_tmp = ''; ! $create_xml = ''; ! $cache_start = false; ! ! while( $row = $db->sql_fetchrow($result) ) ! { ! if ( $block_id_tmp != $row['block_id'] && $cache_start ) ! { ! fwrite($create_xml, "</table>\r\n</xml>"); ! fclose($create_xml); ! } ! ! if ( $block_id_tmp != $row['block_id'] ) ! { ! $create_xml = fopen($xml_file . $row['block_id'] . '.xml', 'w'); ! fwrite($create_xml, "<xml>\r\n<table>\r\n"); ! $cache_start = true; ! } ! ! fwrite($create_xml, "<item>\r\n"); ! for( $j = 0; $line = each($row); $j++ ) ! { ! if ( $j % 2 ) ! { ! fwrite($create_xml, "<$line[0]>" . to_text($line[1]) . "</$line[0]>\r\n"); ! } ! } ! fwrite($create_xml, "</item>\r\n"); ! ! $block_id_tmp = $row['block_id']; ! } ! ! fwrite($create_xml, "</table>\r\n</xml>"); ! fclose($create_xml); ! } ! ! function write_cache_config($block_id = '') ! { ! global $mx_root_path, $lang, $HTTP_SESSION_VARS; $HTTP_SESSION_VARS['cache_read'] = false; $cache_dir = $mx_root_path . 'cache/'; ! @mkdir($cache_dir, 0777); ! @chmod($cache_dir, 0777); ! if ( !is_writable($cache_dir) ) { ! mx_message_die(GENERAL_MESSAGE, $lang['Cache_dir_write_protect'], ''); exit; } /* ! $sql = "SELECT blk.block_id ! , blk.block_title ! , blk.block_desc ! , blk.show_block ! , blk.show_title ! , blk.show_stats ! , blk.block_time ! , blk.block_editor_id ! , blk.function_id ! , blk.auth_view ! , blk.auth_edit ! , blk.auth_delete ! , blk.auth_view_group ! , blk.auth_edit_group ! , blk.auth_moderator_group FROM " . BLOCK_TABLE . " blk" ; ! db2xml($sql, $cache_dir . 'block_config.xml'); */ ! $sql = "SELECT sys.parameter_id, ! sys.block_id, ! par.parameter_name, ! sys.parameter_value, ! sys.bbcode_uid ! FROM " . BLOCK_SYSTEM_PARAMETER_TABLE . " sys, ! " . PARAMETER_TABLE . " par ! WHERE sys.parameter_id = par.parameter_id ! AND sys.block_id = '$block_id'"; ! ! db2xml($sql, $cache_dir . 'block_' . $block_id . '.xml'); /* // Generate page_blocks data ! $sql = "SELECT col.page_id, pag.page_name, pag.page_icon, pag.page_header, pag.page_graph_border, pag.auth_view AS pag_auth_view, pag.auth_view_group AS pag_auth_view_group, pag.auth_moderator_group AS pag_auth_moderator_group, bct.column_id, col.column_title, col.column_order, col.column_size, blk.block_id, blk.auth_view, blk.auth_view_group, blk.auth_edit, blk.auth_edit_group, blk.show_block, blk.show_title, blk.show_stats, blk.block_time, blk.block_editor_id, bct.column_id AS block_col_id, module_path, function_file, function_admin FROM " . COLUMN_BLOCK_TABLE . " bct, " . BLOCK_TABLE . " blk, *************** *** 364,368 **** " . MODULE_TABLE . " mdl, " . PAGE_TABLE . " pag, ! " . COLUMN_TABLE . " col WHERE blk.function_id = fnc.function_id AND pag.page_id = col.page_id --- 418,422 ---- " . MODULE_TABLE . " mdl, " . PAGE_TABLE . " pag, ! " . COLUMN_TABLE . " col WHERE blk.function_id = fnc.function_id AND pag.page_id = col.page_id *************** *** 372,376 **** ORDER BY col.page_id, column_id, column_order, block_order"; ! db2xml( $dbhost, $dbuser, $dbpasswd, $dbname, $sql, $cache_dir . "page_config.xml" ); */ } --- 426,430 ---- ORDER BY col.page_id, column_id, column_order, block_order"; ! db2xml($sql, $cache_dir . 'page_config.xml'); */ } *************** *** 386,392 **** } */ ! get_page_session(); ! $cache_dir = $mx_root_path . 'cache/'; if ( !empty($block_id) && $portal_config['mx_use_cache'] == 1 ) --- 440,446 ---- } */ ! get_page_session(); ! $cache_dir = $mx_root_path . 'cache/'; if ( !empty($block_id) && $portal_config['mx_use_cache'] == 1 ) *************** *** 397,405 **** $portal_cache_time = time(); ! $sql = "UPDATE ".PORTAL_TABLE." SET portal_recached = '$portal_cache_time' WHERE portal_id = 1"; ! if ( !( $result = $db->sql_query( $sql, BEGIN_TRANSACTION ) ) ) { --- 451,459 ---- $portal_cache_time = time(); ! $sql = "UPDATE ".PORTAL_TABLE." SET portal_recached = '$portal_cache_time' WHERE portal_id = 1"; ! if ( !( $result = $db->sql_query( $sql, BEGIN_TRANSACTION ) ) ) { |