Esempio n. 1
0
 protected function loadThumbnail(ModelThumbnail $thumbnail)
 {
     if (file_exists($thumbnail->getLocalFile())) {
         $this->logActivity($thumbnail->size, false, $thumbnail->id);
         response()->headers(['Content-Type: ' . $thumbnail->mime, 'Content-Length: ' . $thumbnail->size])->cache($thumbnail->identifier, strtotime($thumbnail->created));
         readfile($thumbnail->getLocalFile());
         die;
     }
 }
Esempio n. 2
0
 protected function deleteThumbnails($sourceId, $originalName, $path)
 {
     $path = rtrim($path, '/') . '/';
     $thumbnails = ModelThumbnail::getByPath($sourceId, $originalName, $path);
     if ($thumbnails->hasRows()) {
         foreach ($thumbnails as $thumbnail) {
             $thumbnail->delete();
         }
     }
 }
Esempio n. 3
0
 public function __construct($sourceId)
 {
     parent::__construct();
     $source = Source::getById($sourceId);
     if ($source->hasRow()) {
         // Delete thumbnails
         $thumbnails = ModelThumbnail::getBySourceId($source->id);
         if ($thumbnails->hasRows()) {
             foreach ($thumbnails->getRows() as $thumbnail) {
                 $thumbnail->delete();
             }
         }
         Memcache::getInstance()->clear('source_' . $source->subdomain);
         /*$cache = new Cache(getenv('CLOUDFLARE_API_EMAIL'), getenv('CLOUDFLARE_API_KEY'));
           $cache->purge_files(getenv('CLOUDFLARE_ZONE_ID'), array(
               'files' => sprintf('http://%s/*', $source->subdomain)
           ));*/
         $this->setMessage('The cache has been purged', 'success');
         redirect(url('controlpanel.source'));
     }
 }
Esempio n. 4
0
<?php

require_once '../config/init.php';
require_once 'includes/cleanup_helpers.php';
require_once 'includes/global_helpers.php';
// ---- SETTINGS START ----
const NOTIFY_PERCENTAGE_CHANGE = 5;
const NOTIFY_MIN_SPACE_PERCENTAGE = 10;
const THUMBNAIL_MAX_AGE_DAYS = 7;
// ---- SETTINGS END ----
parseSettings();
// -- CLEANUP THUMBNAILS ---
echo chr(10) . '  [ CLEANING UNUSED THUMBNAILS ]' . chr(10) . chr(10);
$thumbnails = \NinjaImg\Model\ModelThumbnail::getByMaxAge(THUMBNAIL_MAX_AGE_DAYS);
if (!$thumbnails->hasRows()) {
    echo '   - No thumbnails found';
} else {
    /* @var $thumbnail \NinjaImg\Model\ModelThumbnail */
    foreach ($thumbnails->getRows() as $thumbnail) {
        echo '   - Deleting thumbnail: ' . $thumbnail->name . chr(10);
        $thumbnail->delete();
    }
}
echo chr(10) . chr(10);
// DETECT DISKSPACE CHANGES
echo '  [ CHECK CONTENT-PROVIDER DISKSPACE ]' . chr(10) . chr(10);
foreach (\NinjaImg\Model\ModelContentProvider::all(true) as $cdn) {
    echo '   + Checking ' . $cdn->name . chr(10);
    $total = $cdn->capacity_max_gb && $cdn->capacity_max_gb > 0 ? $cdn->capacity_max_gb : round(disk_total_space($cdn->path) / 1024 / 1024 / 1024);
    $capacity = round(disk_free_space($cdn->path) / 1024 / 1024 / 1024);
    $leftPercentage = round($capacity / $total * 100);