Browse Source

Merge branch 'master' of https://github.com/Spuds/playpen

emanuele 13 years ago
parent
commit
3efb6a396e
2 changed files with 26 additions and 5 deletions
  1. 25 4
      Sources/Load.php
  2. 1 1
      Themes/default/GenericMenu.template.php

+ 25 - 4
Sources/Load.php

@@ -2659,11 +2659,32 @@ function cache_put_data($key, $value, $ttl = 120)
 		{
 			$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
 			
-			if (file_put_contents($cachedir . '/data_' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data))
+			// Write out the cache file, check that the cache write was successful; all the data must be written
+			// If it fails due to low diskspace, or other, remove the cache file
+			if (version_compare(PHP_VERSION, '5.1', '<'))
 			{
-				// Check that the cache write was successful; all the data should be written
-				// If it fails due to low diskspace, remove the cache file
-				@unlink($cachedir . '/data_' . $key . '.php');
+				$fh = @fopen($cachedir . '/data_' . $key . '.php', 'w');
+				if ($fh)
+				{
+					// Write the file.
+					set_file_buffer($fh, 0);
+
+					if (flock($fh, LOCK_EX))
+						$cache_bytes = fwrite($fh, $cache_data);
+					else
+						$cache_bytes = 0;
+
+					flock($fh, LOCK_UN);
+					fclose($fh);
+
+					if ($cache_bytes !== strlen($cache_data))
+						@unlink($cachedir . '/data_' . $key . '.php');
+				}
+			}
+			else
+			{
+				if (file_put_contents($cachedir . '/data_' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data))
+					@unlink($cachedir . '/data_' . $key . '.php');
 			}
 		}
 	}

+ 1 - 1
Themes/default/GenericMenu.template.php

@@ -146,7 +146,7 @@ function template_generic_menu_dropdown_above()
 				continue;
 
 			echo '
-					<li', (++$additional_items > 6) ? ' class="additional_items"' : '' ,'>';
+					<li', (++$additional_items > 6 && !empty($area['subsections'])) ? ' class="additional_items subsections"' : (($additional_items > 6) ? ' class="additional_items"' : ((!empty($area['subsections'])) ? ' class="subsections"' : '')), '>';
 
 			// Is this the current area, or just some area?
 			if ($i == $menu_context['current_area'])