Example #1
7
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new \ApkParser\Parser('EBHS.apk');
$manifest = $apk->getManifest();
$permissions = $manifest->getPermissions();
echo '<pre>';
echo "Package Name      : " . $manifest->getPackageName() . "" . PHP_EOL;
echo "Version           : " . $manifest->getVersionName() . " (" . $manifest->getVersionCode() . ")" . PHP_EOL;
echo "Min Sdk Level     : " . $manifest->getMinSdkLevel() . "" . PHP_EOL;
echo "Min Sdk Platform  : " . $manifest->getMinSdk()->platform . "" . PHP_EOL;
echo PHP_EOL;
echo "------------- Permssions List -------------" . PHP_EOL;
// find max length to print more pretty.
$perm_keys = array_keys($permissions);
$perm_key_lengths = array_map(function ($perm) {
    return strlen($perm);
}, $perm_keys);
$max_length = max($perm_key_lengths);
foreach ($permissions as $perm => $detail) {
    echo str_pad($perm, $max_length + 4, ' ') . "=> " . $detail['description'] . " " . PHP_EOL;
    echo str_pad('', $max_length - 5, ' ') . ' cost    =>  ' . ($detail['flags']['cost'] ? 'true' : 'false') . " " . PHP_EOL;
    echo str_pad('', $max_length - 5, ' ') . ' warning =>  ' . ($detail['flags']['warning'] ? 'true' : 'false') . " " . PHP_EOL;
Example #2
2
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['file' => 'required']);
     $file = $request->file('file');
     $original_file_name = $file->getClientOriginalName();
     $file_name = pathinfo($original_file_name, PATHINFO_FILENAME);
     $extension = \File::extension($original_file_name);
     $actual_name = $file_name . '.' . $extension;
     $apk = new \ApkParser\Parser($file);
     $manifest = $apk->getManifest();
     $labelResourceId = $apk->getManifest()->getApplication()->getLabel();
     $appLabel = $apk->getResources($labelResourceId);
     $package_name = $manifest->getPackageName();
     if (Apk::packageExist($package_name)) {
         Session::flash('flash_class', 'alert-danger');
         Session::flash('flash_message', 'Apk namespace already exist.');
         return redirect()->route("apk.create");
     }
     Apk::create(array('app_name' => $appLabel[0], 'pkgname' => $package_name, 'version' => $manifest->getVersionCode(), 'version_name' => $manifest->getVersionName(), 'md5' => md5_file($file), 'filename' => $actual_name, 'filesize' => str_format_filesize(\File::size($file)), 'token' => md5(uniqid(mt_rand(), true))));
     $folderpath = base_path() . '/storage/apk/' . $manifest->getPackageName();
     if (!\File::exists($folderpath)) {
         \File::makeDirectory($folderpath);
     }
     $file_path = $request->file('file')->move($folderpath, $actual_name);
     return redirect()->route("apk.index");
 }
 public function saveApk($file, $label, $name, $icon)
 {
     $fileSystem = new Filesystem();
     $parser = new ApkParser\Parser($file->getRealPath());
     $version = $parser->getManifest()->getVersionCode();
     $bundle = $parser->getManifest()->getPackageName();
     if (!$fileSystem->exists(public_path() . '/builds')) {
         $fileSystem->makeDirectory(public_path() . '/builds');
     }
     if (!$fileSystem->exists(public_path() . '/builds/android')) {
         $fileSystem->makeDirectory(public_path() . '/builds/android');
     }
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label);
     }
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version);
     }
     $label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_ANDROID_TYPE_ID)->first();
     if ($label_model != null) {
         $version_model = $label_model->versions()->where('version', '=', $version)->first();
         if ($version_model != null) {
             $build_version_count = Build::where('version_id', '=', $version_model->id)->count();
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
         } else {
             $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
         }
     } else {
         $label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_ANDROID_TYPE_ID));
         $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
         $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
     }
     $fn = public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.apk';
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build);
     }
     $fileSystem->move($file->getRealPath(), $fn);
     $fileSystem->move($icon->getRealPath(), public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
     return Config::get("app.domain") . "/android/builds/{$label}/{$version}/{$build->build}";
 }
