Browse Source

Moved the cache folder

Visman 8 years ago
parent
commit
9d0a2be89a

+ 0 - 0
cache/.htaccess → app/.htaccess


+ 2 - 6
app/Core/Install.php

@@ -82,10 +82,6 @@ class Install implements ContainerAwareInterface
 
         require PUN_ROOT . 'lang/' . $install_lang . '/install.php';
 
-        // If the cache directory is not specified, we use the default setting
-        if (! defined('FORUM_CACHE_DIR'))
-            define('FORUM_CACHE_DIR', PUN_ROOT . 'cache/');
-
         // Make sure we are running at least MIN_PHP_VERSION
         if (! function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
             exit(sprintf($lang_install['You are running error'], 'PHP', PHP_VERSION, FORK_VERSION, MIN_PHP_VERSION));
@@ -188,8 +184,8 @@ class Install implements ContainerAwareInterface
         }
 
         // Check if the cache directory is writable
-        if (! forum_is_writable(FORUM_CACHE_DIR))
-            $alerts[] = sprintf($lang_install['Alert cache'], FORUM_CACHE_DIR);
+        if (! forum_is_writable($this->c->getParameter('DIR_CACHE')))
+            $alerts[] = sprintf($lang_install['Alert cache'], $this->c->getParameter('DIR_CACHE'));
 
         // Check if default avatar directory is writable
         if (! forum_is_writable(PUN_ROOT . 'img/avatars/'))

+ 1 - 1
app/bootstrap.php

@@ -47,5 +47,5 @@ if (file_exists(__DIR__ . '/config/main.php')) {
 define('PUN', 1);
 
 $container->setParameter('DIR_CONFIG', __DIR__ . '/config/');
-//$container->setParameter('DIR_CACHE', __DIR__ . '/cache/');
+$container->setParameter('DIR_CACHE', __DIR__ . '/cache/');
 $container->get('firstAction');

+ 0 - 0
cache/index.html → app/cache/index.html


+ 2 - 2
db_update.php

@@ -88,8 +88,8 @@ if (empty($cookie_name))
 	$cookie_name = 'pun_cookie';
 
 // If the cache directory is not specified, we use the default setting
-if (!defined('FORUM_CACHE_DIR'))
-	define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
+if (!defined('FORUM_CACHE_DIR')) //????
+	define('FORUM_CACHE_DIR', PUN_ROOT.'app/cache/');
 
 // Turn off PHP time limit
 @set_time_limit(0);

+ 5 - 5
extern.php

@@ -392,8 +392,8 @@ if ($action == 'feed')
 			$cache_id = 'feed'.sha1($pun_user['g_id'].'|'.$lang_common['lang_identifier'].'|'.($order_posted ? '1' : '0').($forum_name == '' ? '' : '|'.$fids[0]));
 
 		// Load cached feed
-		if (isset($cache_id) && file_exists(FORUM_CACHE_DIR.'cache_'.$cache_id.'.php'))
-			include FORUM_CACHE_DIR.'cache_'.$cache_id.'.php';
+		if (isset($cache_id) && file_exists($container->getParameter('DIR_CACHE') . 'cache_'.$cache_id.'.php'))
+			include $container->getParameter('DIR_CACHE') . 'cache_'.$cache_id.'.php';
 
 		$now = time();
 		if (!isset($feed) || $cache_expire < $now)
@@ -519,8 +519,8 @@ else if ($action == 'stats')
 	require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php';
 
 	// Collect some statistics from the database
-	if (file_exists(FORUM_CACHE_DIR.'cache_users_info.php'))
-		include FORUM_CACHE_DIR.'cache_users_info.php';
+	if (file_exists($container->getParameter('DIR_CACHE') . 'cache_users_info.php'))
+		include $container->getParameter('DIR_CACHE') . 'cache_users_info.php';
 
 	if (!defined('PUN_USERS_INFO_LOADED'))
 	{
@@ -528,7 +528,7 @@ else if ($action == 'stats')
 			require PUN_ROOT.'include/cache.php';
 
 		generate_users_info_cache();
-		require FORUM_CACHE_DIR.'cache_users_info.php';
+		require $container->getParameter('DIR_CACHE') . 'cache_users_info.php';
 	}
 
 	$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());

+ 3 - 3
footer.php

