Exemplo n.º 1
0
 /**
  * Init class data
  */
 public static function init()
 {
     $defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log';
     self::$logFile = OC_Config::getValue("logfile", $defaultLogFile);
     if (!file_exists(self::$logFile)) {
         self::$logFile = $defaultLogFile;
     }
 }
Exemplo n.º 2
0
 public function testMicrosecondsLogTimestamp()
 {
     # delete old logfile
     unlink(OC_Config::getValue('logfile'));
     # set format & write log line
     OC_Config::setValue('logdateformat', 'u');
     OC_Log_Owncloud::write('test', 'message', \OCP\Util::ERROR);
     # read log line
     $handle = @fopen(OC_Config::getValue('logfile'), 'r');
     $line = fread($handle, 1000);
     fclose($handle);
     # check timestamp has microseconds part
     $values = (array) json_decode($line);
     $microseconds = $values['time'];
     $this->assertNotEquals(0, $microseconds);
 }
Exemplo n.º 3
0
 /**
  * Init class data
  */
 public static function init()
 {
     $defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log';
     self::$logFile = OC_Config::getValue("logfile", $defaultLogFile);
     /*
      * Fall back to default log file if specified logfile does not exist
      * and can not be created. Error suppression is required in order to
      * not end up in the error handler which will try to log the error.
      * A better solution (compared to error suppression) would be checking
      * !is_writable(dirname(self::$logFile)) before touch(), but
      * is_writable() on directories used to be pretty unreliable on Windows
      * for at least some time.
      */
     if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
         self::$logFile = $defaultLogFile;
     }
 }
