$supportedCompression = array('zip', 'rar', 'gz', 'bzip', 'tbz', 'tgz', 'tar');
foreach ($returnArr['files'] as $fileentry) {
    $filename = $fileentry['name'];
    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;
Esempio n. 2
0
    } catch (Exception $e) {
        try {
            rar_close($rar_file);
        } catch (Exception $e) {
        }
        echo "An exception occured while extracting archive: " . $e . "\n";
    }
}
function saveModificationTime()
{
    file_put_contents(DATA_FILE, filemtime(RAR_FILE));
}
##############################
#
# processing
#
##############################
$created = file_get_contents(DATA_FILE);
echo "Starting cronjob...";
if (false === $created || $created != filemtime(RAR_FILE)) {
    // the index.rar is new, so extract it
    echo "Removing previously extracted files...\n";
    removeExtractedFiles(TARGET_DIR);
    echo "Unraring new file...\n";
    unrarFile();
    saveModificationTime();
} else {
    echo "No changes detected. Did not extract the archive.\n";
}
echo "Setting rights...\n";
system('chown gammag:psacln ' . TARGET_DIR . ' -R');