Created
December 20, 2012 09:22
-
-
Save intarstudents/4344095 to your computer and use it in GitHub Desktop.
Get version in which SWF file is compiled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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