Changeset 875 for trunk/Modules/File/File.php
- Timestamp:
- Apr 9, 2020, 1:00:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/File/File.php
r874 r875 76 76 return $Result; 77 77 } 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 } 80 92 81 93 class PageFile extends Page … … 88 100 $this->ClearPage = true; 89 101 $Output = $this->System->Modules['File']->Download($Id); 102 return $Output; 103 } 104 } 105 106 class 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 } 90 152 return $Output; 91 153 } … … 118 180 119 181 $this->System->RegisterPage('file', 'PageFile'); 182 $this->System->RegisterPage('file-check', 'PageFileCheck'); 120 183 $this->System->AddModule(new File($this->System)); 121 184 $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; … … 132 195 array('Caption' => 'Stáhnout', 'URL' => '/file?i=#RowId'), 133 196 ), 197 'Actions' => array( 198 array('Caption' => 'Kontrola souborů', 'URL' => '/file-check'), 199 ), 134 200 )); 135 201 $this->System->FormManager->RegisterClass('FileDirectory', array(
Note:
See TracChangeset
for help on using the changeset viewer.