Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
	/**
	 * @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;
	}
Exemplo n.º 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']);
 }
Exemplo n.º 4
0
 /**
  * @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;
 }
Exemplo n.º 5
0
 /**
  * @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;
 }
Exemplo n.º 6
0
 public function index()
 {
     try {
         $list = Helper::scandir($this->config->getBackupBase());
     } catch (\Exception $e) {
         $list = [];
     }
     clearstatcache();
     $result = [];
     foreach ($list as $item) {
         if (in_array($item, ['.', '..'])) {
             continue;
         }
         $result[] = ['title' => $item, 'date' => date("F d Y H:i:s", filectime($this->config->getBackupBase() . '/' . $item)), 'size' => \OCP\Util::humanFileSize(filesize($this->config->getBackupBase() . '/' . $item))];
     }
     return ['status' => 'success', 'data' => $result];
 }
Exemplo n.º 7
0
 /**
  * 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);
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 /**
  * @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;
 }
Exemplo n.º 10
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $toBeSet = [];
     if ($input->getOption('enable')) {
         $toBeSet['log_type'] = 'owncloud';
     }
     if ($file = $input->getOption('file')) {
         $toBeSet['logfile'] = $file;
     }
     if (($rotateSize = $input->getOption('rotate-size')) !== null) {
         $rotateSize = \OCP\Util::computerFileSize($rotateSize);
         $this->validateRotateSize($rotateSize);
         $toBeSet['log_rotate_size'] = $rotateSize;
     }
     // set config
     foreach ($toBeSet as $option => $value) {
         $this->config->setSystemValue($option, $value);
     }
     // display config
     if ($this->config->getSystemValue('log_type', 'owncloud') === 'owncloud') {
         $enabledText = 'enabled';
     } else {
         $enabledText = 'disabled';
     }
     $output->writeln('Log backend ownCloud: ' . $enabledText);
     $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $defaultLogFile = rtrim($dataDir, '/') . '/owncloud.log';
     $output->writeln('Log file: ' . $this->config->getSystemValue('logfile', $defaultLogFile));
     $rotateSize = $this->config->getSystemValue('log_rotate_size', 0);
     if ($rotateSize) {
         $rotateString = \OCP\Util::humanFileSize($rotateSize);
     } else {
         $rotateString = 'disabled';
     }
     $output->writeln('Rotate at: ' . $rotateString);
 }
Exemplo n.º 11
0
 /**
  * @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;
 }
Exemplo n.º 12
0
 /**
  * @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;
 }
Exemplo n.º 13
0
<?php

// show toolbar
echo '<div id="controls">	
	<a href="' . \OCP\Util::linkToAbsolute('impress', 'documentation.php') . '" class="button docu">' . $l->t('Documentation') . '</a>
	</div>
	';
if (empty($_['list'])) {
    echo '<div id="emptyfolder">' . $l->t('No Impress files are found in your ownCloud. Please upload a .impress file.') . '</div>';
} else {
    echo '<table class="impresslist" >';
    foreach ($_['list'] as $entry) {
        echo '<tr><td width="1"><a target="_blank" href="' . \OCP\Util::linkToAbsolute('impress', 'player.php') . '&file=' . urlencode($entry['url']) . '&name=' . urlencode($entry['name']) . '"><img align="left" src="' . \OCP\Util::linkToAbsolute('impress', 'img/impressbig.png') . '"></a></td><td><a target="_blank" href="' . \OCP\Util::linkToAbsolute('impress', 'player.php') . '&file=' . urlencode($entry['url']) . '&name=' . urlencode($entry['name']) . '">' . $entry['name'] . '</a></td><td>' . \OCP\Util::formatDate($entry['mtime']) . '</td><td>' . \OCP\Util::humanFileSize($entry['size']) . '</td></tr>';
    }
    echo '</table>';
}
Exemplo n.º 14
0
 /**
  * @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;
 }
Exemplo n.º 15
0
 /**
  * @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;
 }
Exemplo n.º 16
0
 /**
  * Make a human file size (2048 to 2 kB)
  * @param int $bytes file size in bytes
  * @return string a human readable file size
  */
 public function humanFileSize($bytes)
 {
     return Util::humanFileSize($bytes);
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @SSOCORS
  */
 public function upload($dir = '/')
 {
     \OC::$server->getSession()->close();
     // Firefox and Konqueror tries to download application/json for me.  --Arthur
     \OCP\JSON::setContentTypeHeader('text/plain');
     // If a directory token is sent along check if public upload is permitted.
     // If not, check the login.
     // If no token is sent along, rely on login only
     $allowedPermissions = \OCP\Constants::PERMISSION_ALL;
     $errorCode = null;
     if (\OC\Files\Filesystem::file_exists($dir) === false) {
         return new DataResponse(array('data' => array_merge(array('message' => 'Invalid directory.')), 'status' => 'error'));
     }
     // get array with current storage stats (e.g. max file size)
     $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
     $files = $this->request->getUploadedFile('files');
     if (!isset($files)) {
         return new DataResponse(array('data' => array_merge(array('message' => 'No file was uploaded. Unknown error'), $storageStats), 'status' => 'error'));
     }
     foreach ($files['error'] as $error) {
         if ($error != 0) {
             $errors = array(UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini: ' . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write to disk');
             $errorMessage = $errors[$error];
             \OC::$server->getLogger()->alert("Upload error: {$error} - {$errorMessage}", array('app' => 'files'));
             return new DataResponse(array('data' => array_merge(array('message' => $errorMessage), $storageStats), 'status' => 'error'));
         }
     }
     $error = false;
     $maxUploadFileSize = $storageStats['uploadMaxFilesize'];
     $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
     $totalSize = 0;
     foreach ($files['size'] as $size) {
         $totalSize += $size;
     }
     if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
         return new DataResponse(array('data' => array('message' => 'Not enough storage available', 'uploadMaxFilesize' => $maxUploadFileSize, '   maxHumanFilesize' => $maxHumanFileSize), 'status' => 'error'));
     }
     $result = array();
     $fileCount = count($files['name']);
     for ($i = 0; $i < $fileCount; $i++) {
         // target directory for when uploading folders
         $relativePath = '';
         $target = \OC\Files\Filesystem::normalizePath($dir . $relativePath . '/' . $files['name'][$i]);
         // relative dir to return to the client
         if (isset($publicDirectory)) {
             // path relative to the public root
             $returnedDir = $publicDirectory . $relativePath;
         } else {
             // full path
             $returnedDir = $dir . $relativePath;
         }
         $returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
         $exists = \OC\Files\Filesystem::file_exists($target);
         if ($exists) {
             $target = \OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
         }
         try {
             if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
                 // updated max file size after upload
                 $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
                 $meta = \OC\Files\Filesystem::getFileInfo($target);
                 if ($meta === false) {
                     $error = 'The target folder has been moved or deleted.';
                     $errorCode = 'targetnotfound';
                 } else {
                     $data = \OCA\Files\Helper::formatFileInfo($meta);
                     $data['originalname'] = $files['name'][$i];
                     $data['uploadMaxFilesize'] = $maxUploadFileSize;
                     $data['maxHumanFilesize'] = $maxHumanFileSize;
                     $data['permissions'] = $meta['permissions'] & $allowedPermissions;
                     $data['directory'] = $returnedDir;
                     $result[] = $data;
                 }
             } else {
                 $error = 'Upload failed. Could not find uploaded file';
             }
         } catch (Exception $ex) {
             $error = $ex->getMessage();
         }
     }
     if ($error === false) {
         $result = \OCP\JSON::encode($result);
         return new DataResponse(array('data' => $result, 'status' => 'success'));
     } else {
         return new DataResponse(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats), 'status' => 'error'));
     }
 }
