Esempio n. 1
0
function GetDrives($dir = '/home/picosafe/drives')
{
    $files = glob($dir . '/*.drive');
    $drives = array();
    foreach ($files as $file) {
        $drives[] = array('name' => base64_decode(basename($file, '.drive')), 'size' => RealFileSize($file));
    }
    return $drives;
}
Esempio n. 2
0
function ListDirectory($directory)
{
    $path = realpath($directory);
    if (file_exists($path)) {
        $files = glob($path . '/*');
        //scandir($directory);
        if ($files[0] == '.') {
            unset($files[0]);
        }
        if ($files[1] == '..') {
            unset($files[1]);
        }
        $files = array_values($files);
        $data = array();
        for ($i = 0; $i < count($files); $i++) {
            $name = basename($files[$i]);
            $type = filetype($files[$i]);
            $size = $type == 'file' ? RealFileSize($files[$i]) : 0;
            $data[] = array('path' => $files[$i], 'name' => $name, 'type' => $type, 'size' => $size);
        }
        return $data;
    }
}
Esempio n. 3
0
<?php

/* ************** Actions ************** */
$action = $_GET['action'];
if ($action == 'filesize') {
    $file = base64_decode($_GET['file']);
    echo RealFileSize($file);
}
if ($action == 'getblock') {
    $file = base64_decode($_GET['file']);
    $block = $_GET['block'];
    $blocksize = $_GET['blocksize'];
    echo GetBlock($file, $block, $blocksize);
}
return;
/* *********** Actions-End  ************ */
function GetBlock($file, $block, $blocksize)
{
    if (!(file_exists($file) && is_numeric($block) && $block > 0 && is_numeric($blocksize) && $blocksize > 0)) {
        return 'invalid arguments';
    }
    $handle = fopen($file, 'r');
    if ($handle == null) {
        return 'cant read block';
    }
    $size = RealFilesize($file);
    $offset = ($block - 1) * $blocksize;
    if (fseek($handle, $offset, SEEK_SET) < 0) {
        fclose($handle);
        return 'cant read block';
    }