/** * build backup-list * * @return backup-list as string */ function backupListDisplay() { global $cfg, $error; // backup-dir $dirBackup = $cfg["path"] . _DIR_BACKUP . '/'; // $retVal = ""; $fileList = backupList(); if (isset($fileList) && $fileList != "") { $retVal .= '<strong>Backups on Server :</strong>'; $retVal .= '<br><br>'; $retVal .= '<table cellpadding="2" cellspacing="1" border="1" bordercolor="' . $cfg["table_border_dk"] . '" bgcolor="' . $cfg["body_data_bg"] . '">'; $retVal .= '<tr>'; $retVal .= '<td align="center" bgcolor="' . $cfg["table_header_bg"] . '"><strong>Version</strong></td>'; $retVal .= '<td align="center" bgcolor="' . $cfg["table_header_bg"] . '"><strong>Date</strong></td>'; $retVal .= '<td align="center" bgcolor="' . $cfg["table_header_bg"] . '"><strong>Comp.</strong></td>'; $retVal .= '<td align="center" bgcolor="' . $cfg["table_header_bg"] . '"><strong>Size</strong></td>'; $retVal .= '<td align="center" bgcolor="' . $cfg["table_header_bg"] . '"> </td>'; $retVal .= '</tr>'; $backupListFiles = explode("\n", $fileList); foreach ($backupListFiles as $backup) { $backup = trim($backup); $backupFile = $dirBackup . $backup; if (isset($backup) && $backup != "" && is_file($backupFile)) { $backupElements = explode("_", $backup); $retVal .= '<tr>'; $retVal .= '<td align="center">' . $backupElements[1] . '</td>'; $retVal .= '<td align="right">' . formatHumanDate(substr($backupElements[2], 0, 14)) . '</td>'; $lastChar = substr($backupElements[2], -1, 1); $retVal .= '<td align="center">'; switch ($lastChar) { case "r": $retVal .= 'none'; break; case "z": $retVal .= 'gzip'; break; case "2": $retVal .= 'bzip2'; break; default: $retVal .= 'unknown'; break; } $retVal .= '</td>'; $retVal .= '<td align="right">' . (string) formatHumanSize(filesize($backupFile)) . '</td>'; $retVal .= '<td align="center">'; $retVal .= '<a href="' . _FILE_THIS . '?b=4&f=' . $backup . '">'; $retVal .= '<img src="images/download_owner.gif" title="Download" border="0">'; $retVal .= '</a>'; $retVal .= ' '; $retVal .= '<a href="' . _FILE_THIS . '?b=5&f=' . $backup . '">'; $retVal .= '<img src="images/delete.png" title="Delete" border="0">'; $retVal .= '</a>'; $retVal .= '</td>'; $retVal .= '</tr>'; } } $retVal .= '</table>'; } else { $retVal .= '<strong>No Backups on Server</strong>'; } return $retVal; }
/** * print file list worker * * @param $basedir * @param $dir * @param $type 1 = list, 2 = checksums * @param $mode 1 = text, 2 = html * @return revision-list as html-snip */ function _printFileList($basedir, $dir, $type = 1, $mode = 2) { global $fileList; if (!is_dir($dir)) { return false; } $dirHandle = opendir($dir); while ($file = readdir($dirHandle)) { $fullpath = $dir . '/' . $file; if (is_dir($fullpath)) { if ($file[0] != '.') { _printFileList($basedir, $fullpath, $type, $mode); } } else { $stringLength = strlen($file); foreach ($fileList['types'] as $ftype) { $extLength = strlen($ftype); if ($stringLength > $extLength && strtolower(substr($file, -$extLength)) === $ftype) { // count $fileList['count'] += 1; // file $_file = str_replace($basedir, '', $fullpath); switch ($type) { default: case 1: // vars $_size = filesize($fullpath); $_rev = getSVNRevisionFromId($fullpath); // size $fileList['size'] += $_size; // rev if ($_rev != 'NoID') { $intrev = intval($_rev); if ($intrev > $fileList['revision']) { $fileList['revision'] = $intrev; } } // print switch ($mode) { default: case 1: echo $_file . ';' . $_size . ';' . $_rev . "\n"; break; case 2: $line = '<a href="' . _URL_SVNFILE . $_file . _URL_SVNFILE_SUFFIX . '" target="_blank">' . $_file . '</a> | '; $line .= formatHumanSize($_size) . ' | '; $line .= $_rev != 'NoID' ? '<a href="' . _URL_SVNLOG . $_rev . _URL_SVNLOG_SUFFIX . '" target="_blank">' . $_rev . '</a>' : 'NoID'; $line .= '<br>'; sendLine($line); break; } break; case 2: // vars $_md5 = md5_file($fullpath); // print switch ($mode) { default: case 1: echo $_file . ';' . $_md5 . "\n"; break; case 2: sendLine($_file . " " . $_md5 . "<br>"); break; } break; } } } } } closedir($dirHandle); }