<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara
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 the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if(!defined('cfg_sso_path'))
define('cfg_sso_path',cfg_data_path);
$group=get('group');
echo '<h2>OpenDataBag '.INFO.'</h2>';
echo '<ul>';
echo '<li>OpenDataBag is an easy-to-install and easy-to-use web data interface. No external database needed.</li>';
echo '<li>Official site: <a href="http://www.opendatabag.net">www.opendatabag.net</a></li>';
echo '<li>Licence: <a href="./LICENCE.txt">GNU GENERAL PUBLIC LICENSE</a></li>';
echo '<li>Check for Updates: <a href="http://sourceforge.net/project/showfiles.php?group_id=144048">Source Forge</a></li>';
echo '</ul>';
echo '<h2>';
myecho('Business logic');
echo '</h2>';
echo '<ul>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=onaccesscheck">onAccessCheck - ';
myecho('run to get user rights');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=onsave">onSave - ';
myecho('run before each update');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=onclone">onClone - ';
myecho('run before each copying');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=onshowaction">onShowAction - ';
myecho('adding custom buttons');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=ondelete">onDelete - ';
myecho('run before each deletion');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=onlogin">onLogin - ';
myecho('run after sign-on');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=ondownload">onDownload - ';
myecho('run before each download');
echo '</a></li>';
echo '<li><a href="index.php?odb_sys=highlight&odb_file=oncron">onCron - ';
myecho('run every few minutes');
echo '</a></li>';
echo '</ul>';
echo '<h2>';
myecho('System logs');
echo '</h2>';
echo '<ul>';
if(!cfg_grep_available)
{
echo '<li><b>';
myecho('WARNING: Grep is not available. This system can run much faster with grep.');
echo '</b></li>';
}
//if(file_exists('http://nawara.home.pl/opendatabag.net/odb.zip'))
{
echo '<li><a href="index.php?upgrade_me=1">';
myecho('Upgrade system');
echo '</a></li>';
}
echo '<li><a href="index.php?odb_search=logs">';
myecho('System logs');
echo '</a></li>';
//echo '<li><a href="../">..</a></li>';
$res=opendir(cfg_data_path.'/temp/errors');
while($fl = readdir($res))
{
if(substr($fl,0,1)!='.' and substr($fl,-3)!='php')
{
echo '<li><a href="index.php?odb_sys=download&odb_log='.substr($fl,0,-4).'">';
myecho('Error log');
echo ' '.$fl.'</a> .... '.readable_size(filesize(cfg_data_path.'/temp/errors/'.$fl)).'</li>';
}
}
closedir($res);
echo '</ul>';
function filesize_r($path)
{
if(!file_exists($path)) return 0;
if(is_file($path)) return filesize($path);
$self = __FUNCTION__;
$ret = 0;
foreach(glob($path."/*") as $fn)
$ret += $self($fn);
return $ret;
}
$filesize_cwd=filesize_r(getcwd());
$filesize_mydata=filesize_r(cfg_data_path);
$filesize_data=filesize_r(cfg_data_path.'/data');
$filesize_files=filesize_r(cfg_data_path.'/data/files');
$filesize_data=$filesize_data-$filesize_files;
$disk_free_space=disk_free_space(cfg_data_path);
$disk_free_space_cwd=disk_free_space(getcwd());
if(strpos('_'.cfg_data_path,getcwd())==0)
$filesize_total=$filesize_mydata+$filesize_cwd;
else
$filesize_total=$filesize_cwd;
echo '<h2>';
myecho('Disk space');
echo '</h2>';
echo '<ul>';
echo '<li>Free space '.readable_size($disk_free_space_cwd).'</li>';
//echo '<li>System size: '.readable_size($filesize_cwd).' (Free '.readable_size($disk_free_space_cwd).')</li>';
if(strpos('_'.cfg_data_path,getcwd())==0)
echo '<li>MyData size: '.readable_size($filesize_mydata).' (Free '.readable_size($disk_free_space).')</li>';
echo '<li>Data size: '.readable_size($filesize_data).'</li>';
echo '<li>Upload size: '.readable_size($filesize_files).'</li>';
//echo '- Rest size: '.readable_size($filesize_mydata-$filesize_data-$filesize_files).'<br />';
echo '<li>Total size: '.readable_size($filesize_total).'</li>';
echo '<li><a href="index.php?odb_run=shrink&odb_search=logs+date%3d'.date('Ymd').'+shrink">';
myecho('Shrink database');
echo '</a></li>';
echo '</ul>';
echo '<h2>';
myecho('Long running searches');
echo '</h2>';
echo '<div class="supergroup">';
echo '<table >';
echo '<tr>';
echo '<th>';
myecho('Date');
echo '</th>';
echo '<th>';
myecho('Problem');
echo '</th>';
echo '<th>';
myecho('Time');
echo '</th>';
echo '<th>';
myecho('Count');
echo '</th>';
echo '<th>';
myecho('Avg. Time');
echo '</th>';
echo '</tr>';
$res=opendir(cfg_data_path.'/temp/errors');
while($fl = readdir($res))
{
if(substr($fl,0,7)=='toolong' and substr($fl,-4)=='.php')
{
$toolong_array=array();
include(cfg_data_path.'/temp/errors/'.$fl);
reset($toolong_array);
foreach($toolong_array as $problem => $details_array)
{
echo '<tr>';
echo '<td>';
echo substr($fl,7,-4);
echo '</td>';
echo '<td>';
echo $details_array['Problem'];
echo '</td>';
echo '<td style="text-align:right;">';
echo $details_array['Time'];
echo '</td>';
echo '<td style="text-align:right;">';
echo $details_array['Count'];
echo '</td>';
echo '<td style="text-align:right;">';
echo ($details_array['Time']/$details_array['Count']);
echo '</td>';
echo '</tr>';
}
}
}
closedir($res);
echo '</table>';
echo '</div>';
echo '<h2>';
myecho('Users sessions');
echo '</h2>';
$tmp_session_array=array();
$res=opendir(cfg_sso_path.'/temp/users');
while($fl = readdir($res))
{
if(strpos('_'.$fl,'.')==0)
{
$tmp_session_array[date('Ymd',filemtime(cfg_sso_path.'/temp/users/'.$fl))]++;
}
}
closedir($res);
krsort($tmp_session_array);
echo '<ul>';
foreach($tmp_session_array as $date => $amount)
echo '<li>'.$date.' ... '.$amount.'</li>';
echo '</ul>';
?>