mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +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('setchecksum', $setchecksum);
|
||||
$view->setParam('repair', $repair);
|
||||
$view->setParam('showtree', showtree());
|
||||
$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);
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
*/
|
||||
require_once("class.Bootstrap.php");
|
||||
|
||||
/**
|
||||
* Include class to preview documents
|
||||
*/
|
||||
require_once("SeedDMS/Preview.php");
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
function tree($dms, $folder, $repair, $path=':', $indent='') { /* {{{ */
|
||||
function tree($dms, $folder, $previewer, $repair, $path=':', $indent='') { /* {{{ */
|
||||
global $user;
|
||||
|
||||
/* Don't do folderlist check for root folder */
|
||||
|
@ -51,11 +56,11 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
$owner = $folder->getOwner();
|
||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||
print "<td>Folder path contains cyclic relation</td>";
|
||||
echo "<td>";
|
||||
if($repair) {
|
||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
||||
} else {
|
||||
print "<td></td>\n";
|
||||
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||
}
|
||||
echo "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
$folderList = $folder->getFolderList();
|
||||
|
@ -74,19 +79,19 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
$owner = $folder->getOwner();
|
||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
||||
echo "<td>";
|
||||
if($repair) {
|
||||
$folder->repair();
|
||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
||||
} else {
|
||||
print "<td></td>\n";
|
||||
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||
}
|
||||
echo "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$subfolders = $folder->getSubFolders();
|
||||
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().':';
|
||||
$documents = $folder->getDocuments();
|
||||
|
@ -109,12 +114,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
$owner = $document->getOwner();
|
||||
print "<td>".htmlspecialchars($owner->getFullName())."</td>";
|
||||
print "<td>Folderlist is '".$folderList."', should be '".$path."'</td>";
|
||||
echo "<td>";
|
||||
if($repair) {
|
||||
$document->repair();
|
||||
print "<td><span class=\"success\">".getMLText('repaired')."</span></td>\n";
|
||||
} else {
|
||||
print "<td></td>\n";
|
||||
print "<span class=\"success\">".getMLText('repaired')."</span>\n";
|
||||
}
|
||||
echo "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
|
@ -124,63 +129,48 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
foreach($versions as $version) {
|
||||
$filepath = $dms->contentDir . $version->getPath();
|
||||
if(!file_exists($filepath)) {
|
||||
print "<tr>\n";
|
||||
print "<tr id=\"table-row-document-".$document->getID()."\" class=\"table-row-document\" rel=\"document_".$document->getID()."\" formtoken=\"".createFormKey('movedocument')."\" draggable=\"true\">";
|
||||
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>";
|
||||
echo $this->documentListRowStart($document);
|
||||
echo $this->documentListRow($document, $previewer, true, $version->getVersion());
|
||||
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 "<div class=\"list-action\">";
|
||||
if($document->getAccessMode($user) >= M_ALL) {
|
||||
echo $this->printDeleteDocumentButton($document, 'splash_rm_document', true);
|
||||
} else {
|
||||
echo '<span style="padding: 2px; color: #CCC;"><i class="icon-remove"></i></span>';
|
||||
if($repair) {
|
||||
print "<span class=\"warning\">Cannot be repaired</span>\n";
|
||||
}
|
||||
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>";
|
||||
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 {
|
||||
print "<tr>\n";
|
||||
print "<td></td>\n";
|
||||
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 has no content! Delete the document manually.</td>";
|
||||
print "</tr>\n";
|
||||
echo $this->documentListRowStart($document);
|
||||
echo $this->documentListRow($document, $previewer, true);
|
||||
echo "<td>Document has no content! Delete the document manually.</td>";
|
||||
echo "<td></td>";
|
||||
echo $this->documentListRowEnd($document);
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
|
@ -212,6 +202,14 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
$setchecksum = $this->params['setchecksum'];
|
||||
$rootfolder = $this->params['rootfolder'];
|
||||
$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');
|
||||
|
||||
|
@ -230,17 +228,17 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
print "<th></th>\n";
|
||||
print "<th>".getMLText("name")."</th>\n";
|
||||
print "<th>".getMLText("owner")."</th>\n";
|
||||
print "<th>".getMLText("error")."</th>\n";
|
||||
print "<th></th>\n";
|
||||
print "<th>".getMLText("error")."</th>\n";
|
||||
print "</tr>\n</thead>\n<tbody>\n";
|
||||
$this->needsrepair = false;
|
||||
$this->tree($dms, $folder, $repair);
|
||||
$this->tree($dms, $folder, $previewer, $repair);
|
||||
print "</tbody></table>\n";
|
||||
$this->contentContainerEnd();
|
||||
|
||||
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) {
|
||||
$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("id")."</th>\n";
|
||||
print "<th>".getMLText("parent")."</th>\n";
|
||||
print "<th>".getMLText("error")."</th>\n";
|
||||
print "<th></th>\n";
|
||||
print "<th>".getMLText("error")."</th>\n";
|
||||
print "</tr>\n</thead>\n<tbody>\n";
|
||||
foreach($unlinkedfolders as $error) {
|
||||
echo "<tr>";
|
||||
|
@ -336,10 +334,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
foreach($nofilesizeversions as $version) {
|
||||
$doc = $version->getDocument();
|
||||
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
||||
echo "<td>";
|
||||
if($setfilesize) {
|
||||
if($version->setFileSize())
|
||||
echo "<td>".getMLText('repaired')."</td>";
|
||||
echo getMLText('repaired');
|
||||
}
|
||||
echo "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</tbody></table>\n";
|
||||
|
@ -365,10 +365,12 @@ class SeedDMS_View_ObjectCheck extends SeedDMS_Bootstrap_Style {
|
|||
foreach($nochecksumversions as $version) {
|
||||
$doc = $version->getDocument();
|
||||
print "<tr><td>".$doc->getId()."</td><td>".$version->getVersion()."</td><td>".$version->getOriginalFileName()."</td><td>".$version->getMimeType()."</td>";
|
||||
echo "<td>";
|
||||
if($setchecksum) {
|
||||
if($version->setChecksum())
|
||||
echo "<td>".getMLText('repaired')."</td>";
|
||||
echo getMLText('repaired');
|
||||
}
|
||||
echo "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</tbody></table>\n";
|
||||
|
|
Loading…
Reference in New Issue
Block a user