Webgui: ongoing development
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/******************************************************************************
|
||||
* YMS - Yacht Management Software
|
||||
* Copyright (C) 2024 Thomas Hooge
|
||||
* Copyright (C) 2024-2026 Thomas Hooge
|
||||
*
|
||||
* SPDX-License-Identifier: WTFPL
|
||||
******************************************************************************
|
||||
@@ -14,8 +14,16 @@ function file_fix_filesize($docid, $filepath) {
|
||||
// set filesize in database to current size in filesystem
|
||||
global $pdo;
|
||||
$newsize = filesize($filepath);
|
||||
$sth = $pdo->prepare("UPDATE document SET docsize=? WHERE docid=?");
|
||||
$sth->execute([$docid, $newsize]);
|
||||
$sql = "UPDATE document SET docsize=? WHERE docid=?";
|
||||
$params = [$newsize, $docid];
|
||||
$sth = $pdo->prepare($sql);
|
||||
try {
|
||||
$sth->execute($params);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
$g_error->Add($sql);
|
||||
$g_error->Add(print_r($params, true));
|
||||
}
|
||||
return $newsize;
|
||||
}
|
||||
|
||||
@@ -23,3 +31,15 @@ function file_get_docname($docid, $doctype, $extension) {
|
||||
global $g_doc_typemap;
|
||||
return sprintf('%s-%06d.%s', $g_doc_typemap[$doctype], $docid, $extension);
|
||||
}
|
||||
|
||||
function dir_get_size($path) {
|
||||
// gets the size of a directory in bytes recursively
|
||||
$total = 0;
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
foreach ($iterator as $file){
|
||||
$total += $file->getSize();
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user