/**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OCP\Util::addscript('core', 'tags');
     \OCP\Util::addStyle($this->appName, 'style');
     \OCP\Util::addStyle($this->appName, 'jquery.Jcrop');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'app');
     \OCP\Util::addscript($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'settings');
     \OCP\Util::addscript($this->appName, 'loader');
     \OCP\Util::addscript($this->appName, 'jquery.scrollTo.min');
     \OCP\Util::addscript($this->appName, 'jquery.nicescroll.min');
     \OCP\Util::addscript('files', 'jquery.fileupload');
     \OCP\Util::addscript($this->appName, 'jquery.Jcrop');
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(50);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 */
	public function index() {
		\OC::$server->getNavigationManager()->setActiveEntry($this->appName);

		$importManager = new ImportManager();
		$imppTypes = Properties::getTypesForProperty('IMPP');
		$adrTypes = Properties::getTypesForProperty('ADR');
		$phoneTypes = Properties::getTypesForProperty('TEL');
		$emailTypes = Properties::getTypesForProperty('EMAIL');
		$ims = Properties::getIMOptions();
		$imProtocols = array();
		foreach($ims as $name => $values) {
			$imProtocols[$name] = $values['displayname'];
		}

		$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');

		$response = new TemplateResponse($this->appName, 'contacts');
		$response->setParams(array(
			'uploadMaxFilesize' => $maxUploadFilesize,
			'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
			'phoneTypes' => $phoneTypes,
			'emailTypes' => $emailTypes,
			'adrTypes' => $adrTypes,
			'imppTypes' => $imppTypes,
			'imProtocols' => $imProtocols,
			'importManager' => $importManager,
		));

		return $response;
	}
