";
}
}
/* Create error header */
$error_collector.= "
"._("PHP error")." \"$errstr\" |
";
/* Extract traceback data - if available */
if (function_exists('debug_backtrace')){
$trace= debug_backtrace();
/* Generate trace history */
for ($index= 1; $index":
$type= _("method");
break;
}
} else {
$type= "-";
}
$args= "";
foreach ($ct['args'] as $arg){
$args.= htmlentities("\"$arg\", ");
}
$args= preg_replace("/, $/", "", $args);
if ($args == ""){
$args= "-";
}
$file= $ct['file'];
$line= $ct['line'];
$color= ($index&1)?'#404040':'606060';
$error_collector.= ""._("Trace")."[$index]: $loc | ";
$error_collector.= ""._("File").": $file ("._('Line')." $line) | "._("Type").": $type |
";
$error_collector.= ""._("Arguments").": $args |
";
}
}
/* Close error table */
$error_collector.= "
";
/* Write to syslog */
gosa_log ("PHP error: $errstr ($errfile, line $errline)");
}
function dummy_error_handler()
{
}
function rmdirRecursive($path, $followLinks=false) {
$dir= opendir($path);
while($entry= readdir($dir)) {
if(is_file($path."/".$entry) || ((!$followLinks) && is_link($path."/".$entry))) {
unlink($path."/".$entry);
} elseif (is_dir($path."/".$entry) && $entry!='.' && $entry!='..') {
rmdirRecursive($path."/".$entry);
}
}
closedir($dir);
return rmdir($path);
}
function clean_smarty_compile_dir($directory)
{
global $svn_revision;
if(is_dir($directory) && is_readable($directory)) {
// Set revision filename to REVISION
$revision_file= $directory."/REVISION";
/* Is there a stamp containing the current revision? */
if(!file_exists($revision_file)) {
// create revision file
create_revision($revision_file, $svn_revision);
} else {
# check for "$config->...['CONFIG']/revision" and the
# contents should match the revision number
if(!compare_revision($revision_file, $svn_revision)){
// If revision differs, clean compile directory
foreach(scandir($directory) as $file) {
if( is_file($directory."/".$file) &&
is_writable($directory."/".$file)) {
// delete file
if(!unlink($directory."/".$file)) {
print_red("File ".$directory."/".$file." could not be deleted.");
// This should never be reached
}
} elseif(is_dir($directory."/".$file) &&
is_writable($directory."/".$file)) {
// Just recursively delete it
rmdirRecursive($directory."/".$file);
}
}
// We should now create a fresh revision file
clean_smarty_compile_dir($directory);
} else {
// Revision matches, nothing to do
}
}
} else {
// Smarty compile dir is not accessible
// (Smarty will warn about this)
}
}
function create_revision($revision_file, $revision)
{
$result= false;
if(is_dir(dirname($revision_file)) && is_writable(dirname($revision_file))) {
if($fh= fopen($revision_file, "w")) {
if(fwrite($fh, $revision)) {
$result= true;
}
}
fclose($fh);
} else {
print_red("Can not write to revision file");
}
return $result;
}
function compare_revision($revision_file, $revision)
{
// false means revision differs
$result= false;
if(file_exists($revision_file) && is_readable($revision_file)) {
// Open file
if($fh= fopen($revision_file, "r")) {
// Compare File contents with current revision
if($revision == fread($fh, filesize($revision_file))) {
$result= true;
}
} else {
print_red("Can not open revision file");
}
// Close file
fclose($fh);
}
return $result;
}
function progressbar($percentage,$width=100,$height=15,$showvalue=false)
{
$str = ""; // Our return value will be saved in this var
$color = dechex($percentage+150);
$color2 = dechex(150 - $percentage);
$progress = (int)(($percentage /100)*$width);
/* Abort printing out percentage, if divs are to small */
/* If theres a better solution for this, use it... */
$str = "
";
if(($height >10)&&($showvalue)){
$str.= "
".$percentage."%
";
}
$str.= "
";
return($str);
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>