Home >Backend Development >PHP Tutorial >Use php to obtain apk information on Linux system, linuxapk_PHP tutorial
Recently I am working on an apk mall, and the system needs to automatically read the apk information (package name, version) after the user uploads the apk number, etc.), the background language uses PHP, and PHP is required to call the system's aapt command to read the apk information. The method to install aapt on the Linux system is:
1. Copy aapt and apktool to /usr/bin/ in the future
2. Run aapt and report an error:
-bash: /usr/bin/aapt: /lib/ld-linux.so .2: bad ELF interpreter: No such file or directory
Solution: Check which package the required file is in
yum whatprovides */ld-linux.so.2
Select installation from the obtained list glibc-2.12-1.132.el6_5.1.i686
yum -y install glibc-2.12-1.132.el6_5.1.i686
If there is a dependency prompt, --skip-broken
3. Run:
yum install glibc.i686
At this time, the aapt still reports an error
aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
Solution: Same as above
yum whatprovides */libz.so.1 --skip-broken
If there is a package version conflict, run: yum install zlib
4, this time Also report an error
aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Solution:
yum whatprovides */libstdc++.so.6
yum -y install libstdc++-4.4.7-4.el6.i686
Conflict
yum -y install libstdc*
yum -y install libstdc++-4.4.7-4.el6.i686
It’s basically ok at this point
aapt software package download address: http://pan.baidu.com/s/1pJkEqcb
Put the file with the PHP extension below and access it on the server.
//Get the original MAC address of the network card
class GetMacAddr{
var $return_array = array(); // Return the MAC address with String array.
var $mac_addr;
function GetMacAddr($os_type){
switch ( strtolower($os_type) ){
case "linux":
$this->forLinux( );
break;
case "solaris":
break;
case "unix":
break;
case "aix":
break;
default :
$this->forWindows();
break;
}
$temp_array = array();
foreach ( $this->return_array as $value ){
if (
preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0- 9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-] "."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i",$value,
$temp_array ) ){
$this->mac_addr = $temp_array[0];
break;
}
}
unset($temp_array);
return $this ->mac_addr;
}
function forWindows(){
@exec("ipconfig /...the rest of the text>>
If the file name is in Chinese, don’t make others feel disgusted. The basic principle of the server is that Chinese file names must not appear.
Because the common default encoding of file names under Linux is UTF-8. But in many cases, the file names in the compressed package are the IO character encoding of the current system. Moreover, when decompressing and writing files, many software do not provide file name encoding conversion.
The result is problems.
Now, you can either use your current encoding to recompress the file. Of course, the encoding of Windows is definitely not UTF8, it can only be Linux, or try to use the English version (you cannot use the language pack to change it to English, Must be in pure English). Otherwise, use a compression protocol that supports file name encoding settings to recompress, but I don’t know what support is available.
The last way is to write the decompression code yourself, get the file name in the code and convert it yourself.