Exemplo n.º 1
0
         $edit = true;
         $item = $h_myshop_files->get($id);
         if (!is_object($item)) {
             myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl, 5);
         }
         $item->unsetNew();
     } else {
         $item = $h_myshop_files->create(true);
     }
     $opRedirect = 'files';
     $item->setVars($_POST);
     $destname = '';
     $result = myshop_utils::uploadFile(0, MYSHOP_ATTACHED_FILES_PATH);
     if ($result === true) {
         $item->setVar('file_filename', basename($destname));
         $item->setVar('file_mimetype', myshop_utils::getMimeType(MYSHOP_ATTACHED_FILES_PATH . DIRECTORY_SEPARATOR . $destname));
     } else {
         if ($result !== false) {
             myshop_utils::redirect(_AM_MYSHOP_SAVE_PB . '<br />' . $result, $baseurl . '?op=' . $opRedirect, 5);
         }
     }
     $res = $h_myshop_files->insert($item);
     if ($res) {
         myshop_utils::updateCache();
         myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
     } else {
         myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
     }
     break;
 case 'delete':
     xoops_cp_header();
Exemplo n.º 2
0
$caddy = $h_myshop_caddy->getCaddyFromPassword($download_id);
if (!is_object($caddy)) {
    myshop_utils::redirect(_MYSHOP_ERROR14, MYSHOP_URL, 5);
}
// Search related product
$product = null;
$product = $h_myshop_products->get($caddy->getVar('caddy_product_id'));
if ($product == null) {
    myshop_utils::redirect(_MYSHOP_ERROR15, MYSHOP_URL, 5);
}
// Verifiy order paiment
$order = null;
$order = $h_myshop_commands->get($caddy->getVar('caddy_cmd_id'));
if ($order == null) {
    myshop_utils::redirect(_MYSHOP_ERROR16, MYSHOP_URL, 5);
}
// Send file to download if it exists
$file = '';
$file = $product->getVar('product_download_url');
if (xoops_trim($file) == '') {
    myshop_utils::redirect(_MYSHOP_ERROR17, MYSHOP_URL, 5);
}
if (!file_exists($file)) {
    myshop_utils::redirect(_MYSHOP_ERROR18, MYSHOP_URL, 5);
}
// Update, file is not available to download
$h_myshop_caddy->markCaddyAsNotDownloadableAnyMore($caddy);
// Display file with mime type
header("Content-Type: " . myshop_utils::getMimeType($file));
header('Content-disposition: inline; filename="' . basename($file) . '"');
readfile($file);