Beispiel #3
0
 public static function buildFileStorageStatistics($dir)
 {
     // information about storage capacities
     $storageInfo = \OC_Helper::getStorageInfo($dir);
     $l = new \OC_L10N('files');
     $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
     $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
     $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
     return array('uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], 'usedSpacePercent' => (int) $storageInfo['relative']);
 }
 /**
  * @NoAdminRequired
  */
 public function upload()
 {
     $request = $this->request;
     $params = $this->request->urlParams;
     $response = new JSONResponse();
     $view = \OCP\Files::getStorage('contacts');
     if (!$view->file_exists('imports')) {
         $view->mkdir('imports');
     }
     if (!isset($request->files['file'])) {
         $response->bailOut(App::$l10n->t('No file was uploaded. Unknown error'));
         return $response;
     }
     $file = $request->files['file'];
     if ($file['error'] !== UPLOAD_ERR_OK) {
         $error = $file['error'];
         $errors = array(UPLOAD_ERR_OK => App::$l10n->t("There is no error, the file uploaded with success"), UPLOAD_ERR_INI_SIZE => App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini") . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), UPLOAD_ERR_PARTIAL => App::$l10n->t("The uploaded file was only partially uploaded"), UPLOAD_ERR_NO_FILE => App::$l10n->t("No file was uploaded"), UPLOAD_ERR_NO_TMP_DIR => App::$l10n->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE => App::$l10n->t('Failed to write to disk'));
         $response->bailOut($errors[$error]);
         return $response;
     }
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
     $totalSize = $file['size'];
     if ($maxUploadFilesize >= 0 and $totalSize > $maxUploadFilesize) {
         $response->bailOut(App::$l10n->t('Not enough storage available'));
         return $response;
     }
     $tmpname = $file['tmp_name'];
     $filename = strtr($file['name'], array('/' => '', "\\" => ''));
     if (is_uploaded_file($tmpname)) {
         if (\OC\Files\Filesystem::isFileBlacklisted($filename)) {
             $response->bailOut(App::$l10n->t('Attempt to upload blacklisted file:') . $filename);
             return $response;
         }
         $content = file_get_contents($tmpname);
         $proxyStatus = \OC_FileProxy::$enabled;
         \OC_FileProxy::$enabled = false;
         if ($view->file_put_contents('/imports/' . $filename, $content)) {
             \OC_FileProxy::$enabled = $proxyStatus;
             $count = substr_count($content, 'BEGIN:');
             $progresskey = 'contacts-import-' . rand();
             $response->setParams(array('filename' => $filename, 'count' => $count, 'progresskey' => $progresskey, 'backend' => $params['backend'], 'addressBookId' => $params['addressBookId']));
             \OC_Cache::set($progresskey, '10', 300);
         } else {
             \OC_FileProxy::$enabled = $proxyStatus;
             $response->bailOut(App::$l10n->t('Error uploading contacts to storage.'));
             return $response;
         }
     } else {
         $response->bailOut('Temporary file: \'' . $tmpname . '\' has gone AWOL?');
         return $response;
     }
     return $response;
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OC::$server->getNavigationManager()->setActiveEntry('documents_index');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
     $response = new TemplateResponse('documents', 'documents', ['enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'useUnstable' => $this->settings->getAppValue('documents', 'unstable', 'false'), 'savePath' => $this->settings->getUserValue($this->uid, 'documents', 'save_path', '/'), 'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes')]);
     $policy = new ContentSecurityPolicy();
     //$policy->addAllowedChildSrcDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
     $policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
     $policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
     $policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
     $policy->addAllowedImageDomain('*');
     $policy->allowInlineScript(true);
     $policy->addAllowedFontDomain('data:');
     $response->setContentSecurityPolicy($policy);
     return $response;
 }
 /**
  * Load the image.
  */
 protected function processImage()
 {
     // If image has already been read return
     if ($this->image instanceof Image) {
         return;
     }
     $this->image = new Image();
     \OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Type: ' . $this->request->getHeader('Content-Type'), \OCP\Util::DEBUG);
     \OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Length: ' . $this->request->getHeader('Content-Length'), \OCP\Util::DEBUG);
     if (substr($this->request->getHeader('Content-Type'), 0, 6) !== 'image/') {
         throw new \Exception('Only images can be used as contact photo', Http::STATUS_UNSUPPORTED_MEDIA_TYPE);
     }
     $maxSize = \OCP\Util::maxUploadFilesize('/');
     if ($this->request->getHeader('Content-Length') > $maxSize) {
         throw new \Exception(sprintf('The size of the file exceeds the maximum allowed %s', \OCP\Util::humanFileSize($maxSize)), Http::STATUS_REQUEST_ENTITY_TOO_LARGE);
     }
     $this->image->loadFromFileHandle($this->request->put);
 }
Beispiel #7
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $activeView = $this->configInfo->getUserValue($this->userId, $this->appName, 'view', 'listview');
     $lastSelectedBook = $this->configInfo->getUserValue($this->userId, $this->appName, 'currentbook', 0);
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(1000);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks, 'activeView' => $activeView, 'lastSelectedBook' => $lastSelectedBook];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OC::$server->getNavigationManager()->setActiveEntry($this->appName);
     $importManager = new ImportManager();
     $imppTypes = Properties::getTypesForProperty('IMPP');
     $adrTypes = Properties::getTypesForProperty('ADR');
     $phoneTypes = Properties::getTypesForProperty('TEL');
     $emailTypes = Properties::getTypesForProperty('EMAIL');
     $ims = Properties::getIMOptions();
     $imProtocols = array();
     foreach ($ims as $name => $values) {
         $imProtocols[$name] = $values['displayname'];
     }
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     \OCP\Util::addScript('', 'jquery.multiselect');
     \OCP\Util::addScript('', 'tags');
     \OCP\Util::addScript('placeholder');
     \OCP\Util::addScript('3rdparty', 'md5/md5.min');
     \OCP\Util::addScript('jquery.avatar');
     \OCP\Util::addScript('avatar');
     \OCP\Util::addScript('contacts', 'jquery.combobox');
     \OCP\Util::addScript('contacts', 'modernizr.custom');
     \OCP\Util::addScript('contacts', 'app');
     \OCP\Util::addScript('contacts', 'addressbooks');
     \OCP\Util::addScript('contacts', 'contacts');
     \OCP\Util::addScript('contacts', 'storage');
     \OCP\Util::addScript('contacts', 'groups');
     \OCP\Util::addScript('contacts', 'jquery.ocaddnew');
     \OCP\Util::addScript('contacts', 'otherbackendconfig');
     \OCP\Util::addScript('files', 'jquery.fileupload');
     \OCP\Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop');
     \OCP\Util::addStyle('', 'jquery.multiselect');
     \OCP\Util::addStyle('contacts', 'jquery.combobox');
     \OCP\Util::addStyle('contacts', 'jquery.ocaddnew');
     \OCP\Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop');
     \OCP\Util::addStyle('contacts', 'contacts');
     $response = new TemplateResponse($this->appName, 'contacts');
     $response->setParams(array('uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'phoneTypes' => $phoneTypes, 'emailTypes' => $emailTypes, 'adrTypes' => $adrTypes, 'imppTypes' => $imppTypes, 'imProtocols' => $imProtocols, 'importManager' => $importManager));
     return $response;
 }
Beispiel #9
0
 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @param string $token
  * @param string $path
  * @return TemplateResponse
  */
 public function showShare($token, $path = '')
 {
     \OC_User::setIncognitoMode(true);
     // Check whether share exists
     $linkItem = Share::getShareByToken($token, false);
     if ($linkItem === false) {
         return new TemplateResponse('core', '404', array(), 'guest');
     }
     $linkItem = OCP\Share::getShareByToken($token, false);
     $shareOwner = $linkItem['uid_owner'];
     $originalSharePath = null;
     $rootLinkItem = OCP\Share::resolveReShare($linkItem);
     if (isset($rootLinkItem['uid_owner'])) {
         OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
         OC_Util::tearDownFS();
         OC_Util::setupFS($rootLinkItem['uid_owner']);
         $originalSharePath = Filesystem::getPath($linkItem['file_source']);
     }
     // Share is password protected - check whether the user is permitted to access the share
     if (isset($linkItem['share_with']) && !Helper::authenticate($linkItem)) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', array('token' => $token)));
     }
     if (Filesystem::isReadable($originalSharePath . $path)) {
         $getPath = Filesystem::normalizePath($path);
         $originalSharePath .= $path;
     }
     $file = basename($originalSharePath);
     $shareTmpl = array();
     $shareTmpl['displayName'] = User::getDisplayName($shareOwner);
     $shareTmpl['filename'] = $file;
     $shareTmpl['directory_path'] = $linkItem['file_target'];
     $shareTmpl['mimetype'] = Filesystem::getMimeType($originalSharePath);
     $shareTmpl['dirToken'] = $linkItem['token'];
     $shareTmpl['sharingToken'] = $token;
     $shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
     $shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false';
     $shareTmpl['dir'] = '';
     $shareTmpl['fileSize'] = \OCP\Util::humanFileSize(\OC\Files\Filesystem::filesize($originalSharePath));
     // Show file list
     if (Filesystem::is_dir($originalSharePath)) {
         $shareTmpl['dir'] = $getPath;
         $files = array();
         $maxUploadFilesize = Util::maxUploadFilesize($originalSharePath);
         $freeSpace = Util::freeSpace($originalSharePath);
         $uploadLimit = Util::uploadLimit();
         $folder = new Template('files', 'list', '');
         $folder->assign('dir', $getPath);
         $folder->assign('dirToken', $linkItem['token']);
         $folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
         $folder->assign('isPublic', true);
         $folder->assign('publicUploadEnabled', 'no');
         $folder->assign('files', $files);
         $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
         $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
         $folder->assign('freeSpace', $freeSpace);
         $folder->assign('uploadLimit', $uploadLimit);
         // PHP upload limit
         $folder->assign('usedSpacePercent', 0);
         $folder->assign('trash', false);
         $shareTmpl['folder'] = $folder->fetchPage();
     }
     $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token));
     return new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
 }
Beispiel #10
0
 * 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/>.
 * 
 */
namespace OCA\Documents;

\OCP\User::checkLoggedIn();
\OCP\JSON::checkAppEnabled('documents');
\OCP\App::setActiveNavigationEntry('documents_index');
\OCP\Util::addStyle('documents', 'style');
\OCP\Util::addStyle('documents', '3rdparty/webodf/dojo-app');
\OCP\Util::addScript('documents', 'documents');
\OCP\Util::addScript('files', 'file-upload');
\OCP\Util::addScript('files', 'jquery.iframe-transport');
\OCP\Util::addScript('files', 'jquery.fileupload');
$tmpl = new \OCP\Template('documents', 'documents', 'user');
$previewsEnabled = \OC::$server->getConfig()->getSystemValue('enable_previews', true);
$unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
$tmpl->assign('enable_previews', $previewsEnabled);
$tmpl->assign('useUnstable', $unstable);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('savePath', $savePath);
$tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
$tmpl->printPage();
 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @param string $token
  * @param string $path
  * @return TemplateResponse|RedirectResponse
  */
 public function showShare($token, $path = '')
 {
     \OC_User::setIncognitoMode(true);
     // Check whether share exists
     $linkItem = Share::getShareByToken($token, false);
     if ($linkItem === false) {
         return new NotFoundResponse();
     }
     $shareOwner = $linkItem['uid_owner'];
     $originalSharePath = $this->getPath($token);
     // Share is password protected - check whether the user is permitted to access the share
     if (isset($linkItem['share_with']) && !Helper::authenticate($linkItem)) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', array('token' => $token)));
     }
     if (Filesystem::isReadable($originalSharePath . $path)) {
         $getPath = Filesystem::normalizePath($path);
         $originalSharePath .= $path;
     } else {
         throw new OCP\Files\NotFoundException();
     }
     $file = basename($originalSharePath);
     $shareTmpl = [];
     $shareTmpl['displayName'] = User::getDisplayName($shareOwner);
     $shareTmpl['filename'] = $file;
     $shareTmpl['directory_path'] = $linkItem['file_target'];
     $shareTmpl['mimetype'] = Filesystem::getMimeType($originalSharePath);
     $shareTmpl['previewSupported'] = \OC::$server->getPreviewManager()->isMimeSupported($shareTmpl['mimetype']);
     $shareTmpl['dirToken'] = $linkItem['token'];
     $shareTmpl['sharingToken'] = $token;
     $shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
     $shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false';
     $shareTmpl['dir'] = '';
     $nonHumanFileSize = \OC\Files\Filesystem::filesize($originalSharePath);
     $shareTmpl['nonHumanFileSize'] = $nonHumanFileSize;
     $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($nonHumanFileSize);
     // Show file list
     if (Filesystem::is_dir($originalSharePath)) {
         $shareTmpl['dir'] = $getPath;
         $maxUploadFilesize = Util::maxUploadFilesize($originalSharePath);
         $freeSpace = Util::freeSpace($originalSharePath);
         $uploadLimit = Util::uploadLimit();
         $folder = new Template('files', 'list', '');
         $folder->assign('dir', $getPath);
         $folder->assign('dirToken', $linkItem['token']);
         $folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
         $folder->assign('isPublic', true);
         $folder->assign('publicUploadEnabled', 'no');
         $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
         $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
         $folder->assign('freeSpace', $freeSpace);
         $folder->assign('uploadLimit', $uploadLimit);
         // PHP upload limit
         $folder->assign('usedSpacePercent', 0);
         $folder->assign('trash', false);
         $shareTmpl['folder'] = $folder->fetchPage();
     }
     $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token));
     $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
     $csp = new OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedFrameDomain('\'self\'');
     $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
     $response->setContentSecurityPolicy($csp);
     return $response;
 }
 /**
  * calculates the maximum upload size respecting system settings, free space
  * and user quota
  *
  * @param string $dir the current folder where the user currently operates
  * @param int $free the number of bytes free on the storage holding $dir,
  *                  if not set this will be received from the storage directly
  * @return int number of bytes representing
  */
 public function maxUploadFilesize($dir, $free = null)
 {
     return Util::maxUploadFilesize($dir, $free);
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $wopiRemote = $this->appConfig->getAppValue('wopi_url');
     if (($parts = parse_url($wopiRemote)) && isset($parts['scheme']) && isset($parts['host'])) {
         $webSocketProtocol = "ws://";
         if ($parts['scheme'] == "https") {
             $webSocketProtocol = "wss://";
         }
         $webSocket = sprintf("%s%s%s", $webSocketProtocol, $parts['host'], isset($parts['port']) ? ":" . $parts['port'] : "");
     } else {
         return $this->responseError($this->l10n->t('Collabora Online: Invalid URL "%s".', array($wopiRemote)), $this->l10n->t('Please ask your administrator to check the Collabora Online server setting.'));
     }
     \OC::$server->getNavigationManager()->setActiveEntry('richdocuments_index');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
     $response = new TemplateResponse('richdocuments', 'documents', ['enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'), 'wopi_url' => $webSocket]);
     $policy = new ContentSecurityPolicy();
     $policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
     /* frame-src is deprecated on Firefox, but Safari wants it! */
     $policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
     $policy->addAllowedChildSrcDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
     $policy->addAllowedConnectDomain($webSocket);
     $policy->addAllowedImageDomain('*');
     $policy->allowInlineScript(true);
     $policy->addAllowedFontDomain('data:');
     $response->setContentSecurityPolicy($policy);
     return $response;
 }
 /**
  * @NoAdminRequired
  */
 public function showContact($id)
 {
     $id = $this->params('id');
     $vcard = ContactsApp::getContactVCard($id);
     $oldaddressbookid = VCard::getAddressbookid($id);
     $addressBookPerm = Addressbook::find($oldaddressbookid);
     $editInfoCard = VCard::structureContact($vcard);
     $TELTYPE = ContactsApp::getTypesOfProperty('TEL');
     $EMAILTYPE = ContactsApp::getTypesOfProperty('EMAIL');
     $URLTYPE = ContactsApp::getTypesOfProperty('URL');
     $ADRTYPE = ContactsApp::getTypesOfProperty('ADR');
     $IMTYPE = ContactsApp::getIMOptions();
     $aDefNArray = array('0' => 'lname', '1' => 'fname', '2' => 'anrede', '3' => 'title');
     $aN = '';
     if (isset($editInfoCard['N'][0]['value']) && count($editInfoCard['N'][0]['value']) > 0) {
         foreach ($editInfoCard['N'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aN[$aDefNArray[$key]] = $val;
             }
         }
     }
     //X-ABSHOWAS;
     $bShowCompany = false;
     if (isset($editInfoCard['ORG'][0]['SHOWAS']) && $editInfoCard['ORG'][0]['SHOWAS'] == 'COMPANY') {
         $bShowCompany = true;
     }
     $aOrgDef = array('0' => 'firm', '1' => 'department');
     $aOrg = array();
     if (isset($editInfoCard['ORG'][0]['value']) && count($editInfoCard['ORG'][0]['value']) > 0) {
         foreach ($editInfoCard['ORG'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aOrg[$aOrgDef[$key]] = $val;
             }
         }
     }
     $sBday = '';
     if (isset($editInfoCard['BDAY'][0]['value']) && !empty($editInfoCard['BDAY'][0]['value'])) {
         $sBday = $editInfoCard['BDAY'][0]['value'];
         $date = new \DateTime($sBday);
         $sBday = $date->format('d. M Y');
     }
     $sNotice = '';
     if (isset($editInfoCard['NOTE'][0]['value']) && !empty($editInfoCard['NOTE'][0]['value'])) {
         $sNotice = stripcslashes($editInfoCard['NOTE'][0]['value']);
         $sNotice = str_replace("\n", '<br />', $sNotice);
     }
     $sNickname = '';
     if (isset($editInfoCard['NICKNAME'][0]['value']) && !empty($editInfoCard['NICKNAME'][0]['value'])) {
         $sNickname = $editInfoCard['NICKNAME'][0]['value'];
     }
     $sPosition = '';
     if (isset($editInfoCard['TITLE'][0]['value']) && !empty($editInfoCard['TITLE'][0]['value'])) {
         $sPosition = $editInfoCard['TITLE'][0]['value'];
     }
     $aAddr = '';
     if (array_key_exists('ADR', $editInfoCard)) {
         $aAddr = $this->getAddressInfo($editInfoCard['ADR'], $ADRTYPE);
     }
     $aTel = '';
     if (array_key_exists('TEL', $editInfoCard)) {
         $aTel = $this->getPhoneInfo($editInfoCard['TEL'], $TELTYPE);
     }
     $aEmail = '';
     if (array_key_exists('EMAIL', $editInfoCard)) {
         $aEmail = $this->getEmailInfo($editInfoCard['EMAIL'], $EMAILTYPE);
     }
     $aUrl = '';
     if (array_key_exists('URL', $editInfoCard)) {
         $aUrl = $this->getUrlInfo($editInfoCard['URL'], $URLTYPE);
     }
     $aImpp = '';
     if (array_key_exists('IMPP', $editInfoCard)) {
         $aImpp = $this->getImppInfo($editInfoCard['IMPP'], $IMTYPE);
     }
     $aCloud = '';
     if (array_key_exists('CLOUD', $editInfoCard)) {
         $aCloud = $this->getCloudInfo($editInfoCard['CLOUD'], $ADRTYPE);
     }
     $bPhoto = 0;
     $imgSrc = '';
     $imgMimeType = '';
     $tmpkey = 'editphoto';
     $thumb = '<div id="noimage" class="ioc ioc-user"></div>';
     if (isset($vcard->PHOTO)) {
         $bPhoto = 1;
         $thumb = '';
         $image = new \OCP\Image();
         $image->loadFromData((string) $vcard->PHOTO);
         $imgSrc = $image->__toString();
         $imgMimeType = $image->mimeType();
         \OC::$server->getCache()->remove($tmpkey);
         \OC::$server->getCache()->set($tmpkey, $image->data(), 600);
     }
     $catOutput = '';
     if (isset($editInfoCard['CATEGORIES'][0]['value']) && count($editInfoCard['CATEGORIES'][0]['value']) > 0) {
         foreach ($editInfoCard['CATEGORIES'] as $key => $catInfo) {
             if ($key == 'value') {
                 $aCatInfo = explode(',', $catInfo['value']);
                 foreach ($aCatInfo as $key => $val) {
                     $backgroundColor = ContactsApp::genColorCodeFromText(trim($val), 80);
                     $color = ContactsApp::generateTextColor($backgroundColor);
                     $catOutput .= '<span class="colorgroup toolTip" data-category="' . $val . '"  style="background-color:' . $backgroundColor . ';color:' . $color . ';" title="' . $val . '">' . mb_substr($val, 0, 1, "UTF-8") . '</span> ';
                 }
             }
         }
     }
     $addressBookName = $addressBookPerm['displayname'];
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $params = ['id' => $id, 'tmpkey' => $tmpkey, 'oldaddressbookid' => $oldaddressbookid, 'addressbooksPerm' => $addressBookPerm, 'isPhoto' => $bPhoto, 'thumbnail' => $thumb, 'categories' => $catOutput, 'addressbookname' => $addressBookName, 'bShowCompany' => $bShowCompany, 'imgsrc' => $imgSrc, 'imgMimeType' => $imgMimeType, 'anrede' => isset($aN['title']) ? $aN['title'] : '', 'fname' => isset($aN['fname']) ? $aN['fname'] : '', 'lname' => isset($aN['lname']) ? $aN['lname'] : '', 'firm' => isset($aOrg['firm']) ? $aOrg['firm'] : '', 'department' => isset($aOrg['department']) ? $aOrg['department'] : '', 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'aTel' => isset($aTel) ? $aTel : '', 'aEmail' => isset($aEmail) ? $aEmail : '', 'aAddr' => isset($aAddr) ? $aAddr : '', 'aUrl' => isset($aUrl) ? $aUrl : '', 'aImpp' => isset($aImpp) ? $aImpp : '', 'aCloud' => isset($aCloud) ? $aCloud : '', 'sBday' => isset($sBday) ? $sBday : '', 'nickname' => isset($sNickname) ? $sNickname : '', 'position' => isset($sPosition) ? $sPosition : '', 'sNotice' => isset($sNotice) ? $sNotice : ''];
     $response = new TemplateResponse($this->appName, 'contact.show', $params, '');
     return $response;
 }
 /**
  * @NoAdminRequired
  */
 public function showContact()
 {
     $id = $this->params('id');
     $vcard = ContactsApp::getContactVCard($id);
     $oldaddressbookid = VCard::getAddressbookid($id);
     $addressBookPerm = Addressbook::find($oldaddressbookid);
     $editInfoCard = VCard::structureContact($vcard);
     $TELTYPE = ContactsApp::getTypesOfProperty('TEL');
     $EMAILTYPE = ContactsApp::getTypesOfProperty('EMAIL');
     $URLTYPE = ContactsApp::getTypesOfProperty('URL');
     $ADRTYPE = ContactsApp::getTypesOfProperty('ADR');
     $aDefNArray = array('0' => 'lname', '1' => 'fname', '2' => 'anrede', '3' => 'title');
     $aN = '';
     if (isset($editInfoCard['N'][0]['value']) && count($editInfoCard['N'][0]['value']) > 0) {
         foreach ($editInfoCard['N'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aN[$aDefNArray[$key]] = $val;
             }
         }
     }
     $aOrgDef = array('0' => 'firm', '1' => 'department');
     $aOrg = array();
     if (isset($editInfoCard['ORG'][0]['value']) && count($editInfoCard['ORG'][0]['value']) > 0) {
         foreach ($editInfoCard['ORG'][0]['value'] as $key => $val) {
             if ($val != '') {
                 $aOrg[$aOrgDef[$key]] = $val;
             }
         }
     }
     $sBday = '';
     if (isset($editInfoCard['BDAY'][0]['value']) && !empty($editInfoCard['BDAY'][0]['value'])) {
         $sBday = $editInfoCard['BDAY'][0]['value'];
         $date = new \DateTime($sBday);
         $sBday = $date->format('d. M Y');
     }
     $sNotice = '';
     if (isset($editInfoCard['NOTE'][0]['value']) && !empty($editInfoCard['NOTE'][0]['value'])) {
         $sNotice = $editInfoCard['NOTE'][0]['value'];
     }
     $sNickname = '';
     if (isset($editInfoCard['NICKNAME'][0]['value']) && !empty($editInfoCard['NICKNAME'][0]['value'])) {
         $sNickname = $editInfoCard['NICKNAME'][0]['value'];
     }
     $sPosition = '';
     if (isset($editInfoCard['TITLE'][0]['value']) && !empty($editInfoCard['TITLE'][0]['value'])) {
         $sPosition = $editInfoCard['TITLE'][0]['value'];
     }
     $aAddr = '';
     if (array_key_exists('ADR', $editInfoCard)) {
         $aAddr = $this->getAddressInfo($editInfoCard['ADR'], $ADRTYPE);
     }
     $aTel = '';
     if (array_key_exists('TEL', $editInfoCard)) {
         $aTel = $this->getPhoneInfo($editInfoCard['TEL'], $TELTYPE);
     }
     $aEmail = '';
     if (array_key_exists('EMAIL', $editInfoCard)) {
         $aEmail = $this->getEmailInfo($editInfoCard['EMAIL'], $EMAILTYPE);
     }
     $aUrl = '';
     if (array_key_exists('URL', $editInfoCard)) {
         $aUrl = $this->getUrlInfo($editInfoCard['URL'], $URLTYPE);
     }
     $bPhoto = 0;
     $imgSrc = '';
     $imgMimeType = '';
     $thumb = '<div id="noimage" class="ioc ioc-user"></div>';
     if (isset($vcard->PHOTO)) {
         $bPhoto = 1;
         $thumb = '';
         $image = new \OCP\Image();
         $image->loadFromData((string) $vcard->PHOTO);
         $imgSrc = $image->__toString();
         $imgMimeType = $image->mimeType();
         \OC::$server->getCache()->set('show-contacts-foto-' . $id, $image->data(), 600);
     }
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $params = ['id' => $id, 'tmpkey' => 'show-contacts-foto-' . $id, 'oldaddressbookid' => $oldaddressbookid, 'addressbooksPerm' => $addressBookPerm, 'isPhoto' => $bPhoto, 'thumbnail' => $thumb, 'imgsrc' => $imgSrc, 'imgMimeType' => $imgMimeType, 'anrede' => isset($aN['title']) ? $aN['title'] : '', 'fname' => isset($aN['fname']) ? $aN['fname'] : '', 'lname' => isset($aN['lname']) ? $aN['lname'] : '', 'firm' => isset($aOrg['firm']) ? $aOrg['firm'] : '', 'department' => isset($aOrg['department']) ? $aOrg['department'] : '', 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'aTel' => isset($aTel) ? $aTel : '', 'aEmail' => isset($aEmail) ? $aEmail : '', 'aAddr' => isset($aAddr) ? $aAddr : '', 'aUrl' => isset($aUrl) ? $aUrl : '', 'sBday' => isset($sBday) ? $sBday : '', 'nickname' => isset($sNickname) ? $sNickname : '', 'position' => isset($sPosition) ? $sPosition : '', 'sNotice' => isset($sNotice) ? $sNotice : ''];
     $response = new TemplateResponse($this->appName, 'contact.show', $params, '');
     return $response;
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OC::$server->getNavigationManager()->setActiveEntry('documents_index');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
     return new TemplateResponse('documents', 'documents', ['enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'useUnstable' => $this->settings->getAppValue('documents', 'unstable', 'false'), 'savePath' => $this->settings->getUserValue($this->uid, 'documents', 'save_path', '/'), 'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes')]);
 }