Пример #1
0
function getStandardImage()
{
    //OCP\Response::setExpiresHeader('P10D');
    OCP\Response::enableCaching();
    OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png'));
    exit;
}
Пример #2
0
function handleGetThumbnails($albumname)
{
    OCP\Response::enableCaching(3600 * 24);
    // 24 hour
    $thumbnail = OC::$CONFIG_DATADIRECTORY . '/../gallery/' . urldecode($albumname) . '.png';
    header('Content-Type: ' . OC_Image::getMimeTypeForFile($thumbnail));
    OCP\Response::sendFile($thumbnail);
}
Пример #3
0
function handleGetThumbnails($albumname)
{
    OCP\Response::enableCaching(3600 * 24);
    // 24 hour
    $view = OCP\Files::getStorage('gallery');
    $thumbnail = $view->fopen(urldecode($albumname) . '.png', 'r');
    header('Content-Type: ' . OC_Image::getMimeTypeForFile($thumbnail));
    OCP\Response::sendFile($thumbnail);
}
Пример #4
0
 public static function setLastModifiedHeader($contact)
 {
     $rev = $contact->getAsString('REV');
     if ($rev) {
         $rev = DateTime::createFromFormat(DateTime::W3C, $rev);
         OCP\Response::setLastModifiedHeader($rev);
     }
 }