Exemplo n.º 18
0
Arquivo: users.php Projeto: kenwi/core
 /** 
  * edit users
  *
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function editUser($parameters)
 {
     /** @var string $targetUserId */
     $targetUserId = $parameters['userid'];
     // Check if user is logged in
     $currentLoggedInUser = $this->userSession->getUser();
     if ($currentLoggedInUser === null) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
     }
     $targetUser = $this->userManager->get($targetUserId);
     if ($targetUser === null) {
         return new OC_OCS_Result(null, 997);
     }
     if ($targetUserId === $currentLoggedInUser->getUID()) {
         // Editing self (display, email)
         $permittedFields[] = 'display';
         $permittedFields[] = 'email';
         $permittedFields[] = 'password';
         // If admin they can edit their own quota
         if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
             $permittedFields[] = 'quota';
         }
     } else {
         // Check if admin / subadmin
         $subAdminManager = $this->groupManager->getSubAdmin();
         if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) || $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
             // They have permissions over the user
             $permittedFields[] = 'display';
             $permittedFields[] = 'quota';
             $permittedFields[] = 'password';
             $permittedFields[] = 'email';
         } else {
             // No rights
             return new OC_OCS_Result(null, 997);
         }
     }
     // Check if permitted to edit this field
     if (!in_array($parameters['_put']['key'], $permittedFields)) {
         return new OC_OCS_Result(null, 997);
     }
     // Process the edit
     switch ($parameters['_put']['key']) {
         case 'display':
             $targetUser->setDisplayName($parameters['_put']['value']);
             break;
         case 'quota':
             $quota = $parameters['_put']['value'];
             if ($quota !== 'none' and $quota !== 'default') {
                 if (is_numeric($quota)) {
                     $quota = floatval($quota);
                 } else {
                     $quota = \OCP\Util::computerFileSize($quota);
                 }
                 if ($quota === false) {
                     return new OC_OCS_Result(null, 103, "Invalid quota value {$parameters['_put']['value']}");
                 }
                 if ($quota === 0) {
                     $quota = 'default';
                 } else {
                     if ($quota === -1) {
                         $quota = 'none';
                     } else {
                         $quota = \OCP\Util::humanFileSize($quota);
                     }
                 }
             }
             $this->config->setUserValue($targetUserId, 'files', 'quota', $quota);
             break;
         case 'password':
             $targetUser->setPassword($parameters['_put']['value']);
             break;
         case 'email':
             if (filter_var($parameters['_put']['value'], FILTER_VALIDATE_EMAIL)) {
                 $this->config->setUserValue($targetUserId, 'settings', 'email', $parameters['_put']['value']);
             } else {
                 return new OC_OCS_Result(null, 102);
             }
             break;
         default:
             return new OC_OCS_Result(null, 103);
             break;
     }
     return new OC_OCS_Result(null, 100);
 }
