Example #1
0
 /**
  * Show files in the cache
  *
  */
 function ShowFiles()
 {
     global $page, $langmessage;
     $page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js';
     $page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});';
     if (!$this->all_files) {
         return;
     }
     echo '<p>';
     echo common::Link('Admin_Cache', 'Empty Cache', 'cmd=EmptyResourceCache', array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => 'Empty the resource cache?'));
     echo '</p>';
     echo '<table class="bordered tablesorter full_width">';
     echo '<thead>';
     echo '<tr><th>';
     echo $langmessage['file_name'];
     echo '</th><th>';
     echo $langmessage['File Size'];
     echo '</th><th>';
     echo 'Touched';
     echo '</th><th>';
     echo $langmessage['options'];
     echo '</th></tr>';
     echo '</thead>';
     $total_size = 0;
     echo '<tbody>';
     foreach ($this->all_files as $file) {
         $full = $this->cache_dir . '/' . $file;
         echo '<tr><td>';
         echo '<a href="?cmd=ViewFile&amp;file=' . rawurlencode($file) . '">';
         echo $file;
         echo '</a>';
         echo '</td><td>';
         $size = filesize($full);
         echo '<span style="display:none">' . $size . '</span>';
         echo admin_tools::FormatBytes($size);
         $total_size += $size;
         echo '</td><td>';
         $elapsed = admin_tools::Elapsed(time() - filemtime($full));
         echo sprintf($langmessage['_ago'], $elapsed);
         echo '</td><td>';
         echo common::Link('Admin_Cache', $langmessage['delete'], 'cmd=DeleteFile&amp;file=' . rawurlencode($file), array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm']));
         echo '</tr>';
     }
     echo '</tbody>';
     //totals
     echo '<tfoot>';
     echo '<tr><td>';
     echo number_format(count($this->all_files)) . ' Files';
     echo '</td><td>';
     echo admin_tools::FormatBytes($total_size);
     echo '</td><td>';
     echo '</tr>';
     echo '</table>';
 }
Example #2
0
 /**
  * Display the revision history of the current file
  *
  */
 public function ViewHistory()
 {
     global $langmessage, $config;
     $files = $this->BackupFiles();
     $rows = array();
     //working draft
     if ($this->draft_exists) {
         ob_start();
         $size = filesize($this->draft_file);
         $date = common::date($langmessage['strftime_datetime'], $this->draft_stats['modified']);
         echo '<tr><td title="' . htmlspecialchars($date) . '">';
         echo '<b>' . $langmessage['Working Draft'] . '</b><br/>';
         $elapsed = admin_tools::Elapsed(time() - $this->draft_stats['modified']);
         echo sprintf($langmessage['_ago'], $elapsed);
         echo '</td><td>';
         echo admin_tools::FormatBytes($size);
         echo '</td><td>' . $this->draft_stats['username'] . '</td><td>';
         echo common::Link($this->title, $langmessage['View']);
         echo ' &nbsp; ' . common::Link($this->title, $langmessage['Publish Draft'], 'cmd=PublishDraft', array('data-cmd' => 'cnreq'));
         echo '</td></tr>';
         $rows[$this->draft_stats['modified']] = ob_get_clean();
     }
     foreach ($files as $time => $file) {
         //remove .gze
         if (strpos($file, '.gze') === strlen($file) - 4) {
             $file = substr($file, 0, -4);
         }
         //get info from filename
         $name = basename($file);
         $parts = explode('.', $name, 3);
         $time = array_shift($parts);
         $size = array_shift($parts);
         $username = false;
         $date = common::date($langmessage['strftime_datetime'], $time);
         if (count($parts)) {
             $username = array_shift($parts);
         }
         //output row
         ob_start();
         echo '<tr><td title="' . htmlspecialchars($date) . '">';
         $elapsed = admin_tools::Elapsed(time() - $time);
         echo sprintf($langmessage['_ago'], $elapsed);
         echo '</td><td>';
         if ($size && is_numeric($size)) {
             echo admin_tools::FormatBytes($size);
         }
         echo '</td><td>';
         echo $username;
         echo '</td><td>';
         echo common::Link($this->title, $langmessage['View'], 'cmd=ViewRevision&time=' . $time, array('data-cmd' => 'cnreq'));
         echo ' &nbsp; ';
         echo common::Link($this->title, $langmessage['delete'], 'cmd=DeleteRevision&time=' . $time, array('data-cmd' => 'gpabox', 'class' => 'gpconfirm'));
         echo '</td></tr>';
         $rows[$time] = ob_get_clean();
     }
     // current page
     // this will likely overwrite one of the history entries
     ob_start();
     $size = filesize($this->file);
     $date = common::date($langmessage['strftime_datetime'], $this->fileModTime);
     echo '<tr><td title="' . htmlspecialchars($date) . '">';
     echo '<b>' . $langmessage['Current Page'] . '</b><br/>';
     $elapsed = admin_tools::Elapsed(time() - $this->fileModTime);
     echo sprintf($langmessage['_ago'], $elapsed);
     echo '</td><td>';
     echo admin_tools::FormatBytes($size);
     echo '</td><td>';
     if (isset($this->file_stats['username'])) {
         echo $this->file_stats['username'];
     }
     echo '</td><td>';
     echo common::Link($this->title, $langmessage['View'], 'cmd=ViewCurrent');
     echo '</td></tr>';
     $rows[$this->fileModTime] = ob_get_clean();
     ob_start();
     echo '<h2>' . $langmessage['Revision History'] . '</h2>';
     echo '<table class="bordered full_width striped"><tr><th>' . $langmessage['Modified'] . '</th><th>' . $langmessage['File Size'] . '</th><th>' . $langmessage['username'] . '</th><th>&nbsp;</th></tr>';
     echo '<tbody>';
     krsort($rows);
     echo implode('', $rows);
     echo '</tbody>';
     echo '</table>';
     echo '<p>' . $langmessage['history_limit'] . ': ' . $config['history_limit'] . '</p>';
     $this->contentBuffer = ob_get_clean();
 }
