| ' ;
if ( $vh['running'] == -1 ) {
$verrors ++ ;
$vbody .= ' ' ;
$actions = '' ;
}
elseif ( $vh['running'] == 1 ) {
$vrunning ++ ;
$vbody .= ' ' ;
$actions = '' ;
}
else {
$vdisabled ++ ;
$vbody .= ' ' ;
$actions = '' ;
}
$vbody .= ' | ' . htmlspecialchars(wordwrap($vn, 40, "\n", true)) . ' | ' ;
if ( isset($vh['templ']) )
$vbody .= $vh['templ'] ;
$vbody .= ' | ' ;
if ( isset($vh['domains']) ) {
$vbody .= htmlspecialchars(wordwrap(implode("\n", array_keys($vh['domains'])), 60, "\n", true)) ;
}
$vbody .= ' | ' ;
$vbody .= $actions ;
$vbody .= ' |
' ;
}
$res = array( 'l_running' => $running,
'l_broken' => $broken,
'v_running' => $vrunning,
'v_disabled' => $vdisabled,
'v_err' => $verrors,
'l_body' => $body,
'v_body' => $vbody
) ;
echo json_encode($res) ;
}
function ajax_dashlog()
{
$logfilter = Service::ServiceData(SInfo::DATA_DASH_LOG) ;
$debug = Service::ServiceData(SInfo::DATA_DEBUGLOG_STATE) ;
$res = array( 'debuglog' => $debug,
'logfound' => $logfilter->Get(LogFilter::FLD_TOTALFOUND),
'logfoundmesg' => $logfilter->Get(LogFilter::FLD_OUTMESG),
'log_body' => $logfilter->GetLogOutput() ) ;
echo json_encode($res) ;
}
function ajax_viewlog()
{
$logfilter = Service::ServiceData(SInfo::DATA_VIEW_LOG) ;
$res = array( 'logfound' => $logfilter->Get(LogFilter::FLD_TOTALFOUND),
'logfoundmesg' => $logfilter->Get(LogFilter::FLD_OUTMESG),
'cur_log_file' => $logfilter->Get(LogFilter::FLD_LOGFILE),
'cur_log_size' => $logfilter->Get(LogFilter::FLD_FILE_SIZE),
'sellevel' => $logfilter->Get(LogFilter::FLD_LEVEL),
'startpos' => $logfilter->Get(LogFilter::FLD_FROMPOS),
'blksize' => $logfilter->Get(LogFilter::FLD_BLKSIZE),
'log_body' => $logfilter->GetLogOutput() ) ;
echo json_encode($res) ;
}
function ajax_downloadlog()
{
$file = UIBase::GrabGoodInput('get', 'filename') ;
if ( file_exists($file) ) {
if ( ob_get_level() ) {
ob_end_clean() ;
}
header('Content-Description: File Transfer') ;
//header('Content-Type: application/octet-stream') ;
header('Content-Type: application/x-download') ;
header('Content-Disposition: attachment; filename=' . basename($file)) ;
header('Expires: 0') ;
header('Cache-Control: must-revalidate') ;
header('Pragma: public') ;
header('Content-Length: ' . filesize($file)) ;
readfile($file) ;
exit ;
}
else {
error_log("download log $file not exist") ;
}
}
function ajax_buildprogress()
{
$progress_file = $_SESSION['progress_file'] ;
$log_file = $_SESSION['log_file'] ;
echo file_get_contents($progress_file) ;
echo "\n**LOG_DETAIL** retrieved from $log_file\n" ;
echo file_get_contents($log_file) ;
}
$id = UIBase::GrabGoodInput('get', 'id') ;
$supported = array( 'dashstat', 'plotstat', 'vhstat', 'dashstatus', 'pid_load',
'dashlog', 'viewlog', 'downloadlog', 'buildprogress' ) ;
if ( in_array($id, $supported) ) {
$func = "ajax_$id" ;
$func() ;
}
else {
error_log("invalid action ajax_data id = $id") ;
}