Merge branch 'master' into calendar_export

This commit is contained in:
Georg Ehrke 2012-06-03 14:56:25 +02:00
commit 865b7d6a7b
10 changed files with 146 additions and 23 deletions

View file

@ -31,8 +31,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
$this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)');
$this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
if(empty($this->ldapGroupFilter) || empty($this->ldapGroupMemberAssocAttr)) {
$this->configured = false;
if(!empty($this->ldapGroupFilter) && !empty($this->ldapGroupMemberAssocAttr)) {
$this->configured = true;
}
}

View file

@ -419,7 +419,7 @@ class OC_FileCache{
}
return $result;
}else{
OC_Log::write('files','getChached(): file not found in cache ('.$path.')',OC_Log::DEBUG);
OC_Log::write('files','getCached(): file not found in cache ('.$path.')',OC_Log::DEBUG);
if(isset(self::$savedData[$path])){
return self::$savedData[$path];
}else{

View file

@ -62,23 +62,26 @@ class OC_Log_Owncloud {
public static function getEntries($limit=50, $offset=0){
self::init();
$minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN );
$entries=array();
if(!file_exists(self::$logFile)) {
return array();
}
$contents=file(self::$logFile);
if(!$contents) {//error while reading log
return array();
}
$end=max(count($contents)-$offset-1, 0);
$start=max($end-$limit,0);
$i=$end;
while($i>$start){
$entry=json_decode($contents[$i]);
if($entry->level>=$minLevel){
$entries[]=$entry;
$entries = array();
$handle = fopen(self::$logFile, 'r');
if ($handle) {
// Just a guess to set the file pointer to the right spot
$maxLineLength = 150;
fseek($handle, -($limit * $maxLineLength + $offset * $maxLineLength), SEEK_END);
// Skip first line, because it is most likely a partial line
fgets($handle);
while (!feof($handle)) {
$line = fgets($handle);
if (!empty($line)) {
$entry = json_decode($line);
if ($entry->level >= $minLevel) {
$entries[] = $entry;
}
}
}
$i--;
fclose($handle);
// Extract the needed entries and reverse the order
$entries = array_reverse(array_slice($entries, -($limit + $offset), $limit));
}
return $entries;
}

View file

@ -94,6 +94,7 @@ class OC_Setup {
'error' => 'MySQL username and/or password not valid',
'hint' => 'You need to enter either an existing account or the administrator.'
);
return($error);
}
else {
$oldUser=OC_Config::getValue('dbuser', false);

View file

@ -21,7 +21,9 @@
*/
/**
* This class provides all methods for user management.
* This class provides wrapper methods for user management. Multiple backends are
* supported. User management operations are delegated to the configured backend for
* execution.
*
* Hooks provided:
* pre_createUser(&run, uid, password)
@ -240,7 +242,7 @@ class OC_User {
* Checks if the user is logged in
*/
public static function isLoggedIn(){
if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){
if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] AND self::userExists($_SESSION['user_id']) ){
return true;
}
else{

View file

@ -40,8 +40,10 @@ define('OC_USER_BACKEND_USER_EXISTS', 0x100000);
/**
* abstract base class for user management
* subclass this for your own backends and see OC_User_Example for descriptions
* Abstract base class for user management. Provides methods for querying backend
* capabilities.
*
* Subclass this for your own backends, and see OC_User_Example for descriptions
*/
abstract class OC_User_Backend {

93
lib/user/http.php Normal file
View file

@ -0,0 +1,93 @@
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Robin Appelman icewind@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* user backend using http auth requests
*/
class OC_User_HTTP extends OC_User_Backend {
/**
* split http://user@host/path into a user and url part
* @param string path
* @return array
*/
private function parseUrl($url){
$parts=parse_url($url);
$url=$parts['scheme'].'://'.$parts['host'];
if(isset($parts['port'])){
$url.=':'.$parts['port'];
}
$url.=$parts['path'];
if(isset($parts['query'])){
$url.='?'.$parts['query'];
}
return array($parts['user'],$url);
}
/**
* check if an url is a valid login
* @param string url
* @return boolean
*/
private function matchUrl($url){
return ! is_null(parse_url($url,PHP_URL_USER));
}
/**
* @brief Check if the password is correct
* @param $uid The username
* @param $password The password
* @returns string
*
* Check if the password is correct without logging in the user
* returns the user id or false
*/
public function checkPassword($uid, $password){
if(!$this->matchUrl($uid)){
return false;
}
list($user,$url)=$this->parseUrl($uid);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $status==200;
}
/**
* @brief check if a user exists
* @param string $uid the username
* @return boolean
*/
public function userExists($uid){
return $this->matchUrl($uid);
}
}

View file

@ -28,6 +28,14 @@ class OC_Util {
exit;
}
// Check if apps folder is writable.
if(!is_writable(OC::$SERVERROOT."/apps/")) {
$tmpl = new OC_Template( '', 'error', 'guest' );
$tmpl->assign('errors',array(1=>array('error'=>"Can't write into apps directory 'apps'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
$tmpl->printPage();
exit;
}
// Create root dir.
if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){
$success=@mkdir($CONFIG_DATADIRECTORY_ROOT);
@ -256,6 +264,9 @@ class OC_Util {
if(floatval(phpversion())<5.3){
$errors[]=array('error'=>'PHP 5.3 is required.<br/>','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
}
if(!defined('PDO::ATTR_DRIVER_NAME')){
$errors[]=array('error'=>'PHP PDO module is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
}
return $errors;
}

View file

@ -20,6 +20,7 @@ $rootInfo=OC_FileCache::get('');
$used=$rootInfo['size'];
$free=OC_Filesystem::free_space();
$total=$free+$used;
if($total==0) $total=1; // prevent division by zero
$relative=round(($used/$total)*10000)/100;
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email','');

View file

@ -20,6 +20,16 @@
*
*/
/**
* Abstract class to provide the basis of backend-specific unit test classes.
*
* All subclasses MUST assign a backend property in setUp() which implements
* user operations (add, remove, etc.). Test methods in this class will then be
* run on each separate subclass and backend therein.
*
* For an example see /tests/lib/user/dummy.php
*/
abstract class Test_User_Backend extends UnitTestCase {
/**
* @var OC_User_Backend $backend