Esempio n. 1
0
 /**
  * Selects a database using the current class's $this->dbh
  * @param string $db name
  */
 function select($db)
 {
     global $__FM_CONFIG;
     if (!@mysql_select_db($db, $this->dbh)) {
         bailOut(_('The database is not installed. Click \'Start Setup\' to start the installation process.') . '<p class="step"><a href="' . $GLOBALS['RELPATH'] . 'fm-install.php" class="button click_once">' . _('Start Setup') . '</a></p>');
     }
 }
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.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/edit.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/edit.php: ' . $msg, OC_Log::DEBUG);
}
require_once '../../../lib/base.php';
OC_JSON::checkLoggedIn();
$app = isset($_GET['app']) ? $_GET['app'] : null;
if (is_null($app)) {
    bailOut('Application name not provided.');
}
OC_JSON::checkAppEnabled($app);
$tmpl = new OC_TEMPLATE("core", "edit_categories_dialog");
$vcategories = new OC_VCategories($app);
$categories = $vcategories->categories();
debug(print_r($categories, true));
$tmpl->assign('categories', $categories);
$tmpl->printpage();
Esempio n. 3
0
/** Set installation variable */
define('UPGRADE', true);
/** Enforce authentication */
require_once ABSPATH . 'fm-modules/facileManager/classes/class_logins.php';
require_once 'fm-init.php';
ini_set('display_errors', false);
error_reporting(0);
if (!$fm_login->isLoggedIn() || !currentUserCan('do_everything') && getOption('fm_db_version') >= 32) {
    header('Location: ' . dirname($_SERVER['PHP_SELF']));
}
/** Ensure we meet the requirements */
require_once ABSPATH . 'fm-includes/init.php';
require_once ABSPATH . 'fm-includes/version.php';
$app_compat = checkAppVersions(false);
if ($app_compat) {
    bailOut($app_compat);
}
$step = isset($_GET['step']) ? $_GET['step'] : 0;
if (array_key_exists('backup', $_GET)) {
    if (!class_exists('fm_tools')) {
        include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . 'facileManager' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class_tools.php';
    }
    $fm_tools->backupDatabase();
    header('Location: ' . $GLOBALS['basename']);
}
$branding_logo = $GLOBALS['RELPATH'] . 'fm-modules/' . $fm_name . '/images/fm.png';
printHeader(_('Upgrade'), 'install');
switch ($step) {
    case 0:
    case 1:
        if (!file_exists(ABSPATH . 'config.inc.php') || !file_get_contents(ABSPATH . 'config.inc.php')) {
Esempio n. 4
0
$fn = isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false;
if ($fn) {
    if ($view->file_put_contents('/' . $tmpfile, file_get_contents('php://input'))) {
        OCP\JSON::success(array('data' => array('path' => '', 'file' => $tmpfile)));
        exit;
    } else {
        bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
    }
}
// File input transfers are handled here
if (!isset($_FILES['importfile'])) {
    OCP\Util::writeLog('contacts', 'ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
    OCP\JSON::error(array('data' => array('message' => 'No file was uploaded. Unknown error')));
    exit;
}
$error = $_FILES['importfile']['error'];
if ($error !== UPLOAD_ERR_OK) {
    $errors = array(0 => OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"), 1 => OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini") . ini_get('upload_max_filesize'), 2 => OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), 3 => OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"), 4 => OC_Contacts_App::$l10n->t("No file was uploaded"), 6 => OC_Contacts_App::$l10n->t("Missing a temporary folder"));
    bailOut($errors[$error]);
}
$file = $_FILES['importfile'];
$tmpfname = tempnam(get_temp_dir(), "occOrig");
if (file_exists($file['tmp_name'])) {
    if ($view->file_put_contents('/' . $tmpfile, file_get_contents($file['tmp_name']))) {
        OCP\JSON::success(array('data' => array('path' => '', 'file' => $tmpfile)));
    } else {
        bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
    }
} else {
    bailOut('Temporary file: \'' . $file['tmp_name'] . '\' has gone AWOL?');
}
Esempio n. 5
0
            debug('Setting string:' . $name . ' ' . $value);
            $vcard->children[$line]->setValue($value);
            break;
        case 'EMAIL':
        case 'TEL':
        case 'ADR':
            // should I delete the property if empty or throw an error?
            debug('Setting element: (EMAIL/TEL/ADR)' . $element);
            $vcard->children[$line]->setValue($value);
            $vcard->children[$line]->parameters = array();
            if (!is_null($parameters)) {
                debug('Setting parameters: ' . $parameters);
                foreach ($parameters as $key => $parameter) {
                    debug('Adding parameter: ' . $key);
                    foreach ($parameter as $val) {
                        debug('Adding parameter: ' . $key . '=>' . $val);
                        $vcard->children[$line]->add(new Sabre_VObject_Parameter($key, strtoupper(strip_tags($val))));
                    }
                }
            }
            break;
    }
    // Do checksum and be happy
    $checksum = md5($vcard->children[$line]->serialize());
}
//debug('New checksum: '.$checksum);
if (!OC_Contacts_VCard::edit($id, $vcard)) {
    bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));
    exit;
}
OCP\JSON::success(array('data' => array('line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'])));
}
if (!isset($_GET['path'])) {
    bailOut(OC_Contacts_App::$l10n->t('No photo path was submitted.'));
}
$localpath = OC_Filesystem::getLocalFile($_GET['path']);
$tmpfname = tempnam(get_temp_dir(), "occOrig");
if (!file_exists($localpath)) {
    bailOut(OC_Contacts_App::$l10n->t('File doesn\'t exist:') . $localpath);
}
file_put_contents($tmpfname, file_get_contents($localpath));
$image = new OC_Image();
if (!$image) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if (!$image->loadFromFile($tmpfname)) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if ($image->width() > 400 || $image->height() > 400) {
    $image->resize(400);
    // Prettier resizing than with browser and saves bandwidth.
}
if (!$image->fixOrientation()) {
    // No fatal error so we don't bail out.
    debug('Couldn\'t save correct image orientation: ' . $tmpfname);
}
if ($image->save($tmpfname)) {
    OCP\JSON::success(array('data' => array('id' => $_GET['id'], 'tmp' => $tmpfname)));
    exit;
} else {
    bailOut('Couldn\'t save temporary image: ' . $tmpfname);
}
Esempio n. 7
0
require_once __DIR__ . '/../loghandler.php';
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
$fromobjects = isset($_POST['fromobjects']) && ($_POST['fromobjects'] === 'true' || $_POST['fromobjects'] === '1') ? true : false;
if (is_null($categories)) {
    bailOut(OCA\Contacts\App::$l10n->t('No categories selected for deletion.'));
}
debug(print_r($categories, true));
if ($fromobjects) {
    $addressbooks = OCA\Contacts\Addressbook::all(OCP\USER::getUser());
    if (count($addressbooks) == 0) {
        bailOut(OCA\Contacts\App::$l10n->t('No address books found.'));
    }
    $addressbookids = array();
    foreach ($addressbooks as $addressbook) {
        $addressbookids[] = $addressbook['id'];
    }
    $contacts = OCA\Contacts\VCard::all($addressbookids);
    if (count($contacts) == 0) {
        bailOut(OCA\Contacts\App::$l10n->t('No contacts found.'));
    }
    $cards = array();
    foreach ($contacts as $contact) {
        $cards[] = array($contact['id'], $contact['carddata']);
    }
}
$catman = new OC_VCategories('contact');
$catman->delete($categories, $cards);
if ($fromobjects) {
    OCA\Contacts\VCard::updateDataByID($cards);
}
OCP\JSON::success();
Esempio n. 8
0
// 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;
        } else {
            bailOut(OCA\Contacts\App::$l10n->t('Error saving temporary file.'));
        }
    } else {
        bailOut(OCA\Contacts\App::$l10n->t('The loading photo is not valid.'));
    }
}
Esempio n. 9
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.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: ' . $msg, OC_Log::DEBUG);
}
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$type = isset($_GET['type']) ? $_GET['type'] : null;
if (is_null($type)) {
    $l = OC_L10N::get('core');
    bailOut($l->t('Object type not provided.'));
}
$categories = new OC_VCategories($type);
$ids = $categories->getFavorites($type);
OC_JSON::success(array('ids' => $ids));
Esempio n. 10
0
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once __DIR__ . '/../loghandler.php';
$aid = isset($_POST['aid']) ? $_POST['aid'] : null;
if (!$aid) {
    $addressbooks = OCA\Contacts\Addressbook::all(OCP\User::getUser(), true, false);
    if (count($addressbooks) === 0) {
        bailOut(OCA\Contacts\App::$l10n->t('You have no addressbooks.'));
    } else {
        $aid = $addressbooks[0]['id'];
    }
}
$isnew = isset($_POST['isnew']) ? $_POST['isnew'] : false;
$vcard = Sabre\VObject\Component::create('VCARD');
$uid = substr(md5(rand() . time()), 0, 10);
$vcard->add('UID', $uid);
$id = null;
try {
    $id = OCA\Contacts\VCard::add($aid, $vcard, null, $isnew);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
if (!$id) {
    bailOut('There was an error adding the contact.');
}
$lastmodified = OCA\Contacts\App::lastModified($vcard);
if (!$lastmodified) {
    $lastmodified = new DateTime();
}
OCP\JSON::success(array('data' => array('id' => $id, 'aid' => $aid, 'details' => OCA\Contacts\VCard::structureContact($vcard), 'lastmodified' => $lastmodified->format('U'))));
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('contacts', 'ajax/contactdetails.php: ' . $msg, OCP\Util::DEBUG);
    exit;
}
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$id = isset($_GET['id']) ? $_GET['id'] : null;
if (is_null($id)) {
    bailOut(OC_Contacts_App::$l10n->t('Missing ID'));
}
$vcard = OC_Contacts_App::getContactVCard($id);
if (is_null($vcard)) {
    bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "' . $id . '"'));
}
$details = OC_Contacts_VCard::structureContact($vcard);
// Some Google exported files have no FN field.
/*if(!isset($details['FN'])) {
	$fn = '';
	if(isset($details['N'])) {
		$details['FN'] = array(implode(' ', $details['N'][0]['value']));
	} elseif(isset($details['EMAIL'])) {
		$details['FN'] = array('value' => $details['EMAIL'][0]['value']);
	} else {
		$details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown'));
	}
}*/
// Make up for not supporting the 'N' field in earlier version.
if (!isset($details['N'])) {
Esempio n. 12
0
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
foreach ($_POST as $key => $element) {
    debug('_POST: ' . $key . '=>' . print_r($element, true));
}
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('calendar', 'ajax/categories/rescan.php: ' . $msg, OCP\Util::DEBUG);
    exit;
}
function debug($msg)
{
    OCP\Util::writeLog('calendar', 'ajax/categories/rescan.php: ' . $msg, OCP\Util::DEBUG);
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
if (count($calendars) == 0) {
    bailOut(OC_Calendar_App::$l10n->t('No calendars found.'));
}
$events = array();
foreach ($calendars as $calendar) {
    $calendar_events = OC_Calendar_Object::all($calendar['id']);
    $events = $events + $calendar_events;
}
if (count($events) == 0) {
    bailOut(OC_Calendar_App::$l10n->t('No events found.'));
}
OC_Calendar_App::scanCategories($events);
$categories = OC_Calendar_App::getCategoryOptions();
OCP\JSON::success(array('data' => array('categories' => $categories)));
Esempio n. 13
0
<?php

/**
 * Copyright (c) 2011 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');
require_once 'loghandler.php';
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
$id = isset($_GET['id']) ? $_GET['id'] : '';
if ($id) {
    $vcard = OCA\Contacts\App::getContactVCard($id);
    $name = array('', '', '', '', '');
    if ($vcard->__isset('N')) {
        $property = $vcard->__get('N');
        if ($property) {
            $name = OCA\Contacts\VCard::structureProperty($property);
        }
    }
    $name = array_map('htmlspecialchars', $name['value']);
    $tmpl->assign('name', $name, false);
    $tmpl->assign('id', $id, false);
} else {
    bailOut(OCA\Contacts\App::$l10n->t('Contact ID is missing.'));
}
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page' => $page)));
Esempio n. 14
0
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: ' . $msg, OC_Log::DEBUG);
}
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = OC_L10N::get('core');
$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null;
$type = isset($_POST['type']) ? $_POST['type'] : null;
if (is_null($type)) {
    bailOut($l->t('Object type not provided.'));
}
if (is_null($id)) {
    bailOut($l->t('%s ID not provided.', $type));
}
$categories = new OC_VCategories($type);
if (!$categories->addToFavorites($id, $type)) {
    bailOut($l->t('Error adding %s to favorites.', $id));
}
OC_JSON::success();
Esempio n. 15
0
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
// foreach ($_POST as $key=>$element) {
// 	OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
// }
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('contacts', 'ajax/loadphoto.php: ' . $msg, OCP\Util::DEBUG);
    exit;
}
$image = null;
$id = isset($_GET['id']) ? $_GET['id'] : '';
$refresh = isset($_GET['refresh']) ? true : false;
if ($id == '') {
    bailOut(OC_Contacts_App::$l10n->t('Missing contact id.'));
}
$checksum = '';
$vcard = OC_Contacts_App::getContactVCard($id);
foreach ($vcard->children as $property) {
    if ($property->name == 'PHOTO') {
        $checksum = md5($property->serialize());
        break;
    }
}
$tmpl = new OCP\Template("contacts", "part.contactphoto");
$tmpl->assign('id', $id);
if ($refresh) {
    $tmpl->assign('refresh', 1);
}
$page = $tmpl->fetchPage();
Esempio n. 16
0
/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/delete.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/delete.php: ' . $msg, OC_Log::DEBUG);
}
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = OC_L10N::get('core');
$type = isset($_POST['type']) ? $_POST['type'] : null;
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
if (is_null($type)) {
    bailOut($l->t('Object type not provided.'));
}
debug('The application using category type "' . $type . '" uses the default file for deletion. OC_VObjects will not be updated.');
if (is_null($categories)) {
    bailOut($l->t('No categories selected for deletion.'));
}
$vcategories = new OC_VCategories($type);
$vcategories->delete($categories);
OC_JSON::success(array('data' => array('categories' => $vcategories->categories())));
                            exit;
                        } else {
                            header("Content-Type: text/plain");
                            echo $requestFile . " is not a valid file-ressource-id.";
                            exit;
                        }
                    } else {
                        bailOut(true);
                    }
                } else {
                    bailOut(true);
                }
                exit;
        }
    } else {
        bailOut(false);
    }
}
// standard-action
$action = @trim($_REQUEST["a"]);
switch ($action) {
    case "0":
        // news
        outputData(rewriteNews(getDataFromFile(_FILE_NEWS)));
        exit;
    case "1":
        // changelog
        outputData(getDataFromFile(_FILE_CHANGELOG));
        exit;
    case "2":
        // issues
Esempio n. 18
0
<?php

/**
 * Copyright (c) 2011-2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
require_once __DIR__ . '/../loghandler.php';
$id = $_POST['id'];
$name = trim(strip_tags($_POST['name']));
$description = trim(strip_tags($_POST['description']));
if (!$id) {
    bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
}
if (!$name) {
    bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'));
}
try {
    OC_Contacts_Addressbook::edit($id, $name, $description);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
if (!OC_Contacts_Addressbook::setActive($id, $_POST['active'])) {
    bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'));
}
$addressbook = OC_Contacts_App::getAddressbook($id);
OCP\JSON::success(array('data' => array('addressbook' => $addressbook)));
Esempio n. 19
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');
OCP\JSON::callCheck();
require_once __DIR__ . '/../loghandler.php';
$category = isset($_POST['category']) ? trim(strip_tags($_POST['category'])) : null;
if (is_null($category) || $category === "") {
    bailOut(OCA\Contacts\App::$l10n->t('No category name given.'));
}
$catman = new OC_VCategories('contact');
$id = $catman->add($category);
if ($id !== false) {
    OCP\JSON::success(array('data' => array('id' => $id)));
} else {
    bailOut(OCA\Contacts\App::$l10n->t('Error adding group.'));
}
Esempio n. 20
0
                    $tmpl = new OCP\Template("contacts", "part.contactphoto");
                    $tmpl->assign('tmp_path', $tmpfname);
                    $tmpl->assign('mime', $image->mimeType());
                    $tmpl->assign('id', $id);
                    $tmpl->assign('refresh', true);
                    $tmpl->assign('width', $image->width());
                    $tmpl->assign('height', $image->height());
                    $page = $tmpl->fetchPage();
                    OCP\JSON::success(array('data' => array('page' => $page, 'tmp' => $tmpfname)));
                    exit;
                } else {
                    if (file_exists($tmpfname)) {
                        unlink($tmpfname);
                    }
                    bailOut('Error saving temporary image');
                }
            } else {
                bailOut('Error resizing image');
            }
        } else {
            bailOut('Error cropping image');
        }
    } else {
        bailOut('Error creating temporary image');
    }
} else {
    bailOut('Error finding image: ' . $tmp_path);
}
if ($tmp_path != '' && file_exists($tmp_path)) {
    unlink($tmp_path);
}
Esempio n. 21
0
    bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
}
if (!isset($_GET['path'])) {
    bailOut(OC_Contacts_App::$l10n->t('No photo path was submitted.'));
}
$localpath = OC_Filesystem::getLocalFile($_GET['path']);
$tmpkey = 'contact-photo-' . $_GET['id'];
if (!file_exists($localpath)) {
    bailOut(OC_Contacts_App::$l10n->t('File doesn\'t exist:') . $localpath);
}
$image = new OC_Image();
if (!$image) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if (!$image->loadFromFile($localpath)) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if ($image->width() > 400 || $image->height() > 400) {
    $image->resize(400);
    // Prettier resizing than with browser and saves bandwidth.
}
if (!$image->fixOrientation()) {
    // No fatal error so we don't bail out.
    OCP\Util::writeLog('contacts', 'ajax/oc_photo.php: Couldn\'t save correct image orientation: ' . $localpath, OCP\Util::DEBUG);
}
if (OC_Cache::set($tmpkey, $image->data(), 600)) {
    OCP\JSON::success(array('data' => array('id' => $_GET['id'], 'tmp' => $tmpkey)));
    exit;
} else {
    bailOut('Couldn\'t save temporary image: ' . $tmpkey);
}
Esempio n. 22
0
 * 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/>.
 *
 */
/**
 * @brief Set user preference.
 * @param $key
 * @param $value
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once 'loghandler.php';
$key = isset($_POST['key']) ? $_POST['key'] : null;
$value = isset($_POST['value']) ? $_POST['value'] : null;
if (is_null($key)) {
    bailOut(OCA\Contacts\App::$l10n->t('Key is not set for: ' . $value));
}
if (is_null($value)) {
    bailOut(OCA\Contacts\App::$l10n->t('Value is not set for: ' . $key));
}
if (OCP\Config::setUserValue(OCP\USER::getUser(), 'contacts', $key, $value)) {
    OCP\JSON::success(array('data' => array('key' => $key, 'value' => $value)));
} else {
    bailOut(OCA\Contacts\App::$l10n->t('Could not set preference: ' . $key . ':' . $value));
}
Esempio n. 23
0
 * @copyright 2011 Jakob Sack mail@jakobsack.de
 *
 * 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/>.
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once __DIR__ . '/../loghandler.php';
$id = $_POST['id'];
if (!$id) {
    bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
}
try {
    OC_Contacts_Addressbook::delete($id);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
OCP\JSON::success(array('data' => array('id' => $id)));
Esempio n. 24
0
 * See the COPYING-README file.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/add.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/add.php: ' . $msg, OC_Log::DEBUG);
}
require_once '../../../lib/base.php';
OC_JSON::checkLoggedIn();
$category = isset($_GET['category']) ? strip_tags($_GET['category']) : null;
$app = isset($_GET['app']) ? $_GET['app'] : null;
if (is_null($app)) {
    bailOut(OC_Contacts_App::$l10n->t('Application name not provided.'));
}
OC_JSON::checkAppEnabled($app);
if (is_null($category)) {
    bailOut(OC_Contacts_App::$l10n->t('No category to add?'));
}
debug(print_r($category, true));
$categories = new OC_VCategories($app);
if ($categories->hasCategory($category)) {
    bailOut(OC_Contacts_App::$l10n->t('This category already exists: ' . $category));
} else {
    $categories->add($category, true);
}
OC_JSON::success(array('data' => array('categories' => $categories->categories())));
Esempio n. 25
0
OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('contacts', 'ajax/editname.php: ' . $msg, OCP\Util::DEBUG);
    exit;
}
function debug($msg)
{
    OCP\Util::writeLog('contacts', 'ajax/editname.php: ' . $msg, OCP\Util::DEBUG);
}
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
$id = isset($_GET['id']) ? $_GET['id'] : '';
debug('id: ' . $id);
if ($id) {
    $vcard = OC_Contacts_App::getContactVCard($id);
    $name = array('', '', '', '', '');
    if ($vcard->__isset('N')) {
        $property = $vcard->__get('N');
        if ($property) {
            $name = OC_Contacts_VCard::structureProperty($property);
        }
    }
    $tmpl->assign('name', $name);
    $tmpl->assign('id', $id);
} else {
    bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
    //$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
    //$tmpl->assign('addressbooks', $addressbooks);
}
$tmpl->printpage();
Esempio n. 26
0
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
function bailOut($msg)
{
    OC_JSON::error(array('data' => array('message' => $msg)));
    OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: ' . $msg, OC_Log::DEBUG);
    exit;
}
function debug($msg)
{
    OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: ' . $msg, OC_Log::DEBUG);
}
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = OC_L10N::get('core');
$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null;
$type = isset($_POST['type']) ? $_POST['type'] : null;
if (is_null($type)) {
    bailOut($l->t('Object type not provided.'));
}
if (is_null($id)) {
    bailOut($l->t('%s ID not provided.', array($type)));
}
$categories = new OC_VCategories($type);
if (!$categories->removeFromFavorites($id, $type)) {
    bailOut($l->t('Error removing %s from favorites.', array($id)));
}
OC_JSON::success();
Esempio n. 27
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');
OCP\JSON::callCheck();
require_once __DIR__ . '/../loghandler.php';
$categoryid = isset($_POST['categoryid']) ? $_POST['categoryid'] : null;
$contactids = isset($_POST['contactids']) ? $_POST['contactids'] : null;
if (is_null($categoryid)) {
    bailOut(OCA\Contacts\App::$l10n->t('Group ID missing from request.'));
}
if (is_null($contactids)) {
    bailOut(OCA\Contacts\App::$l10n->t('Contact ID missing from request.'));
}
$catmgr = OCA\Contacts\App::getVCategories();
foreach ($contactids as $contactid) {
    debug('id: ' . $contactid . ', categoryid: ' . $categoryid);
    $catmgr->removeFromCategory($contactid, $categoryid);
}
OCP\JSON::success();
Esempio n. 28
0
     printHeader(_('Installation'), 'install');
     processSetup();
     break;
 case 3:
     if (!file_exists(ABSPATH . 'config.inc.php') || !file_get_contents(ABSPATH . 'config.inc.php')) {
         header('Location: ' . $GLOBALS['RELPATH'] . 'fm-install.php');
     }
     require_once ABSPATH . 'fm-modules/facileManager/install.php';
     @(include ABSPATH . 'config.inc.php');
     $link = @mysql_connect($__FM_CONFIG['db']['host'], $__FM_CONFIG['db']['user'], $__FM_CONFIG['db']['pass']);
     if (!$link) {
         bailOut(_('The connection to the database has failed. Please check the configuration.') . '<p class="step"><a href="" class="button">' . _('Try Again') . '</a></p>');
         break;
     }
     if (version_compare(mysql_get_server_info(), $required_mysql_version, '<')) {
         bailOut(sprintf('<p style="text-align: center;">' . _('Your MySQL server (%1$s) is running MySQL version %2$s but %3$s %4$s requires at least %5$s.') . '</p>', $__FM_CONFIG['db']['host'], mysql_get_server_info(), $fm_name, $fm_version, $required_mysql_version));
         break;
     }
     printHeader(_('Installation'), 'install');
     /** Check if already installed */
     if (isset($__FM_CONFIG['db']['name'])) {
         $query = "SELECT option_id FROM `{$__FM_CONFIG['db']['name']}`.`fm_options` WHERE `option_name`='fm_db_version'";
         $result = @mysql_query($query, $link);
     } else {
         header('Location: ' . $GLOBALS['RELPATH']);
     }
     if ($result && @mysql_num_rows($result)) {
         /** Check if the default admin account exists */
         if (!checkAccountCreation($link, $__FM_CONFIG['db']['name'])) {
             header('Location: ' . $GLOBALS['RELPATH'] . 'fm-install.php?step=4');
         } else {
Esempio n. 29
0
function debug($msg)
{
    OCP\Util::writeLog('contacts', 'ajax/categories/delete.php: ' . $msg, OCP\Util::DEBUG);
}
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
if (is_null($categories)) {
    bailOut(OC_Contacts_App::$l10n->t('No categories selected for deletion.'));
}
debug(print_r($categories, true));
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
if (count($addressbooks) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
}
$addressbookids = array();
foreach ($addressbooks as $addressbook) {
    $addressbookids[] = $addressbook['id'];
}
$contacts = OC_Contacts_VCard::all($addressbookids);
if (count($contacts) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
}
$cards = array();
foreach ($contacts as $contact) {
    $cards[] = array($contact['id'], $contact['carddata']);
}
debug('Before delete: ' . print_r($categories, true));
$catman = new OC_VCategories('contacts');
$catman->delete($categories, $cards);
debug('After delete: ' . print_r($catman->categories(), true));
OC_Contacts_VCard::updateDataByID($cards);
OCP\JSON::success(array('data' => array('categories' => $catman->categories())));
Esempio n. 30
0
                    $property->parameters[] = new Sabre\VObject\Parameter('ENCODING', 'b');
                    $property->parameters[] = new Sabre\VObject\Parameter('TYPE', $image->mimeType());
                    $vcard->__set('PHOTO', $property);
                } else {
                    OCP\Util::writeLog('contacts', 'savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
                    // For vCard 3.0 the type must be e.g. JPEG or PNG
                    // For version 4.0 the full mimetype should be used.
                    // https://tools.ietf.org/html/rfc2426#section-3.1.4
                    $type = $vcard->VERSION == '4.0' ? $image->mimeType() : strtoupper(array_pop(explode('/', $image->mimeType())));
                    $vcard->add('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $type));
                }
                $now = new DateTime();
                $vcard->{'REV'} = $now->format(DateTime::W3C);
                if (!OCA\Contacts\VCard::edit($id, $vcard)) {
                    bailOut(OCA\Contacts\App::$l10n->t('Error saving contact.'));
                }
                OCA\Contacts\App::cacheThumbnail($id, $image);
                OCP\JSON::success(array('data' => array('id' => $id, 'width' => $image->width(), 'height' => $image->height(), 'lastmodified' => OCA\Contacts\App::lastModified($vcard)->format('U'))));
            } else {
                bailOut(OCA\Contacts\App::$l10n->t('Error resizing image'));
            }
        } else {
            bailOut(OCA\Contacts\App::$l10n->t('Error cropping image'));
        }
    } else {
        bailOut(OCA\Contacts\App::$l10n->t('Error creating temporary image'));
    }
} else {
    bailOut(OCA\Contacts\App::$l10n->t('Error finding image: ') . $tmpkey);
}
OC_Cache::remove($tmpkey);