mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 13:42:04 +00:00
add check for mismatch of fileType and mimeType
works only for some common mimetypes
This commit is contained in:
parent
30ca5c71cd
commit
a5bf963bc5
|
@ -88,7 +88,12 @@ if($view) {
|
||||||
$view->setParam('setfilesize', $setfilesize);
|
$view->setParam('setfilesize', $setfilesize);
|
||||||
$view->setParam('setchecksum', $setchecksum);
|
$view->setParam('setchecksum', $setchecksum);
|
||||||
$view->setParam('repair', $repair);
|
$view->setParam('repair', $repair);
|
||||||
|
$view->setParam('showtree', showtree());
|
||||||
$view->setParam('rootfolder', $rootfolder);
|
$view->setParam('rootfolder', $rootfolder);
|
||||||
|
$view->setParam('previewWidthList', $settings->_previewWidthList);
|
||||||
|
$view->setParam('previewConverters', isset($settings->_converters['preview']) ? $settings->_converters['preview'] : array());
|
||||||
|
$view->setParam('timeout', $settings->_cmdTimeout);
|
||||||
|
$view->setParam('xsendfile', $settings->_enableXsendfile);
|
||||||
$view($_GET);
|
$view($_GET);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
*/
|
*/
|
||||||
require_once("class.Bootstrap.php");
|
require_once("class.Bootstrap.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include class to preview documents
|
||||||
|
*/
|
||||||
|
require_once("SeedDMS/Preview.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which outputs the html page for ObjectCheck view
|
* Class which outputs the html page for ObjectCheck view
|
||||||
*
|
*
|
||||||
|
@ -31,7 +36,7 @@ require_once("class.Bootstrap.php");
|
||||||
*/
|
*/
|
||||||
class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
|
|
||||||
function tree($dms, $folder, $repair, $path=':', $indent='') { /* {{{ */
|
function tree($dms, $folder, $previewer, $repair, $path=':', $indent='') { /* {{{ */
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
/* Don't do folderlist check for root folder */
|
/* Don't do folderlist check for root folder */
|
||||||
|
@ -51,11 +56,11 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
$owner = $folder->getOwner();
|
$owner = $folder->getOwner();
|
||||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||||
print "<td>Folder path contains cyclic relation</td>";
|
print "<td>Folder path contains cyclic relation</td>";
|
||||||
|
echo "<td>";
|
||||||
if($repair) {
|
if($repair) {
|
||||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||||
} else {
|
|
||||||
print "<td></td>\n";
|
|
||||||
}
|
}
|
||||||
|
echo "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$folderList = $folder->getFolderList();
|
$folderList = $folder->getFolderList();
|
||||||
|
@ -74,19 +79,19 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
$owner = $folder->getOwner();
|
$owner = $folder->getOwner();
|
||||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||||
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
||||||
|
echo "<td>";
|
||||||
if($repair) {
|
if($repair) {
|
||||||
$folder->repair();
|
$folder->repair();
|
||||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||||
} else {
|
|
||||||
print "<td></td>\n";
|
|
||||||
}
|
}
|
||||||
|
echo "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$subfolders = $folder->getSubFolders();
|
$subfolders = $folder->getSubFolders();
|
||||||
foreach($subfolders as $subfolder) {
|
foreach($subfolders as $subfolder) {
|
||||||
$this->tree($dms, $subfolder, $repair, $path.$folder->getId().':', $indent.' ');
|
$this->tree($dms, $subfolder, $previewer, $repair, $path.$folder->getId().':', $indent.' ');
|
||||||
}
|
}
|
||||||
$path .= $folder->getId().':';
|
$path .= $folder->getId().':';
|
||||||
$documents = $folder->getDocuments();
|
$documents = $folder->getDocuments();
|
||||||
|
@ -109,12 +114,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
$owner = $document->getOwner();
|
$owner = $document->getOwner();
|
||||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||||
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
||||||
|
echo "<td>";
|
||||||
if($repair) {
|
if($repair) {
|
||||||
$document->repair();
|
$document->repair();
|
||||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||||
} else {
|
|
||||||
print "<td></td>\n";
|
|
||||||
}
|
}
|
||||||
|
echo "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,63 +129,48 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
foreach($versions as $version) {
|
foreach($versions as $version) {
|
||||||
$filepath = $dms->contentDir . $version->getPath();
|
$filepath = $dms->contentDir . $version->getPath();
|
||||||
if(!file_exists($filepath)) {
|
if(!file_exists($filepath)) {
|
||||||
print "<tr>\n";
|
echo $this->documentListRowStart($document);
|
||||||
print "<tr id=\"table-row-document-".$document->getID()."\" class=\"table-row-document\" rel=\"document_".$document->getID()."\" formtoken=\"".createFormKey('movedocument')."\" draggable=\"true\">";
|
echo $this->documentListRow($document, $previewer, true, $version->getVersion());
|
||||||
print "<td><a class=\"standardText\" href=\"../out/out.ViewDocument.php?documentid=".$document->getID()."\"><img class=\"mimeicon\" src=\"".$this->getMimeIcon($version->getFileType())."\" title=\"".$version->getMimeType()."\"></a></td>";
|
|
||||||
print "<td><a class=\"standardText\" href=\"../out/out.ViewDocument.php?documentid=".$document->getID()."\">/";
|
|
||||||
$folder = $document->getFolder();
|
|
||||||
$tmppath = $folder->getPath();
|
|
||||||
for ($i = 1; $i < count($tmppath); $i++) {
|
|
||||||
print htmlspecialchars($tmppath[$i]->getName())."/";
|
|
||||||
}
|
|
||||||
print htmlspecialchars($document->getName());
|
|
||||||
print "</a></td>";
|
|
||||||
$owner = $document->getOwner();
|
|
||||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
|
||||||
print "<td>Document content of version ".$version->getVersion()." is missing ('".$path."')</td>";
|
print "<td>Document content of version ".$version->getVersion()." is missing ('".$path."')</td>";
|
||||||
if($repair) {
|
|
||||||
print "<td><span class=\"warning\">Cannot repaired</span></td>\n";
|
|
||||||
} else {
|
|
||||||
print "<td></td>\n";
|
|
||||||
}
|
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
echo "<div class=\"list-action\">";
|
if($repair) {
|
||||||
if($document->getAccessMode($user) >= M_ALL) {
|
print "<span class=\"warning\">Cannot be repaired</span>\n";
|
||||||
echo $this->printDeleteDocumentButton($document, 'splash_rm_document', true);
|
|
||||||
} else {
|
|
||||||
echo '<span style="padding: 2px; color: #CCC;"><i class="icon-remove"></i></span>';
|
|
||||||
}
|
}
|
||||||
if($document->getAccessMode($user) >= M_READWRITE) {
|
|
||||||
print '<a href="../out/out.EditDocument.php?documentid='.$document->getID().'" title="'.getMLText("edit_document_props").'"><i class="icon-edit"></i></a>';
|
|
||||||
} else {
|
|
||||||
print '<span style="padding: 2px; color: #CCC;"><i class="icon-edit"></i></span>';
|
|
||||||
}
|
|
||||||
if($document->getAccessMode($user) >= M_READWRITE) {
|
|
||||||
print $this->printLockButton($document, 'splash_document_locked', 'splash_document_unlocked', true);
|
|
||||||
}
|
|
||||||
if($this->enableClipboard) {
|
|
||||||
print '<a class="addtoclipboard" rel="D'.$document->getID().'" msg="'.getMLText('splash_added_to_clipboard').'" title="'.getMLText("add_to_clipboard").'"><i class="icon-copy"></i></a>';
|
|
||||||
}
|
|
||||||
echo "</div>";
|
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
print "</tr>\n";
|
echo $this->documentListRowEnd($document);
|
||||||
|
}
|
||||||
|
$mimetype = $version->getMimeType();
|
||||||
|
$filetype = $version->getFileType();
|
||||||
|
if(strlen($filetype) < 2) {
|
||||||
|
switch($mimetype) {
|
||||||
|
case "application/pdf":
|
||||||
|
case "image/png":
|
||||||
|
case "image/gif":
|
||||||
|
case "image/jpg":
|
||||||
|
$expect = substr($mimetype, -3, 3);
|
||||||
|
if($filetype != '.'.$expect) {
|
||||||
|
$this->needsrepair = true;
|
||||||
|
echo $this->documentListRowStart($document);
|
||||||
|
echo $this->documentListRow($document, $previewer, true, $version->getVersion());
|
||||||
|
echo "<td>.".$expect." != ".$filetype."</td>";
|
||||||
|
echo "<td>";
|
||||||
|
if($repair) {
|
||||||
|
$version->repair();
|
||||||
|
echo "<span class=\"success\">".getMLText('repaired')."</span>";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
|
echo $this->documentListRowEnd($document);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "<tr>\n";
|
echo $this->documentListRowStart($document);
|
||||||
print "<td></td>\n";
|
echo $this->documentListRow($document, $previewer, true);
|
||||||
print "<td><a class=\"standardText\" href=\"../out/out.ViewDocument.php?documentid=".$document->getID()."\">/";
|
echo "<td>Document has no content! Delete the document manually.</td>";
|
||||||
$folder = $document->getFolder();
|
echo "<td></td>";
|
||||||
$tmppath = $folder->getPath();
|
echo $this->documentListRowEnd($document);
|
||||||
for ($i = 1; $i < count($tmppath); $i++) {
|
|
||||||
print htmlspecialchars($tmppath[$i]->getName())."/";
|
|
||||||
}
|
|
||||||
print htmlspecialchars($document->getName());
|
|
||||||
print "</a></td>";
|
|
||||||
$owner = $document->getOwner();
|
|
||||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
|
||||||
print "<td>Document has no content! Delete the document manually.</td>";
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -212,6 +202,14 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
$setchecksum = $this->params['setchecksum'];
|
$setchecksum = $this->params['setchecksum'];
|
||||||
$rootfolder = $this->params['rootfolder'];
|
$rootfolder = $this->params['rootfolder'];
|
||||||
$this->enableClipboard = $this->params['enableclipboard'];
|
$this->enableClipboard = $this->params['enableclipboard'];
|
||||||
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$previewwidth = $this->params['previewWidthList'];
|
||||||
|
$previewconverters = $this->params['previewConverters'];
|
||||||
|
$timeout = $this->params['timeout'];
|
||||||
|
$xsendfile = $this->params['xsendfile'];
|
||||||
|
|
||||||
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
|
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
|
@ -230,17 +228,17 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
print "<th></th>\n";
|
print "<th></th>\n";
|
||||||
print "<th>".getMLText("name")."</th>\n";
|
print "<th>".getMLText("name")."</th>\n";
|
||||||
print "<th>".getMLText("owner")."</th>\n";
|
print "<th>".getMLText("owner")."</th>\n";
|
||||||
print "<th>".getMLText("error")."</th>\n";
|
|
||||||
print "<th></th>\n";
|
print "<th></th>\n";
|
||||||
|
print "<th>".getMLText("error")."</th>\n";
|
||||||
print "</tr>\n</thead>\n<tbody>\n";
|
print "</tr>\n</thead>\n<tbody>\n";
|
||||||
$this->needsrepair = false;
|
$this->needsrepair = false;
|
||||||
$this->tree($dms, $folder, $repair);
|
$this->tree($dms, $folder, $previewer, $repair);
|
||||||
print "</tbody></table>\n";
|
print "</tbody></table>\n";
|
||||||
|
$this->contentContainerEnd();
|
||||||
|
|
||||||
if($this->needsrepair && $repair == 0) {
|
if($this->needsrepair && $repair == 0) {
|
||||||
echo '<p><a href="out.ObjectCheck.php?repair=1">'.getMLText('do_object_repair').'</a></p>';
|
echo '<p><a href="out.ObjectCheck.php?repair=1" class="btn btn-primary">'.getMLText('do_object_repair').'</a></p>';
|
||||||
}
|
}
|
||||||
$this->contentContainerEnd();
|
|
||||||
|
|
||||||
if($unlinkedfolders) {
|
if($unlinkedfolders) {
|
||||||
$this->contentHeading(getMLText("unlinked_folders"));
|
$this->contentHeading(getMLText("unlinked_folders"));
|
||||||
|
@ -250,8 +248,8 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
print "<th>".getMLText("name")."</th>\n";
|
print "<th>".getMLText("name")."</th>\n";
|
||||||
print "<th>".getMLText("id")."</th>\n";
|
print "<th>".getMLText("id")."</th>\n";
|
||||||
print "<th>".getMLText("parent")."</th>\n";
|
print "<th>".getMLText("parent")."</th>\n";
|
||||||
print "<th>".getMLText("error")."</th>\n";
|
|
||||||
print "<th></th>\n";
|
print "<th></th>\n";
|
||||||
|
print "<th>".getMLText("error")."</th>\n";
|
||||||
print "</tr>\n</thead>\n<tbody>\n";
|
print "</tr>\n</thead>\n<tbody>\n";
|
||||||
foreach($unlinkedfolders as $error) {
|
foreach($unlinkedfolders as $error) {
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
|
@ -336,10 +334,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
foreach($nofilesizeversions as $version) {
|
foreach($nofilesizeversions as $version) {
|
||||||
$doc = $version->getDocument();
|
$doc = $version->getDocument();
|
||||||
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
||||||
|
echo "<td>";
|
||||||
if($setfilesize) {
|
if($setfilesize) {
|
||||||
if($version->setFileSize())
|
if($version->setFileSize())
|
||||||
echo "<td>".getMLText('repaired')."</td>";
|
echo getMLText('repaired');
|
||||||
}
|
}
|
||||||
|
echo "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
print "</tbody></table>\n";
|
print "</tbody></table>\n";
|
||||||
|
@ -365,10 +365,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
||||||
foreach($nochecksumversions as $version) {
|
foreach($nochecksumversions as $version) {
|
||||||
$doc = $version->getDocument();
|
$doc = $version->getDocument();
|
||||||
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
||||||
|
echo "<td>";
|
||||||
if($setchecksum) {
|
if($setchecksum) {
|
||||||
if($version->setChecksum())
|
if($version->setChecksum())
|
||||||
echo "<td>".getMLText('repaired')."</td>";
|
echo getMLText('repaired');
|
||||||
}
|
}
|
||||||
|
echo "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
print "</tbody></table>\n";
|
print "</tbody></table>\n";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user