Пример #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     /*
         create thumbnails for all existing image files
         that havn't got one yet
     */
     #createThumbsForAll(); // helper function in helpers.php
     /*
         get missing file sizes for song and item attachments
     */
     // get list of all files
     $files = DB::table('files')->get();
     # change into the directory containing the uploaded files
     chdir('public/' . config('files.uploads.webpath'));
     foreach ($files as $key => $file) {
         # check if file size is already defined
         if ($file->filesize > 0) {
             echo $file->filesize . '- Already done for: ' . $file->filename . "\n";
             continue;
         }
         # get actual file size
         if (file_exists($file->token)) {
             $filesize = filesize($file->token);
         } else {
             echo "Error! File '{$file->token}' not found!\n";
             $filesize = 0;
         }
         echo 'Size: ' . humanFilesize($filesize) . ", Name: " . $file->filename . "\n";
         # write filesize back to DB table
         DB::table('files')->where('id', $file->id)->update(['filesize' => $filesize]);
     }
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $files = glob($_ENV['THUMCNO_PATH'] . '/cache/*');
     $fileSize = 0;
     foreach ($files as $file) {
         if (basename($file) == 'index.html') {
             continue;
         }
         $fileSize += filesize($file);
     }
     $numberOfFiles = count($files) - 1;
     $output->writeln(PHP_EOL . 'Cache information' . PHP_EOL);
     $output->writeln('Files cache: <comment>' . $numberOfFiles . '</comment>');
     $output->writeln('Size of cache files: <comment>' . humanFilesize($fileSize) . '</comment>.');
 }
Пример #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $files = glob($_ENV['THUMCNO_PATH'] . '/cache/*');
     $fileSize = 0;
     foreach ($files as $file) {
         if (basename($file) == 'index.html') {
             continue;
         }
         $fileSize += filesize($file);
         unlink($file);
         $output->write('<comment>.</comment>');
     }
     $output->writeln(PHP_EOL . PHP_EOL . '<info>Successfully! Cache cleared :D</info>' . PHP_EOL);
     $numberOfFiles = count($files) - 1;
     $output->writeln('Files deleted: <comment>' . $numberOfFiles . '</comment>');
     $output->writeln('Cleared: <comment>' . humanFilesize($fileSize) . '</comment>.');
 }
Пример #4
0
 /**
  * Administartion.
  *
  * @param Filesystem $filesystem
  *
  * @return \Illuminate\View\View
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function admin(Filesystem $filesystem, AdminPageRequest $request)
 {
     $applicationLogFilePath = (new FileLogger())->getLogFilePath();
     $applicationLog = $filesystem->exists($applicationLogFilePath) ? $filesystem->get($applicationLogFilePath) : null;
     $systemLogs = $filesystem->files(storage_path() . '/logs');
     $systemLogs = array_reverse(array_filter(array_map(function ($value) use($applicationLogFilePath) {
         if ($value !== $applicationLogFilePath) {
             $updated_at = date('Y-m-d H:i:s.', filemtime($value));
             $logFile['filename'] = pathinfo($value, PATHINFO_BASENAME);
             $logFile['filesize'] = filesize($value);
             $logFile['humanFilesize'] = humanFilesize(filesize($value));
             $logFile['updated_at'] = $updated_at;
             $logFile['updated_at_for_humans'] = Carbon::parse($updated_at)->diffForHumans();
             return $logFile;
         }
     }, $systemLogs)));
     return view('results.admin', compact('applicationLog', 'systemLogs'));
 }
Пример #5
0
    // If Tor could not determine IP, an exception is thrown
    $address = $tc->getInfoAddress();
} catch (ProtocolError $pex) {
    $address = 'Unknown';
}
try {
    // get router fingerprint (if any) - clients will not have a fingerprint
    $fingerprint = $tc->getInfoFingerprint();
} catch (ProtocolError $pex) {
    $fingerprint = $pex->getMessage();
}
echo sprintf("*** Controller IP Address: %s  / Fingerprint: %s ***\n", $address, $fingerprint);
// ask controller how many bytes Tor has transferred
$read = $tc->getInfoTrafficRead();
$writ = $tc->getInfoTrafficWritten();
echo sprintf("*** Tor traffic (read / written): %s / %s ***\n", humanFilesize($read), humanFilesize($writ));
echo "\n";
try {
    // fetch info for this descriptor from controller
    $descriptor = $tc->getInfoDescriptor('drew010relay01');
    // if descriptor found, query directory info to get flags
    $dirinfo = $tc->getInfoDirectoryStatus($descriptor->fingerprint);
    echo "== Descriptor Info ==\n" . "Nickname      : {$descriptor->nickname}\n" . "Fingerprint   : {$descriptor->fingerprint}\n" . "Running       : {$descriptor->platform}\n" . "Uptime        : " . uptimeToString($descriptor->getCurrentUptime(), false) . "\n" . "OR Address(es): " . $descriptor->ip_address . ':' . $descriptor->or_port;
    if (sizeof($descriptor->or_address) > 0) {
        echo ', ' . implode(', ', $descriptor->or_address);
    }
    echo "\n" . "Contact       : {$descriptor->contact}\n" . "BW (observed) : " . number_format($descriptor->bandwidth_observed) . " B/s\n" . "BW (average)  : " . number_format($descriptor->bandwidth_average) . " B/s\n" . "Flags         : " . implode(' ', $dirinfo->flags) . "\n\n";
} catch (ProtocolError $pe) {
    // doesn't necessarily mean the node doesn't exist
    // the controller may not have updated directory info yet
    echo $pe->getMessage() . "\n\n";
Пример #6
0
$directoryIterator = $directoryFinder->in($path->path);
$directoryArray = array();
foreach ($directoryIterator as $directory) {
    $directoryArray[] = array("path" => $directory->getRelativePathname(), "name" => $directory->getBasename());
}
$fileFinder = new Finder();
$fileFinder->files()->ignoreUnreadableDirs()->depth(0);
$allowedImageTypes = loadPicFile("helpers/imagetypes.php");
foreach ($allowedImageTypes as $imageType) {
    $fileFinder->name("*.{$imageType}");
}
foreach (array_map("strtoupper", $allowedImageTypes) as $imageType) {
    $fileFinder->name("*.{$imageType}");
}
$fileFinder->sortByName();
if ($path->hasPermission("symlinks")) {
    $fileFinder->followLinks();
}
if (!empty($relpath)) {
    $fileFinder->path($relpath)->depth(substr_count($relpath, "/") + 1);
}
if ($path->hasPermission("nsfw") === false) {
    $fileFinder->notPath("/.*\\/NSFW\\/.*/")->notPath("/NSFW\\/.*/")->notPath("/.*\\/NSFW/");
}
$fileIterator = $fileFinder->in($path->path);
$fileArray = array();
foreach ($fileIterator as $file) {
    $fileArray[] = array("filename" => $file->getBasename(), "relpath" => $file->getRelativePathname(), "size" => humanFilesize($file->getSize()), "mtime" => date("Y-m-d H:i:s", $file->getMTime()));
}
header("Content-type: application/json");
echo json_encode(array("directories" => $directoryArray, "files" => $fileArray));