function handleGetGallery($token, $path) { $owner = OC_Gallery_Sharing::getTokenOwner($token); $apath = OC_Gallery_Sharing::getPath($token); if ($path == false) { $root = $apath; } else { $root = rtrim($apath, '/') . $path; } $r = OC_Gallery_Album::find($owner, null, $root); $albums = array(); $photos = array(); $albumId = -1; if ($row = $r->fetchRow()) { $albumId = $row['album_id']; } if ($albumId != -1) { if (OC_Gallery_Sharing::isRecursive($token)) { $r = OC_Gallery_Album::find($owner, null, null, $root); while ($row = $r->fetchRow()) { $albums[] = $row['album_name']; } } $r = OC_Gallery_Photo::find($albumId); while ($row = $r->fetchRow()) { $photos[] = $row['file_path']; } } OCP\JSON::success(array('albums' => $albums, 'photos' => $photos)); }
/** * Check is a given user exists - send json error msg if not * @param string $user */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { $l = OC_L10N::get('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user')))); exit; } }
/** * Check is a given user exists - send json error msg if not * @param string $user * @deprecated Use a AppFramework JSONResponse instead */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { $l = \OC::$server->getL10N('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user'))); exit; } }
/** * @NoAdminRequired * @NoCSRFRequired */ public function exportContacts() { $bookid = $this->params('bookid'); $bookid = isset($bookid) ? $bookid : null; $contactid = $this->params('contactid'); $contactid = isset($contactid) ? $contactid : null; $selectedids = $this->params('selectedids'); $selectedids = isset($selectedids) ? $selectedids : null; $nl = "\n"; if (!is_null($bookid)) { try { $addressbook = Addressbook::find($bookid); } catch (Exception $e) { OCP\JSON::error(array('data' => array('message' => $e->getMessage()))); exit; } $start = 0; $ContactsOutput = ''; $batchsize = $this->configInfo->getUserValue($this->userId, $this->appName, 'export_batch_size', 20); while ($cardobjects = VCard::all($bookid, $start, $batchsize, array('carddata'))) { foreach ($cardobjects as $card) { $ContactsOutput .= $card['carddata'] . $nl; } $start += $batchsize; } $name = str_replace(' ', '_', $addressbook['displayname']) . '.vcf'; $response = new DataDownloadResponse($ContactsOutput, $name, 'text/directory'); return $response; } elseif (!is_null($contactid)) { try { $data = VCard::find($contactid); } catch (Exception $e) { OCP\JSON::error(array('data' => array('message' => $e->getMessage()))); exit; } $name = str_replace(' ', '_', $data['fullname']) . '.vcf'; $response = new DataDownloadResponse($data['carddata'], $name, 'text/vcard'); return $response; } elseif (!is_null($selectedids)) { $selectedids = explode(',', $selectedids); $name = (string) $this->l10n->t('%d_selected_contacts', array(count($selectedids))) . '.vcf'; $ContactsOutput = ''; foreach ($selectedids as $id) { try { $data = VCard::find($id); $ContactsOutput .= $data['carddata'] . $nl; } catch (Exception $e) { continue; } } $response = new DataDownloadResponse($ContactsOutput, $name, 'text/directory'); return $response; } }
public static function getContactObject($id) { $card = OC_Contacts_VCard::find($id); if ($card === false) { OCP\Util::writeLog('contacts', 'Contact could not be found: ' . $id, OCP\Util::ERROR); OCP\JSON::error(array('data' => array('message' => self::$l10n->t('Contact could not be found.') . ' ' . $id))); exit; } self::getAddressbook($card['addressbookid']); //access check return $card; }
public function checkPassword($uid, $assertion) { if ($this->_isPersonaRequest) { $email = OCA\User_persona\Validator::Validate($assertion); if ($email) { return OCA\User_persona\Policy::apply($email, $uid); } //we've got incorrect assertion OCP\Util::writeLog('OC_USER_PERSONA', 'Validation failed. Incorrect Assertion.', OCP\Util::DEBUG); OCP\JSON::error(array('msg' => 'Incorrect Assertion')); exit; } return false; }
function index() { if (isset($_GET['fileid'])) { $fileIds = array($_GET['fileid']); } else { $fileIds = OCA\Search_Lucene\Indexer::getUnindexed(); } $eventSource = new OC_EventSource(); $eventSource->send('count', count($fileIds)); $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr')); foreach ($fileIds as $id) { $skipped = false; $fileStatus = OCA\Search_Lucene\Status::fromFileId($id); try { //before we start mark the file as error so we know there was a problem when the php execution dies $fileStatus->markError(); $path = OC\Files\Filesystem::getPath($id); $eventSource->send('indexing', $path); foreach ($skippedDirs as $skippedDir) { if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) { $result = $fileStatus->markSkipped(); $skipped = true; break; } } if (!$skipped) { if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) { $result = $fileStatus->markIndexed(); } } if (!$result) { OCP\JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $path); } } catch (Exception $e) { //sqlite might report database locked errors when stock filescan is in progress //this also catches db locked exception that might come up when using sqlite \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR); OCP\JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $e->getMessage()); //try to mark the file as new to let it reindex $fileStatus->markNew(); // Add UI to trigger rescan of files with status 'E'rror? } } $eventSource->send('done', ''); $eventSource->close(); }
/** * send a message to the client * @param string $type * @param mixed $data * * if only one parameter is given, a typeless message will be send with that parameter as data */ public function send($type, $data = null) { if (is_null($data)) { $data = $type; $type = null; } if ($this->fallback) { $fallBackId = OC_Util::sanitizeHTML($this->fallBackId); $response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack(' . $fallBackId . ',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL; echo $response; } else { if ($type) { echo 'event: ' . $type . PHP_EOL; } echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL; } echo PHP_EOL; flush(); }
/** * send a message to the client * * @param string $type * @param mixed $data * * @throws \BadMethodCallException * if only one parameter is given, a typeless message will be send with that parameter as data */ public function send($type, $data = null) { if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) { throw new BadMethodCallException('Type needs to be alphanumeric (' . $type . ')'); } $this->init(); if (is_null($data)) { $data = $type; $type = null; } if ($this->fallback) { $response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack(' . $this->fallBackId . ',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL; echo $response; } else { if ($type) { echo 'event: ' . $type . PHP_EOL; } echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL; } echo PHP_EOL; flush(); }
public static function av_scan($path) { $path = $path[\OC\Files\Filesystem::signal_param_path]; if ($path != '') { $files_view = \OCP\Files::getStorage("files"); if ($files_view->file_exists($path)) { $root = OC_User::getHome(OC_User::getUser()) . '/files'; $file = $root . $path; $result = self::clamav_scan($file); switch ($result) { case CLAMAV_SCANRESULT_UNCHECKED: //TODO: Show warning to the user: The file can not be checked break; case CLAMAV_SCANRESULT_INFECTED: //remove file $files_view->unlink($path); OCP\JSON::error(array("data" => array("message" => "Virus detected! Can't upload the file."))); $email = OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG); if (!empty($email)) { $tmpl = new OC_Template('files_antivirus', 'notification'); $tmpl->assign('file', $path); $tmpl->assign('host', OCP\Util::getServerHost()); $tmpl->assign('user', OC_User::getUser()); $msg = $tmpl->fetchPage(); $from = OCP\Util::getDefaultEmailAddress('security-noreply'); OCP\Util::sendMail($email, OC_User::getUser(), 'Malware detected', $msg, $from, 'ownCloud', 1); } exit; break; case CLAMAV_SCANRESULT_CLEAN: //do nothing break; } } } }
<?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' => OC_Contacts_App::$l10n->t('No ID provided')))); exit; } $vcard = OC_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' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
* 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 user and app status OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $l = OC_L10N::get('user_ldap'); $ldapWrapper = new OCA\user_ldap\lib\LDAP(); $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null); //needs to be true, otherwise it will also fail with an irritating message $_POST['ldap_configuration_active'] = 1; if ($connection->setConfiguration($_POST)) { //Configuration is okay if ($connection->bind()) { OCP\JSON::success(array('message' => $l->t('The configuration is valid and the connection could be established!'))); } else { OCP\JSON::error(array('message' => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'))); } } else { OCP\JSON::error(array('message' => $l->t('The configuration is invalid. Please have a look at the logs for further details.'))); }
function bailOut($msg) { OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts', 'ajax/categories/delete.php: ' . $msg, OCP\Util::DEBUG); exit; }
exit; } $linkedItem = \OCP\Share::getShareByToken($token); if ($linkedItem === false || $linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder') { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG); exit; } if (!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) { \OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR); \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN); exit; } $rootLinkItem = OCP\Share::resolveReShare($linkedItem); $userId = $rootLinkItem['uid_owner']; OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); \OC_Util::setupFS($userId); \OC\Files\Filesystem::initMountPoints($userId); $view = new \OC\Files\View('/' . $userId . '/files'); $pathId = $linkedItem['file_source']; $path = $view->getPath($pathId); if ($path === null) { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); \OCP\Util::writeLog('core-preview', 'Could not resolve file for shared item', \OCP\Util::WARN); exit; } $pathInfo = $view->getFileInfo($path); $sharedFile = null; if ($linkedItem['item_type'] === 'folder') { $isValid = \OC\Files\Filesystem::isValidPath($file); if (!$isValid) {
<?php // Init owncloud require_once '../../lib/base.php'; OCP\JSON::callCheck(); // Check if we are a user if (!OC_User::isLoggedIn() || !OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) { OC_JSON::error(array("data" => array("message" => "Authentication error"))); exit; } OCP\JSON::callCheck(); $isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin') ? true : false; if ($isadmin) { $groups = array(); if (isset($_POST["groups"])) { $groups = $_POST["groups"]; } } else { if (isset($_POST["groups"])) { $groups = array(); foreach ($_POST["groups"] as $group) { if (OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group)) { $groups[] = $group; } } if (count($groups) == 0) { $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()); } } else { $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()); }
// Load the files $dir = $data['realPath']; $dir = \OC\Files\Filesystem::normalizePath($dir); if (!\OC\Files\Filesystem::is_dir($dir . '/')) { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); \OCP\JSON::error(array('success' => false)); exit; } $data = array(); // make filelist $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection); $formattedFiles = array(); foreach ($files as $file) { $entry = \OCA\Files\Helper::formatFileInfo($file); unset($entry['directory']); // for now $entry['permissions'] = \OCP\PERMISSION_READ; $formattedFiles[] = $entry; } $data['directory'] = $relativePath; $data['files'] = $formattedFiles; $data['dirToken'] = $linkItem['token']; $permissions = $linkItem['permissions']; // if globally disabled if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') { // only allow reading $permissions = \OCP\PERMISSION_READ; } $data['permissions'] = $permissions; OCP\JSON::success(array('data' => $data));
$parentname = dirname($curdir); $dirs[$curdir] = $selectdir; $selectdir = $curdir; } if ($safeguard === 0) { //some funny directory loop OCP\JSON::error(array('data' => array('message' => 'An error occured while exploring the path: ' . $_POST['path']))); } else { foreach ($dirs as $dir => $subdir) { if (strpos($dir, $localroot) !== 0) { unset($dirs[$dir]); } } OCP\JSON::success(array('data' => $dirs)); } } else { //normal directory listing, return an array //where key is a sibdir name and value is it's full path $dirs = array(); foreach (glob($path . '/*', GLOB_ONLYDIR) as $subdir) { $dirs[basename($subdir)] = $subdir; } OCP\JSON::success(array('data' => $dirs)); } } else { OCP\JSON::success(array('message' => 'outside of starting dir')); } } else { //no path provided OCP\JSON::error(array('data' => array('message' => 'Please provide the path for directory listing'))); }
$path = $dir . '/' . $file; if ($dir === '/') { $file = ltrim($file, '/'); $delimiter = strrpos($file, '.d'); $filename = substr($file, 0, $delimiter); $timestamp = substr($file, $delimiter + 2); } else { $path_parts = pathinfo($file); $filename = $path_parts['basename']; $timestamp = null; } if (!OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp)) { $error[] = $filename; \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, \OCP\Util::ERROR); } else { $success[$i]['filename'] = $file; $success[$i]['timestamp'] = $timestamp; $i++; } } if ($error) { $filelist = ''; foreach ($error as $e) { $filelist .= $e . ', '; } $l = OC::$server->getL10N('files_trashbin'); $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); OCP\JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); } else { OCP\JSON::success(array("data" => array("success" => $success))); }
* * @author Thomas Tanghus * @copyright 2012 Thomas Tanghus <*****@*****.**> * * 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/>. * */ // Init owncloud // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $tmp_path = $_GET['tmp_path']; $id = $_GET['id']; OCP\Util::writeLog('contacts', 'ajax/cropphoto.php: tmp_path: ' . $tmp_path . ', exists: ' . file_exists($tmp_path), OCP\Util::DEBUG); $tmpl = new OCP\Template("contacts", "part.cropphoto"); $tmpl->assign('tmp_path', $tmp_path); $tmpl->assign('id', $id); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array('page' => $page)));
/** * @author Arthur Schiwon <*****@*****.**> * @author Christopher Schäpers <*****@*****.**> * @author Lukas Reschke <*****@*****.**> * @author Morris Jobke <*****@*****.**> * * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.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 user and app status OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $prefix = (string) $_POST['ldap_serverconfig_chooser']; $ldapWrapper = new OCA\user_ldap\lib\LDAP(); $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix); OCP\JSON::success(array('configuration' => $connection->getConfiguration()));
} catch (\Exception $e) { \OCP\JSON::error(array('message' => $e->getMessage())); exit; } \OCP\JSON::error(); exit; break; case 'save': $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; if ($key === false || is_null($val)) { \OCP\JSON::error(array('message' => $l->t('No data specified'))); exit; } $cfg = array($key => $val); $setParameters = array(); $configuration->setConfiguration($cfg, $setParameters); if (!in_array($key, $setParameters)) { \OCP\JSON::error(array('message' => $l->t($key . ' Could not set configuration %s', $setParameters[0]))); exit; } $configuration->saveConfiguration(); //clear the cache on save $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix); $connection->clearCache(); OCP\JSON::success(); break; default: \OCP\JSON::error(array('message' => $l->t('Action does not exist'))); break; }
return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage)); }); } $rootInfo = \OC\Files\Filesystem::getFileInfo($path); $rootView = new \OC\Files\View(''); /** * @param \OCP\Files\FileInfo $dir * @param \OC\Files\View $view * @return array */ function getChildInfo($dir, $view) { $children = $view->getDirectoryContent($dir->getPath()); $result = array(); foreach ($children as $child) { $formated = \OCA\Files\Helper::formatFileInfo($child); if ($child->getType() === 'dir') { $formated['children'] = getChildInfo($child, $view); } $formated['mtime'] = $formated['mtime'] / 1000; $result[] = $formated; } return $result; } $result = \OCA\Files\Helper::formatFileInfo($rootInfo); $result['mtime'] = $result['mtime'] / 1000; if ($rootInfo->getType() === 'dir') { $result['children'] = getChildInfo($rootInfo, $rootView); } OCP\JSON::success(array('data' => $result));
$userDirectory = '/' . OCP\USER::getUser() . '/files'; $sources = explode(';', $_POST['sources']); $uid_shared_with = $_POST['uid_shared_with']; $permissions = $_POST['permissions']; foreach ($sources as $source) { $file = OC_FileCache::get($source); $path = ltrim($source, '/'); $source = $userDirectory . $source; // Check if the file exists or if the file is being reshared if ($source && $file['encrypted'] == false && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) { try { $shared = new OC_Share($source, $uid_shared_with, $permissions); // If this is a private link, return the token if ($uid_shared_with == OC_Share::PUBLICLINK) { OCP\JSON::success(array('data' => $shared->getToken())); } else { OCP\JSON::success(); } } catch (Exception $exception) { OCP\Util::writeLog('files_sharing', 'Unexpected Error : ' . $exception->getMessage(), OCP\Util::ERROR); OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); } } else { if ($file['encrypted'] == true) { OCP\JSON::error(array('data' => array('message' => 'Encrypted files cannot be shared'))); } else { OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :' . $source, OCP\Util::ERROR); OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable'))); } } }
<?php OCP\JSON::checkAppEnabled('files_external'); OCP\JSON::callCheck(); if ($_POST['isPersonal'] == 'true') { OCP\JSON::checkLoggedIn(); $isPersonal = true; } else { OCP\JSON::checkAdminUser(); $isPersonal = false; } $mountPoint = (string) $_POST['mountPoint']; $oldMountPoint = (string) $_POST['oldMountPoint']; $class = (string) $_POST['class']; $options = (string) $_POST['classOptions']; $type = (string) $_POST['mountType']; $applicable = (string) $_POST['applicable']; if ($oldMountPoint and $oldMountPoint !== $mountPoint) { OC_Mount_Config::removeMountPoint($oldMountPoint, $type, $applicable, $isPersonal); } $status = OC_Mount_Config::addMountPoint($mountPoint, $class, $options, $type, $applicable, $isPersonal); OCP\JSON::success(array('data' => array('message' => $status)));
} header('Content-Type: text/directory'); header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf'); $start = 0; $batchsize = OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'export_batch_size', 20); while ($cardobjects = OCA\Contacts\VCard::all($bookid, $start, $batchsize, array('carddata'))) { foreach ($cardobjects as $card) { echo $card['carddata'] . $nl; } $start += $batchsize; } } elseif (!is_null($contactid)) { try { $data = OCA\Contacts\VCard::find($contactid); } catch (Exception $e) { OCP\JSON::error(array('data' => array('message' => $e->getMessage()))); exit; } header('Content-Type: text/vcard'); header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf'); echo $data['carddata']; } elseif (!is_null($selectedids)) { $selectedids = explode(',', $selectedids); $l10n = \OC_L10N::get('contacts'); header('Content-Type: text/directory'); header('Content-Disposition: inline; filename=' . $l10n->t('%d_selected_contacts', array(count($selectedids))) . '.vcf'); foreach ($selectedids as $id) { try { $data = OCA\Contacts\VCard::find($id); echo $data['carddata'] . $nl; } catch (Exception $e) {
<?php /** * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * 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('calendar'); OCP\JSON::callCheck(); $errarr = OC_Calendar_Object::validateRequest($_POST); $event_id = -1; if ($errarr) { //show validate errors OCP\JSON::error($errarr); exit; } else { $cal = $_POST['calendar']; $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST); try { $event_id = OC_Calendar_Object::add($cal, $vcalendar->serialize()); } catch (Exception $e) { OCP\JSON::error(array('message' => $e->getMessage())); exit; } OCP\JSON::success(array('event_id' => $event_id)); }
$mailNotification = new \OC\Share\MailNotifications(); $expiration = null; if (isset($_POST['expiration']) && $_POST['expiration'] !== '') { try { $date = new DateTime((string) $_POST['expiration']); $expiration = $date->getTimestamp(); } catch (Exception $e) { \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR); } } $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration); if (empty($result)) { \OCP\JSON::success(); } else { $l = \OC::$server->getL10N('core'); OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't send mail to following users: %s ", implode(', ', $result))))); } break; } } else { if (isset($_GET['fetch'])) { switch ($_GET['fetch']) { case 'getItemsSharedStatuses': if (isset($_GET['itemType'])) { $return = OCP\Share::getItemsShared((string) $_GET['itemType'], OCP\Share::FORMAT_STATUSES); is_array($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error(); } break; case 'getItem': if (isset($_GET['itemType']) && isset($_GET['itemSource']) && isset($_GET['checkReshare']) && isset($_GET['checkShares'])) { if ($_GET['checkReshare'] == 'true') {
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ OCP\JSON::checkAdminUser(); OCP\JSON::callCheck(); if (!array_key_exists('appid', $_POST)) { OCP\JSON::error(array('message' => 'No AppId given!')); return; } $appId = (string) $_POST['appid']; if (!is_numeric($appId)) { $appId = \OC::$server->getAppConfig()->getValue($appId, 'ocsid', null); if ($appId === null) { OCP\JSON::error(array('message' => 'No OCS-ID found for app!')); exit; } } $appId = OC_App::cleanAppId($appId); $config = \OC::$server->getConfig(); $config->setSystemValue('maintenance', true); try { $result = OC_Installer::updateAppByOCSId($appId); $config->setSystemValue('maintenance', false); } catch (Exception $ex) { $config->setSystemValue('maintenance', false); OC_JSON::error(array("data" => array("message" => $ex->getMessage()))); return; } if ($result !== false) {
OCP\JSON::checkAppEnabled('files_external'); OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); $l = \OC::$server->getL10N('files_external'); if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST['redirect'])) { $client = new Google_Client(); $client->setClientId($_POST['client_id']); $client->setClientSecret($_POST['client_secret']); $client->setRedirectUri($_POST['redirect']); $client->setScopes(array('https://www.googleapis.com/auth/drive')); if (isset($_POST['step'])) { $step = $_POST['step']; if ($step == 1) { try { $authUrl = $client->createAuthUrl(); OCP\JSON::success(array('data' => array('url' => $authUrl))); } catch (Exception $exception) { OCP\JSON::error(array('data' => array('message' => $l->t('Step 1 failed. Exception: %s', array($exception->getMessage()))))); } } else { if ($step == 2 && isset($_POST['code'])) { try { $token = $client->authenticate($_POST['code']); OCP\JSON::success(array('data' => array('token' => $token))); } catch (Exception $exception) { OCP\JSON::error(array('data' => array('message' => $l->t('Step 2 failed. Exception: %s', array($exception->getMessage()))))); } } } } }
* @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);