diff options
-rw-r--r-- | apps/files/ajax/download.php | 2 | ||||
-rw-r--r-- | apps/files/ajax/list.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/settings-personal.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/amazons3.php | 2 | ||||
-rwxr-xr-x | apps/files_external/lib/config.php | 12 | ||||
-rw-r--r-- | apps/files_external/lib/sftp.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/public.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/css/settings.css | 8 | ||||
-rw-r--r-- | apps/user_ldap/js/settings.js | 7 | ||||
-rw-r--r-- | apps/user_ldap/lib/connection.php | 7 | ||||
-rw-r--r-- | apps/user_ldap/lib/helper.php | 28 | ||||
-rw-r--r-- | apps/user_ldap/settings.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/templates/settings.php | 13 | ||||
-rw-r--r-- | core/css/styles.css | 1 | ||||
-rw-r--r-- | core/js/js.js | 2 | ||||
-rw-r--r-- | lib/autoloader.php | 26 | ||||
-rw-r--r-- | lib/connector/sabre/principal.php | 14 | ||||
-rw-r--r-- | lib/memcache/factory.php | 29 | ||||
-rwxr-xr-x | settings/admin.php | 2 | ||||
-rw-r--r-- | settings/ajax/getlog.php | 2 |
20 files changed, 135 insertions, 34 deletions
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index b2bfd53506d..6a34cbe4ef1 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -39,4 +39,4 @@ if (!is_array($files_list)) { $files_list = array($files); } -OC_Files::get($dir, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); +OC_Files::get($dir, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD'); diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 878e4cb2159..c50e96b2429 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -10,7 +10,7 @@ OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; -$doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false; +$doBreadcrumb = isset($_GET['breadcrumb']); $data = array(); // Make breadcrumb diff --git a/apps/files_encryption/settings-personal.php b/apps/files_encryption/settings-personal.php index fddc3ea5eee..589219f32ad 100644 --- a/apps/files_encryption/settings-personal.php +++ b/apps/files_encryption/settings-personal.php @@ -16,7 +16,7 @@ $view = new \OC_FilesystemView('/'); $util = new \OCA\Encryption\Util($view, $user);
$session = new \OCA\Encryption\Session($view);
-$privateKeySet = ($session->getPrivateKey() !== false) ? true : false;
+$privateKeySet = $session->getPrivateKey() !== false; $recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');
$recoveryEnabledForUser = $util->recoveryEnabledForUser();
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index f4d1940b184..9363a350e27 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -79,7 +79,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $this->bucket = $params['bucket']; $scheme = ($params['use_ssl'] === 'false') ? 'http' : 'https'; - $this->test = ( isset($params['test'])) ? true : false; + $this->test = isset($params['test']); $this->timeout = ( ! isset($params['timeout'])) ? 15 : $params['timeout']; $params['region'] = ( ! isset($params['region'])) ? 'eu-west-1' : $params['region']; $params['hostname'] = ( !isset($params['hostname'])) ? 's3.amazonaws.com' : $params['hostname']; diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 14e974d65ca..1935740cd2e 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -418,9 +418,9 @@ class OC_Mount_Config { public static function checksmbclient() { if(function_exists('shell_exec')) { $output=shell_exec('which smbclient'); - return (empty($output)?false:true); + return !empty($output); }else{ - return(false); + return false; } } @@ -429,9 +429,9 @@ class OC_Mount_Config { */ public static function checkphpftp() { if(function_exists('ftp_login')) { - return(true); + return true; }else{ - return(false); + return false; } } @@ -439,7 +439,7 @@ class OC_Mount_Config { * check if curl is installed */ public static function checkcurl() { - return (function_exists('curl_init')); + return function_exists('curl_init'); } /** @@ -460,6 +460,6 @@ class OC_Mount_Config { $txt.=$l->t('<b>Warning:</b> The Curl support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV or GoogleDrive is not possible. Please ask your system administrator to install it.').'<br />'; } - return($txt); + return $txt; } } diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 4fd36096463..f7f329b8993 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -170,7 +170,7 @@ class SFTP extends \OC\Files\Storage\Common { public function file_exists($path) { try { - return $this->client->stat($this->abs_path($path)) === false ? false : true; + return $this->client->stat($this->abs_path($path)) !== false; } catch (\Exception $e) { return false; } diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 741ab145384..e9fdf6e4c95 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -112,9 +112,9 @@ if (isset($path)) { if ($files_list === NULL ) { $files_list = array($files); } - OC_Files::get($path, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + OC_Files::get($path, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD'); } else { - OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD'); } exit(); } else { @@ -133,7 +133,7 @@ if (isset($path)) { $tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path)); $tmpl->assign('fileTarget', basename($linkItem['file_target'])); $tmpl->assign('dirToken', $linkItem['token']); - $allowPublicUploadEnabled = (($linkItem['permissions'] & OCP\PERMISSION_CREATE) ? true : false ); + $allowPublicUploadEnabled = (bool) ($linkItem['permissions'] & OCP\PERMISSION_CREATE); if (\OCP\App::isEnabled('files_encryption')) { $allowPublicUploadEnabled = false; } diff --git a/apps/user_ldap/css/settings.css b/apps/user_ldap/css/settings.css index 431e064def8..6086c7b74e6 100644 --- a/apps/user_ldap/css/settings.css +++ b/apps/user_ldap/css/settings.css @@ -3,14 +3,20 @@ max-width: 200px; display: inline-block; vertical-align: top; + text-align: right; padding-top: 9px; + padding-right: 5px; } #ldap fieldset input, #ldap fieldset textarea { - width: 70%; + width: 60%; display: inline-block; } +#ldap fieldset p input[type=checkbox] { + vertical-align: bottom; +} + .ldapIndent { margin-left: 50px; } diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 78c9719480d..78ec71b70ad 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -176,6 +176,13 @@ $(document).ready(function() { $('#ldap_submit').effect('highlight', {'color':'#A8FA87'}, 5000, function() { $('#ldap_submit').css('background', bgcolor); }); + //update the Label in the config chooser + caption = $('#ldap_serverconfig_chooser option:selected:first').text(); + pretext = '. Server: '; + caption = caption.slice(0, caption.indexOf(pretext) + pretext.length); + caption = caption + $('#ldap_host').val(); + $('#ldap_serverconfig_chooser option:selected:first').text(caption); + } else { $('#ldap_submit').css('background', '#fff'); $('#ldap_submit').effect('highlight', {'color':'#E97'}, 5000, function() { diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 0372112f0e2..e5d9b4d5b40 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -80,7 +80,12 @@ class Connection { public function __construct($configPrefix = '', $configID = 'user_ldap') { $this->configPrefix = $configPrefix; $this->configID = $configID; - $this->cache = \OC_Cache::getGlobalCache(); + $memcache = new \OC\Memcache\Factory(); + if($memcache->isAvailable()) { + $this->cache = $memcache->create(); + } else { + $this->cache = \OC_Cache::getGlobalCache(); + } $this->config['hasPagedResultSupport'] = (function_exists('ldap_control_paged_result') && function_exists('ldap_control_paged_result_response')); } diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index f65f466789f..4c9dd07a12c 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -71,6 +71,34 @@ class Helper { } /** + * + * @brief determines the host for every configured connection + * @return an array with configprefix as keys + * + */ + static public function getServerConfigurationHosts() { + $referenceConfigkey = 'ldap_host'; + + $query = ' + SELECT DISTINCT `configkey`, `configvalue` + FROM `*PREFIX*appconfig` + WHERE `appid` = \'user_ldap\' + AND `configkey` LIKE ? + '; + $query = \OCP\DB::prepare($query); + $configHosts = $query->execute(array('%'.$referenceConfigkey))->fetchAll(); + $result = array(); + + foreach($configHosts as $configHost) { + $len = strlen($configHost['configkey']) - strlen($referenceConfigkey); + $prefix = substr($configHost['configkey'], 0, $len); + $result[$prefix] = $configHost['configvalue']; + } + + return $result; + } + + /** * @brief deletes a given saved LDAP/AD server configuration. * @param string the configuration prefix of the config to delete * @return bool true on success, false otherwise diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 22e2dac6d26..7169192a18e 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -44,7 +44,9 @@ OCP\Util::addstyle('user_ldap', 'settings'); $tmpl = new OCP\Template('user_ldap', 'settings'); $prefixes = \OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(); +$hosts = \OCA\user_ldap\lib\Helper::getServerConfigurationHosts(); $tmpl->assign('serverConfigurationPrefixes', $prefixes); +$tmpl->assign('serverConfigurationHosts', $hosts); // assign default values if(!isset($ldap)) { diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 95aa592594b..e214d57fb1d 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -24,7 +24,7 @@ $sel = ' selected'; foreach($_['serverConfigurationPrefixes'] as $prefix) { ?> - <option value="<?php p($prefix); ?>"<?php p($sel); ?>><?php p($i++); ?>. Server</option> + <option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($i++); ?>. Server: <?php p($_['serverConfigurationHosts'][$prefix]); ?></option> <?php } } @@ -51,18 +51,15 @@ <p><label for="ldap_login_filter"><?php p($l->t('User Login Filter'));?></label> <input type="text" id="ldap_login_filter" name="ldap_login_filter" data-default="<?php p($_['ldap_login_filter_default']); ?>" - title="<?php p($l->t('Defines the filter to apply, when login is attempted. %%uid replaces the username in the login action.'));?>" /> - <br /><small><?php p($l->t('use %%uid placeholder, e.g. "uid=%%uid"'));?></small></p> + title="<?php p($l->t('Defines the filter to apply, when login is attempted. %%uid replaces the username in the login action. Example: "uid=%%uid"'));?>" /></p> <p><label for="ldap_userlist_filter"><?php p($l->t('User List Filter'));?></label> <input type="text" id="ldap_userlist_filter" name="ldap_userlist_filter" data-default="<?php p($_['ldap_userlist_filter_default']); ?>" - title="<?php p($l->t('Defines the filter to apply, when retrieving users.'));?>" /> - <br /><small><?php p($l->t('without any placeholder, e.g. "objectClass=person".'));?></small></p> + title="<?php p($l->t('Defines the filter to apply, when retrieving users (no placeholders). Example: "objectClass=person"'));?>" /></p> <p><label for="ldap_group_filter"><?php p($l->t('Group Filter'));?></label> <input type="text" id="ldap_group_filter" name="ldap_group_filter" data-default="<?php p($_['ldap_group_filter_default']); ?>" - title="<?php p($l->t('Defines the filter to apply, when retrieving groups.'));?>" /> - <br /><small><?php p($l->t('without any placeholder, e.g. "objectClass=posixGroup".'));?></small></p> + title="<?php p($l->t('Defines the filter to apply, when retrieving groups (no placeholders). Example: "objectClass=posixGroup"'));?>" /></p> </fieldset> <fieldset id="ldapSettings-2"> <div id="ldapAdvancedAccordion"> @@ -75,7 +72,7 @@ <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server'));?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.'));?>" /></p> <p><label for="ldap_tls"><?php p($l->t('Use TLS'));?></label><input type="checkbox" id="ldap_tls" name="ldap_tls" value="1" data-default="<?php p($_['ldap_tls_default']); ?>" title="<?php p($l->t('Do not use it additionally for LDAPS connections, it will fail.'));?>" /></p> <p><label for="ldap_nocase"><?php p($l->t('Case insensitve LDAP server (Windows)'));?></label><input type="checkbox" id="ldap_nocase" name="ldap_nocase" data-default="<?php p($_['ldap_nocase_default']); ?>" value="1"<?php if (isset($_['ldap_nocase']) && ($_['ldap_nocase'])) p(' checked'); ?>></p> - <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName() ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/><small><?php p($l->t('Not recommended, use for testing only.'));?></small></p> + <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName() ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live'));?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.'));?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> </div> <h3><?php p($l->t('Directory Settings'));?></h3> diff --git a/core/css/styles.css b/core/css/styles.css index becf0af9056..52a265d2031 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -414,6 +414,7 @@ label.infield { cursor:text !important; top:1.05em; left:.85em; } .error-wide { width: 800px; + margin-left: -250px; } /* Fixes for log in page, TODO should be removed some time */ diff --git a/core/js/js.js b/core/js/js.js index c2b81ae3272..d580b6113e6 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -69,7 +69,7 @@ function initL10N(app) { var code = 'var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };'; t.plural_function = new Function("n", code); } else { - console.log("Syntax error in language file. Plural-Forms header is invalid ["+plural_forms+"]"); + console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]"); } } } diff --git a/lib/autoloader.php b/lib/autoloader.php index 21170639092..01841f831be 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -111,15 +111,39 @@ class Autoloader { * @param string $class * @return bool */ + protected $memoryCache = null; + protected $constructingMemoryCache = true; // hack to prevent recursion public function load($class) { - $paths = $this->findClass($class); + // Does this PHP have an in-memory cache? We cache the paths there + if ($this->constructingMemoryCache && !$this->memoryCache) { + $this->constructingMemoryCache = false; + $this->memoryCache = \OC\Memcache\Factory::createLowLatency('Autoloader'); + } + if ($this->memoryCache) { + $pathsToRequire = $this->memoryCache->get($class); + if (is_array($pathsToRequire)) { + foreach ($pathsToRequire as $path) { + require_once $path; + } + return false; + } + } + // Use the normal class loading path + $paths = $this->findClass($class); if (is_array($paths)) { + $pathsToRequire = array(); foreach ($paths as $path) { if ($fullPath = stream_resolve_include_path($path)) { require_once $fullPath; + $pathsToRequire[] = $fullPath; } } + + // Save in our memory cache + if ($this->memoryCache) { + $this->memoryCache->set($class, $pathsToRequire, 60); // cache 60 sec + } } return false; } diff --git a/lib/connector/sabre/principal.php b/lib/connector/sabre/principal.php index 16c88b96ea6..59a96797c16 100644 --- a/lib/connector/sabre/principal.php +++ b/lib/connector/sabre/principal.php @@ -66,13 +66,13 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { */ public function getGroupMemberSet($principal) { // TODO: for now the group principal has only one member, the user itself - list($prefix, $name) = Sabre_DAV_URLUtil::splitPath($principal); - - $principal = $this->getPrincipalByPath($prefix); - if (!$principal) throw new Sabre_DAV_Exception('Principal not found'); + $principal = $this->getPrincipalByPath($principal); + if (!$principal) { + throw new Sabre_DAV_Exception('Principal not found'); + } return array( - $prefix + $principal['uri'] ); } @@ -88,7 +88,9 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { $group_membership = array(); if ($prefix == 'principals') { $principal = $this->getPrincipalByPath($principal); - if (!$principal) throw new Sabre_DAV_Exception('Principal not found'); + if (!$principal) { + throw new Sabre_DAV_Exception('Principal not found'); + } // TODO: for now the user principal has only its own groups return array( diff --git a/lib/memcache/factory.php b/lib/memcache/factory.php index 4c1b1ab207f..fde7d947567 100644 --- a/lib/memcache/factory.php +++ b/lib/memcache/factory.php @@ -37,4 +37,33 @@ class Factory { public function isAvailable() { return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable(); } + + /** + * get a in-server cache instance, will return null if no backend is available + * + * @param string $prefix + * @return \OC\Memcache\Cache + */ + public static function createLowLatency($prefix = '') { + if (XCache::isAvailable()) { + return new XCache($prefix); + } elseif (APCu::isAvailable()) { + return new APCu($prefix); + } elseif (APC::isAvailable()) { + return new APC($prefix); + } else { + return null; + } + } + + /** + * check if there is a in-server backend available + * + * @return bool + */ + public static function isAvailableLowLatency() { + return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable(); + } + + } diff --git a/settings/admin.php b/settings/admin.php index 10e239204f2..869729a9e41 100755 --- a/settings/admin.php +++ b/settings/admin.php @@ -18,7 +18,7 @@ $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; +$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3; $tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 )); $tmpl->assign('entries', $entries); diff --git a/settings/ajax/getlog.php b/settings/ajax/getlog.php index e7151419286..34c8d3ce467 100644 --- a/settings/ajax/getlog.php +++ b/settings/ajax/getlog.php @@ -16,6 +16,6 @@ $data = array(); OC_JSON::success( array( "data" => $entries, - "remain"=>(count(OC_Log_Owncloud::getEntries(1, $offset + $count)) !== 0) ? true : false + "remain" => count(OC_Log_Owncloud::getEntries(1, $offset + $count)) !== 0, ) ); |