|
From: Jon O. <jon...@us...> - 2005-05-06 06:48:08
|
Update of /cvsroot/mxbb/core27x/cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13016/cache Added Files: .htaccess index.htm mx_cache.php Log Message: Initital core 2.7.x commit :-) --- NEW FILE: .htaccess --- deny from all --- NEW FILE: mx_cache.php --- <?php /*************************************************************************** * mx_cache.php * ------------------- * begin : juin, 2002 * copyright : (C) 2002 MX-System * email : su...@mx... * * $Id: mx_cache.php,v 1.1 2005/05/06 06:47:57 jonohlsson Exp $ * ***************************************************************************/ function from_text($string) { // puts 'em back... $string = ereg_replace( '([^\\\\])\\\\n', "\\1\n", $string); $string = ereg_replace( '([^\\\\])\\\\r', "\\1\r", $string); $string = str_replace( '\\\\', '\\', $string); return $string; } function to_text($string) { // removes all newlines etc... $string = str_replace( '\\', '\\\\', $string); $string = str_replace( "\n", '\n', $string); $string = str_replace( "\r", '\r', $string); return $string; } // // Read the cache file for the block configuration // function read_cache_config() { global $db, $mx_root_path, $HTTP_SESSION_VARS; get_block_config(); get_block_config_param(); $HTTP_SESSION_VARS['cache_read'] = TRUE; } function get_block_config() { global $db, $mx_root_path, $HTTP_SESSION_VARS; $file = $mx_root_path . "cache/block_config.xml"; if (!($handle = fopen($file, "r"))) { die("could not open XML input"); } $contents = fread ( $handle, filesize ($file)); fclose ($handle); while ( 0 != strpos($contents,"</item>",0) ) { $start = strpos($contents,"<item>",0); $end = strpos($contents,"</item>",0); $param = substr( $contents, $next, $end ); // $parameter_name = getpart( $param, 'parameter_name', 0 ); $block_id = getpart( $param, 'block_id' ); $block_title = getpart( $param, 'block_title' ); $block_desc = getpart( $param, 'block_desc' ); $function_id = getpart( $param, 'function_id' ); $auth_view = getpart( $param, 'auth_view' ); $auth_edit = getpart( $param, 'auth_edit' ); $auth_delete = getpart( $param, 'auth_delete' ); $auth_view_group = getpart( $param, 'auth_view_group' ); $auth_edit_group = getpart( $param, 'auth_edit_group' ); $row = array( "block_id" => $block_id, "block_title" => $block_title, "block_desc" => $block_desc, "function_id" => $function_id, "auth_view" => $auth_view, "auth_edit" => $auth_edit, "auth_delete" => $auth_delete, "auth_view_group" => $auth_view_group, "auth_edit_group" => $auth_edit_group); $HTTP_SESSION_VARS['block_' . $block_id] = $row; $contents = substr( $contents, $end + 1 ); }; } function get_block_config_param() { global $db, $mx_root_path, $HTTP_SESSION_VARS; $file = $mx_root_path . "cache/block_config_param.xml"; if (!($handle = fopen($file, "r"))) { die("could not open XML input"); } $contents = fread ( $handle, filesize ($file)); fclose ($handle); while ( 0 != strpos($contents,"</item>",0) ) { $start = strpos($contents,"<item>",0); $end = strpos($contents,"</item>",0); $param = substr( $contents, $next, $end ); // $parameter_name = getpart( $param, 'parameter_name', 0 ); $parameter_id = getpart( $param,'parameter_id' ); $block_id = getpart( $param,'block_id' ); $parameter_name = getpart( $param,'parameter_name' ); $parameter_value = from_text( getpart( $param,'parameter_value' )); $bbcode_uid = getpart( $param,'bbcode_uid' ); $param_row = array( "parameter_value" => $parameter_value, "bbcode_uid" => $bbcode_uid, "parameter_id" => $parameter_id ); $HTTP_SESSION_VARS['block_' . $block_id][$parameter_name] = $param_row; $contents = substr( $contents, $end + 1 ); }; } function getpart($texto,$string,$position=0) { $p0 = 0; $p0 += $position; $get = ""; $string = trim($string); if(strpos($texto,"<$string>",$p0) >=0) { $p1 = strpos($texto,"<$string>",$p0); $p2 = strpos($texto,"</$string>",$p0); $len = strlen("<$string>"); $get = substr($texto,($p1 + $len),($p2 - $p1 - $len)); $p0 = $p2+$len; } return $get; } 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() { global $mx_root_path; $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.function_id , blk.auth_view , blk.auth_edit , blk.auth_delete , blk.auth_view_group , blk.auth_edit_group FROM " . BLOCK_TABLE . " blk ORDER BY blk.block_id"; 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 ORDER BY sys.block_id, sys.parameter_id"; db2xml($sql, $cache_dir. "block_config_param.xml"); } ?> --- NEW FILE: index.htm --- <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> |