Blame view

sources/apps/gallery/ajax/thumbnail.php 978 Bytes
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
6
7
8
9
  <?php
  /**
   * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
   * This file is licensed under the Affero General Public License version 3 or
   * later.
   * See the COPYING-README file.
   */
  
  OCP\JSON::checkAppEnabled('gallery');
6d9380f96   Cédric Dupont   Update sources OC...
10
11
  list($owner, $img) = explode('/', $_GET['file'], 2);
  $linkItem = \OCP\Share::getShareByToken($owner);
d1bafeea1   Kload   [fix] Upgrade to ...
12
13
14
  if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
  	// seems to be a valid share
  	$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
6d9380f96   Cédric Dupont   Update sources OC...
15
16
17
18
  	$user = $rootLinkItem['uid_owner'];
  
  	// Setup filesystem
  	OCP\JSON::checkUserExists($user);
d1bafeea1   Kload   [fix] Upgrade to ...
19
  	OC_Util::tearDownFS();
6d9380f96   Cédric Dupont   Update sources OC...
20
21
22
23
  	OC_Util::setupFS($user);
  
  	$fullPath = \OC\Files\Filesystem::getPath($linkItem['file_source']);
  	$img = trim($fullPath . '/' . $img);
d1bafeea1   Kload   [fix] Upgrade to ...
24
25
  } else {
  	OCP\JSON::checkLoggedIn();
6d9380f96   Cédric Dupont   Update sources OC...
26
  	$user = OCP\User::getUser();
d1bafeea1   Kload   [fix] Upgrade to ...
27
28
29
  }
  
  session_write_close();
d1bafeea1   Kload   [fix] Upgrade to ...
30
  $square = isset($_GET['square']) ? (bool)$_GET['square'] : false;
6d9380f96   Cédric Dupont   Update sources OC...
31
  $image = new \OCA\Gallery\Thumbnail('/' . $img, $user, $square);
d1bafeea1   Kload   [fix] Upgrade to ...
32
  $image->show();