예제 #1
0
    debug("The filename is {$filename}\n");
    $ext = end(explode('.', $filename));
    debug("The extension is {$ext}\n");
    if (in_array($ext, $supportedCompression)) {
        debug("{$filename} is a supported archive\n");
        $owner = getTransmissionTransferOwner($tHash);
        debug("The owner is {$owner}\n");
        $message = "Torrent {$tName} was finished and unzipping of file {$filename} has started.";
        //SaveMessage($to_user, $cfg["user"], htmlentities($message), (empty($to_all_r)) ? 0 : 1, (!empty($force_read_r) && $cfg['isAdmin']) ? 1 : 0);
        SaveMessage($owner, $owner, htmlentities($message), 0, 0);
        // start uncompressing the file
        if ($ext === "rar") {
            unrarFile($returnArr['downloadDir'], $filename, $returnArr['name']);
        }
        if ($ext === "zip") {
            unzipFile($returnArr['downloadDir'], $filename, $returnArr['name']);
        }
        if ($ext === "gz") {
            print "Not yet implemented";
        }
    }
}
debug("\nEnd of script");
exit;
// unrar file
function unrarFile($downloadDir, $filename, $name, $password = "******")
{
    global $logfile, $cfg;
    $unrar = $cfg['bin_unrar'];
    $log = $downloadDir . $logfile;
    if (file_exists($log)) {
예제 #2
0
파일: zip.php 프로젝트: alexscarp/middix
            $destination_folder = $destination_folder . '/';
        }
        $vzip = new SimpleUnzip($filename);
        foreach ($vzip->Entries as $extr) {
            $path = $extr->Path;
            $path_folder = explode('/', $path);
            $new_path = '';
            foreach ($path_folder as $folder) {
                $new_path .= $folder . '/';
                $to_create = $destination_folder . $new_path;
                if (substr($to_create, -1) == '/') {
                    $to_create = substr($to_create, 0, strlen($to_create) - 1);
                }
                @mkdir($to_create, 0777);
            }
            $new_path = '';
            $filev = fopen($destination_folder . $extr->Path . '/' . $extr->Name, 'w');
            fwrite($filev, $extr->Data);
            fclose($filev);
        }
    }
    $filepath = urldecode($_REQUEST["t"]);
    $fileperms = has_permissions($filepath);
    $filepath = $fileperms[1];
    $zippath = urldecode($_REQUEST["z"]);
    $zipperms = has_permissions($zippath);
    $zippath = $zipperms[1];
    if ($fileperms[0][1] && $zipperms[0][0]) {
        unzipFile("../../" . $zippath, "../../" . $filepath);
    }
}
예제 #3
0
<?php

//Author		: Wendowski, Kevin
//File Name		: index.php
//Includes
include "gtfs.library.php";
//Download:
$url = "http://www2.septa.org/developer/download.php?fc=septa_gtfs.zip&download=download";
$saveDirectory = "feeds/gtfs.zip";
$result = downloadFile($url, $saveDirectory);
//Unzip:
$feedDirectory = "feeds";
$filename = $feedDirectory . "/gtfs.zip";
$filenameRail = $feedDirectory . "/gtfs/google_rail.zip";
$unzip = unzipFile($filename, $filenameRail, $feedDirectory);
//Read Files:
$directory = "feeds/google_rail";
$files = readDirectory($directory);
var_dump($files);
foreach ($files as $file) {
    $location = "feeds/google_rail/" . $file;
    $GTFSFilename = substr(strrchr($location, '/'), 1);
    clearGTFSData($GTFSFilename);
    $result = readGTFSData($location);
}
//Function:
function readDirectory($directory)
{
    $files = array();
    if ($handle = opendir($directory)) {
        /* This is the correct way to loop over the directory. */