Browse Source

Better check if the files exist unless we want the logs full of errors :P

Signed-off-by: emanuele <emanuele45@gmail.com>
emanuele 12 years ago
parent
commit
06cedc0d9d
1 changed files with 10 additions and 7 deletions
  1. 10 7
      Sources/Subs.php

+ 10 - 7
Sources/Subs.php

@@ -4053,7 +4053,6 @@ function call_integration_hook($hook, $parameters = array())
 		return $results;
 
 	$functions = explode(',', $modSettings[$hook]);
-
 	// Loop through each function.
 	foreach ($functions as $function)
 	{
@@ -4064,10 +4063,12 @@ function call_integration_hook($hook, $parameters = array())
 			if (strpos($call[1], ':') !== false)
 			{
 				list($func, $file) = explode(':', $call[1]);
-				if (!empty($settings['theme_dir']))
-					include_once(strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)));
+				if (empty($settings['theme_dir']))
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
 				else
-					include_once(strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])));
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
+				if (file_exists($absPath))
+					require_once($absPath);
 				$call = array($call[0], $func);
 			}
 		}
@@ -4077,10 +4078,12 @@ function call_integration_hook($hook, $parameters = array())
 			if (strpos($function, ':') !== false)
 			{
 				list($func, $file) = explode(':', $function);
-				if (!empty($settings['theme_dir']))
-					include_once(strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)));
+				if (empty($settings['theme_dir']))
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
 				else
-					include_once(strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])));
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
+				if (file_exists($absPath))
+					require_once($absPath);
 				$call = $function;
 			}
 		}