Skip to content

Instantly share code, notes, and snippets.

@intarstudents
Created December 20, 2012 09:22
Show Gist options
  • Save intarstudents/4344095 to your computer and use it in GitHub Desktop.
Save intarstudents/4344095 to your computer and use it in GitHub Desktop.
Get version in which SWF file is compiled
<?php
/**
* Get version in which SWF file is compiled
* @param string $file_path Path to SWF file
* @return int Version number (or -1 on error)
*/
function swf_version($file_path){
$ret = -1;
$fh = @fopen($file_path, "r");
if ($fh !== false){
// Read first 8 bytes
$header = fread($fh, 7);
fclose($fh);
// Seperate first 4 header bytes
list($c, $w, $s, $v) = $header;
$v = !is_null($v) ? ord($v) : 0;
// Verify that this is SWF header
if (in_array($c, array("C", "F")) && ($w == "W" && $s == "S"))
$ret = $v;
}
return $ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment