Changeset 875


Ignore:
Timestamp:
Apr 9, 2020, 1:00:37 AM (4 years ago)
Author:
chronos
Message:
  • Added: New page for checking if files exists on filesystem.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r873 r875  
    11<?php
    22
    3 $Revision = 873; // Subversion revision
     3$Revision = 874; // Subversion revision
    44$DatabaseRevision = 870; // SQL structure revision
    5 $ReleaseTime = strtotime('2020-04-06');
     5$ReleaseTime = strtotime('2020-04-08');
  • trunk/Modules/File/File.php

    r874 r875  
    7676    return $Result;
    7777  }
    78 }
    79 
     78
     79  function GetFullPath($Id)
     80  {
     81    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
     82    if ($DbResult->num_rows > 0)
     83    {
     84      $DbRow = $DbResult->fetch_assoc();
     85      if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);
     86        else $FileName = $this->FilesDir;
     87      $FileName .= $DbRow['Name'];
     88      return $FileName;
     89    } else echo('Soubor nenalezen!');
     90  }
     91}
    8092
    8193class PageFile extends Page
     
    88100    $this->ClearPage = true;
    89101    $Output = $this->System->Modules['File']->Download($Id);
     102    return $Output;
     103  }
     104}
     105
     106class PageFileCheck extends Page
     107{
     108  function __construct($System)
     109  {
     110    parent::__construct($System);
     111    $this->FullTitle = 'File check';
     112    $this->ShortTitle = 'File check';
     113    $this->ParentClass = 'PagePortal';
     114  }
     115
     116  function GetAbsolutePath($Path)
     117  {
     118    $Path = trim($Path);
     119    $IsRoot = substr($Path, 0, 1) == '/';
     120    $Path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $Path);
     121    $Parts = array_filter(explode(DIRECTORY_SEPARATOR, $Path), 'strlen');
     122    $Absolutes = array();
     123    foreach ($Parts as $Part)
     124    {
     125      if ('.' == $Part) continue;
     126      if ('..' == $Part)
     127      {
     128        array_pop($Absolutes);
     129      } else
     130      {
     131        $Absolutes[] = $Part;
     132      }
     133    }
     134    $Path = implode(DIRECTORY_SEPARATOR, $Absolutes);
     135    if ($IsRoot) $Path = DIRECTORY_SEPARATOR.$Path;
     136    return $Path;
     137  }
     138
     139  function Show()
     140  {
     141    $Output = '<strong>Missing files:</strong><br>';
     142    if (!$this->System->User->CheckPermission('File', 'Check'))
     143      return 'Nemáte oprávnění';
     144    $DbResult = $this->Database->select('File', 'Id');
     145    while ($DbRow = $DbResult->fetch_assoc())
     146    {
     147      $Id = $DbRow['Id'];
     148      $FileName = $this->GetAbsolutePath($this->System->Modules['File']->GetFullPath($Id));
     149      if (!file_exists($FileName))
     150        $Output .= $FileName.'<br>';
     151    }
    90152    return $Output;
    91153  }
     
    118180
    119181    $this->System->RegisterPage('file', 'PageFile');
     182    $this->System->RegisterPage('file-check', 'PageFileCheck');
    120183    $this->System->AddModule(new File($this->System));
    121184    $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'];
     
    132195        array('Caption' => 'Stáhnout', 'URL' => '/file?i=#RowId'),
    133196      ),
     197      'Actions' => array(
     198        array('Caption' => 'Kontrola souborů', 'URL' => '/file-check'),
     199      ),
    134200    ));
    135201    $this->System->FormManager->RegisterClass('FileDirectory', array(
Note: See TracChangeset for help on using the changeset viewer.