Get Version of exe via PHP

前端 未结 8 1420
自闭症患者
自闭症患者 2020-12-08 11:14

Is getting the version of a exe possible with php? I\'d like to print the version of a file that can be downloaded...

Windows exe and php is running on linux server<

8条回答
  •  猫巷女王i
    2020-12-08 11:29

    I wrote a small code that will pull the file version directly from the executable.

    PHP:

    "F\x00i\x00l\x00e\x00V\x00e\x00r\x00s\x00i\x00o\x00n",'end'=>"\x00\x00\x00");
        if (file_exists($file) && is_readable($file)) {
            $version = file_get_contents($file);
            $version = explode($parser_model['begin'], $version);
            $version = explode($parser_model['end'], $version[1]);
            $version = str_replace("\x00", null, $version[1]);
            return ((!empty($version) ? "\x1b[32m$file version: $version\x1b[0m" : "\x1b[31mNo version\x1b[0m"));
        } else {
            print "\x1b[31m".(is_dir($file) ? "Specified path points to a directory, not a file." : "The specified path to the file may not exist or is not a file at all.")."\x1b[0m";
            return false;
        }
    }
    
    @print exeparser_fileversion($argv[1]);
    
    ?>
    


    Windows command (optional):

    @php "%~dp0\exeparser.php" %*
    

    Result:

提交回复
热议问题