Exemplo n.º 1
0
 public function ajaxFile()
 {
     require_once 'CFDBDie.php';
     //if (!$this->canUserDoRoleOption('CanSeeSubmitData')) {
     if (!$this->canUserDoRoleOption('CanSeeSubmitDataViaShortcode')) {
         CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
     }
     $submitTime = $_REQUEST['s'];
     $formName = $_REQUEST['form'];
     $fieldName = $_REQUEST['field'];
     if (!$submitTime || !$formName || !$fieldName) {
         CFDBDie::wp_die(__('Missing form parameters', 'contact-form-7-to-database-extension'));
     }
     $fileInfo = (array) $this->getFileFromDB($submitTime, $formName, $fieldName);
     if ($fileInfo == null) {
         CFDBDie::wp_die(__('No such file.', 'contact-form-7-to-database-extension'));
     }
     require_once 'CFDBMimeTypeExtensions.php';
     $mimeMap = new CFDBMimeTypeExtensions();
     $mimeType = $mimeMap->get_type_by_filename($fileInfo[0]);
     if ($mimeType) {
         header('Content-Type: ' . $mimeType);
         header("Content-Disposition: inline; filename=\"{$fileInfo['0']}\"");
     } else {
         header("Content-Disposition: attachment; filename=\"{$fileInfo['0']}\"");
     }
     echo $fileInfo[1];
     die;
 }
Exemplo n.º 2
0
 public function ajaxFile()
 {
     $this->ajaxCheckForLoginAndDoRedirect();
     require_once 'CFDBDie.php';
     if (!$this->canUserDoRoleOption('CanSeeSubmitData') && !$this->canUserDoRoleOption('CanSeeSubmitDataViaShortcode')) {
         CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
     }
     $submitTime = stripslashes($_REQUEST['s']);
     $formName = stripslashes($_REQUEST['form']);
     $fieldName = stripslashes($_REQUEST['field']);
     if (!$submitTime || !$formName || !$fieldName) {
         CFDBDie::wp_die(__('Missing form parameters', 'contact-form-7-to-database-extension'));
     }
     $fileInfo = (array) $this->getFileFromDB($submitTime, $formName, $fieldName);
     if ($fileInfo == null) {
         CFDBDie::wp_die(__('No such file.', 'contact-form-7-to-database-extension'));
     }
     require_once 'CFDBMimeTypeExtensions.php';
     $mimeMap = new CFDBMimeTypeExtensions();
     $mimeType = $mimeMap->get_type_by_filename($fileInfo[0]);
     if (ob_get_level()) {
         ob_end_clean();
         // Fix bug where download files can be corrupted
     }
     ob_end_clean();
     // Not sure why have to do this on some sites
     if ($mimeType) {
         header('Content-Type: ' . $mimeType);
         header("Content-Disposition: inline; filename=\"{$fileInfo['0']}\"");
     } else {
         header("Content-Disposition: attachment; filename=\"{$fileInfo['0']}\"");
     }
     echo $fileInfo[1];
     die;
 }