Пример #1
0
function findLapseFiles($d)
{
    //return an arranged in time order and then must have a matching 4 digit batch and an incrementing lapse number
    $batch = getFileIndex($d);
    $padlen = strlen($batch);
    $fullname = LBASE_DIR . '/' . MEDIA_PATH . '/' . dataFilename($d);
    $path = dirname($fullname);
    $start = filemtime("{$fullname}");
    $files = array();
    $scanfiles = scandir($path);
    $lapsefiles = array();
    foreach ($scanfiles as $file) {
        if (strpos($file, $batch) !== false) {
            if (!isThumbnail($file)) {
                $fDate = filemtime("{$path}/{$file}");
                if ($fDate >= $start) {
                    $files[$file] = $fDate;
                }
            }
        }
    }
    asort($files);
    $lapseCount = 1;
    foreach ($files as $key => $value) {
        if (strpos($key, str_pad($lapseCount, $padlen, 0, STR_PAD_LEFT)) !== false) {
            $lapsefiles[] = "{$path}/{$key}";
            $lapseCount++;
        } else {
            break;
        }
    }
    return $lapsefiles;
}
Пример #2
0
function purgeFiles()
{
    global $schedulePars;
    $videoHours = $schedulePars[SCHEDULE_PURGEVIDEOHOURS];
    $imageHours = $schedulePars[SCHEDULE_PURGEIMAGEHOURS];
    $lapseHours = $schedulePars[SCHEDULE_PURGELAPSEHOURS];
    $purgeCount = 0;
    if ($videoHours > 0 || $imageHours > 0 || $lapseHours > 0) {
        $files = scandir(BASE_DIR . '/' . MEDIA_PATH);
        $currentHours = time() / 3600;
        foreach ($files as $file) {
            if ($file != '.' && $file != '..' && isThumbnail($file)) {
                $fType = getFileType($file);
                $purgeHours = 0;
                switch ($fType) {
                    case 'i':
                        $purgeHours = $imageHours;
                        break;
                    case 't':
                        $purgeHours = $lapseHours;
                        break;
                    case 'v':
                        $purgeHours = $videoHours;
                        break;
                }
                if ($purgeHours > 0) {
                    $fModHours = filemtime(BASE_DIR . '/' . MEDIA_PATH . "/{$file}") / 3600;
                    if ($fModHours > 0 && $currentHours - $fModHours > $purgeHours) {
                        deleteFile($file);
                        $purgeCount++;
                    }
                }
            }
        }
    }
    if ($schedulePars[SCHEDULE_PURGESPACEMODE] > 0) {
        $totalSize = disk_total_space(BASE_DIR . '/' . MEDIA_PATH) / 1024;
        //KB
        $level = str_replace(array('%', 'G', 'B', 'g', 'b'), '', $schedulePars[SCHEDULE_PURGESPACELEVEL]);
        switch ($schedulePars[SCHEDULE_PURGESPACEMODE]) {
            case 1:
            case 2:
                $level = min(max($schedulePars[SCHEDULE_PURGESPACELEVEL], 3), 97) * $totalSize / 100;
                break;
            case 3:
            case 4:
                $level = $level * 1048576.0;
                break;
        }
        switch ($schedulePars[SCHEDULE_PURGESPACEMODE]) {
            case 1:
                //Free Space
            //Free Space
            case 3:
                $currentAvailable = disk_free_space(BASE_DIR . '/' . MEDIA_PATH) / 1024;
                //KB
                //writeLog(" free space purge total $totalSize current: $currentAvailable target: $level");
                if ($currentAvailable < $level) {
                    $pFiles = getSortedFiles(false);
                    //files in latest to earliest order
                    while ($currentAvailable < $level && count($pFiles) > 0) {
                        $currentAvailable += deleteFile(array_pop($pFiles));
                        $purgeCount++;
                    }
                }
                //writeLog("Finished. Current now: $currentAvailable");
                break;
            case 2:
                // Max usage
            // Max usage
            case 4:
                $pFiles = getSortedFiles(false);
                //files in latest to earliest order
                //writeLog(" Max space purge max: $level");
                foreach ($pFiles as $pFile) {
                    $del = $level <= 0;
                    $level -= deleteFile($pFile, $del);
                    if ($del) {
                        $purgeCount++;
                    }
                }
                break;
        }
    }
    if ($purgeCount > 0) {
        writeLog("Purged {$purgeCount} Files");
    }
}
Пример #3
0
function getThumbnails()
{
    global $sortOrder;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            $thumbnails[] = $file;
        }
    }
    return $thumbnails;
}
Пример #4
0
function getThumbnails()
{
    global $sortOrder;
    global $showTypes;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            $fType = getFileType($file);
            if ($showTypes == '1') {
                $thumbnails[] = $file;
            } elseif ($showTypes == '2' && ($fType == 'i' || $fType == 't')) {
                $thumbnails[] = $file;
            } elseif ($showTypes == '3' && $fType == 'v') {
                $thumbnails[] = $file;
            }
        }
    }
    return $thumbnails;
}
Пример #5
0
function getThumbnails()
{
    global $sortOrder;
    global $showTypes;
    global $timeFilter, $timeFilterMax;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    $nowTime = time();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            if ($timeFilter == 1) {
                $include = true;
            } else {
                $timeD = $nowTime - filemtime(MEDIA_PATH . "/{$file}");
                if ($timeFilter == $timeFilterMax) {
                    $include = $timeD >= 86400 * ($timeFilter - 1);
                } else {
                    $include = $timeD >= 86400 * ($timeFilter - 2) && $timeD < ($timeFilter - 1) * 86400;
                }
            }
            if ($include) {
                $fType = getFileType($file);
                if ($showTypes == '1') {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '2' && ($fType == 'i' || $fType == 't')) {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '3' && $fType == 'v') {
                    $thumbnails[] = $file;
                }
            }
        }
    }
    return $thumbnails;
}
echo "&nbsp;&nbsp;<button class='btn btn-primary' type='submit' name='action' value='selectNone'>" . BTN_SELECTNONE . "</button>";
echo "&nbsp;&nbsp;<button class='btn btn-primary' type='submit' name='action' value='selectAll'>" . BTN_SELECTALL . "</button>";
echo "&nbsp;&nbsp;<button class='btn btn-primary' type='submit' name='action' value='zipSel'>" . BTN_GETZIP . "</button>";
echo "&nbsp;&nbsp;<button class='btn btn-danger' type='submit' name='action' value='deleteSel' onclick=\"return confirm('Are you sure?');\">" . BTN_DELETESEL . "</button>";
echo "&nbsp;&nbsp;<button class='btn btn-danger' type='submit' name='action' value='deleteAll' onclick=\"return confirm('Are you sure?');\">" . BTN_DELETEALL . "</button>";
echo "</h1>";
diskUsage();
if ($debugString != "") {
    echo "{$debugString}<br>";
}
$files = scandir(MEDIA_PATH);
if (count($files) == 2) {
    echo "<p>No videos/images saved</p>";
} else {
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file, -7)) {
            drawFile($file, $thumbSize, $dSelect);
        }
    }
}
echo "<p><p>" . TXT_PREVIEW . " <input type='text' size='4' name='previewSize' value='{$previewSize}'>";
echo "&nbsp;&nbsp;" . TXT_THUMB . " <input type='text' size='3' name='thumbSize' value='{$thumbSize}'>";
echo "&nbsp;&nbsp;<button class='btn btn-primary' type='submit' name='action' value='updateSizes'>" . BTN_UPDATESIZES . "</button>";
?>
      </form>
      
      <form id="zipform" method="post" action="preview.php" style="display:none;">
         <input id="zipdownload" type="hidden" name="zipdownload"/>
      </form>
      
      </div>