@@ -90,8 +90,8 @@ echo "\t\t\t".'<div class="conl">'."\n";
 if ($pun_config['o_quickjump'] == '1')
 {
 	// Load cached quick jump
-	if (file_exists(FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php'))
-		include FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
+	if (file_exists($container->getParameter('DIR_CACHE') . 'cache_quickjump_'.$pun_user['g_id'].'.php'))
+		include $container->getParameter('DIR_CACHE') . 'cache_quickjump_'.$pun_user['g_id'].'.php';
 
 	if (!defined('PUN_QJ_LOADED'))
 	{
@@ -99,7 +99,7 @@ if ($pun_config['o_quickjump'] == '1')
 			require PUN_ROOT.'include/cache.php';
 
 		generate_quickjump_cache($pun_user['g_id']);
-		require FORUM_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php';
+		require $container->getParameter('DIR_CACHE') . 'cache_quickjump_'.$pun_user['g_id'].'.php';
 	}
 	$page_js['c'][] = 'document.getElementById("qjump").getElementsByTagName("div")[0].getElementsByTagName("input")[0].style.display = "none";'; // Visman - скрываем кнопку перехода при включенном js
 }

+ 3 - 3
include/bbcode.inc.php

@@ -16,15 +16,15 @@ else
 
 if (!isset($smilies))
 {
-	if (file_exists(FORUM_CACHE_DIR.'cache_smilies.php'))
-		include FORUM_CACHE_DIR.'cache_smilies.php';
+	if (file_exists($container->getParameter('DIR_CACHE') . 'cache_smilies.php'))
+		include $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 	else
 	{
 		if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 			require PUN_ROOT.'include/cache.php';
 
 		generate_smiley_cache();
-		require FORUM_CACHE_DIR.'cache_smilies.php';
+		require $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 	}
 }
 

+ 13 - 9
include/cache.php

@@ -126,12 +126,12 @@ function generate_quickjump_cache($group_id = false)
 		if ($read_board == '1')
 		{
 			// Load cached subforums - Visman
-			if (file_exists(FORUM_CACHE_DIR.'cache_subforums_'.$group_id.'.php'))
-				include FORUM_CACHE_DIR.'cache_subforums_'.$group_id.'.php';
+			if (file_exists($container->getParameter('DIR_CACHE') . 'cache_subforums_'.$group_id.'.php'))
+				include $container->getParameter('DIR_CACHE') . 'cache_subforums_'.$group_id.'.php';
 			else
 			{
 				generate_subforums_cache($group_id);
-				require FORUM_CACHE_DIR.'cache_subforums_'.$group_id.'.php';
+				require $container->getParameter('DIR_CACHE') . 'cache_subforums_'.$group_id.'.php';
 			}
 
 			$output .= generate_quickjump_sf_list($sf_array_tree);
@@ -246,9 +246,11 @@ function generate_admins_cache()
 //
 function fluxbb_write_cache_file($file, $content)
 {
-	$fh = @fopen(FORUM_CACHE_DIR.$file, 'wb');
+    global $container;
+
+	$fh = @fopen($container->getParameter('DIR_CACHE') . $file, 'wb');
 	if (!$fh)
-		error('Unable to write cache file '.pun_htmlspecialchars($file).' to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars(FORUM_CACHE_DIR).'\'', __FILE__, __LINE__);
+		error('Unable to write cache file '.pun_htmlspecialchars($file).' to cache directory. Please make sure PHP has write access to the directory \''.pun_htmlspecialchars($container->getParameter('DIR_CACHE')).'\'', __FILE__, __LINE__);
 
 	flock($fh, LOCK_EX);
 	ftruncate($fh, 0);
@@ -258,7 +260,7 @@ function fluxbb_write_cache_file($file, $content)
 	flock($fh, LOCK_UN);
 	fclose($fh);
 
-	fluxbb_invalidate_cached_file(FORUM_CACHE_DIR.$file);
+	fluxbb_invalidate_cached_file($container->getParameter('DIR_CACHE') . $file);
 }
 
 
@@ -267,13 +269,15 @@ function fluxbb_write_cache_file($file, $content)
 //
 function clear_feed_cache()
 {
-	$d = dir(FORUM_CACHE_DIR);
+    global $container;
+
+	$d = dir($container->getParameter('DIR_CACHE'));
 	while (($entry = $d->read()) !== false)
 	{
 		if (substr($entry, 0, 10) == 'cache_feed' && substr($entry, -4) == '.php')
 		{
-			@unlink(FORUM_CACHE_DIR.$entry);
-			fluxbb_invalidate_cached_file(FORUM_CACHE_DIR.$entry);
+			@unlink($container->getParameter('DIR_CACHE') . $entry);
+			fluxbb_invalidate_cached_file($container->getParameter('DIR_CACHE') . $entry);
 		}
 	}
 	$d->close();

+ 9 - 13
include/common.php

@@ -55,10 +55,6 @@ require PUN_ROOT . 'app/bootstrap.php';
 // The addon manager is responsible for storing the hook listeners and communicating with the addons
 $flux_addons = new flux_addon_manager();
 
-// If the cache directory is not specified, we use the default setting
-if (!defined('FORUM_CACHE_DIR'))
-	define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
-
 // Define a few commonly used constants
 define('PUN_UNVERIFIED', 0);
 define('PUN_ADMIN', 1);
@@ -72,8 +68,8 @@ $db = $container->get('DB');
 $db->start_transaction();
 
 // Load cached config
-if (file_exists(FORUM_CACHE_DIR.'cache_config.php'))
-	include FORUM_CACHE_DIR.'cache_config.php';
+if (file_exists($container->getParameter('DIR_CACHE') . 'cache_config.php'))
+	include $container->getParameter('DIR_CACHE') . 'cache_config.php';
 
 if (!defined('PUN_CONFIG_LOADED'))
 {
@@ -81,7 +77,7 @@ if (!defined('PUN_CONFIG_LOADED'))
 		require PUN_ROOT.'include/cache.php';
 
 	generate_config_cache();
-	require FORUM_CACHE_DIR.'cache_config.php';
+	require $container->getParameter('DIR_CACHE') . 'cache_config.php';
 }
 
 // Verify that we are running the proper database schema revision
@@ -119,8 +115,8 @@ if ($pun_config['o_maintenance'] && $pun_user['g_id'] > PUN_ADMIN && !defined('P
 	maintenance_message();
 
 // Load cached bans
-if (file_exists(FORUM_CACHE_DIR.'cache_bans.php'))
-	include FORUM_CACHE_DIR.'cache_bans.php';
+if (file_exists($container->getParameter('DIR_CACHE') . 'cache_bans.php'))
+	include $container->getParameter('DIR_CACHE') . 'cache_bans.php';
 
 if (!defined('PUN_BANS_LOADED'))
 {
@@ -128,7 +124,7 @@ if (!defined('PUN_BANS_LOADED'))
 		require PUN_ROOT.'include/cache.php';
 
 	generate_bans_cache();
-	require FORUM_CACHE_DIR.'cache_bans.php';
+	require $container->getParameter('DIR_CACHE') . 'cache_bans.php';
 }
 
 // Check if current user is banned
@@ -156,8 +152,8 @@ if (!defined('FORUM_MAX_COOKIE_SIZE'))
 	define('FORUM_MAX_COOKIE_SIZE', 4048);
 
 // Load cached subforums - Visman
-if (file_exists(FORUM_CACHE_DIR.'cache_subforums_'.$pun_user['g_id'].'.php'))
-	include FORUM_CACHE_DIR.'cache_subforums_'.$pun_user['g_id'].'.php';
+if (file_exists($container->getParameter('DIR_CACHE') . 'cache_subforums_'.$pun_user['g_id'].'.php'))
+	include $container->getParameter('DIR_CACHE') . 'cache_subforums_'.$pun_user['g_id'].'.php';
 
 if (!isset($sf_array_tree))
 {
@@ -165,5 +161,5 @@ if (!isset($sf_array_tree))
 		require PUN_ROOT.'include/cache.php';
 
 	generate_subforums_cache($pun_user['g_id']);
-	require FORUM_CACHE_DIR.'cache_subforums_'.$pun_user['g_id'].'.php';
+	require $container->getParameter('DIR_CACHE') . 'cache_subforums_'.$pun_user['g_id'].'.php';
 }

+ 13 - 9
include/functions.php

@@ -255,8 +255,10 @@ function get_base_url($support_https = false)
 //
 function get_admin_ids()
 {
-	if (file_exists(FORUM_CACHE_DIR.'cache_admins.php'))
-		include FORUM_CACHE_DIR.'cache_admins.php';
+    global $container;
+
+	if (file_exists($container->getParameter('DIR_CACHE') . 'cache_admins.php'))
+		include $container->getParameter('DIR_CACHE') . 'cache_admins.php';
 
 	if (!defined('PUN_ADMINS_LOADED'))
 	{
@@ -264,7 +266,7 @@ function get_admin_ids()
 			require PUN_ROOT.'include/cache.php';
 
 		generate_admins_cache();
-		require FORUM_CACHE_DIR.'cache_admins.php';
+		require $container->getParameter('DIR_CACHE') . 'cache_admins.php';
 	}
 
 	return $pun_admins;
@@ -916,11 +918,13 @@ function delete_post($post_id, $topic_id)
 //
 function forum_clear_cache()
 {
-	$d = dir(FORUM_CACHE_DIR);
+    global $container;
+
+	$d = dir($container->getParameter('DIR_CACHE'));
 	while (($entry = $d->read()) !== false)
 	{
 		if (substr($entry, -4) == '.php')
-			@unlink(FORUM_CACHE_DIR.$entry);
+			@unlink($container->getParameter('DIR_CACHE') . $entry);
 	}
 	$d->close();
 }
@@ -931,13 +935,13 @@ function forum_clear_cache()
 //
 function censor_words($text)
 {
-	static $search_for, $replace_with;
+	static $container, $search_for, $replace_with;
 
 	// If not already built in a previous call, build an array of censor words and their replacement text
 	if (!isset($search_for))
 	{
-		if (file_exists(FORUM_CACHE_DIR.'cache_censoring.php'))
-			include FORUM_CACHE_DIR.'cache_censoring.php';
+		if (file_exists($container->getParameter('DIR_CACHE') . 'cache_censoring.php'))
+			include $container->getParameter('DIR_CACHE') . 'cache_censoring.php';
 
 		if (!defined('PUN_CENSOR_LOADED'))
 		{
@@ -945,7 +949,7 @@ function censor_words($text)
 				require PUN_ROOT.'include/cache.php';
 
 			generate_censoring_cache();
-			require FORUM_CACHE_DIR.'cache_censoring.php';
+			require $container->getParameter('DIR_CACHE') . 'cache_censoring.php';
 		}
 	}
 

+ 3 - 3
include/parser.php

@@ -42,15 +42,15 @@ $re_list = '%\[list(?:=([1a*]))?+\]((?:[^\[]*+(?:(?!\[list(?:=[1a*])?+\]|\[/list
 // Load smilies cache - Visman
 if (!isset($smilies))
 {
-	if (file_exists(FORUM_CACHE_DIR.'cache_smilies.php'))
-		include FORUM_CACHE_DIR.'cache_smilies.php';
+	if (file_exists($container->getParameter('DIR_CACHE') . 'cache_smilies.php'))
+		include $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 	else
 	{
 		if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 			require PUN_ROOT.'include/cache.php';
 
 		generate_smiley_cache();
-		require FORUM_CACHE_DIR.'cache_smilies.php';
+		require $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 	}
 }
 

+ 10 - 8
include/poll.php

@@ -78,8 +78,8 @@ function poll_info($tid, $uid = null)
 
 	if ($tid == 0) return null;
 	
-	if (file_exists(FORUM_CACHE_DIR.'polls/'.$tid.'.php'))
-		include FORUM_CACHE_DIR.'polls/'.$tid.'.php';
+	if (file_exists($container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php'))
+		include $container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php';
 		
 	if (!isset($kol))
 	{
@@ -113,10 +113,10 @@ function poll_info($tid, $uid = null)
 			'type' => $type,
 			);
 
-		if (!is_dir(FORUM_CACHE_DIR.'polls/'))
-			mkdir(FORUM_CACHE_DIR.'polls', 0755);
+		if (!is_dir($container->getParameter('DIR_CACHE') . 'polls/'))
+			mkdir($container->getParameter('DIR_CACHE') . 'polls', 0755);
 
-		$fh = @fopen(FORUM_CACHE_DIR.'polls/'.$tid.'.php', 'wb');
+		$fh = @fopen($container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php', 'wb');
 		if (!$fh)
 			error('Unable to write configuration cache file to cache(/polls) directory. Please make sure PHP has write access to this directory.', __FILE__, __LINE__);
 
@@ -129,7 +129,7 @@ function poll_info($tid, $uid = null)
 		fclose($fh);
 
 		if (function_exists('apc_delete_file'))
-			@apc_delete_file(FORUM_CACHE_DIR.'polls/'.$tid.'.php');
+			@apc_delete_file($container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php');
 	}
 	
 	if ($kol == 0) return null;
@@ -409,8 +409,10 @@ function poll_form_validate($tid, &$errors)
 // удаление кэша опроса ********************************************************
 function poll_cache_delete($tid)
 {
-	if (file_exists(FORUM_CACHE_DIR.'polls/'.$tid.'.php'))
-		@unlink(FORUM_CACHE_DIR.'polls/'.$tid.'.php');
+    global $container;
+
+	if (file_exists($container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php'))
+		@unlink($container->getParameter('DIR_CACHE') . 'polls/'.$tid.'.php');
 }
 
 // удаление опроса *************************************************************

+ 4 - 4
include/search_idx.php

@@ -160,7 +160,7 @@ function split_words($text, $idx)
 //
 function validate_search_word($word, $idx)
 {
-	static $stopwords;
+	static $container, $stopwords;
 
 	// If the word is a keyword we don't want to index it, but we do want to be allowed to search it
 	if (is_keyword($word))
@@ -168,8 +168,8 @@ function validate_search_word($word, $idx)
 
 	if (!isset($stopwords))
 	{
-		if (file_exists(FORUM_CACHE_DIR.'cache_stopwords.php'))
-			include FORUM_CACHE_DIR.'cache_stopwords.php';
+		if (file_exists($container->getParameter('DIR_CACHE') . 'cache_stopwords.php'))
+			include $container->getParameter('DIR_CACHE') . 'cache_stopwords.php';
 
 		if (!defined('PUN_STOPWORDS_LOADED'))
 		{
@@ -177,7 +177,7 @@ function validate_search_word($word, $idx)
 				require PUN_ROOT.'include/cache.php';
 
 			generate_stopwords_cache();
-			require FORUM_CACHE_DIR.'cache_stopwords.php';
+			require $container->getParameter('DIR_CACHE') . 'cache_stopwords.php';
 		}
 	}
 

+ 3 - 3
index.php

@@ -48,8 +48,8 @@ require PUN_ROOT.'header.php';
 require PUN_ROOT.'include/subforums_view.php'; // MOD subforums - Visman
 
 // Collect some statistics from the database
-if (file_exists(FORUM_CACHE_DIR.'cache_users_info.php'))
-	include FORUM_CACHE_DIR.'cache_users_info.php';
+if (file_exists($container->getParameter('DIR_CACHE') . 'cache_users_info.php'))
+	include $container->getParameter('DIR_CACHE') . 'cache_users_info.php';
 
 if (!defined('PUN_USERS_INFO_LOADED'))
 {
@@ -57,7 +57,7 @@ if (!defined('PUN_USERS_INFO_LOADED'))
 		require PUN_ROOT.'include/cache.php';
 
 	generate_users_info_cache();
-	require FORUM_CACHE_DIR.'cache_users_info.php';
+	require $container->getParameter('DIR_CACHE') . 'cache_users_info.php';
 }
 
 $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());

+ 3 - 3
plugins/AP_Smilies.php

@@ -28,15 +28,15 @@ else
 	require PUN_ROOT.'lang/English/admin_plugin_smilies.php';
 
 // Retrieve the smiley set
-if (file_exists(FORUM_CACHE_DIR.'cache_smilies.php'))
-	include FORUM_CACHE_DIR.'cache_smilies.php';
+if (file_exists($container->getParameter('DIR_CACHE') . 'cache_smilies.php'))
+	include $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 else
 {
 	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 		require PUN_ROOT.'include/cache.php';
 
 	generate_smiley_cache();
-	require FORUM_CACHE_DIR.'cache_smilies.php';
+	require $container->getParameter('DIR_CACHE') . 'cache_smilies.php';
 }
 
 // Retrieve the smiley images