当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::writeLog方法代码示例

本文整理汇总了PHP中OCP\Util::writeLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::writeLog方法的具体用法?PHP Util::writeLog怎么用?PHP Util::writeLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\Util的用法示例。


在下文中一共展示了Util::writeLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: returnAsJson

 /**
  * @CORS
  * @NoAdminRequired
  * @NoCSRFRequired
  * @PublicPage
  */
 public function returnAsJson($user, $password = null, $tags = array(), $conjunction = "or", $select = null, $sortby = "")
 {
     if ($user == null || $this->userManager->userExists($user) == false) {
         return $this->newJsonErrorMessage("User could not be identified");
     }
     if ($tags[0] == "") {
         $tags = array();
     }
     $public = true;
     if ($password != null) {
         $public = false;
     }
     if (!$public && !$this->userManager->checkPassword($user, $password)) {
         $msg = 'REST API accessed with wrong password';
         \OCP\Util::writeLog('bookmarks', $msg, \OCP\Util::WARN);
         return $this->newJsonErrorMessage("Wrong password for user " . $user);
     }
     $attributesToSelect = array('url', 'title');
     if ($select != null) {
         $attributesToSelect = array_merge($attributesToSelect, $select);
         $attributesToSelect = array_unique($attributesToSelect);
     }
     $output = Bookmarks::findBookmarks($user, $this->db, 0, $sortby, $tags, true, -1, $public, $attributesToSelect, $conjunction);
     if (count($output) == 0) {
         $output["status"] = 'error';
         $output["message"] = "No results from this query";
         return new JSONResponse($output);
     }
     return new JSONResponse($output);
 }
开发者ID:codeXtension,项目名称:bookmarks,代码行数:36,代码来源:publiccontroller.php

