website - load mobile .apk version, and embedded IITC version, dynamically - ensures the data remains up to date, even for the 'test builds' page
This commit is contained in:
		
							
								
								
									
										32
									
								
								website/page/code/mobile-version.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								website/page/code/mobile-version.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| <?php | ||||
|  | ||||
| include_once ( "apk/ApkParser.php" ); | ||||
| include_once ( "userscript.php" ); | ||||
|  | ||||
| function getMobileVersion($apkfile) | ||||
| { | ||||
| 	$result = Array(); | ||||
|  | ||||
|  | ||||
| 	$apkinfo = new ApkParser ( $apkfile ); | ||||
|  | ||||
| 	$manifest = $apkinfo->getManifest(); | ||||
|  | ||||
| 	$result['apk_version'] = $manifest->getVersionName(); | ||||
|  | ||||
|  | ||||
| 	$archive = $apkinfo->getApkArchive(); | ||||
| 	$iitc_file = "assets/total-conversion-build.user.js"; | ||||
| 	if ( $archive->statName ( $iitc_file ) === FALSE ); | ||||
| 		$iitc_file = "assets/iitc.js"; | ||||
|  | ||||
| 	$stream = $archive->getStream ( $iitc_file ); | ||||
|  | ||||
| 	$header = loadUserScriptHeader ( $stream ); | ||||
|  | ||||
| 	$result['iitc_version'] = $header['@version']; | ||||
|  | ||||
| 	return $result; | ||||
| } | ||||
|  | ||||
| ?> | ||||
| @@ -1,11 +1,14 @@ | ||||
| <?php | ||||
|  | ||||
| function loadUserScriptHeader($path) | ||||
| function loadUserScriptHeader($file) | ||||
| { | ||||
| 	$result = Array(); | ||||
|  | ||||
| 	$f = fopen ( $path, "rt" ); | ||||
| 	while ( ( $line = fgets ( $f ) ) !== FALSE ) | ||||
| 	if ( is_string($file) ) | ||||
| 		$file = fopen ( $file, "rt" ); | ||||
| 	# else assume it's already a readable stream | ||||
|  | ||||
| 	while ( ( $line = fgets ( $file ) ) !== FALSE ) | ||||
| 	{ | ||||
| 		if ( preg_match ( '#//[ \\t]*==/UserScript==#', $line ) ) | ||||
| 			break; | ||||
|   | ||||
| @@ -36,9 +36,34 @@ IITC Mobile is still in the early stages of development. Many things do not yet | ||||
|  | ||||
| <h3>Download</h3> | ||||
|  | ||||
| <p> | ||||
| IITC Mobile version 0.3 (with IITC version 0.11.2). | ||||
| </p> | ||||
| <?php | ||||
|  | ||||
| <a onclick="if(track){track('mobile','download','iitc-mobile');}" href="mobile/IITC-Mobile-0.3.apk" class="btn btn-large btn-primary">Download</a> | ||||
| include_once ( "code/mobile-version.php" ); | ||||
|  | ||||
| $apkfile = "mobile/IITC-Mobile-0.3.apk"; | ||||
|  | ||||
|  | ||||
| if ( file_exists($apkfile) ) | ||||
| { | ||||
| 	$version = getMobileVersion ( $apkfile ); | ||||
|  | ||||
| 	$apk_version = $version['apk_version']; | ||||
| 	$iitc_version = preg_replace ( '/^(\d+\.\d+\.\d+)\.(\d{8}\.\d{6})/', '\1<small class="muted">.\2</small>', $version['iitc_version'] ); | ||||
|  | ||||
| 	print "<p>IITC Mobile version $apk_version, with IITC version $iitc_version</p>\n"; | ||||
|  | ||||
| 	print "<p><a onclick=\"if(track)({track{'mobile','download','release');}\" class=\"btn btn-large btn-primary\" href=\"$apkfile\">Download</a></p>\n"; | ||||
|  | ||||
| } | ||||
| else | ||||
| { | ||||
| 	print "<div class=\"alert alert-error\">Error: <b>$apkfile</b> not found</div>\n"; | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
|  | ||||
| <div class="alert alert-info"> | ||||
| As IITC Mobile is regularly updated, you may want to consider trying the latest | ||||
| <a href="?page=test#test-mobile">test build</a>. | ||||
| </div> | ||||
|   | ||||
| @@ -16,6 +16,7 @@ builds. | ||||
|  | ||||
| include_once ( "code/desktop-download.php" ); | ||||
|  | ||||
|  | ||||
| $path = "test"; | ||||
|  | ||||
| if ( $_REQUEST['build'] == 'dev' ) | ||||
| @@ -57,7 +58,30 @@ iitcDesktopPluginDownloadTable ( $path ); | ||||
|  | ||||
| <h3 id="test-mobile">Mobile test build</h3> | ||||
|  | ||||
| <p>IITC Mobile version informpation - not currently available for test builds</p> | ||||
| <?php | ||||
|  | ||||
| include_once ( "code/mobile-version.php" ); | ||||
|  | ||||
| $apkfile = "$path/IITC_Mobile-test.apk"; | ||||
|  | ||||
| if ( file_exists($apkfile) ) | ||||
| { | ||||
| 	$version = getMobileVersion ( $apkfile ); | ||||
|  | ||||
| 	$apk_version = $version['apk_version']; | ||||
| 	$iitc_version = preg_replace ( '/^(\d+\.\d+\.\d+)\.(\d{8}\.\d{6})/', '\1<small class="muted">.\2</small>', $version['iitc_version'] ); | ||||
|  | ||||
| 	print "<p>IITC Mobile version $apk_version, with IITC version $iitc_version</p>\n"; | ||||
|  | ||||
| 	print "<a onclick=\"if(track)({track{'mobile','download','$path');}\" class=\"btn btn-large btn-primary\" href=\"$apkfile\">Download</a>\n"; | ||||
|  | ||||
| } | ||||
| else | ||||
| { | ||||
| 	print "<div class=\"alert alert-error\">Error: <b>$apkfile</b> not found</div>\n"; | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
|  | ||||
| <a class="btn btn-large btn-primary" href="<?php print $path; ?>/IITC_Mobile-test.apk">Download</a> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user