mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
- declare $dms global
This commit is contained in:
parent
d4507695b0
commit
457b805f2c
|
@ -1,105 +1,103 @@
|
||||||
<?php
|
<?php
|
||||||
// MyDMS. Document Management System
|
// MyDMS. Document Management System
|
||||||
// Copyright (C) 2002-2005 Markus Westphal
|
// Copyright (C) 2002-2005 Markus Westphal
|
||||||
// Copyright (C) 2006-2008 Malcolm Cowe
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||||
// Copyright (C) 2010 Matteo Lucarelli
|
// Copyright (C) 2010 Matteo Lucarelli
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
function formatted_size($size_bytes)
|
function formatted_size($size_bytes) { /* {{{ */
|
||||||
{
|
|
||||||
if ($size_bytes>1000000000) return number_format($size_bytes/1000000000,1,".","")." GBytes";
|
if ($size_bytes>1000000000) return number_format($size_bytes/1000000000,1,".","")." GBytes";
|
||||||
else if ($size_bytes>1000000) return number_format($size_bytes/1000000,1,".","")." MBytes";
|
else if ($size_bytes>1000000) return number_format($size_bytes/1000000,1,".","")." MBytes";
|
||||||
else if ($size_bytes>1000) return number_format($size_bytes/1000,1,".","")." KBytes";
|
else if ($size_bytes>1000) return number_format($size_bytes/1000,1,".","")." KBytes";
|
||||||
return number_format($size_bytes,0,"","")." Bytes";
|
return number_format($size_bytes,0,"","")." Bytes";
|
||||||
}
|
} /* }}} */
|
||||||
|
|
||||||
function getReadableDate($timestamp) {
|
function getReadableDate($timestamp) {
|
||||||
return date("d.m.Y", $timestamp);
|
return date("d.m.Y", $timestamp);
|
||||||
}
|
|
||||||
|
|
||||||
function getLongReadableDate($timestamp) {
|
|
||||||
return date("d/m/Y H:i", $timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
function getLongReadableDate($timestamp) {
|
||||||
// The original string sanitizer, kept for reference.
|
return date("d/m/Y H:i", $timestamp);
|
||||||
//function sanitizeString($string) {
|
|
||||||
// $string = str_replace("'", "'", $string);
|
|
||||||
// $string = str_replace("--", "", $string);
|
|
||||||
// $string = str_replace("<", "<", $string);
|
|
||||||
// $string = str_replace(">", ">", $string);
|
|
||||||
// $string = str_replace("/*", "", $string);
|
|
||||||
// $string = str_replace("*/", "", $string);
|
|
||||||
// $string = str_replace("\"", """, $string);
|
|
||||||
//
|
|
||||||
// return $string;
|
|
||||||
//}
|
|
||||||
|
|
||||||
function sanitizeString($string) {
|
|
||||||
|
|
||||||
$string = (string) $string;
|
|
||||||
if (get_magic_quotes_gpc()) {
|
|
||||||
$string = stripslashes($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
$string = str_replace("\\", "\\\\", $string);
|
|
||||||
$string = str_replace("--", "\-\-", $string);
|
|
||||||
$string = str_replace(";", "\;", $string);
|
|
||||||
// Use HTML entities to represent the other characters that have special
|
|
||||||
// meaning in SQL. These can be easily converted back to ASCII / UTF-8
|
|
||||||
// with a decode function if need be.
|
|
||||||
$string = str_replace("&", "&", $string);
|
|
||||||
$string = str_replace("%", "%", $string); // percent
|
|
||||||
$string = str_replace("\"", """, $string); // double quote
|
|
||||||
$string = str_replace("/*", "/*", $string); // start of comment
|
|
||||||
$string = str_replace("*/", "*/", $string); // end of comment
|
|
||||||
$string = str_replace("<", "<", $string);
|
|
||||||
$string = str_replace(">", ">", $string);
|
|
||||||
$string = str_replace("=", "=", $string);
|
|
||||||
$string = str_replace(")", ")", $string);
|
|
||||||
$string = str_replace("(", "(", $string);
|
|
||||||
$string = str_replace("'", "'", $string);
|
|
||||||
$string = str_replace("+", "+", $string);
|
|
||||||
|
|
||||||
return trim($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mydmsDecodeString($string) {
|
|
||||||
|
|
||||||
$string = (string)$string;
|
|
||||||
|
|
||||||
$string = str_replace("&", "&", $string);
|
|
||||||
$string = str_replace("%", "%", $string); // percent
|
|
||||||
$string = str_replace(""", "\"", $string); // double quote
|
|
||||||
$string = str_replace("/*", "/*", $string); // start of comment
|
|
||||||
$string = str_replace("*/", "*/", $string); // end of comment
|
|
||||||
$string = str_replace("<", "<", $string);
|
|
||||||
$string = str_replace(">", ">", $string);
|
|
||||||
$string = str_replace("=", "=", $string);
|
|
||||||
$string = str_replace(")", ")", $string);
|
|
||||||
$string = str_replace("(", "(", $string);
|
|
||||||
$string = str_replace("'", "'", $string);
|
|
||||||
$string = str_replace("+", "+", $string);
|
|
||||||
|
|
||||||
return $string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVersionigFile($document)
|
//
|
||||||
{
|
// The original string sanitizer, kept for reference.
|
||||||
global $settings;
|
//function sanitizeString($string) {
|
||||||
|
// $string = str_replace("'", "'", $string);
|
||||||
|
// $string = str_replace("--", "", $string);
|
||||||
|
// $string = str_replace("<", "<", $string);
|
||||||
|
// $string = str_replace(">", ">", $string);
|
||||||
|
// $string = str_replace("/*", "", $string);
|
||||||
|
// $string = str_replace("*/", "", $string);
|
||||||
|
// $string = str_replace("\"", """, $string);
|
||||||
|
//
|
||||||
|
// return $string;
|
||||||
|
//}
|
||||||
|
|
||||||
|
function sanitizeString($string) { /* {{{ */
|
||||||
|
|
||||||
|
$string = (string) $string;
|
||||||
|
if (get_magic_quotes_gpc()) {
|
||||||
|
$string = stripslashes($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
$string = str_replace("\\", "\\\\", $string);
|
||||||
|
$string = str_replace("--", "\-\-", $string);
|
||||||
|
$string = str_replace(";", "\;", $string);
|
||||||
|
// Use HTML entities to represent the other characters that have special
|
||||||
|
// meaning in SQL. These can be easily converted back to ASCII / UTF-8
|
||||||
|
// with a decode function if need be.
|
||||||
|
$string = str_replace("&", "&", $string);
|
||||||
|
$string = str_replace("%", "%", $string); // percent
|
||||||
|
$string = str_replace("\"", """, $string); // double quote
|
||||||
|
$string = str_replace("/*", "/*", $string); // start of comment
|
||||||
|
$string = str_replace("*/", "*/", $string); // end of comment
|
||||||
|
$string = str_replace("<", "<", $string);
|
||||||
|
$string = str_replace(">", ">", $string);
|
||||||
|
$string = str_replace("=", "=", $string);
|
||||||
|
$string = str_replace(")", ")", $string);
|
||||||
|
$string = str_replace("(", "(", $string);
|
||||||
|
$string = str_replace("'", "'", $string);
|
||||||
|
$string = str_replace("+", "+", $string);
|
||||||
|
|
||||||
|
return trim($string);
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function mydmsDecodeString($string) { /* {{{ */
|
||||||
|
|
||||||
|
$string = (string)$string;
|
||||||
|
|
||||||
|
$string = str_replace("&", "&", $string);
|
||||||
|
$string = str_replace("%", "%", $string); // percent
|
||||||
|
$string = str_replace(""", "\"", $string); // double quote
|
||||||
|
$string = str_replace("/*", "/*", $string); // start of comment
|
||||||
|
$string = str_replace("*/", "*/", $string); // end of comment
|
||||||
|
$string = str_replace("<", "<", $string);
|
||||||
|
$string = str_replace(">", ">", $string);
|
||||||
|
$string = str_replace("=", "=", $string);
|
||||||
|
$string = str_replace(")", ")", $string);
|
||||||
|
$string = str_replace("(", "(", $string);
|
||||||
|
$string = str_replace("'", "'", $string);
|
||||||
|
$string = str_replace("+", "+", $string);
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function createVersionigFile($document) { /* {{{ */
|
||||||
|
global $settings, $dms;
|
||||||
|
|
||||||
// if directory has been removed recreate it
|
// if directory has been removed recreate it
|
||||||
if (!file_exists($settings->_contentDir . $document->getDir()))
|
if (!file_exists($settings->_contentDir . $document->getDir()))
|
||||||
|
@ -116,7 +114,7 @@ function createVersionigFile($document)
|
||||||
$tmp = getMLText("owner")." = ".$owner->getFullName()." <".$owner->getEmail().">\n";
|
$tmp = getMLText("owner")." = ".$owner->getFullName()." <".$owner->getEmail().">\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("creation_date")." = ".getLongReadableDate($document->getDate())."\n";
|
$tmp = getMLText("creation_date")." = ".getLongReadableDate($document->getDate())."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$latestContent = $document->getLatestContent();
|
$latestContent = $document->getLatestContent();
|
||||||
|
@ -125,14 +123,14 @@ function createVersionigFile($document)
|
||||||
|
|
||||||
$tmp = getMLText("version")." = ".$latestContent->getVersion()."\n";
|
$tmp = getMLText("version")." = ".$latestContent->getVersion()."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("file")." = ".$latestContent->getOriginalFileName()." (".$latestContent->getMimeType().")\n";
|
$tmp = getMLText("file")." = ".$latestContent->getOriginalFileName()." (".$latestContent->getMimeType().")\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("comment")." = ". mydmsDecodeString($latestContent->getComment())."\n";
|
$tmp = getMLText("comment")." = ". mydmsDecodeString($latestContent->getComment())."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$status = $latestContent->getStatus();
|
$status = $latestContent->getStatus();
|
||||||
$tmp = getMLText("status")." = ".getOverallStatusText($status["status"])."\n";
|
$tmp = getMLText("status")." = ".getOverallStatusText($status["status"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
|
@ -142,62 +140,62 @@ function createVersionigFile($document)
|
||||||
|
|
||||||
foreach ($reviewStatus as $r) {
|
foreach ($reviewStatus as $r) {
|
||||||
|
|
||||||
switch ($r["type"]) {
|
switch ($r["type"]) {
|
||||||
case 0: // Reviewer is an individual.
|
case 0: // Reviewer is an individual.
|
||||||
$required = $dms->getUser($r["required"]);
|
$required = $dms->getUser($r["required"]);
|
||||||
if (!is_object($required)) $reqName = getMLText("unknown_user")." = ".$r["required"];
|
if (!is_object($required)) $reqName = getMLText("unknown_user")." = ".$r["required"];
|
||||||
else $reqName = getMLText("user")." = ".$required->getFullName();
|
else $reqName = getMLText("user")." = ".$required->getFullName();
|
||||||
break;
|
break;
|
||||||
case 1: // Reviewer is a group.
|
case 1: // Reviewer is a group.
|
||||||
$required = $dms->getGroup($r["required"]);
|
$required = $dms->getGroup($r["required"]);
|
||||||
if (!is_object($required)) $reqName = getMLText("unknown_group")." = ".$r["required"];
|
if (!is_object($required)) $reqName = getMLText("unknown_group")." = ".$r["required"];
|
||||||
else $reqName = getMLText("group")." = ".$required->getName();
|
else $reqName = getMLText("group")." = ".$required->getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = "\n".$reqName."\n";
|
$tmp = "\n".$reqName."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("status")." = ".getReviewStatusText($r["status"])."\n";
|
$tmp = getMLText("status")." = ".getReviewStatusText($r["status"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("comment")." = ". mydmsDecodeString($r["comment"])."\n";
|
$tmp = getMLText("comment")." = ". mydmsDecodeString($r["comment"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("last_update")." = ".$r["date"]."\n";
|
$tmp = getMLText("last_update")." = ".$r["date"]."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$approvalStatus = $latestContent->getApprovalStatus();
|
$approvalStatus = $latestContent->getApprovalStatus();
|
||||||
$tmp = "\n### ".getMLText("approvers")." ###\n";
|
$tmp = "\n### ".getMLText("approvers")." ###\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
foreach ($approvalStatus as $r) {
|
foreach ($approvalStatus as $r) {
|
||||||
|
|
||||||
switch ($r["type"]) {
|
switch ($r["type"]) {
|
||||||
case 0: // Reviewer is an individual.
|
case 0: // Reviewer is an individual.
|
||||||
$required = $dms->getUser($r["required"]);
|
$required = $dms->getUser($r["required"]);
|
||||||
if (!is_object($required)) $reqName = getMLText("unknown_user")." = ".$r["required"];
|
if (!is_object($required)) $reqName = getMLText("unknown_user")." = ".$r["required"];
|
||||||
else $reqName = getMLText("user")." = ".$required->getFullName();
|
else $reqName = getMLText("user")." = ".$required->getFullName();
|
||||||
break;
|
break;
|
||||||
case 1: // Reviewer is a group.
|
case 1: // Reviewer is a group.
|
||||||
$required = $dms->getGroup($r["required"]);
|
$required = $dms->getGroup($r["required"]);
|
||||||
if (!is_object($required)) $reqName = getMLText("unknown_group")." = ".$r["required"];
|
if (!is_object($required)) $reqName = getMLText("unknown_group")." = ".$r["required"];
|
||||||
else $reqName = getMLText("group")." = ".$required->getName();
|
else $reqName = getMLText("group")." = ".$required->getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = "\n".$reqName."\n";
|
$tmp = "\n".$reqName."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("status")." = ".getApprovalStatusText($r["status"])."\n";
|
$tmp = getMLText("status")." = ".getApprovalStatusText($r["status"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("comment")." = ". mydmsDecodeString($r["comment"])."\n";
|
$tmp = getMLText("comment")." = ". mydmsDecodeString($r["comment"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("last_update")." = ".$r["date"]."\n";
|
$tmp = getMLText("last_update")." = ".$r["date"]."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
|
@ -206,33 +204,32 @@ function createVersionigFile($document)
|
||||||
$versions = $document->getContent();
|
$versions = $document->getContent();
|
||||||
$tmp = "\n### ".getMLText("previous_versions")." ###\n";
|
$tmp = "\n### ".getMLText("previous_versions")." ###\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
for ($i = count($versions)-2; $i >= 0; $i--){
|
for ($i = count($versions)-2; $i >= 0; $i--){
|
||||||
|
|
||||||
$version = $versions[$i];
|
$version = $versions[$i];
|
||||||
$status = $version->getStatus();
|
$status = $version->getStatus();
|
||||||
|
|
||||||
$tmp = "\n".getMLText("version")." = ".$version->getVersion()."\n";
|
$tmp = "\n".getMLText("version")." = ".$version->getVersion()."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("file")." = ".$version->getOriginalFileName()." (".$version->getMimeType().")\n";
|
$tmp = getMLText("file")." = ".$version->getOriginalFileName()." (".$version->getMimeType().")\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$tmp = getMLText("comment")." = ". mydmsDecodeString($version->getComment())."\n";
|
$tmp = getMLText("comment")." = ". mydmsDecodeString($version->getComment())."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
$status = $latestContent->getStatus();
|
$status = $latestContent->getStatus();
|
||||||
$tmp = getMLText("status")." = ".getOverallStatusText($status["status"])."\n";
|
$tmp = getMLText("status")." = ".getOverallStatusText($status["status"])."\n";
|
||||||
fwrite($handle, $tmp);
|
fwrite($handle, $tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return true;
|
return true;
|
||||||
}
|
} /* }}} */
|
||||||
|
|
||||||
function add_log_line($msg="")
|
function add_log_line($msg="") { /* {{{ */
|
||||||
{
|
|
||||||
global $settings,$user;
|
global $settings,$user;
|
||||||
|
|
||||||
if ($settings->_logFileEnable!=TRUE) return;
|
if ($settings->_logFileEnable!=TRUE) return;
|
||||||
|
@ -245,16 +242,15 @@ function add_log_line($msg="")
|
||||||
fwrite($h,date("Y/m/d H:i", time())." ".$user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg."\n");
|
fwrite($h,date("Y/m/d H:i", time())." ".$user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg."\n");
|
||||||
fclose($h);
|
fclose($h);
|
||||||
}
|
}
|
||||||
}
|
} /* }}} */
|
||||||
|
|
||||||
function showtree()
|
function showtree() { /* {{{ */
|
||||||
{
|
|
||||||
global $settings;
|
global $settings;
|
||||||
|
|
||||||
if (isset($_GET["showtree"])) return $_GET["showtree"];
|
if (isset($_GET["showtree"])) return $_GET["showtree"];
|
||||||
else if ($settings->_enableFolderTree==0) return 0;
|
else if ($settings->_enableFolderTree==0) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} /* }}} */
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user