Changeset 873 for trunk/Modules/File/File.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/File/File.php
r738 r873 16 16 { 17 17 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); 18 if ($DbResult->num_rows > 0)18 if ($DbResult->num_rows > 0) 19 19 { 20 20 $DbRow = $DbResult->fetch_assoc(); … … 28 28 // Submited form with file input have to be enctype="multipart/form-data" 29 29 $Result = 0; 30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != ''))30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != '')) 31 31 { 32 if (file_exists($_FILES[$Name]['tmp_name']))32 if (file_exists($_FILES[$Name]['tmp_name'])) 33 33 { 34 34 $FileName = substr($_FILES[$Name]['name'], strrpos($_FILES[$Name]['name'], '/')); 35 35 $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')'); 36 36 $InsertId = $this->Database->insert_id; 37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId; 38 38 } 39 39 } 40 return ($Result);40 return ($Result); 41 41 } 42 42 … … 46 46 47 47 $Result = $MimeTypes[pathinfo($FileName, PATHINFO_EXTENSION)][0]; 48 return ($Result);48 return ($Result); 49 49 } 50 50 … … 52 52 { 53 53 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); 54 if ($DbResult->num_rows > 0)54 if ($DbResult->num_rows > 0) 55 55 { 56 56 $DbRow = $DbResult->fetch_assoc(); 57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']); 58 58 else $FileName = $this->FilesDir; 59 59 $FileName .= $DbRow['Name']; 60 if (file_exists($FileName))60 if (file_exists($FileName)) 61 61 { 62 62 Header('Content-Type: '.$this->DetectMimeType($FileName)); … … 71 71 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); 72 72 $DbRow = $DbResult->fetch_assoc(); 73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']);73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']); 74 74 else $Result = $this->FilesDir; 75 75 $Result .= $DbRow['Name'].'/'; 76 return ($Result);76 return ($Result); 77 77 } 78 78 } … … 83 83 function Show() 84 84 { 85 if (array_key_exists('id', $_GET)) $Id = $_GET['id'];86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i'];87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru'));85 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; 86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i']; 87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru')); 88 88 $this->ClearPage = true; 89 89 $Output = $this->System->Modules['File']->Download($Id); 90 return ($Output);90 return ($Output); 91 91 } 92 92 }
Note:
See TracChangeset
for help on using the changeset viewer.