Beispiel #1
0
<?php

require 'inc/util.php';
require 'inc/zipcreate.cls.lib.php';
require 'inc/zipcreate.cls.php';
# get the directory to zip
$dir = isset($_GET['d']) ? clean_path(stripslashes($_GET['d'])) : '';
if (strlen($dir) > 0 && is_dir($dir)) {
    date_default_timezone_set('America/Los_Angeles');
    if (!ends_with($dir, '/')) {
        $dir .= '/';
    }
    # create new zip stream object
    $zip = new ZipCreate('gzip', true, basename($dir) . '.zip');
    # add files
    $files = dir_get_files($dir);
    $dir_len = strlen($dir);
    foreach ($files as $file) {
        # get file data
        $data = file_get_contents($file);
        # add file to archive
        $zip->add_file($data, substr($file, $dir_len), filemtime($file));
    }
    # finish archive
    $zipcontent = $zip->finish_stream();
}
    }
}
//Unmount Partitions
foreach ($settings['mount'] as $mpoint => $config) {
    scriptadd('unmount("' . $mpoint . '");');
    scriptadd('ui_print("Unmounting ' . $mpoint . '");');
}
//Create Zip
include 'includes/functions.lib.php';
include 'includes/zipcreate.cls.php';
if (!is_dir("zip/")) {
    mkdir("zip/");
    chmod("zip/", 0777);
}
$filename = "zip/" . date('m-d-y-his') . "-" . substr(sha1(rand() . implode($_GET) . time()), -6) . ".zip";
$zip = new ZipCreate();
foreach ($filelist as $realpath => $zippath) {
    if ($fp = fopen($realpath, 'rb')) {
        $contents = fread($fp, filesize($realpath));
        fclose($fp);
        $zip->add_file($contents, $zippath, filemtime($realpath));
    }
}
if ($fp = fopen("files/update-binary", 'rb')) {
    $contents = fread($fp, filesize("files/update-binary"));
    fclose($fp);
    $zip->add_file($contents, "META-INF/com/google/android/update-binary", filemtime("files/update-binary"));
}
//Progress Bar Generation
$numlines = count($updatescript);
$num = bcdiv(1, $numlines / 5, 6);