Bladeren bron

! Bye bye loadClassFile we hardly knew you ... plus not need for PHP 5.0.0+ Admin.php, ManageLanguages.php, ManagePaid.php, ManageSearch.php, PackageGet.php, Packages.php, Search.php, Subs-Package.php
! Left shell function of loadClassFile for mod compatibility Subs.php

Spuds 13 jaren geleden
bovenliggende
commit
1121311b73

+ 1 - 1
Sources/Admin.php

@@ -891,7 +891,7 @@ function AdminSearchOM()
 
 	// Otherwise we simply walk through the XML and stick it in context for display.
 	$context['search_results'] = array();
-	loadClassFile('Class-Package.php');
+	require_once($sourcedir . '/Class-Package.php');
 
 	// Get the results loaded into an array for processing!
 	$results = new xmlArray($search_results, false);

+ 1 - 1
Sources/ManageLanguages.php

@@ -81,7 +81,7 @@ function AddLanguage()
 		$url = 'http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => '')));
 
 		// Load the class file and stick it into an array.
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 		$language_list = new xmlArray(fetch_web_data($url), true);
 
 		// Check it exists.

+ 1 - 1
Sources/ManagePaid.php

@@ -1788,7 +1788,7 @@ function loadPaymentGateways()
 
 				if (strpos($header, '// SMF Payment Gateway: ' . strtolower($matches[1])) !== false)
 				{
-					loadClassFile($file);
+					require_once($sourcedir . '/' . $file);
 
 					$gateways[] = array(
 						'filename' => $file,

+ 1 - 1
Sources/ManageSearch.php

@@ -769,7 +769,7 @@ function loadSearchAPIs()
 
 				if (strpos($header, '* SearchAPI-' . $matches[1] . '.php') !== false)
 				{
-					loadClassFile($file);
+					require_once($sourcedir . '/' . $file);
 
 					$index_name = strtolower($matches[1]);
 					$search_class_name = $index_name . '_search';

+ 3 - 3
Sources/PackageGet.php

@@ -123,7 +123,7 @@ function PackageServers()
 	{
 		if (isset($_POST['ftp_username']))
 		{
-			loadClassFile('Class-Package.php');
+			require_once($sourcedir . '/Class-Package.php');
 			$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
 
 			if ($ftp->error === false)
@@ -141,7 +141,7 @@ function PackageServers()
 		{
 			if (!isset($ftp))
 			{
-				loadClassFile('Class-Package.php');
+				require_once($sourcedir . '/Class-Package.php');
 				$ftp = new ftp_connection(null);
 			}
 			elseif ($ftp->error !== false && !isset($ftp_error))
@@ -252,7 +252,7 @@ function PackageGBrowse()
 	@set_time_limit(600);
 
 	// Read packages.xml and parse into xmlArray. (the true tells it to trim things ;).)
-	loadClassFile('Class-Package.php');
+	require_once($sourcedir . '/Class-Package.php');
 	$listing = new xmlArray(fetch_web_data($_GET['package']), true);
 
 	// Errm.... empty file?  Try the URL....

+ 1 - 1
Sources/Packages.php

@@ -1567,7 +1567,7 @@ function PackagePermissions()
 
 	if (empty($package_ftp) && !isset($_POST['skip_ftp']))
 	{
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 		$ftp = new ftp_connection(null);
 		list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
 

+ 2 - 2
Sources/Search.php

@@ -2110,7 +2110,7 @@ function findSearchAPI()
 	$modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
 	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
 		fatal_lang_error('search_api_missing');
-	loadClassFile('SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
+	require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
 
 	// Create an instance of the search API and check it is valid for this version of SMF.
 	$search_class_name = $modSettings['search_index'] . '_search';
@@ -2123,7 +2123,7 @@ function findSearchAPI()
 		loadLanguage('Errors');
 		log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');
 
-		loadClassFile('SearchAPI-Standard.php');
+		require_once($sourcedir . '/SearchAPI-Standard.php');
 		$searchAPI = new standard_search();
 	}
 

+ 12 - 12
Sources/Subs-Package.php

@@ -427,7 +427,7 @@ function loadInstalledPackages()
  */
 function getPackageInfo($gzfilename)
 {
-	global $boarddir;
+	global $boarddir, $sourcedir;
 
 	// Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.)
 	if (strpos($gzfilename, 'http://') !== false)
@@ -450,7 +450,7 @@ function getPackageInfo($gzfilename)
 		return 'package_get_error_is_zero';
 
 	// Parse package-info.xml into an xmlArray.
-	loadClassFile('Class-Package.php');
+	require_once($sourcedir . '/Class-Package.php');
 	$packageInfo = new xmlArray($packageInfo);
 
 	// @todo Error message of some sort?
@@ -657,7 +657,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 	if (!empty($_SESSION['pack_ftp']['connected']))
 	{
 		// Load the file containing the ftp_connection class.
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 
 		$package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password']));
 	}
@@ -665,7 +665,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 	// Just got a submission did we?
 	if (empty($package_ftp) && isset($_POST['ftp_username']))
 	{
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
 
 		// We're connected, jolly good!
@@ -731,7 +731,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 		{
 			if (!isset($ftp))
 			{
-				loadClassFile('Class-Package.php');
+				require_once($sourcedir . '/Class-Package.php');
 				$ftp = new ftp_connection(null);
 			}
 			elseif ($ftp->error !== false && !isset($ftp_error))
@@ -781,7 +781,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
  */
 function packageRequireFTP($destination_url, $files = null, $return = false)
 {
-	global $context, $modSettings, $package_ftp, $boarddir, $txt;
+	global $context, $modSettings, $package_ftp, $boarddir, $txt, $sourcedir;
 
 	// Try to make them writable the manual way.
 	if ($files !== null)
@@ -848,7 +848,7 @@ function packageRequireFTP($destination_url, $files = null, $return = false)
 	elseif (isset($_SESSION['pack_ftp']))
 	{
 		// Load the file containing the ftp_connection class.
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 
 		$package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password']));
 
@@ -888,7 +888,7 @@ function packageRequireFTP($destination_url, $files = null, $return = false)
 	}
 	elseif (isset($_POST['ftp_username']))
 	{
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
 
 		if ($ftp->error === false)
@@ -906,7 +906,7 @@ function packageRequireFTP($destination_url, $files = null, $return = false)
 	{
 		if (!isset($ftp))
 		{
-			loadClassFile('Class-Package.php');
+			require_once($sourcedir . '/Class-Package.php');
 			$ftp = new ftp_connection(null);
 		}
 		elseif ($ftp->error !== false && !isset($ftp_error))
@@ -1735,7 +1735,7 @@ function parseModification($file, $testing = true, $undo = false, $theme_paths =
 	global $boarddir, $sourcedir, $settings, $txt, $modSettings, $package_ftp;
 
 	@set_time_limit(600);
-	loadClassFile('Class-Package.php');
+	require_once($sourcedir . '/Class-Package.php');
 	$xml = new xmlArray(strtr($file, array("\r" => '')));
 	$actions = array();
 	$everything_found = true;
@@ -2840,7 +2840,7 @@ function package_create_backup($id = 'backup')
  */
 function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection_level = 0)
 {
-	global $webmaster_email;
+	global $webmaster_email, $sourcedir;
 	static $keep_alive_dom = null, $keep_alive_fp = null;
 
 	preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match);
@@ -2851,7 +2851,7 @@ function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection
 	elseif ($match[1] == 'ftp')
 	{
 		// Include the file containing the ftp_connection class.
-		loadClassFile('Class-Package.php');
+		require_once($sourcedir . '/Class-Package.php');
 
 		// Establish a connection and attempt to enable passive mode.
 		$ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);

+ 3 - 32
Sources/Subs.php

@@ -3456,6 +3456,8 @@ function clean_cache($type = '')
 
 /**
  * Load classes that are both (E_STRICT) PHP 4 and PHP 5 compatible.
+ * - removed php4 support
+ * - left shell in place for mod compatablily
  *
  * @param string $filename
  * @todo remove this function since we are no longer supporting PHP < 5
@@ -3463,42 +3465,11 @@ function clean_cache($type = '')
 function loadClassFile($filename)
 {
 	global $sourcedir;
-	static $files_included = array();
 
 	if (!file_exists($sourcedir . '/' . $filename))
 		fatal_lang_error('error_bad_file', 'general', array($sourcedir . '/' . $filename));
 
-	// Using a version below PHP 5.0? Do a compatibility conversion.
-	if (version_compare(PHP_VERSION, '5.0.0', '<='))
-	{
-		// Check if it was included before.
-		if (in_array($filename, $files_included))
-			return;
-
-		// Make sure we don't include it again.
-		$files_included[] = $filename;
-
-		// Do some replacements to make it PHP 4 compatible.
-		eval('?' . '>' . preg_replace(array(
-			'~class\s+([\w-_]+)([^}]+)function\s+__construct\s*\(~',
-			'~([\s\t]+)public\s+\$~',
-			'~([\s\t]+)private\s+\$~',
-			'~([\s\t]+)protected\s+\$~',
-			'~([\s\t]+)public\s+function\s+~',
-			'~([\s\t]+)private\s+function\s+~',
-			'~([\s\t]+)protected\s+function\s+~',
-		), array(
-			'class $1$2function $1(',
-			'$1var $',
-			'$1var $',
-			'$1var $',
-			'$1function ',
-			'$1function ',
-			'$1function ',
-		), rtrim(file_get_contents($sourcedir . '/' . $filename))));
-	}
-	else
-		require_once($sourcedir . '/' . $filename);
+	require_once($sourcedir . '/' . $filename);
 }
 
 /**