コード例 #1
0
 public function execute()
 {
     $name = basename(waRequest::get('file', 'export.csv'));
     $profile = waRequest::get('profile', 0, waRequest::TYPE_INT);
     $file = wa()->getTempPath('csv/download/' . $profile . '/' . $name);
     waFiles::readFile($file, $name);
 }
コード例 #2
0
 public function execute()
 {
     $path = null;
     $photo_rights_model = new photosPhotoRightsModel();
     $photo_id = waRequest::get('photo_id', null, waRequest::TYPE_INT);
     if ($photo_rights_model->checkRights($photo_id, true)) {
         $photo_model = new photosPhotoModel();
         if ($photo = $photo_model->getById($photo_id)) {
             if (waRequest::get('original')) {
                 $path = photosPhoto::getOriginalPhotoPath($photo);
             } else {
                 $path = photosPhoto::getPhotoPath($photo);
             }
         }
     }
     if ($path) {
         if ($attach = waRequest::get('attach') ? true : false) {
             $response = $this->getResponse();
             $response->addHeader('Expires', 'tomorrow');
             $response->addHeader('Cache-Control', ($photo['status'] == 1 ? 'public' : 'private') . ', max-age=' . 86400 * 30);
         }
         waFiles::readFile($path, $attach ? null : basename($photo['name'] . '.' . $photo['ext']), true, !$attach);
     } else {
         throw new waException(_w("Photo not found"), 404);
     }
 }
 public function execute()
 {
     $filepath = wa()->getCachePath('plugins/discountcards/export-discountcards.csv', 'shop');
     if (!file_exists($filepath)) {
         throw new waException(_ws("Page not found"), 404);
     }
     waFiles::readFile($filepath, 'export-discountcards.csv');
 }
コード例 #4
0
 public function execute()
 {
     $app_id = $this->getRequest()->get('app');
     $path = $this->getRequest()->get('path');
     if ($this->getRequest()->get('temp')) {
         $file = waSystem::getInstance()->getTempPath($path, $app_id);
     } else {
         $file = waSystem::getInstance()->getDataPath($path, false, $app_id);
     }
     waFiles::readFile($file);
 }
コード例 #5
0
 public function execute()
 {
     $path = rtrim(waRequest::get('path'), ' /');
     $path = wa()->getDataPath($path, true, null, false);
     $file = waRequest::get('file');
     $path .= '/' . $file;
     if (file_exists($path) && is_file($path) && !in_array(waFiles::extension($path, array('php', 'phtml')))) {
         waFiles::readFile($path, $file);
     } else {
         throw new waException("File not found", 404);
     }
 }
コード例 #6
0
 public function execute()
 {
     $path = waRequest::get('path');
     $full_path = logsHelper::getAbsolutePath($path);
     $available = logsHelper::checkPath($full_path, false);
     if ($available) {
         $file_name = basename($full_path);
         waFiles::readFile($full_path, $file_name);
     } else {
         $this->redirect(wa()->getAppUrl());
     }
 }
コード例 #7
0
 /**
  * Userpic
  */
 public function photoAction()
 {
     $id = (int) waRequest::get('id');
     if (!$id) {
         $id = $this->getUser()->getId();
     }
     $contact = new waContact($id);
     $rand = $contact['photo'];
     $file = wa()->getDataPath("photo/{$id}/{$rand}.original.jpg", TRUE, 'contacts');
     $size = waRequest::get('size');
     if (!file_exists($file)) {
         $size = (int) $size;
         if (!in_array($size, array(20, 32, 50, 96))) {
             $size = 96;
         }
         waFiles::readFile($this->getConfig()->getRootPath() . '/wa-content/img/userpic' . $size . '.jpg');
     } else {
         // original file
         if ($size == 'original') {
             waFiles::readFile($file);
         } elseif ($size == 'full') {
             $file = str_replace('.original.jpg', '.jpg', $file);
             waFiles::readFile($file);
         } else {
             if (!$size) {
                 $size = '96x96';
             }
             $size_parts = explode('x', $size, 2);
             $size_parts[0] = (int) $size_parts[0];
             if (!isset($size_parts[1])) {
                 $size_parts[1] = $size_parts[0];
             } else {
                 $size_parts[1] = (int) $size_parts[1];
             }
             if (!$size_parts[0] || !$size_parts[1]) {
                 $size_parts = array(96, 96);
             }
             $size = $size_parts[0] . 'x' . $size_parts[1];
             $thumb_file = str_replace('.original.jpg', '.' . $size . '.jpg', $file);
             $file = str_replace('.original.jpg', '.jpg', $file);
             if (!file_exists($thumb_file) || filemtime($thumb_file) < filemtime($file)) {
                 waImage::factory($file)->resize($size_parts[0], $size_parts[1])->save($thumb_file);
                 clearstatcache();
             }
             waFiles::readFile($thumb_file);
         }
     }
 }
コード例 #8
0
 public function execute()
 {
     $id = waRequest::get('id', 0, waRequest::TYPE_INT);
     if (!$id) {
         throw new waException(_w("Image not found"), 404);
     }
     $product_images_model = new shopProductImagesModel();
     $image = $product_images_model->getById($id);
     if (!$image) {
         throw new waException(_w("Image not found"), 404);
     }
     if (waRequest::get('original')) {
         $path = shopImage::getOriginalPath($image);
     } else {
         $path = shopImage::getPath($image);
     }
     if (!$path || !file_exists($path)) {
         throw new waException(_w("Image not found"), 404);
     }
     waFiles::readFile($path, "Image_{$image['product_id']}_{$image['id']}.{$image['ext']}", true, true);
 }
