Esempio n. 1
0
 * 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/>.
 *
 */
// Firefox and Konqueror tries to download application/json for me.  --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
require_once 'loghandler.php';
if (!isset($_GET['id'])) {
    bailOut(OCA\Contacts\App::$l10n->t('No contact ID was submitted.'));
}
$contact = OCA\Contacts\App::getContactVCard($_GET['id']);
// invalid vcard
if (is_null($contact)) {
    bailOut(OCA\Contacts\App::$l10n->t('Error reading contact photo.'));
} else {
    $image = new OC_Image();
    if (!isset($contact->PHOTO) || !$image->loadFromBase64((string) $contact->PHOTO)) {
        if (isset($contact->LOGO)) {
            $image->loadFromBase64((string) $contact->LOGO);
        }
    }
    if ($image->valid()) {
        $tmpkey = 'contact-photo-' . $contact->UID;
        if (OC_Cache::set($tmpkey, $image->data(), 600)) {
            OCP\JSON::success(array('data' => array('id' => $_GET['id'], 'tmp' => $tmpkey)));
            exit;
Esempio n. 2
0
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$id = isset($_GET['id']) ? $_GET['id'] : null;
if (is_null($id)) {
    OCP\JSON::error(array('data' => array('message' => OCA\Contacts\App::$l10n->t('No ID provided'))));
    exit;
}
$vcard = OCA\Contacts\App::getContactVCard($id);
foreach ($vcard->children as $property) {
    if ($property->name == 'CATEGORIES') {
        $checksum = md5($property->serialize());
        OCP\JSON::success(array('data' => array('value' => $property->value, 'checksum' => $checksum)));
        exit;
    }
}
OCP\JSON::error(array('data' => array('message' => OCA\Contacts\App::$l10n->t('Error setting checksum.'))));
Esempio n. 3
0
    OCP\Response::enableCaching();
    OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png'));
    exit;
}
$id = isset($_GET['id']) ? $_GET['id'] : null;
$etag = null;
$caching = null;
$max_size = 170;
if (!$id || $id === 'new') {
    getStandardImage();
}
if (!extension_loaded('gd') || !function_exists('gd_info')) {
    OCP\Util::writeLog('contacts', 'photo.php. GD module not installed', OCP\Util::DEBUG);
    getStandardImage();
}
$contact = OCA\Contacts\App::getContactVCard($id);
$image = new OC_Image();
if (!$image || !$contact) {
    getStandardImage();
}
// invalid vcard
if (is_null($contact)) {
    OCP\Util::writeLog('contacts', 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', OCP\Util::ERROR);
} else {
    // Photo :-)
    if (isset($contact->PHOTO) && $image->loadFromBase64((string) $contact->PHOTO)) {
        // OK
        $etag = md5($contact->PHOTO);
    } else {
        // Logo :-/
        if (isset($contact->LOGO) && $image->loadFromBase64((string) $contact->LOGO)) {