本文整理汇总了PHP中OC_Log::write方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Log::write方法的具体用法?PHP OC_Log::write怎么用?PHP OC_Log::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Log
的用法示例。
在下文中一共展示了OC_Log::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPassword
public function checkPassword($uid, $password)
{
$uid = strtolower($uid);
$unix_user = posix_getpwnam($uid);
// checks if the Unix UID number is allowed to connect
if (empty($unix_user)) {
return false;
}
//user does not exist
if (!in_array($unix_user['uid'], $this->pwauth_uid_list)) {
return false;
}
$handle = popen($this->pwauth_bin_path, 'w');
if ($handle === false) {
// Can't open pwauth executable
OC_Log::write('OC_USER_PWAUTH', 'Cannot open pwauth executable, check that it is installed on server.', 3);
return false;
}
if (fwrite($handle, "{$uid}\n{$password}\n") === false) {
// Can't pipe uid and password
return false;
}
// Is the password valid?
$result = pclose($handle);
if ($result == 0) {
return $uid;
}
return false;
}
示例2: prepare
/**
* Prepares an SQL statement.
*
* @param string $statement The SQL statement to prepare.
* @param int $limit
* @param int $offset
* @return \Doctrine\DBAL\Driver\Statement The prepared statement.
*/
public function prepare($statement, $limit = null, $offset = null)
{
if ($limit === -1) {
$limit = null;
}
if (!is_null($limit)) {
$platform = $this->getDatabasePlatform();
$statement = $platform->modifyLimitQuery($statement, $limit, $offset);
} else {
if (isset($this->preparedQueries[$statement]) && $this->cachingQueryStatementEnabled) {
return $this->preparedQueries[$statement];
}
$origStatement = $statement;
}
$statement = $this->replaceTablePrefix($statement);
$statement = $this->adapter->fixupStatement($statement);
if (\OC_Config::getValue('log_query', false)) {
\OC_Log::write('core', 'DB prepare : ' . $statement, \OC_Log::DEBUG);
}
$result = parent::prepare($statement);
if (is_null($limit) && $this->cachingQueryStatementEnabled) {
$this->preparedQueries[$origStatement] = $result;
}
return $result;
}
示例3: getThumbnail
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = get_temp_dir();
$defaultParameters = ' --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);
$export = 'export HOME=/' . $tmpDir;
shell_exec($export . "\n" . $exec);
//create imagick object from pdf
try {
$pdf = new \imagick($absPath . '.pdf' . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($absPath . '.pdf');
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($absPath . '.pdf');
return $image->valid() ? $image : false;
}
示例4: insertIfNotExist
/**
* insert the @input values when they do not exist yet
* @param string $table name
* @param array $input key->value pairs
* @return int count of inserted rows
*/
public function insertIfNotExist($table, $input)
{
$query = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($input)) . '`) SELECT ' . str_repeat('?,', count($input) - 1) . '? ' . 'FROM `' . $table . '` WHERE ';
$inserts = array_values($input);
foreach ($input as $key => $value) {
$query .= '`' . $key . '`';
if (is_null($value)) {
$query .= ' IS NULL AND ';
} else {
$inserts[] = $value;
$query .= ' = ? AND ';
}
}
$query = substr($query, 0, strlen($query) - 5);
$query .= ' HAVING COUNT(*) = 0';
try {
return $this->conn->executeUpdate($query, $inserts);
} catch (\Doctrine\DBAL\DBALException $e) {
$entry = 'DB Error: "' . $e->getMessage() . '"<br />';
$entry .= 'Offending command was: ' . $query . '<br />';
\OC_Log::write('core', $entry, \OC_Log::FATAL);
error_log('DB error: ' . $entry);
\OC_Template::printErrorPage($entry);
}
}
示例5: insertIfNotExist
/**
* insert the @input values when they do not exist yet
* @param string $table name
* @param array $input key->value pair, key has to be sanitized properly
* @throws \OC\HintException
* @return int count of inserted rows
*/
public function insertIfNotExist($table, $input)
{
$query = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($input)) . '`) SELECT ' . str_repeat('?,', count($input) - 1) . '? ' . 'FROM `' . $table . '` WHERE ';
$inserts = array_values($input);
foreach ($input as $key => $value) {
$query .= '`' . $key . '`';
if (is_null($value)) {
$query .= ' IS NULL AND ';
} else {
$inserts[] = $value;
$query .= ' = ? AND ';
}
}
$query = substr($query, 0, strlen($query) - 5);
$query .= ' HAVING COUNT(*) = 0';
try {
return $this->conn->executeUpdate($query, $inserts);
} catch (\Doctrine\DBAL\DBALException $e) {
$entry = 'DB Error: "' . $e->getMessage() . '"<br />';
$entry .= 'Offending command was: ' . $query . '<br />';
\OC_Log::write('core', $entry, \OC_Log::FATAL);
$l = \OC::$server->getL10N('lib');
throw new \OC\HintException($l->t('Database Error'), $l->t('Please contact your system administrator.'), 0, $e);
}
}
示例6: getThumbnail
public function getThumbnail($path)
{
$gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
if (file_exists($gallery_path . $path)) {
return new \OC_Image($gallery_path . $path);
}
if (!\OC_Filesystem::file_exists($path)) {
\OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
return false;
}
$image = new \OC_Image();
$image->loadFromFile(\OC_Filesystem::getLocalFile($path));
if (!$image->valid()) {
return false;
}
$image->fixOrientation();
$ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
if (!$ret) {
\OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
unset($image);
return false;
}
$image->save($gallery_path . '/' . $path);
return $image;
}
示例7: emit
/**
* emits a signal
*
* @param string $signalClass class name of emitter
* @param string $signalName name of signal
* @param mixed $params default: array() array with additional data
* @return bool true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
*
* TODO: write example
*/
public static function emit($signalClass, $signalName, $params = array())
{
// Return false if no hook handlers are listening to this
// emitting class
if (!array_key_exists($signalClass, self::$registered)) {
return false;
}
// Return false if no hook handlers are listening to this
// emitting method
if (!array_key_exists($signalName, self::$registered[$signalClass])) {
return false;
}
// Call all slots
foreach (self::$registered[$signalClass][$signalName] as $i) {
try {
call_user_func(array($i["class"], $i["name"]), $params);
} catch (Exception $e) {
self::$thrownExceptions[] = $e;
$class = $i["class"];
if (is_object($i["class"])) {
$class = get_class($i["class"]);
}
$message = $e->getMessage();
if (empty($message)) {
$message = get_class($e);
}
OC_Log::write('hook', 'error while running hook (' . $class . '::' . $i["name"] . '): ' . $message, OC_Log::ERROR);
if ($e instanceof \OC\ServerNotAvailableException) {
throw $e;
}
}
}
// return true
return true;
}
示例8: emit
/**
* emits a signal
* @param string $signalclass class name of emitter
* @param string $signalname name of signal
* @param mixed $params default: array() array with additional data
* @return bool, true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
*
* TODO: write example
*/
public static function emit($signalclass, $signalname, $params = array())
{
// Return false if no hook handlers are listening to this
// emitting class
if (!array_key_exists($signalclass, self::$registered)) {
return false;
}
// Return false if no hook handlers are listening to this
// emitting method
if (!array_key_exists($signalname, self::$registered[$signalclass])) {
return false;
}
// Call all slots
foreach (self::$registered[$signalclass][$signalname] as $i) {
try {
call_user_func(array($i["class"], $i["name"]), $params);
} catch (Exception $e) {
OC_Log::write('hook', 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): ' . $e->getMessage(), OC_Log::ERROR);
if ($e instanceof \OC\ServerNotAvailableException && $signalclass === 'OC_Filesystem' && $signalname === 'setup') {
throw $e;
}
}
}
// return true
return true;
}
示例9: getThumbnail
/**
* {@inheritDoc}
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = get_temp_dir();
$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);
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($pdfPreview);
return $image->valid() ? $image : false;
}
示例10: getThumbnail
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) {
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
//new image object
$image = new \OC_Image();
$image->loadFromData($svg);
//check if image object is valid
return $image->valid() ? $image : false;
}
示例11: 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 . '"';
\OC_Log::write('OC\\Log\\Rotate', $msg, \OC_Log::WARN);
}
示例12: run
/**
*
*/
function run()
{
if ($this->checkGet('app', 'usv2')) {
$uid = $this->tokens->getUserId();
if ($uid === false || $uid === null) {
if ($this->appConfig->getValue('user_servervars2', 'stop_if_empty', false)) {
throw new \Exception('token error');
}
// Danger: possibilité de fabriquer une boucle avec janus
$ssoURL = $this->appConfig->getValue('user_servervars2', 'sso_url', 'http://localhost/sso');
$this->redirector->redirectTo($ssoURL);
} else {
$isLoggedIn = $this->uag->isLoggedIn();
if (!$isLoggedIn) {
$isLoggedIn = $this->uag->login($uid);
}
if (!$isLoggedIn) {
// if ( !$this->uag->isLoggedIn()) {
\OC_Log::write('servervars', 'Error trying to log-in the user' . $uid, \OC_Log::DEBUG);
return;
}
\OC::$REQUESTEDAPP = '';
$this->redirector->redirectToDefaultPage();
}
}
}
示例13: 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;
}
}
示例14: send
/**
* send an email
*
* @param string $toaddress
* @param string $toname
* @param string $subject
* @param string $mailtext
* @param string $fromaddress
* @param string $fromname
* @param bool $html
*/
public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '')
{
$SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail');
$SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1');
$SMTPAUTH = OC_Config::getValue('mail_smtpauth', false);
$SMTPUSERNAME = OC_Config::getValue('mail_smtpname', '');
$SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', '');
$mailo = new PHPMailer(true);
if ($SMTPMODE == 'sendmail') {
$mailo->IsSendmail();
} elseif ($SMTPMODE == 'smtp') {
$mailo->IsSMTP();
} elseif ($SMTPMODE == 'qmail') {
$mailo->IsQmail();
} else {
$mailo->IsMail();
}
$mailo->Host = $SMTPHOST;
$mailo->SMTPAuth = $SMTPAUTH;
$mailo->Username = $SMTPUSERNAME;
$mailo->Password = $SMTPPASSWORD;
$mailo->From = $fromaddress;
$mailo->FromName = $fromname;
$mailo->Sender = $fromaddress;
$a = explode(' ', $toaddress);
try {
foreach ($a as $ad) {
$mailo->AddAddress($ad, $toname);
}
if ($ccaddress != '') {
$mailo->AddCC($ccaddress, $ccname);
}
if ($bcc != '') {
$mailo->AddBCC($bcc);
}
$mailo->AddReplyTo($fromaddress, $fromname);
$mailo->WordWrap = 50;
if ($html == 1) {
$mailo->IsHTML(true);
} else {
$mailo->IsHTML(false);
}
$mailo->Subject = $subject;
if ($altbody == '') {
$mailo->Body = $mailtext . OC_MAIL::getfooter();
$mailo->AltBody = '';
} else {
$mailo->Body = $mailtext;
$mailo->AltBody = $altbody;
}
$mailo->CharSet = 'UTF-8';
$mailo->Send();
unset($mailo);
OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG);
} catch (Exception $exception) {
OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
throw $exception;
}
}
示例15: logout
public static function logout($parameters)
{
$samlBackend = new OC_USER_SAML();
if ($samlBackend->auth->isAuthenticated()) {
OC_Log::write('saml', 'Executing SAML logout: ' . $parameters['uid'], OC_Log::DEBUG);
$samlBackend->auth->logout();
}
return true;
}