Exemplo n.º 1
0
 private static function doLogFile($logId, $action)
 {
     $files = array('email' => array('file' => Form::getEmailLogFile(), 'as' => 'email-log.txt'), 'data' => array('file' => Form::getFormDataFile(), 'as' => 'form-data.csv'));
     $file = $files[$logId];
     if (!is_file($file['file'])) {
         self::header();
         echo "<b>No " . ($logId == 'email' ? 'email traffic log' : 'form data') . " found.</b>";
         self::footer();
         return;
     }
     switch ($action) {
         case 'view':
             self::header();
             if ($logId == 'data') {
                 $dm = new DataManager();
                 $dm->displayRecords();
             } else {
                 $content = file_get_contents($file['file']);
                 echo "<pre>" . htmlspecialchars($content) . "</pre>";
             }
             self::footer();
             break;
         case 'download':
             self::download($file['file'], $file['as'], true, 1);
             // skip the first line
             break;
         case 'delete':
             self::header();
             $yes = unlink($file['file']);
             echo $yes ? 'Log file deleted.' : 'Failed to delte log file.';
             self::footer();
             break;
     }
     // switch
 }
Exemplo n.º 2
0
 function __construct()
 {
     $this->dataFile = Form::getFormDataFile();
 }