Exemplo n.º 19
0
 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @param string $token
  * @param string $path
  * @return TemplateResponse|RedirectResponse
  * @throws NotFoundException
  */
 public function showShare($token, $path = '')
 {
     \OC_User::setIncognitoMode(true);
     // Check whether share exists
     try {
         $share = $this->shareManager->getShareByToken($token);
     } catch (\OC\Share20\Exception\ShareNotFound $e) {
         return new NotFoundResponse();
     }
     // Share is password protected - check whether the user is permitted to access the share
     if ($share->getPassword() !== null && !$this->linkShareAuth($share)) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', array('token' => $token)));
     }
     // We can't get the path of a file share
     if ($share->getNode() instanceof \OCP\Files\File && $path !== '') {
         throw new NotFoundException();
     }
     $rootFolder = null;
     if ($share->getNode() instanceof \OCP\Files\Folder) {
         /** @var \OCP\Files\Folder $rootFolder */
         $rootFolder = $share->getNode();
         try {
             $path = $rootFolder->get($path);
         } catch (\OCP\Files\NotFoundException $e) {
             throw new NotFoundException();
         }
     }
     $shareTmpl = [];
     $shareTmpl['displayName'] = $share->getShareOwner()->getDisplayName();
     $shareTmpl['owner'] = $share->getShareOwner()->getUID();
     $shareTmpl['filename'] = $share->getNode()->getName();
     $shareTmpl['directory_path'] = $share->getTarget();
     $shareTmpl['mimetype'] = $share->getNode()->getMimetype();
     $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($share->getNode()->getMimetype());
     $shareTmpl['dirToken'] = $token;
     $shareTmpl['sharingToken'] = $token;
     $shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
     $shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
     $shareTmpl['dir'] = '';
     $shareTmpl['nonHumanFileSize'] = $share->getNode()->getSize();
     $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($share->getNode()->getSize());
     // Show file list
     if ($share->getNode() instanceof \OCP\Files\Folder) {
         $shareTmpl['dir'] = $rootFolder->getRelativePath($path->getPath());
         /*
          * The OC_Util methods require a view. This just uses the node API
          */
         $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
         if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN) {
             $freeSpace = max($freeSpace, 0);
         } else {
             $freeSpace = INF > 0 ? INF : PHP_INT_MAX;
             // work around https://bugs.php.net/bug.php?id=69188
         }
         $uploadLimit = Util::uploadLimit();
         $maxUploadFilesize = min($freeSpace, $uploadLimit);
         $folder = new Template('files', 'list', '');
         $folder->assign('dir', $rootFolder->getRelativePath($path->getPath()));
         $folder->assign('dirToken', $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);
     $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
     $csp = new OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedFrameDomain('\'self\'');
     $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
     $response->setContentSecurityPolicy($csp);
     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')]);
 }