Example #4
1
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new \ApkParser\Parser('EBHS.apk');
$resourceId = $apk->getManifest()->getApplication()->getIcon();
$resources = $apk->getResources($resourceId);
$labelResourceId = $apk->getManifest()->getApplication()->getLabel();
$appLabel = $apk->getResources($labelResourceId);
echo $appLabel[0];
header('Content-type: text/html');
echo $appLabel[0] . '<br/>';
foreach ($resources as $resource) {
    echo '<img src="data:image/png;base64,', base64_encode(stream_get_contents($apk->getStream($resource))), '" />';
}
Example #5
1
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new ApkParser\Parser('EBHS.apk');
echo '<pre>';
foreach ($apk->getManifest()->getApplication()->getActivityNameList() as $activityName) {
    echo $activityName . PHP_EOL;
}
Example #6
1
function apkinfo($path)
{
    include '/home/wwwroot/www.voteapps.com/terry/libs/apk-parser/examples/autoload.php';
    //print_r($_GET[path]);
    $apk = new \ApkParser\Parser($path);
    $manifest = $apk->getManifest();
    $permissions = $manifest->getPermissions();
    //$info.='<pre>';
    //$info="Package Name      : " . $manifest->getPackageName() . "" . PHP_EOL;
    //$info.="Version           : " . $manifest->getVersionName() . " (" . $manifest->getVersionCode() . ")" . PHP_EOL;
    $info[PackageName] = $manifest->getPackageName();
    $info[version] = $manifest->getVersionName();
    $info[MinSdkLevel] = $manifest->getMinSdkLevel();
    $info[platform] = $manifest->getMinSdk()->platform;
    //$info.="Min Sdk Level     : " . $manifest->getMinSdkLevel() . "" . PHP_EOL;
    //$info.="Min Sdk Platform  : " . $manifest->getMinSdk()->platform . "" . PHP_EOL;
    //$info.=PHP_EOL;
    //$info.="------------- Permssions List -------------" . PHP_EOL;
    $info[permissions] = $permissions;
    // find max length to print more pretty.
    $perm_keys = array_keys($permissions);
    $perm_key_lengths = array_map(function ($perm) {
        return strlen($perm);
    }, $perm_keys);
    $max_length = max($perm_key_lengths);
    /*************
    foreach ($permissions as $perm => $detail) {
        $info.=str_pad($perm, $max_length + 4, ' ') . "=> " . $detail['description'] . " " . PHP_EOL;
        $info.=str_pad('', $max_length - 5, ' ') . ' cost    =>  ' . ($detail['flags']['cost'] ? 'true' : 'false') . " " . PHP_EOL;
        $info.=str_pad('', $max_length - 5, ' ') . ' warning =>  ' . ($detail['flags']['warning'] ? 'true' : 'false') . " " . PHP_EOL;
        $info.=str_pad('', $max_length - 5, ' ') . ' danger  =>  ' . ($detail['flags']['danger'] ? 'true' : 'false') . " " . PHP_EOL;
    
    }
    
    
    //$info.=PHP_EOL;
    //$info.="------------- Activities  -------------" . PHP_EOL;
    
    
    foreach ($apk->getManifest()->getApplication()->activities as $activity) {
        $info.=$activity->name . ($activity->isLauncher ? ' (Launcher)' : null) . PHP_EOL;
    }
    
    $info.=PHP_EOL;
    $info.="------------- All Classes List -------------" . PHP_EOL;
    
    
    foreach ($apk->getClasses() as $className) {
        $info.=$className . PHP_EOL;
    }
    *********/
    return $info;
}
Example #7
1
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new ApkParser\Parser('EBHS.apk');
echo '<pre>';
foreach ($apk->getClasses() as $className) {
    echo $className . PHP_EOL;
}
Example #8
1
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new \ApkParser\Parser('EBHS.apk');
$extractFolder = 'extract_folder';
if (is_dir($extractFolder) || mkdir($extractFolder)) {
    $apk->extractTo($extractFolder);
}
<?php

/**
 * This file is part of the Apk Parser package.
 *
 * (c) Tufan Baris Yildirim <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include 'autoload.php';
$apk = new ApkParser\Parser('EBHS.apk');
header("Content-Type:text/xml;Charset=UTF-8");
echo $apk->getManifest()->getXmlString();