Пример #5
0
/**
* ownCloud - gallery application
*
* @author Bartek Przybylski
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('gallery');
require_once 'apps/gallery/lib/managers.php';
$img = $_GET['filepath'];
$image = \OC\Pictures\ThumbnailsManager::getInstance()->getThumbnail($img);
if ($image) {
    OCP\Response::enableCaching(3600 * 24);
    // 24 hour
    $image->show();
}
Пример #6
0
}
session_write_close();
$ownerView = new \OC\Files\View('/' . $user . '/files');
$mime = $ownerView->getMimeType($img);
list($mimePart, ) = explode('/', $mime);
if ($mimePart === 'image') {
    $fileInfo = $ownerView->getFileInfo($img);
    if ($fileInfo['encrypted'] === true) {
        $local = $ownerView->toTmpFile($img);
    } else {
        $local = $ownerView->getLocalFile($img);
    }
    $rotate = false;
    if (is_callable('exif_read_data')) {
        //don't use OCP\Image here, using OCP\Image will always cause parsing the image file
        $exif = @exif_read_data($local, 'IFD0');
        if (isset($exif['Orientation'])) {
            $rotate = $exif['Orientation'] > 1;
        }
    }
    OCP\Response::setContentDispositionHeader(basename($img), 'attachment');
    if ($rotate) {
        $image = new OCP\Image($local);
        $image->fixOrientation();
        $image->show();
    } else {
        //use the original file if we dont need to rotate, saves having to re-encode the image
        header('Content-Type: ' . $mime);
        $ownerView->readfile($img);
    }
}
Пример #7
0
OCP\JSON::checkAppEnabled('contacts');
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$aid = isset($_GET['aid']) ? $_GET['aid'] : null;
$active_addressbooks = array();
if (is_null($aid)) {
    // Called initially to get the active addressbooks.
    $active_addressbooks = OCA\Contacts\Addressbook::active(OCP\USER::getUser());
} else {
    // called each time more contacts has to be shown.
    $active_addressbooks = array(OCA\Contacts\Addressbook::find($aid));
}
$lastModified = OCA\Contacts\App::lastModified();
if (!is_null($lastModified)) {
    OCP\Response::enableCaching();
    OCP\Response::setLastModifiedHeader($lastModified);
    OCP\Response::setETagHeader(md5($lastModified->format('U')));
}
session_write_close();
// create the addressbook associate array
$contacts_addressbook = array();
$ids = array();
foreach ($active_addressbooks as $addressbook) {
    $ids[] = $addressbook['id'];
    /*if(!isset($contacts_addressbook[$addressbook['id']])) {
    		$contacts_addressbook[$addressbook['id']]
    				= array('contacts' => array('type' => 'book',));
    		$contacts_addressbook[$addressbook['id']]['displayname']
    				= $addressbook['displayname'];
    		$contacts_addressbook[$addressbook['id']]['description']
    				= $addressbook['description'];
    		$contacts_addressbook[$addressbook['id']]['permissions']
Пример #8
0
                    break;
                case "sharedAbook":
                    $href = OCP\Util::linkTo("contacts", "index.php");
                    break;
                case "sharedFile":
                    $href = OCP\Util::linkTo("files", "index.php", array("dir" => "/Shared" . rtrim(dirname($notification["params"]["name"]), "/")));
                    break;
                case "sharedFolder":
                    $href = OCP\Util::linkTo("files", "index.php", array("dir" => "/Shared" . $notification["params"]["name"]));
                    break;
                default:
                    $href = OCP\Util::linkTo("files", "index.php");
            }
        } else {
            if ($notification["href"]) {
                $href = $notification["href"];
            } else {
                $href = OCP\Util::linkTo("files", "index.php");
            }
        }
        OCP\Response::redirect($href);
    } else {
        $tmpl = new OCP\Template("", $notification ? "403" : "404", "guest");
        $tmpl->assign("file", sprintf("ID: %s", $id));
        $tmpl->printPage();
    }
} catch (Exception $e) {
    $tmpl = new OCP\Template("", "404", "guest");
    $tmpl->assign("file", $e->getMessage());
    $tmpl->printPage();
}
Пример #9
0
 /**
  * @brief analyses the parameter for calendar parameter and returns the objects
  * @param (string) $calendarid - calendarid
  * @param (int) $start - unixtimestamp of start
  * @param (int) $end - unixtimestamp of end
  * @return (array) $events
  */
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
         foreach ($singleevents as $singleevent) {
             // Skip this single event if the whole calendar is already shared with the user.
             $calendarShared = false;
             foreach ($calendars as $calendar) {
                 if ($singleevent['calendarid'] === $calendar['id']) {
                     $calendarShared = true;
                     break;
                 }
             }
             if ($calendarShared === true) {
                 continue;
             }
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end, $calendar['userid'] !== OCP\User::getUser());
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Пример #10
0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
// Check if we are a user
OCP\User::checkLoggedIn();
$filename = $_GET["file"];
if (!\OC\Files\Filesystem::file_exists($filename)) {
    header("HTTP/1.0 404 Not Found");
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->assign('file', $filename);
    $tmpl->printPage();
    exit;
}
$ftype = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
header('Content-Type:' . $ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
OCP\Response::setContentLengthHeader(\OC\Files\Filesystem::filesize($filename));
OC_Util::obEnd();
\OC\Files\Filesystem::readfile($filename);
Пример #11
0
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_rw' || $calendarid == 'shared_r') {
         $calendars = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::CALENDAR, 1, $_GET['calendar_id'] == 'shared_rw' ? 'rw' : 'r');
         foreach ($calendars as $calendar) {
             $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end);
             foreach ($calendarevents as $event) {
                 $event['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($event['id']) . ')';
             }
             $events = array_merge($events, $calendarevents);
         }
         $singleevents = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::EVENT, 1, $_GET['calendar_id'] == 'shared_rw' ? 'rw' : 'r');
         foreach ($singleevents as $singleevent) {
             $event = OC_Calendar_Object::find($singleevent['eventid']);
             if (!array_key_exists('summary', $event)) {
                 $event['summary'] = self::$l10n->t('unnamed');
             }
             $event['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($event['id']) . ')';
             $events[] = $event;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end);
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Пример #12
0
 /**
  * @brief analyses the parameter for calendar parameter and returns the objects
  * @param (string) $calendarid - calendarid
  * @param (int) $start - unixtimestamp of start
  * @param (int) $end - unixtimestamp of end
  * @return (array) $events
  */
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         foreach ($singleevents as $singleevent) {
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end);
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Пример #13
0
                    $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
                    OCP\JSON::encodedPrint($song);
                }
            }
            break;
        case 'play':
            @ob_end_clean();
            $ftype = OC_Filesystem::getMimeType($arguments['path']);
            if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') {
                echo 'Not an audio file';
                exit;
            }
            $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
            OC_MEDIA_COLLECTION::registerPlay($songId);
            header('Content-Type:' . $ftype);
            OCP\Response::enableCaching(3600 * 24);
            // 24 hour
            header('Accept-Ranges: bytes');
            header('Content-Length: ' . OC_Filesystem::filesize($arguments['path']));
            $mtime = OC_Filesystem::filemtime($arguments['path']);
            OCP\Response::setLastModifiedHeader($mtime);
            OC_Filesystem::readfile($arguments['path']);
            exit;
        case 'find_music':
            $music = OC_FileCache::searchByMime('audio');
            $ogg = OC_FileCache::searchByMime('application', 'ogg');
            $music = array_merge($music, $ogg);
            OCP\JSON::encodedPrint($music);
            exit;
    }
}
Пример #14
0
function handleGetPhoto($token, $photo)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $view = OCP\Files::getStorage('files');
    $file = $view->fopen(urldecode($photo), 'r');
    header('Content-Type: ' . OC_Image::getMimeTypeForFile($file));
    OCP\Response::sendFile($file);
}
Пример #15
0
function handleGetPhoto($token, $photo)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $file = OCP\Config::getSystemValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $owner . '/files' . urldecode($photo);
    header('Content-Type: ' . OC_Image::getMimeTypeForFile($file));
    OCP\Response::sendFile($file);
}
Пример #16
0
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
// Init owncloud
// Check if we are a user
OCP\User::checkLoggedIn();
$filename = $_GET["file"];
if (!OC_Filesystem::file_exists($filename)) {
    header("HTTP/1.0 404 Not Found");
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->assign('file', $filename);
    $tmpl->printPage();
    exit;
}
$ftype = OC_Filesystem::getMimeType($filename);
header('Content-Type:' . $ftype);
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
OCP\Response::disableCaching();
header('Content-Length: ' . OC_Filesystem::filesize($filename));
@ob_end_clean();
OC_Filesystem::readfile($filename);
Пример #17
0
 * Copyright (c) 2012 Georg Ehrke <*****@*****.**>
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
    header('HTTP/1.0 404 Not Found');
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->printPage();
    exit;
}
$urlGenerator = \OC::$server->getURLGenerator();
$token = isset($_GET['t']) ? $_GET['t'] : '';
if ($token !== '') {
    OCP\Response::redirect($urlGenerator->linkToRoute('calendarplus.public.index', array('token' => $token)));
} else {
    header('HTTP/1.0 404 Not Found');
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->printPage();
    exit;
}
Пример #18
0
* @author Bjoern Schiessle
* @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\JSON::checkAppEnabled('files_versions');
//OCP\JSON::callCheck();
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file);
$versionName = '/' . $uid . '/files_versions/' . $filename . '.v' . $revision;
$view = new OC\Files\View('/');
$ftype = $view->getMimeType('/' . $uid . '/files/' . $filename);
header('Content-Type:' . $ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
OCP\Response::setContentLengthHeader($view->filesize($versionName));
OC_Util::obEnd();
$view->readfile($versionName);
Пример #19
0
function getStandardImage()
{
    OCP\Response::enableCaching();
    OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person.png'));
}