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:
Jon Atkins
2013-04-30 16:39:17 +01:00
parent ec7d18232a
commit a9034f3832
4 changed files with 93 additions and 9 deletions

View 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;
}
?>

View File

@ -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;