示例2: guessTimeZoneFromOffset

 /**
  * Guess the DateTimeZone for a given offset
  *
  * We first try to find a Etc/GMT* timezone, if that does not exist,
  * we try to find it manually, before falling back to UTC.
  *
  * @param mixed $offset
  * @param bool|int $timestamp
  * @return \DateTimeZone
  */
 protected function guessTimeZoneFromOffset($offset, $timestamp)
 {
     try {
         // Note: the timeZone name is the inverse to the offset,
         // so a positive offset means negative timeZone
         // and the other way around.
         if ($offset > 0) {
             $timeZone = 'Etc/GMT-' . $offset;
         } else {
             $timeZone = 'Etc/GMT+' . abs($offset);
         }
         return new \DateTimeZone($timeZone);
     } catch (\Exception $e) {
         // If the offset has no Etc/GMT* timezone,
         // we try to guess one timezone that has the same offset
         foreach (\DateTimeZone::listIdentifiers() as $timeZone) {
             $dtz = new \DateTimeZone($timeZone);
             $dateTime = new \DateTime();
             if ($timestamp !== false) {
                 $dateTime->setTimestamp($timestamp);
             }
             $dtOffset = $dtz->getOffset($dateTime);
             if ($dtOffset == 3600 * $offset) {
                 return $dtz;
             }
         }
         // No timezone found, fallback to UTC
         \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", \OCP\Util::DEBUG);
         return new \DateTimeZone($this->getDefaultTimeZone());
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:41,代码来源:datetimezone.php

示例3: saveUserFiles

 /**
  * Move files from User before account deletion
  * @param \OC\User\User $user
  */
 public function saveUserFiles(\OC\User\User $user)
 {
     // mv the files (<datadir>/uid)
     // TODO: quid du cas où un gros fichier est en train d'être uploadé / downloadé au moment du move ?
     if ($this->isUserBackupEnabled()) {
         // user ID (and name of user dir on owncloud)
         $uid = $user->getUID();
         // backup dir to store user's files before user deletion
         $userBackupDir = $this->getUserBackupDir();
         if (!file_exists($userBackupDir)) {
             mkdir($userBackupDir, 0700, true);
         }
         // owncloud data dir
         $OCDataDir = $this->getOCDataDir();
         $moveFrom = $OCDataDir . '/' . $uid;
         $moveTo = $userBackupDir . '/' . $uid . date('Ymd_His');
         if (file_exists($moveFrom) and !file_exists($moveTo)) {
             // $this->logger->info("Files backup before deletion for user $uid is done into $moveTo", array('app' => $this->appName));
             \OCP\Util::writeLog($this->appName, "Files backup before deletion for user {$uid} is done into {$moveTo}", \OCP\Util::INFO);
             rename($moveFrom, $moveTo);
         }
         // then re-create the 'uid' dir to no interfere with normal deletion process
         if (!file_exists($moveFrom)) {
             mkdir($moveFrom);
         }
     } else {
         $this->logger->error("Files backup before deletion has failed for user {$uid}", array('app' => $this->appName));
     }
 }
开发者ID:Victor-Bordage-Gorry,项目名称:user_account_actions,代码行数:33,代码来源:fileaction.php

示例4: __construct

 /**
  * Object constructor
  *
  * @param string  $data
  * @param boolean $storeContent
  */
 private function __construct($data, $storeContent)
 {
     try {
         $zendpdf = \Zend_Pdf::parse($data);
         // Store meta data properties
         if (isset($zendpdf->properties['Title'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('title', $zendpdf->properties['Title']));
         }
         if (isset($zendpdf->properties['Author'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('author', $zendpdf->properties['Author']));
         }
         if (isset($zendpdf->properties['Subject'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('subject', $zendpdf->properties['Subject']));
         }
         if (isset($zendpdf->properties['Keywords'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('keywords', $zendpdf->properties['Keywords']));
         }
         //TODO handle PDF 1.6 metadata Zend_Pdf::getMetadata()
         //do the content extraction
         $pdfParse = new \App_Search_Helper_PdfParser();
         $body = $pdfParse->pdf2txt($zendpdf->render());
         if ($body != '') {
             // Store contents
             if ($storeContent) {
                 $this->addField(\Zend_Search_Lucene_Field::Text('body', $body, 'UTF-8'));
             } else {
                 $this->addField(\Zend_Search_Lucene_Field::UnStored('body', $body, 'UTF-8'));
             }
         }
     } catch (\Exception $e) {
         Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), Util::ERROR);
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:39,代码来源:Pdf.php

示例5: get_url

 public static function get_url()
 {
     $appConfig = \OC::$server->getAppConfig();
     $result = $appConfig->getValue('privacyIDEA', 'privacyidea_url', 'https://localhost');
     \OCP\Util::writeLog('user_privacyidea', "Gettting result: {$result}", \OCP\Util::DEBUG);
     return $result;
 }
开发者ID:Reality9,项目名称:privacyidea,代码行数:7,代码来源:helper.php

示例6: register

 public function register()
 {
     $loginRecord = function ($user) {
         \OCP\Util::writeLog('core', "user:" . \OCP\User::getDisplayName() . " action:login success", \OCP\Util::INFO);
     };
     $logoutRecord = function () {
         \OCP\Util::writeLog('core', "user:" . \OCP\User::getDisplayName() . " action:logout success", \OCP\Util::INFO);
     };
     $createRecord = function ($node) {
         \OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:cretes " . $node->getName() . " sucess", \OCP\Util::INFO);
     };
     $deleteRecord = function ($node) {
         \OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:deletes " . $node->getName() . " sucess", \OCP\Util::INFO);
     };
     $renameRecord = function ($node) {
         \OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:renames " . $node->getName() . " sucess", \OCP\Util::INFO);
     };
     $touchRecord = function ($node) {
         \OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:touches " . $node->getName() . " sucess", \OCP\Util::INFO);
     };
     $this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
     $this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
 }
开发者ID:JuliusChen,项目名称:owncloud-log_extension,代码行数:26,代码来源:userhooks.php

示例7: scan

 public static function scan($id, $path, $storage)
 {
     $file = $storage->getLocalFile($path);
     $result = OC_Files_Antivirus::clamav_scan($file);
     switch ($result) {
         case CLAMAV_SCANRESULT_UNCHECKED:
             \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR);
             break;
         case CLAMAV_SCANRESULT_INFECTED:
             $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
             if ($infected_action == 'delete') {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR);
                 unlink($file);
             } else {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR);
             }
             break;
         case CLAMAV_SCANRESULT_CLEAN:
             $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
             try {
                 $result = $stmt->execute(array($id, time()));
                 if (\OC_DB::isError($result)) {
                     \OC_Log::write('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             }
             break;
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:scanner.php

示例8: rotate

 protected function rotate($logfile)
 {
     $rotatedLogfile = $logfile . '.1';
     rename($logfile, $rotatedLogfile);
     $msg = 'Log file "' . $logfile . '" was over ' . $this->max_log_size . ' bytes, moved to "' . $rotatedLogfile . '"';
     \OCP\Util::writeLog('OC\\Log\\Rotate', $msg, \OCP\Util::WARN);
 }
开发者ID:evanjt,项目名称:core,代码行数:7,代码来源:rotate.php

示例9: getThumbnail

	/**
	 * {@inheritDoc}
	 */
	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
		try {
			$svg = new \Imagick();
			$svg->setBackgroundColor(new \ImagickPixel('transparent'));

			$content = stream_get_contents($fileview->fopen($path, 'r'));
			if (substr($content, 0, 5) !== '<?xml') {
				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
			}

			// Do not parse SVG files with references
			if (stripos($content, 'xlink:href') !== false) {
				return false;
			}

			$svg->readImageBlob($content);
			$svg->setImageFormat('png32');
		} catch (\Exception $e) {
			\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
			return false;
		}

		//new image object
		$image = new \OC_Image();
		$image->loadFromData($svg);
		//check if image object is valid
		if ($image->valid()) {
			$image->scaleDownToFit($maxX, $maxY);

			return $image;
		}
		return false;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:36,代码来源:svg.php

示例10: getThumbnail

 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
     $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
     $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
     $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
     shell_exec($exec);
     //create imagick object from pdf
     $pdfPreview = null;
     try {
         list($dirname, , , $filename) = array_values(pathinfo($absPath));
         $pdfPreview = $dirname . '/' . $filename . '.pdf';
         $pdf = new \imagick($pdfPreview . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($pdfPreview);
         \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($pdfPreview);
     if ($image->valid()) {
         $image->scaleDownToFit($maxX, $maxY);
         return $image;
     }
     return false;
 }
开发者ID:loulancn,项目名称:core,代码行数:38,代码来源:office.php

示例11: scan

 protected function scan($fileView, $filepath)
 {
     $this->status = new Status();
     $fhandler = $this->getFileHandle($fileView, $filepath);
     \OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
     // using 2>&1 to grab the full command-line output.
     $cmd = escapeshellcmd($this->avPath) . " - 2>&1";
     $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     $pipes = array();
     $process = proc_open($cmd, $descriptorSpec, $pipes);
     if (!is_resource($process)) {
         fclose($fhandler);
         throw new \RuntimeException('Error starting process');
     }
     // write to stdin
     $shandler = $pipes[0];
     while (!feof($fhandler)) {
         $chunk = fread($fhandler, $this->chunkSize);
         fwrite($shandler, $chunk);
     }
     fclose($shandler);
     fclose($fhandler);
     $output = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $result = proc_close($process);
     $this->status->parseResponse($output, $result);
     return $this->status->getNumericStatus();
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:28,代码来源:local.php

示例12: register

 public function register()
 {
     $loginRecord = function ($user) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:login success", Util::INFO);
     };
     $logoutRecord = function () {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $this->UserRole . " action:logout success", Util::INFO);
     };
     $createRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
     };
     $deleteRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
     };
     $renameRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
     };
     $touchRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
     };
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
     $this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
     $this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
 }
开发者ID:inwinstack,项目名称:owncloud-activity_logging,代码行数:33,代码来源:userhooks.php

示例13: get_realm

 public static function get_realm()
 {
     $appConfig = \OC::$server->getAppConfig();
     $result = $appConfig->getValue('privacyIDEA', 'realm', '');
     \OCP\Util::writeLog('user_privacyidea', "Getting result for realm: {$result}", \OCP\Util::DEBUG);
     return $result;
 }
开发者ID:vDorst,项目名称:privacyidea,代码行数:7,代码来源:helper.php

示例14: sendMail

 public static function sendMail($path)
 {
     if (!\OCP\User::isLoggedIn()) {
         return;
     }
     $config = \OC::$server->getConfig();
     $user = \OC::$server->getUserSession()->getUser();
     $email = $user->getEMailAddress();
     $displayName = $user->getDisplayName();
     if (strval($displayName) === '') {
         $displayName = $user->getUID();
     }
     \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
     if (!empty($email)) {
         try {
             $tmpl = new \OCP\Template('files_antivirus', 'notification');
             $tmpl->assign('file', $path);
             $tmpl->assign('host', \OC::$server->getRequest()->getServerHost());
             $tmpl->assign('user', $displayName);
             $msg = $tmpl->fetchPage();
             $from = \OCP\Util::getDefaultEmailAddress('security-noreply');
             $mailer = \OC::$server->getMailer();
             $message = $mailer->createMessage();
             $message->setSubject(\OCP\Util::getL10N('files_antivirus')->t('Malware detected'));
             $message->setFrom([$from => 'ownCloud Notifier']);
             $message->setTo([$email => $displayName]);
             $message->setPlainBody($msg);
             $message->setHtmlBody($msg);
             $mailer->send($message);
         } catch (\Exception $e) {
             \OC::$server->getLogger()->error(__METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']);
         }
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:34,代码来源:notification.php

示例15: __construct

 /**
  * if session is started, check if ownCloud key pair is set up, if not create it
  * @param \OC\Files\View $view
  *
  * @note The ownCloud key pair is used to allow public link sharing even if encryption is enabled
  */
 public function __construct($view)
 {
     $this->view = $view;
     if (!$this->view->is_dir('files_encryption')) {
         $this->view->mkdir('files_encryption');
     }
     $appConfig = \OC::$server->getAppConfig();
     $publicShareKeyId = Helper::getPublicShareKeyId();
     if ($publicShareKeyId === false) {
         $publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8);
         $appConfig->setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId);
     }
     if (!Keymanager::publicShareKeyExists($view)) {
         $keypair = Crypt::createKeypair();
         // Save public key
         Keymanager::setPublicKey($keypair['publicKey'], $publicShareKeyId);
         // Encrypt private key empty passphrase
         $cipher = Helper::getCipher();
         $encryptedKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], '', $cipher);
         if ($encryptedKey) {
             Keymanager::setPrivateSystemKey($encryptedKey, $publicShareKeyId);
         } else {
             \OCP\Util::writeLog('files_encryption', 'Could not create public share keys', \OCP\Util::ERROR);
         }
     }
     if (Helper::isPublicAccess() && !self::getPublicSharePrivateKey()) {
         // Disable encryption proxy to prevent recursive calls
         $proxyStatus = \OC_FileProxy::$enabled;
         \OC_FileProxy::$enabled = false;
         $encryptedKey = Keymanager::getPrivateSystemKey($publicShareKeyId);
         $privateKey = Crypt::decryptPrivateKey($encryptedKey, '');
         self::setPublicSharePrivateKey($privateKey);
         \OC_FileProxy::$enabled = $proxyStatus;
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:41,代码来源:session.php


注:本文中的OCP\Util::writeLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。