public static function getAll() { global $lC_Language; $media = $_GET['media']; $lC_DirectoryListing = new lC_DirectoryListing(DIR_FS_BACKUP); $lC_DirectoryListing->setIncludeDirectories(false); $lC_DirectoryListing->setCheckExtension('zip'); $lC_DirectoryListing->setCheckExtension('sql'); $lC_DirectoryListing->setCheckExtension('gz'); $cnt = 0; $result = array('aaData' => array()); foreach ($lC_DirectoryListing->getFiles() as $file) { $downloadLink = lc_href_link_admin(FILENAME_DEFAULT, 'backup&action=download&file=' . $file['name']); $check = '<td><input class="batch" type="checkbox" name="batch[]" value="' . $file['name'] . '" id="' . $file['name'] . '"></td>'; $filename = '<td><a href="' . $downloadLink . '"><span class="icon-download icon-orange with-tooltip" title="' . $lC_Language->icon_download . '"> ' . $file['name'] . '</a></td>'; $date = '<td>' . lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(@filemtime(DIR_FS_BACKUP . $file['name'])), true) . '</td>'; $size = '<td>' . number_format(@filesize(DIR_FS_BACKUP . $file['name'])) . '</td>'; $action = '<td class="align-right vertical-center"><span class="button-group compact"> <a href="' . ((int) ($_SESSION['admin']['access']['backup'] < 3) ? '#' : 'javascript://" onclick="restoreEntry(\'' . $file['name'] . '\')') . '" class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['backup'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_restore')) . '</a> <a href="' . ((int) ($_SESSION['admin']['access']['backup'] < 4) ? '#' : 'javascript://" onclick="deleteEntry(\'' . $file['name'] . '\', \'' . urlencode($file['name']) . '\')') . '" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access']['backup'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a> </span></td>'; $result['aaData'][] = array("{$check}", "{$filename}", "{$date}", "{$size}", "{$action}"); $cnt++; } $result['total'] = $cnt; return $result; }
public static function getAll() { global $lC_Language, $_module; $media = $_GET['media']; $lC_DirectoryListing = new lC_DirectoryListing(DIR_FS_WORK . 'cache/'); $lC_DirectoryListing->setIncludeDirectories(false); $lC_DirectoryListing->setCheckExtension('cache'); $cached_files = array(); foreach ($lC_DirectoryListing->getFiles() as $file) { $last_modified = filemtime(DIR_FS_WORK . 'cache/' . $file['name']); if (strpos($file['name'], '-') !== false) { $code = substr($file['name'], 0, strpos($file['name'], '-')); } else { $code = substr($file['name'], 0, strpos($file['name'], '.')); } if (isset($cached_files[$code])) { $cached_files[$code]['total']++; if ($last_modified > $cached_files[$code]['last_modified']) { $cached_files[$code]['last_modified'] = $last_modified; } } else { $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified); } } $result = array('aaData' => array()); foreach ($cached_files as $cache => $stats) { $check = '<td><input class="batch" type="checkbox" name="batch[]" value="' . $cache . '" id="' . $cache . '"></td>'; $block = '<td>' . $cache . '</td>'; $total = '<td>' . $stats['total'] . '</td>'; $last = '<td>' . lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp($stats['last_modified']), true) . '</td>'; $action = '<td><span class="button-group compact"> <a href="' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? '#' : 'javascript://" onclick="deleteEntry(\'' . $cache . '\', \'' . urlencode($cache) . '\')') . '" class="button icon-trash' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_delete')) . '</a> </span></td>'; $result['aaData'][] = array("{$check}", "{$block}", "{$total}", "{$last}", "{$action}"); } return $result; }
break; default: $file_array['compression'] = TEXT_NO_EXTENSION; break; } $buInfo = new objectInfo($file_array); } ?> <tr onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);"> <td><?php echo lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&action=download&file=' . $entry), lc_icon_admin('save.png', ICON_FILE_DOWNLOAD) . ' ' . $entry); ?> </td> <td><?php echo lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(filemtime(DIR_FS_BACKUP . $entry)), true); ?> </td> <td><?php echo number_format(filesize(DIR_FS_BACKUP . $entry)); ?> bytes</td> <td align="right"> <?php if (isset($buInfo) && $entry == $buInfo->file) { echo lc_link_object('#', lc_icon_admin('tape.png', IMAGE_RESTORE), 'onclick="toggleInfoBox(\'bRestore\');"') . ' ' . lc_link_object('#', lc_icon_admin('trash.png', IMAGE_DELETE), 'onclick="toggleInfoBox(\'bDelete\');"'); } else { echo lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&file=' . $entry . '&action=bRestore'), lc_icon_admin('tape.png', IMAGE_RESTORE)) . ' ' . lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&file=' . $entry . '&action=bDelete'), lc_icon_admin('trash.png', IMAGE_DELETE)); } ?>
/** * Retrieve log data * * @param string $log The log file to retrieve * @access public * @return array */ public static function getLog($log) { $log = basename($log); if (substr($log, 0, -4) != '.txt') { $log .= '.txt'; } $result = array('entries' => array()); foreach (file(DIR_FS_WORK . 'logs/' . $log) as $l) { if (preg_match('/^\\[([0-9]{2})-([A-Za-z]{3})-([0-9]{4}) ([0-9]{2}):([0-5][0-9]):([0-5][0-9])\\] (.*)$/', $l)) { $result['entries'][] = array('date' => lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(lC_DateTime::getTimestamp(substr($l, 1, 20), 'd-M-Y H:i:s')), true), 'message' => substr($l, 23)); } } $result['total'] = count($result['entries']); return $result; }