Exemplo n.º 4
0
 /**
  * Init class data
  */
 public static function init()
 {
     $systemConfig = \OC::$server->getSystemConfig();
     $defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log';
     self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
     /**
      * Fall back to default log file if specified logfile does not exist
      * and can not be created.
      */
     if (!file_exists(self::$logFile)) {
         if (!is_writable(dirname(self::$logFile))) {
             self::$logFile = $defaultLogFile;
         } else {
             if (!touch(self::$logFile)) {
                 self::$logFile = $defaultLogFile;
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * write a message in the log
  * @param string $app
  * @param string $message
  * @param int $level
  */
 public static function write($app, $message, $level)
 {
     $minLevel = min(OC_Config::getValue("loglevel", OC_Log::WARN), OC_Log::ERROR);
     if ($level >= $minLevel) {
         // default to ISO8601
         $format = OC_Config::getValue('logdateformat', 'c');
         $logtimezone = OC_Config::getValue("logtimezone", 'UTC');
         try {
             $timezone = new DateTimeZone($logtimezone);
         } catch (Exception $e) {
             $timezone = new DateTimeZone('UTC');
         }
         $time = new DateTime(null, $timezone);
         // remove username/passwords from URLs before writing the to the log file
         $time = $time->format($format);
         if ($minLevel == OC_Log::DEBUG) {
             if (empty(self::$reqId)) {
                 self::$reqId = uniqid();
             }
             $reqId = self::$reqId;
             $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '--';
             $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '--';
             $entry = compact('reqId', 'app', 'message', 'level', 'time', 'method', 'url');
         } else {
             $entry = compact('app', 'message', 'level', 'time');
         }
         $entry = json_encode($entry);
         $handle = @fopen(self::$logFile, 'a');
         @chmod(self::$logFile, 0640);
         if ($handle) {
             fwrite($handle, $entry . "\n");
             fclose($handle);
         } else {
             // Fall back to error_log
             error_log($entry);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * download logfile
  *
  * @NoCSRFRequired
  *
  * @return StreamResponse
  */
 public function download()
 {
     $resp = new StreamResponse(\OC_Log_Owncloud::getLogFilePath());
     $resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"');
     return $resp;
 }
Exemplo n.º 7
0
<?php

/**
 * Copyright (c) 2011, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
require_once '../lib/base.php';
OC_Util::checkAdminUser();
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("settings", "admin");
OC_Util::addScript("settings", "log");
OC_App::setActiveNavigationEntry("admin");
$tmpl = new OC_Template('settings', 'admin', 'user');
$forms = OC_App::getForms('admin');
$entries = OC_Log_Owncloud::getEntries(3);
function compareEntries($a, $b)
{
    return $b->time - $a->time;
}
usort($entries, 'compareEntries');
$tmpl->assign('loglevel', OC_Config::getValue("loglevel", 2));
$tmpl->assign('entries', $entries);
$tmpl->assign('forms', array());
foreach ($forms as $form) {
    $tmpl->append('forms', $form);
}
$tmpl->printPage();
Exemplo n.º 8
0
/**
 * Copyright (c) 2011, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
require_once '../lib/base.php';
OC_Util::checkAdminUser();
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("settings", "admin");
OC_Util::addScript("settings", "log");
OC_App::setActiveNavigationEntry("admin");
$tmpl = new OC_Template('settings', 'admin', 'user');
$forms = OC_App::getForms('admin');
$htaccessworking = OC_Util::ishtaccessworking();
$entries = OC_Log_Owncloud::getEntries(3);
$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3 ? true : false;
function compareEntries($a, $b)
{
    return $b->time - $a->time;
}
usort($entries, 'compareEntries');
$tmpl->assign('loglevel', OC_Config::getValue("loglevel", 2));
$tmpl->assign('entries', OC_Util::sanitizeHTML($entries));
$tmpl->assign('entriesremain', $entriesremain);
$tmpl->assign('htaccessworking', $htaccessworking);
$tmpl->assign('forms', array());
foreach ($forms as $form) {
    $tmpl->append('forms', $form);
}
$tmpl->printPage();
Exemplo n.º 9
0
<?php

/**
 * Copyright (c) 2012, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkAdminUser();
$count = isset($_GET['count']) ? $_GET['count'] : 50;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$entries = OC_Log_Owncloud::getEntries($count, $offset);
OC_JSON::success(array("data" => $entries));
Exemplo n.º 10
0
 /**
  * Init class data
  */
 public static function init()
 {
     $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data');
     self::$logFile = OC_Config::getValue("logfile", $datadir . '/owncloud.log');
 }
Exemplo n.º 11
0
 */
OC_Util::checkAdminUser();
OCP\Util::addStyle('settings', 'settings');
OCP\Util::addScript('settings', 'settings');
OCP\Util::addScript("settings", "admin");
OCP\Util::addScript("settings", "log");
OCP\Util::addScript('core', 'multiselect');
OCP\Util::addScript('core', 'select2/select2');
OCP\Util::addStyle('core', 'select2/select2');
OCP\Util::addScript('core', 'setupchecks');
OC_App::setActiveNavigationEntry("admin");
$tmpl = new OC_Template('settings', 'admin', 'user');
$forms = OC_App::getForms('admin');
$htaccessworking = OC_Util::isHtaccessWorking();
$entries = OC_Log_Owncloud::getEntries(3);
$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
$config = \OC::$server->getConfig();
// Should we display sendmail as an option?
$tmpl->assign('sendmail_is_available', (bool) findBinaryPath('sendmail'));
$tmpl->assign('loglevel', OC_Config::getValue("loglevel", 2));
$tmpl->assign('mail_domain', OC_Config::getValue("mail_domain", ''));
$tmpl->assign('mail_from_address', OC_Config::getValue("mail_from_address", ''));
$tmpl->assign('mail_smtpmode', OC_Config::getValue("mail_smtpmode", ''));
$tmpl->assign('mail_smtpsecure', OC_Config::getValue("mail_smtpsecure", ''));
$tmpl->assign('mail_smtphost', OC_Config::getValue("mail_smtphost", ''));
$tmpl->assign('mail_smtpport', OC_Config::getValue("mail_smtpport", ''));
$tmpl->assign('mail_smtpauthtype', OC_Config::getValue("mail_smtpauthtype", ''));
$tmpl->assign('mail_smtpauth', OC_Config::getValue("mail_smtpauth", false));
$tmpl->assign('mail_smtpname', OC_Config::getValue("mail_smtpname", ''));
$tmpl->assign('mail_smtppassword', OC_Config::getValue("mail_smtppassword", ''));
$tmpl->assign('entries', $entries);
Exemplo n.º 12
0
<?php

/**
 * Copyright (c) 2012, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_JSON::checkAdminUser();
$count = isset($_GET['count']) ? $_GET['count'] : 50;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$entries = OC_Log_Owncloud::getEntries($count, $offset);
$data = array();
OC_JSON::success(array("data" => $entries, "remain" => count(OC_Log_Owncloud::getEntries(1, $offset + $offset)) != 0 ? true : false));
Exemplo n.º 13
0
<?php

/**
 * Copyright (c) 2012, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_JSON::checkAdminUser();
$count = isset($_GET['count']) ? $_GET['count'] : 50;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$entries = OC_Log_Owncloud::getEntries($count, $offset);
$data = array();
OC_JSON::success(array("data" => $entries, "remain" => count(OC_Log_Owncloud::getEntries(1, $offset + $count)) !== 0));
Exemplo n.º 14
0
<?php

/**
 * Copyright (c) 2011, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_Util::checkAdminUser();
OC_App::setActiveNavigationEntry("admin");
$template = new OC_Template('settings', 'admin', 'user');
$htAccessWorking = OC_Util::isHtaccessWorking();
$entries = OC_Log_Owncloud::getEntries(3);
$entriesRemaining = count(OC_Log_Owncloud::getEntries(4)) > 3;
$config = \OC::$server->getConfig();
$appConfig = \OC::$server->getAppConfig();
// Should we display sendmail as an option?
$template->assign('sendmail_is_available', (bool) findBinaryPath('sendmail'));
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
$template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
$template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
$template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
$template->assign('entries', $entries);
$template->assign('entriesremain', $entriesRemaining);
$template->assign('htaccessworking', $htAccessWorking);
Exemplo n.º 15
0
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
use OC\Lock\NoopLockingProvider;
OC_Util::checkAdminUser();
OC_App::setActiveNavigationEntry("admin");
$template = new OC_Template('settings', 'admin', 'user');
$l = OC_L10N::get('settings');
$showLog = \OC::$server->getConfig()->getSystemValue('log_type', 'owncloud') === 'owncloud';
$numEntriesToLoad = 3;
$entries = OC_Log_Owncloud::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFilePath = OC_Log_Owncloud::getLogFilePath();
$doesLogFileExist = file_exists($logFilePath);
$logFileSize = filesize($logFilePath);
$config = \OC::$server->getConfig();
$appConfig = \OC::$server->getAppConfig();
$request = \OC::$server->getRequest();
// Should we display sendmail as an option?
$template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
Exemplo n.º 16
0
<?php

/**
 * Copyright (c) 2012, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_JSON::checkAdminUser();
$count = isset($_GET['count']) ? $_GET['count'] : 50;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$entries = OC_Log_Owncloud::getEntries($count, $offset);
OC_JSON::success(array("data" => OC_Util::sanitizeHTML($entries), "remain" => count(OC_Log_Owncloud::getEntries(1, $offset + $offset)) != 0 ? true : false));
 /**
  * download logfile
  *
  * @NoCSRFRequired
  *
  * @return DataDownloadResponse
  */
 public function download()
 {
     return new DataDownloadResponse(json_encode(\OC_Log_Owncloud::getEntries(null, null)), $this->getFilenameForDownload(), 'application/json');
 }