コード例 #9
0
 public function execute()
 {
     $encoded_order_id = waRequest::param('id');
     $order_id = shopHelper::decodeOrderId($encoded_order_id);
     if (!$order_id) {
         // fall back to non-encoded id
         $order_id = $encoded_order_id;
         $encoded_order_id = shopHelper::encodeOrderId($order_id);
     }
     $om = new shopOrderModel();
     $order = $om->getOrder($order_id);
     if (!$order) {
         throw new waException(_w('Order not found'), 404);
     }
     if (!$this->isAuth($order)) {
         throw new waException(_w('The file will be available for download after the order is paid and processed.'), 404);
     }
     // Check auth code
     $opm = new shopOrderParamsModel();
     $params = $opm->get($order_id);
     $code = waRequest::param('code');
     if (ifset($params['auth_code']) !== $code) {
         throw new waException(_w('Order not found'), 404);
     }
     if ($item = ifempty($order['items'][waRequest::param('item')])) {
         $skus_model = new shopProductSkusModel();
         $sku = $skus_model->getById(ifempty($item['sku_id']));
         if ($sku['file_name'] && $sku['file_size']) {
             $file_path = shopProductSkusModel::getPath($sku);
             waFiles::readFile($file_path, $sku['file_name']);
         } else {
             throw new waException(_w('File not found'), 404);
         }
     } else {
         throw new waException(_w('Order item not found'), 404);
     }
 }
コード例 #10
0
ファイル: thumb.php プロジェクト: Lazary/webasyst
        }
        unset($s);
        $size = implode('x', $size);
    }
}
wa()->getStorage()->close();
if ($file && file_exists($protected_path . $file) && !file_exists($public_path . $request_file)) {
    $main_thumb_file_path = $public_path . $main_thumb_file;
    $target_dir_path = dirname($public_path . $request_file);
    if (!file_exists($target_dir_path)) {
        waFiles::create($target_dir_path . '/');
    }
    $max_size = $app_config->getOption('max_size');
    $image = photosPhoto::generateThumb(array('path' => $main_thumb_file_path, 'size' => $main_thumbnail_size), $protected_path . $file, $size, $app_config->getOption('sharpen'), $max_size ? $enable_2x ? 2 * $max_size : $max_size : false);
    if ($image) {
        $quality = $app_config->getSaveQuality($enable_2x);
        $image->save($public_path . $request_file, $quality);
        clearstatcache();
    }
}
if ($file && file_exists($public_path . $request_file)) {
    waFiles::readFile($public_path . $request_file);
} else {
    /*
    $url = wa()->getRootUrl();
    $url = substr($url, 0, -strlen('/wa-data/public/photo/'));
    header("Location: ".$url."wa-apps/photos/img/image-not-found.png");
    */
    header("HTTP/1.0 404 Not Found");
    exit;
}
コード例 #11
0
 public function dtdAction()
 {
     waFiles::readFile(shopYandexmarketPlugin::path('shops.dtd'));
 }
コード例 #12
0
 public function themeDownloadAction()
 {
     $theme_id = waRequest::get('theme');
     $theme = new waTheme($theme_id, $this->getAppId());
     $this->logAction('theme_download', $theme_id);
     $target_file = $theme->compress(wa()->getTempPath("themes"));
     waFiles::readFile($target_file, basename($target_file), false);
     waFiles::delete($target_file);
     $this->displayJson(array());
 }
コード例 #13
0
 public function execute()
 {
     $installer = new waInstaller();
     waFiles::readFile($installer->getLogPath(), 'update.txt');
 }
コード例 #14
0
if (count($file) != 4) {
    header("Location: {$root_url}wa-content/img/userpic96.jpg");
    exit;
}
$request_file = $file[3];
$contact_id = (int) $file[2];
$file = explode(".", $file[3]);
if (!$contact_id || count($file) != 3) {
    header("Location: {$root_url}wa-content/img/userpic96.jpg");
    exit;
}
$size = explode("x", $file[1]);
if (count($size) != 2 || !$size[0] || !$size[1]) {
    header("Location: {$root_url}wa-content/img/userpic96.jpg");
    exit;
}
$file = $file[0] . ".jpg";
$path = wa()->getDataPath(waContact::getPhotoDir($contact_id), true, 'contacts', false);
$filepath = "{$path}{$file}";
if (!file_exists($filepath)) {
    header("Location: {$root_url}wa-content/img/userpic96.jpg");
    exit;
}
if ($size[0] == $size[1]) {
    waImage::factory($filepath)->resize($size[0], $size[1])->save($path . $request_file);
} else {
    waImage::factory($filepath)->resize($size[0], $size[1], waImage::INVERSE)->crop($size[0], $size[1])->save($path . $request_file);
}
clearstatcache();
waFiles::readFile($path . $request_file);
コード例 #15
0
ファイル: thumb.php プロジェクト: Lazary/webasyst
        foreach ($size as &$s) {
            $s *= 2;
        }
        unset($s);
        $size = implode('x', $size);
    }
}
wa()->getStorage()->close();
$original_path = $protected_path . $file;
$thumb_path = $public_path . $request_file;
if ($file && file_exists($original_path) && !file_exists($thumb_path)) {
    $thumbs_dir = dirname($thumb_path);
    if (!file_exists($thumbs_dir)) {
        waFiles::create($thumbs_dir);
    }
    $max_size = $app_config->getOption('image_max_size');
    if ($max_size && $enable_2x) {
        $max_size *= 2;
    }
    $image = shopImage::generateThumb($original_path, $size, $max_size);
    if ($image) {
        $image->save($thumb_path, $app_config->getSaveQuality($enable_2x));
        clearstatcache();
    }
}
if ($file && file_exists($thumb_path)) {
    waFiles::readFile($thumb_path);
} else {
    header("HTTP/1.0 404 Not Found");
    exit;
}