Seite 1 von 1

[Beta] Color-Groups-Caching

Verfasst: 14.04.2005 14:08
von Fundus
Inspiriert durch den Versionscache von CyberAlien hab ich das ganze jetzt mal auf den color-groups 1.20 Mod von Nivisec übertragen

Der Ordner "cache" braucht CHMOD777

Bitte mal testen :D

Der Snippet dient dazu die Queries zu senken

Code: Alles auswählen

#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_color_groups.php

#
#-----[ FIND ]------------------------------------------------
#
function color_group_colorize_name($user_id, $no_profile = false)
{
	global $board_config, $phpEx, $db, $phpbb_root_path;
	
	// First see if the user is Anon
	if ($user_id != ANONYMOUS)
	{

#
#-----[ AFTER, ADD ]------------------------------------------
#
   // Version cache mod start 
   // Change following two variables if you need to: 
   $cache_update = 3600; // 1 hours cache timeout. change it to whatever you want 
   $cache_file = $phpbb_root_path . '/cache/cg-user' . $user_id .'.php'; // file where to store cache 

   $do_update = true; 
   if ( (@file_exists($cache_file)) && (empty($disable_color_cache)) )
   { 
	  $last_update = 0; 
	  include($cache_file); 
	  if($last_update > (time() - $cache_update)) 
	  { 
		 $do_update = false; 
	  } 
   } 

   if($do_update) 
   { 
  // Version cache mod end 

#
#-----[ FIND ]------------------------------------------------
#
							$curr = $row['order_num'];
							$style_color = 'style="font-weight:bold;color:' . $row['group_color'] . '"';
						}
					}
			}

#
#-----[ AFTER, ADD ]------------------------------------------
#
		// Version cache mod start 
		if(@$f = fopen($cache_file, 'w')) 
		{ 
			fwrite($f, '<' . '?php $last_update = ' . time() . '; $style_color = \'' . $style_color . '\'; $username = \'' . $username . '\'; ?' . '>'); 
			fclose($f); 
			@chmod($cache_file, 0666); 
		} 
	} 
	// Version cache mod end 
#
#---[ SAVE/CLOSE ALL FILES ]-----------------------
#
# eom