本文整理汇总了PHP中OCP\Config::getAppValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getAppValue方法的具体用法?PHP Config::getAppValue怎么用?PHP Config::getAppValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Config
的用法示例。
在下文中一共展示了Config::getAppValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scan
protected function scan($fileView, $filepath)
{
$this->status = new Status();
if ($this->useSocket) {
$av_socket = \OCP\Config::getAppValue('files_antivirus', 'av_socket', '');
$shandler = stream_socket_client('unix://' . $av_socket, $errno, $errstr, 5);
if (!$shandler) {
throw new \RuntimeException('Cannot connect to "' . $av_socket . '": ' . $errstr . ' (code ' . $errno . ')');
}
} else {
$av_host = \OCP\Config::getAppValue('files_antivirus', 'av_host', '');
$av_port = \OCP\Config::getAppValue('files_antivirus', 'av_port', '');
$shandler = $av_host && $av_port ? @fsockopen($av_host, $av_port) : false;
if (!$shandler) {
throw new \RuntimeException('The clamav module is not configured for daemon mode.');
}
}
$fhandler = $this->getFileHandle($fileView, $filepath);
\OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
// request scan from the daemon
fwrite($shandler, "nINSTREAM\n");
while (!feof($fhandler)) {
$chunk = fread($fhandler, $this->chunkSize);
$chunk_len = pack('N', strlen($chunk));
fwrite($shandler, $chunk_len . $chunk);
}
fwrite($shandler, pack('N', 0));
$response = fgets($shandler);
\OCP\Util::writeLog('files_antivirus', 'Response :: ' . $response, \OCP\Util::DEBUG);
fclose($shandler);
fclose($fhandler);
$this->status->parseResponse($response);
return $this->status->getNumericStatus();
}
示例2: getSites
public static function getSites()
{
if (($sites = json_decode(\OCP\Config::getAppValue("external", "sites", ''))) != null) {
return $sites;
}
return array();
}
示例3: 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;
}
}
示例4: backendStatus
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function backendStatus()
{
$response = new JSONResponse();
$params = $this->request->urlParams;
$backend = $params['backend'];
$enabled = \OCP\Config::getAppValue('contacts', 'backend_' . $backend, "false");
return $response->setData($enabled);
}
示例5: __construct
public function __construct($user = null, $addressBooksTableName = '*PREFIX*addressbook', $backendsTableName = '*PREFIX*addressbooks_backend', $dbBackend = null)
{
$this->user = $user ? $user : \OC::$server->getUserSession()->getUser()->getUId();
$this->addressBooksTableName = $addressBooksTableName;
$this->backendsTableName = $backendsTableName;
$this->dbBackend = $dbBackend ? $dbBackend : new Backend\Database($user);
if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") {
self::$backendClasses['ldap'] = 'OCA\\Contacts\\Backend\\Ldap';
}
}
示例6: __construct
public function __construct()
{
parent::__construct();
// get the path to the executable
$avPath = \OCP\Config::getAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan');
// check that the executable is available
if (!file_exists($avPath)) {
throw new \RuntimeException('The antivirus executable could not be found at ' . $avPath);
}
$this->avPath = $avPath;
}
示例7: isSecure
function isSecure()
{
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (false !== strpos($url, 'd=1')) {
OC_Log::write('passwords', 'Passwords app accessed without secure connection.', OC_Log::WARN);
return true;
}
// test if at least one is true in:
// (1) header, (2) port number, (3) config.php setting, (4) admin setting
return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 || \OC_Config::getValue('forcessl', '') || \OCP\Config::getAppValue('passwords', 'https_check', 'true') == 'false';
}
示例8: getVersions
/**
* Returns the list of allowed "versions"
* @return array
*/
public static function getVersions()
{
$versions = array();
$result = json_decode(\OCP\Config::getAppValue('user_files_restore', 'versions', ''));
if (is_array($result)) {
foreach ($result as $item) {
array_push($versions, $item);
}
}
return $versions;
}
示例9: __construct
public function __construct()
{
$this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
$this->cas_link_to_ldap_backend = \OCP\Config::getAppValue('user_cas', 'cas_link_to_ldap_backend', false);
$this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
$this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
$this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
$this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
$this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
$this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
self::initialized_php_cas();
}
示例10: __construct
/**
* Initialize Image data handler
*/
function __construct()
{
// Check if ImageMagick is enabled; use standard GD otherwise
$useImageMagick = intval(\OCP\Config::getAppValue('oclife', 'useImageMagick'));
$this->imagick = extension_loaded('imagick') && $useImageMagick === 1;
if ($this->imagick) {
$this->handableImageType = array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'xbm', 'nef', 'cr2', 'tif', 'pcd');
} else {
$this->handableImageType = array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'xbm');
}
// Set default background color as black
$this->htmlBgColor = '#000000';
$this->setColorFromHTML($this->htmlBgColor);
}
示例11: initializeUser
public function initializeUser($attr)
{
//check backend status
if (!$this->enabled) {
return false;
}
//retrieve UUID from LDAP server
$this->connect();
$linkattr = \OCP\Config::getAppValue('user_shibboleth', 'ldap_link_attribute', 'mail');
$uuidattr = \OCP\Config::getAppValue('user_shibboleth', 'ldap_uuid_attribute', 'dn');
$filter = $linkattr . '=' . $attr;
$result = $this->access->searchUsers($filter, $uuidattr);
if (count($result) === 1) {
return $this->access->dn2ocname($result[0]);
}
return false;
}
示例12: shouldEncrypt
/**
* Check if a file requires encryption
* @param string $path
* @return bool
*
* Tests if server side encryption is enabled, and file is allowed by blacklists
*/
private static function shouldEncrypt($path)
{
$userId = Helper::getUser($path);
if (\OCP\App::isEnabled('files_encryption') === false || Crypt::mode() !== 'server' || strpos($path, '/' . $userId . '/files') !== 0) {
return false;
}
if (is_null(self::$blackList)) {
self::$blackList = explode(',', \OCP\Config::getAppValue('files_encryption', 'type_blacklist', ''));
}
if (Crypt::isCatfileContent($path)) {
return true;
}
$extension = substr($path, strrpos($path, '.') + 1);
if (array_search($extension, self::$blackList) === false) {
return true;
}
return false;
}
示例13: setUp
public function setUp()
{
\OC_User::clearBackends();
\OC_User::useBackend(new \OC_User_Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
\OC\Files\Filesystem::clearMounts();
$textData = "sample file\n";
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->storage->file_put_contents(self::TEST_CLEAN_FILENAME, $textData);
$this->storage->file_put_contents(self::TEST_INFECTED_FILENAME, $textData);
\OC\Files\Filesystem::mount($this->storage, array(), '/');
$this->config['av_mode'] = \OCP\Config::getAppValue('files_antivirus', 'av_mode', null);
$this->config['av_path'] = \OCP\Config::getAppValue('files_antivirus', 'av_path', null);
\OCP\Config::setAppValue('files_antivirus', 'av_mode', 'executable');
\OCP\Config::setAppValue('files_antivirus', 'av_path', __DIR__ . '/avir.sh');
}
示例14: webStep
private static function webStep()
{
// Iterate over all users
$lastid = \OCP\Config::getAppValue('news', 'backgroundjob_lastid', 0);
$feedmapper = new FeedMapper();
$feeds = $feedmapper->findAll();
usort($feeds, array('OCA\\News\\Backgroundjob', 'sortFeeds'));
$done = false;
foreach ($feeds as $feed) {
if ($feed['id'] > $lastid) {
// set lastid BEFORE updating feed!
\OCP\Config::setAppValue('news', 'backgroundjob_lastid', $feed['id']);
$done = true;
self::updateFeed($feedmapper, $feed);
}
}
if (!$done) {
\OCP\Config::setAppValue('news', 'backgroundjob_lastid', 0);
}
}
示例15: scan
public static function scan($id, $path, $storage)
{
$fileStatus = \OCA\Files_Antivirus\Scanner::scanFile($storage, $path);
$result = $fileStatus->getNumericStatus();
//TODO: Fix undefined $user here
switch ($result) {
case \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED:
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is not checked', \OCP\Util::ERROR);
break;
case \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED:
$infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
if ($infected_action == 'delete') {
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is infected, file deleted', \OCP\Util::ERROR);
$storage->unlink($path);
} else {
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is infected', \OCP\Util::ERROR);
}
break;
case \OCA\Files_Antivirus\Status::SCANRESULT_CLEAN:
try {
$stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*files_antivirus` WHERE `fileid` = ?');
$result = $stmt->execute(array($id));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return;
}
$stmt = \OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
$result = $stmt->execute(array($id, time()));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('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;
}
}