Exemplo n.º 21
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();
Exemplo n.º 22
0
 /**
  * converts a zend lucene search object to a OC_SearchResult
  *
  * Example:
  * 
  * Text | Some Document.txt
  *      | /path/to/file, 148kb, Score: 0.55
  * 
  * @author Jörn Dreyer <*****@*****.**>
  *
  * @param Zend_Search_Lucene_Search_QueryHit $hit The Lucene Search Result
  * @return OC_Search_Result an OC_Search_Result
  */
 private static function asOCSearchResult(\Zend_Search_Lucene_Search_QueryHit $hit)
 {
     $mimeBase = self::baseTypeOf($hit->mimetype);
     switch ($mimeBase) {
         case 'audio':
             $type = 'Music';
             break;
         case 'text':
             $type = 'Text';
             break;
         case 'image':
             $type = 'Images';
             break;
         default:
             if ($hit->mimetype == 'application/xml') {
                 $type = 'Text';
             } else {
                 $type = 'Files';
             }
     }
     switch ($hit->mimetype) {
         case 'httpd/unix-directory':
             $url = Util::linkTo('files', 'index.php') . '?dir=' . $hit->path;
             break;
         default:
             $url = \OC::$server->getRouter()->generate('download', array('file' => $hit->path));
     }
     return new \OC_Search_Result(basename($hit->path), dirname($hit->path) . ', ' . \OCP\Util::humanFileSize($hit->size) . ', Score: ' . number_format($hit->score, 2), $url, $type, dirname($hit->path));
 }
Exemplo n.º 23
0
<?php

/**
 * ownCloud - Updater plugin
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Updater;

\OCP\JSON::checkAdminUser();
\OCP\JSON::callCheck();
try {
    $list = Helper::scandir(App::getBackupBase());
} catch (\Exception $e) {
    $list = array();
}
clearstatcache();
$result = array();
foreach ($list as $item) {
    if ($item == '.' || $item == '..') {
        continue;
    }
    $result[] = array('title' => $item, 'date' => date("F d Y H:i:s", filectime(App::getBackupBase() . '/' . $item)), 'size' => \OCP\Util::humanFileSize(filesize(App::getBackupBase() . '/' . $item)));
}
\OCP\JSON::success(array('data' => $result));
Exemplo n.º 24
0
 public function getListArray()
 {
     $data = [];
     $data['id'] = $this->getUid();
     $data['from'] = $this->getFrom();
     $data['fromEmail'] = $this->getFromEmail();
     $data['fromList'] = $this->getFromList();
     $data['to'] = $this->getTo();
     $data['toEmail'] = $this->getToEmail();
     $data['toList'] = $this->getToList();
     $data['subject'] = $this->getSubject();
     $data['date'] = Util::formatDate($this->getSentDate()->format('U'));
     $data['size'] = Util::humanFileSize($this->getSize());
     $data['flags'] = $this->getFlags();
     $data['dateInt'] = $this->getSentDate()->getTimestamp();
     $data['dateIso'] = $this->getSentDate()->format('c');
     $data['ccList'] = $this->getCCList();
     return $data;
 }
Exemplo n.º 25
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');
 }
Exemplo n.º 26
0
 public function getListArray()
 {
     $data = array();
     $data['id'] = $this->getUid();
     $data['from'] = $this->getFrom();
     $data['to'] = $this->getTo();
     $data['subject'] = $this->getSubject();
     $data['date'] = \OCP\Util::formatDate($this->getSentDate()->format('U'));
     $data['size'] = \OCP\Util::humanFileSize($this->getSize());
     $data['flags'] = $this->getFlags();
     return $data;
 }