website: 1st pass at backend for version check plugin
This commit is contained in:
		| @@ -1,8 +1,11 @@ | ||||
| <?php | ||||
| 
 | ||||
| $response = Array(); | ||||
| include_once "code/userscript.php"; | ||||
| include_once "code/url/url_to_absolute.php"; | ||||
| 
 | ||||
| 
 | ||||
| $response = Array(); | ||||
| 
 | ||||
| 
 | ||||
| $build = $_REQUEST['build']; | ||||
| 
 | ||||
| @@ -11,20 +14,24 @@ $details = Array ( | ||||
| 	'jonatkins' => Array ( # live release
 | ||||
| 		'path' => 'release', | ||||
| 		'name' => 'Stable release build', | ||||
| 		'web' => 'http://iitc.jonatkins.com/?page=download', | ||||
| 	), | ||||
| 	'jonatkins-test' => Array ( # public test builds
 | ||||
| 		'path' => 'test', | ||||
| 		'name' => 'Test build', | ||||
| 		'web' => 'http://iitc.jonatkins.com/?page=test', | ||||
| 	), | ||||
| 
 | ||||
| 	'jonatkins-experimental' => Array ( # rarely used, for features not quite ready for 'test'
 | ||||
| 		'path' => 'experimental', | ||||
| 		'name' => 'Experimental build', | ||||
| 		'web' => 'http://iitc.jonatkins.com/?page=test&build=experimental', | ||||
| 	), | ||||
| 
 | ||||
| 	'jonatkins-dev' => Array ( # personal
 | ||||
| 		'path' => 'dev', | ||||
| 		'name' => 'Development builds - not for public use', | ||||
| 		'web' => 'http://iitc.jonatkins.com/?page=test&build=dev', | ||||
| 	), | ||||
| 
 | ||||
| 	'local' => Array ( # not a real build, but often the default for local development
 | ||||
| @@ -37,9 +44,35 @@ if ( array_key_exists ( $build, $details ) ) | ||||
| { | ||||
| 	$info = $details[$build]; | ||||
| 
 | ||||
| 	$response['buildPath'] = $info['path']; | ||||
| 	$pageurl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | ||||
| 
 | ||||
| 	$response['name'] = $info['name']; | ||||
| 
 | ||||
| 	$dir = $info['path']; | ||||
| 
 | ||||
| 	// load main script version
 | ||||
| 	$iitc_details = loadUserScriptHeader ( "$dir/total-conversion-build.user.js" ); | ||||
| 	$response['iitc'] = Array ( | ||||
| 		'version' => $iitc_details['@version'], | ||||
| 		'downloadUrl' => url_to_absolute ( $pageurl, "$dir/total-conversion-build.user.js" ), | ||||
| 		'pageUrl' => url_to_absolute ( $pageurl, $info['web'] ), | ||||
| 	); | ||||
| 
 | ||||
| 	// and now the plugins
 | ||||
| 
 | ||||
| 	$response['plugins'] = Array(); | ||||
| 
 | ||||
| 	foreach ( glob ( "$dir/plugins/*.user.js" ) as $path ) | ||||
| 	{ | ||||
| 		$basename = basename ( $path, ".user.js" ); | ||||
| 		$details = loadUserScriptHeader ( $path ); | ||||
| 
 | ||||
| 		$response['plugins'][$basename] = Array ( | ||||
| 			'version' => $details['@version'], | ||||
| 			'downloadUrl' => url_to_absolute ( $pageurl, "$dir/plugins/$basename.user.js" ), | ||||
| 			'pageUrl' => url_to_absolute ( $pageurl, $info['web']."#plugin-$basename" ), | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| else | ||||
		Reference in New Issue
	
	Block a user