Example #3
0
 function TrashRow($trash_index, $info, $show_orphaned = false)
 {
     global $langmessage;
     $class = '';
     if (isset($info['orphaned'])) {
         $class = 'orphaned';
     }
     //title
     echo '<tr class="' . $class . '"><td>';
     echo '<label style="display:block;">';
     echo '<input type="checkbox" name="titles[]" value="' . htmlspecialchars($trash_index) . '" />';
     echo ' &nbsp; ';
     if (isset($info['orphaned'])) {
         echo '(Orphaned) &nbsp; ';
     }
     echo common::Link('Admin_Trash/' . $trash_index, str_replace('_', ' ', $info['title']));
     echo '</label>';
     //time
     echo '</td><td>';
     if (!empty($info['time'])) {
         $elapsed = admin_tools::Elapsed(time() - $info['time']);
         echo sprintf($langmessage['_ago'], $elapsed);
     }
     echo '</td><td>';
     if (isset($info['type'])) {
         $this->TitleTypes($info['type']);
     }
     echo '</td><td>';
     if (admin_tools::CheckPostedNewPage($info['title'], $msg)) {
         echo common::Link('Admin_Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     } else {
         echo '<span>' . $langmessage['restore'] . '</span>';
     }
     echo ' &nbsp; ';
     echo common::Link('Admin_Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     echo '</td></tr>';
 }
Example #4
0
 /**
  * Display the error log
  *
  */
 function ErrorLog()
 {
     $error_log = ini_get('error_log');
     echo '<h2 class="hmargin">';
     echo common::Link('Admin_Errors', 'Fatal Errors');
     echo ' <span> | </span>';
     echo ' Error Log';
     echo '</h2>';
     if (!self::ReadableLog()) {
         echo '<p>Sorry, an error log could not be found or could not be read.</p>';
         echo '<p>Log File: ' . $error_log . '</p>';
         return;
     }
     echo '<p><b>Please Note:</b> The following errors are not limited to your installation of gpEasy.';
     echo '</p>';
     $lines = file($error_log);
     $lines = array_reverse($lines);
     $time = null;
     $displayed = array();
     foreach ($lines as $line) {
         $line = trim($line);
         if (empty($line)) {
             continue;
         }
         preg_match('#^\\[[a-zA-Z0-9:\\- ]*\\]#', $line, $date);
         if (count($date)) {
             $date = $date[0];
             $line = substr($line, strlen($date));
             $date = trim($date, '[]');
             $new_time = strtotime($date);
             if ($new_time !== $time) {
                 if ($time) {
                     echo '</pre>';
                 }
                 echo '<p>';
                 $elapsed = admin_tools::Elapsed(time() - $new_time);
                 echo sprintf($langmessage['_ago'], $elapsed);
                 echo ' (' . $date . ')';
                 echo '</p>';
                 echo '<pre>';
                 $time = $new_time;
                 $displayed = array();
             }
         }
         $line_hash = md5($line);
         if (in_array($line_hash, $displayed)) {
             continue;
         }
         echo $line;
         $displayed[] = $line_hash;
         echo "\n";
     }
     echo '</pre>';
 }