Merge pull request #242 from fmms/checkstyle05

Checkstyle fixes
This commit is contained in:
Thomas Müller 2012-11-05 01:34:11 -08:00
commit 135680e50b
41 changed files with 632 additions and 638 deletions

View File

@ -92,7 +92,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
}elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb') {
if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0) {
//first encrypt the target file so we don't end up with a half encrypted file
OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing', OCP\Util::DEBUG);
OCP\Util::writeLog('files_encryption', 'Decrypting '.$path.' before writing', OCP\Util::DEBUG);
$tmp=fopen('php://temp');
OCP\Files::streamCopy($result, $tmp);
fclose($result);

View File

@ -24,7 +24,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
if(substr($this->root,-1, 1)!='/') {
if(substr($this->root, -1, 1)!='/') {
$this->root.='/';
}
if(!$this->share || $this->share[0]!='/') {
@ -41,7 +41,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
}
public function constructUrl($path) {
if(substr($path,-1)=='/') {
if(substr($path, -1)=='/') {
$path=substr($path, 0, -1);
}
return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;

View File

@ -46,7 +46,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
if($caview = \OCP\Files::getStorage('files_external')) {
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
if (file_exists($certPath)) {
if (file_exists($certPath)) {
$this->client->addTrustedCertificates($certPath);
}
}

View File

@ -1,223 +1,223 @@
<?php
// Load other apps for file previews
OC_App::loadApps();
// Compatibility with shared-by-link items from ownCloud 4.0
// requires old Sharing table !
// support will be removed in OC 5.0,a
if (isset($_GET['token'])) {
unset($_GET['file']);
$qry = \OC_DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? LIMIT 1');
$filepath = $qry->execute(array($_GET['token']))->fetchOne();
if(isset($filepath)) {
$info = OC_FileCache_Cached::get($filepath, '');
if(strtolower($info['mimetype']) == 'httpd/unix-directory') {
$_GET['dir'] = $filepath;
} else {
$_GET['file'] = $filepath;
}
\OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN);
}
}
// Enf of backward compatibility
function getID($path) {
// use the share table from the db to find the item source if the file was reshared because shared files
//are not stored in the file cache.
if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {
$path_parts = explode('/', $path, 5);
$user = $path_parts[1];
$intPath = '/'.$path_parts[4];
$query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? ');
$result = $query->execute(array($user, $intPath));
$row = $result->fetchRow();
$fileSource = $row['item_source'];
} else {
$fileSource = OC_Filecache::getId($path, '');
}
return $fileSource;
}
if (isset($_GET['file']) || isset($_GET['dir'])) {
if (isset($_GET['dir'])) {
$type = 'folder';
$path = $_GET['dir'];
if(strlen($path)>1 and substr($path, -1, 1)==='/') {
$path=substr($path, 0, -1);
}
$baseDir = $path;
$dir = $baseDir;
} else {
$type = 'file';
$path = $_GET['file'];
if(strlen($path)>1 and substr($path, -1, 1)==='/') {
$path=substr($path, 0, -1);
}
}
$uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
if (OCP\User::userExists($uidOwner)) {
OC_Util::setupFS($uidOwner);
$fileSource = getId($path);
if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
// TODO Fix in the getItems
if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
exit();
}
if (isset($linkItem['share_with'])) {
// Check password
if (isset($_GET['file'])) {
$url = OCP\Util::linkToPublic('files').'&file='.$_GET['file'];
} else {
$url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
$storedHash = $linkItem['share_with'];
$forcePortable = (CRYPT_BLOWFISH != 1);
$hasher = new PasswordHash(8, $forcePortable);
if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) {
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
$tmpl->assign('URL', $url);
$tmpl->assign('error', true);
$tmpl->printPage();
exit();
} else {
// Save item id in session for future requests
$_SESSION['public_link_authenticated'] = $linkItem['id'];
}
// Check if item id is set in session
} else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
// Prompt for password
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
$tmpl->assign('URL', $url);
$tmpl->printPage();
exit();
}
}
$path = $linkItem['path'];
if (isset($_GET['path'])) {
$path .= $_GET['path'];
$dir .= $_GET['path'];
if (!OC_Filesystem::file_exists($path)) {
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
exit();
}
}
// Download the file
if (isset($_GET['download'])) {
if (isset($_GET['dir'])) {
if ( isset($_GET['files']) ) { // download selected files
OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
} else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory
OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
} else { // download the whole shared directory
OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
}
} else { // download a single shared file
OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
}
} else {
OCP\Util::addStyle('files_sharing', 'public');
OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions');
$tmpl = new OCP\Template('files_sharing', 'public', 'base');
$tmpl->assign('owner', $uidOwner);
// Show file list
if (OC_Filesystem::is_dir($path)) {
OCP\Util::addStyle('files', 'files');
OCP\Util::addScript('files', 'files');
OCP\Util::addScript('files', 'filelist');
$files = array();
$rootLength = strlen($baseDir) + 1;
foreach (OC_Files::getDirectoryContent($path) as $i) {
$i['date'] = OCP\Util::formatDate($i['mtime']);
if ($i['type'] == 'file') {
$fileinfo = pathinfo($i['name']);
$i['basename'] = $fileinfo['filename'];
$i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
}
$i['directory'] = '/'.substr('/'.$uidOwner.'/files'.$i['directory'], $rootLength);
if ($i['directory'] == '/') {
$i['directory'] = '';
}
$i['permissions'] = OCP\Share::PERMISSION_READ;
$files[] = $i;
}
// Make breadcrumb
$breadcrumb = array();
$pathtohere = '';
$count = 1;
foreach (explode('/', $dir) as $i) {
if ($i != '') {
if ($i != $baseDir) {
$pathtohere .= '/'.$i;
}
if ( strlen($pathtohere) < strlen($_GET['dir'])) {
continue;
}
$breadcrumb[] = array('dir' => str_replace($_GET['dir'], "", $pathtohere, $count), 'name' => $i);
}
}
$list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files, false);
$list->assign('publicListView', true);
$list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
$list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path=', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' );
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
$folder = new OCP\Template('files', 'index', '');
$folder->assign('fileList', $list->fetchPage(), false);
$folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
$folder->assign('dir', basename($dir));
$folder->assign('isCreatable', false);
$folder->assign('permissions', 0);
$folder->assign('files', $files);
$folder->assign('uploadMaxFilesize', 0);
$folder->assign('uploadMaxHumanFilesize', 0);
$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->assign('folder', $folder->fetchPage(), false);
$tmpl->assign('uidOwner', $uidOwner);
$tmpl->assign('dir', basename($dir));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
} else {
// Show file preview if viewer is available
$tmpl->assign('uidOwner', $uidOwner);
$tmpl->assign('dir', dirname($path));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
if ($type == 'file') {
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false);
} else {
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
}
}
$tmpl->printPage();
}
exit();
}
}
}
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
<?php
// Load other apps for file previews
OC_App::loadApps();
// Compatibility with shared-by-link items from ownCloud 4.0
// requires old Sharing table !
// support will be removed in OC 5.0,a
if (isset($_GET['token'])) {
unset($_GET['file']);
$qry = \OC_DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? LIMIT 1');
$filepath = $qry->execute(array($_GET['token']))->fetchOne();
if(isset($filepath)) {
$info = OC_FileCache_Cached::get($filepath, '');
if(strtolower($info['mimetype']) == 'httpd/unix-directory') {
$_GET['dir'] = $filepath;
} else {
$_GET['file'] = $filepath;
}
\OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN);
}
}
// Enf of backward compatibility
function getID($path) {
// use the share table from the db to find the item source if the file was reshared because shared files
//are not stored in the file cache.
if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {
$path_parts = explode('/', $path, 5);
$user = $path_parts[1];
$intPath = '/'.$path_parts[4];
$query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? ');
$result = $query->execute(array($user, $intPath));
$row = $result->fetchRow();
$fileSource = $row['item_source'];
} else {
$fileSource = OC_Filecache::getId($path, '');
}
return $fileSource;
}
if (isset($_GET['file']) || isset($_GET['dir'])) {
if (isset($_GET['dir'])) {
$type = 'folder';
$path = $_GET['dir'];
if(strlen($path)>1 and substr($path, -1, 1)==='/') {
$path=substr($path, 0, -1);
}
$baseDir = $path;
$dir = $baseDir;
} else {
$type = 'file';
$path = $_GET['file'];
if(strlen($path)>1 and substr($path, -1, 1)==='/') {
$path=substr($path, 0, -1);
}
}
$uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
if (OCP\User::userExists($uidOwner)) {
OC_Util::setupFS($uidOwner);
$fileSource = getId($path);
if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
// TODO Fix in the getItems
if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
exit();
}
if (isset($linkItem['share_with'])) {
// Check password
if (isset($_GET['file'])) {
$url = OCP\Util::linkToPublic('files').'&file='.$_GET['file'];
} else {
$url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
$storedHash = $linkItem['share_with'];
$forcePortable = (CRYPT_BLOWFISH != 1);
$hasher = new PasswordHash(8, $forcePortable);
if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) {
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
$tmpl->assign('URL', $url);
$tmpl->assign('error', true);
$tmpl->printPage();
exit();
} else {
// Save item id in session for future requests
$_SESSION['public_link_authenticated'] = $linkItem['id'];
}
// Check if item id is set in session
} else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
// Prompt for password
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
$tmpl->assign('URL', $url);
$tmpl->printPage();
exit();
}
}
$path = $linkItem['path'];
if (isset($_GET['path'])) {
$path .= $_GET['path'];
$dir .= $_GET['path'];
if (!OC_Filesystem::file_exists($path)) {
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
exit();
}
}
// Download the file
if (isset($_GET['download'])) {
if (isset($_GET['dir'])) {
if ( isset($_GET['files']) ) { // download selected files
OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
} else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory
OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
} else { // download the whole shared directory
OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
}
} else { // download a single shared file
OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
}
} else {
OCP\Util::addStyle('files_sharing', 'public');
OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions');
$tmpl = new OCP\Template('files_sharing', 'public', 'base');
$tmpl->assign('owner', $uidOwner);
// Show file list
if (OC_Filesystem::is_dir($path)) {
OCP\Util::addStyle('files', 'files');
OCP\Util::addScript('files', 'files');
OCP\Util::addScript('files', 'filelist');
$files = array();
$rootLength = strlen($baseDir) + 1;
foreach (OC_Files::getDirectoryContent($path) as $i) {
$i['date'] = OCP\Util::formatDate($i['mtime']);
if ($i['type'] == 'file') {
$fileinfo = pathinfo($i['name']);
$i['basename'] = $fileinfo['filename'];
$i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
}
$i['directory'] = '/'.substr('/'.$uidOwner.'/files'.$i['directory'], $rootLength);
if ($i['directory'] == '/') {
$i['directory'] = '';
}
$i['permissions'] = OCP\Share::PERMISSION_READ;
$files[] = $i;
}
// Make breadcrumb
$breadcrumb = array();
$pathtohere = '';
$count = 1;
foreach (explode('/', $dir) as $i) {
if ($i != '') {
if ($i != $baseDir) {
$pathtohere .= '/'.$i;
}
if ( strlen($pathtohere) < strlen($_GET['dir'])) {
continue;
}
$breadcrumb[] = array('dir' => str_replace($_GET['dir'], "", $pathtohere, $count), 'name' => $i);
}
}
$list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files, false);
$list->assign('publicListView', true);
$list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
$list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path=', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' );
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
$folder = new OCP\Template('files', 'index', '');
$folder->assign('fileList', $list->fetchPage(), false);
$folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
$folder->assign('dir', basename($dir));
$folder->assign('isCreatable', false);
$folder->assign('permissions', 0);
$folder->assign('files', $files);
$folder->assign('uploadMaxFilesize', 0);
$folder->assign('uploadMaxHumanFilesize', 0);
$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->assign('folder', $folder->fetchPage(), false);
$tmpl->assign('uidOwner', $uidOwner);
$tmpl->assign('dir', basename($dir));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
} else {
// Show file preview if viewer is available
$tmpl->assign('uidOwner', $uidOwner);
$tmpl->assign('dir', dirname($path));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
if ($type == 'file') {
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false);
} else {
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
}
}
$tmpl->printPage();
}
exit();
}
}
}
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();

View File

@ -1,278 +1,278 @@
<?php
/**
* Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
/**
* Versions
*
* A class to handle the versioning of files.
*/
namespace OCA_Versions;
class Storage {
// config.php configuration:
// - files_versions
// - files_versionsfolder
// - files_versionsblacklist
// - files_versionsmaxfilesize
// - files_versionsinterval
// - files_versionmaxversions
//
// todo:
// - finish porting to OC_FilesystemView to enable network transparency
// - add transparent compression. first test if it´s worth it.
const DEFAULTENABLED=true;
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
const DEFAULTMAXFILESIZE=1048576; // 10MB
const DEFAULTMININTERVAL=60; // 1 min
const DEFAULTMAXVERSIONS=50;
private static function getUidAndFilename($filename)
{
if (\OCP\App::isEnabled('files_sharing')
&& substr($filename, 0, 7) == '/Shared'
&& $source = \OCP\Share::getItemSharedWith('file',
substr($filename, 7),
\OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) {
$filename = $source['path'];
$pos = strpos($filename, '/files', 1);
$uid = substr($filename, 1, $pos - 1);
$filename = substr($filename, $pos + 6);
} else {
$uid = \OCP\User::getUser();
}
return array($uid, $filename);
}
/**
* store a new version of a file.
*/
public function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$files_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/files');
$users_view = new \OC_FilesystemView('/'.\OCP\User::getUser());
//check if source file already exist as version to avoid recursions.
// todo does this check work?
if ($users_view->file_exists($filename)) {
return false;
}
// check if filename is a directory
if($files_view->is_dir($filename)) {
return false;
}
// check filetype blacklist
$blacklist=explode(' ', \OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST));
foreach($blacklist as $bl) {
$parts=explode('.', $filename);
$ext=end($parts);
if(strtolower($ext)==$bl) {
return false;
}
}
// we should have a source file to work with
if (!$files_view->file_exists($filename)) {
return false;
}
// check filesize
if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) {
return false;
}
// check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval)
if ($uid == \OCP\User::getUser()) {
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
$matches=glob($versionsName.'.v*');
sort($matches);
$parts=explode('.v', end($matches));
if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) {
return false;
}
}
// create all parent folders
$info=pathinfo($filename);
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
mkdir($versionsFolderName.'/'.$info['dirname'], 0750, true);
}
// store a new version of a file
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time());
// expire old revisions if necessary
Storage::expire($filename);
}
}
/**
* rollback to an old version of a file.
*/
public static function rollback($filename, $revision) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$users_view = new \OC_FilesystemView('/'.\OCP\User::getUser());
// rollback
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
return true;
}else{
return false;
}
}
}
/**
* check if old versions of a file exist.
*/
public static function isversioned($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
$matches=glob($versionsName.'.v*');
if(count($matches)>0) {
return true;
}else{
return false;
}
}else{
return(false);
}
}
/**
* @brief get a list of all available versions of a file in descending chronological order
* @param $filename file to find versions of, relative to the user files dir
* @param $count number of versions to return
* @returns array
*/
public static function getVersions( $filename, $count = 0 ) {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
$versions = array();
// fetch for old versions
$matches = glob( $versionsName.'.v*' );
sort( $matches );
$i = 0;
$files_view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files');
$local_file = $files_view->getLocalFile($filename);
foreach( $matches as $ma ) {
$i++;
$versions[$i]['cur'] = 0;
$parts = explode( '.v', $ma );
$versions[$i]['version'] = ( end( $parts ) );
// if file with modified date exists, flag it in array as currently enabled version
( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 );
}
$versions = array_reverse( $versions );
foreach( $versions as $key => $value ) {
// flag the first matched file in array (which will have latest modification date) as current version
if ( $value['fileMatch'] ) {
$value['cur'] = 1;
break;
}
}
$versions = array_reverse( $versions );
// only show the newest commits
if( $count != 0 and ( count( $versions )>$count ) ) {
$versions = array_slice( $versions, count( $versions ) - $count );
}
return( $versions );
} else {
// if versioning isn't enabled then return an empty array
return( array() );
}
}
/**
* @brief Erase a file's versions which exceed the set quota
*/
public static function expire($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
$matches = glob( $versionsName.'.v*' );
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
$numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS );
// delete old versions of a file
$deleteItems = array_slice( $matches, 0, $numberToDelete );
foreach( $deleteItems as $de ) {
unlink( $versionsName.'.v'.$de );
}
}
}
}
/**
* @brief Erase all old versions of all user files
* @return true/false
*/
public function expireAll() {
$view = \OCP\Files::getStorage('files_versions');
return $view->deleteAll('', true);
}
<?php
/**
* Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
/**
* Versions
*
* A class to handle the versioning of files.
*/
namespace OCA_Versions;
class Storage {
// config.php configuration:
// - files_versions
// - files_versionsfolder
// - files_versionsblacklist
// - files_versionsmaxfilesize
// - files_versionsinterval
// - files_versionmaxversions
//
// todo:
// - finish porting to OC_FilesystemView to enable network transparency
// - add transparent compression. first test if it´s worth it.
const DEFAULTENABLED=true;
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
const DEFAULTMAXFILESIZE=1048576; // 10MB
const DEFAULTMININTERVAL=60; // 1 min
const DEFAULTMAXVERSIONS=50;
private static function getUidAndFilename($filename)
{
if (\OCP\App::isEnabled('files_sharing')
&& substr($filename, 0, 7) == '/Shared'
&& $source = \OCP\Share::getItemSharedWith('file',
substr($filename, 7),
\OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) {
$filename = $source['path'];
$pos = strpos($filename, '/files', 1);
$uid = substr($filename, 1, $pos - 1);
$filename = substr($filename, $pos + 6);
} else {
$uid = \OCP\User::getUser();
}
return array($uid, $filename);
}
/**
* store a new version of a file.
*/
public function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$files_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/files');
$users_view = new \OC_FilesystemView('/'.\OCP\User::getUser());
//check if source file already exist as version to avoid recursions.
// todo does this check work?
if ($users_view->file_exists($filename)) {
return false;
}
// check if filename is a directory
if($files_view->is_dir($filename)) {
return false;
}
// check filetype blacklist
$blacklist=explode(' ', \OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST));
foreach($blacklist as $bl) {
$parts=explode('.', $filename);
$ext=end($parts);
if(strtolower($ext)==$bl) {
return false;
}
}
// we should have a source file to work with
if (!$files_view->file_exists($filename)) {
return false;
}
// check filesize
if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) {
return false;
}
// check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval)
if ($uid == \OCP\User::getUser()) {
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
$matches=glob($versionsName.'.v*');
sort($matches);
$parts=explode('.v', end($matches));
if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) {
return false;
}
}
// create all parent folders
$info=pathinfo($filename);
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
mkdir($versionsFolderName.'/'.$info['dirname'], 0750, true);
}
// store a new version of a file
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time());
// expire old revisions if necessary
Storage::expire($filename);
}
}
/**
* rollback to an old version of a file.
*/
public static function rollback($filename, $revision) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$users_view = new \OC_FilesystemView('/'.\OCP\User::getUser());
// rollback
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
return true;
}else{
return false;
}
}
}
/**
* check if old versions of a file exist.
*/
public static function isversioned($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
$matches=glob($versionsName.'.v*');
if(count($matches)>0) {
return true;
}else{
return false;
}
}else{
return(false);
}
}
/**
* @brief get a list of all available versions of a file in descending chronological order
* @param $filename file to find versions of, relative to the user files dir
* @param $count number of versions to return
* @returns array
*/
public static function getVersions( $filename, $count = 0 ) {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions');
$versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
$versions = array();
// fetch for old versions
$matches = glob( $versionsName.'.v*' );
sort( $matches );
$i = 0;
$files_view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files');
$local_file = $files_view->getLocalFile($filename);
foreach( $matches as $ma ) {
$i++;
$versions[$i]['cur'] = 0;
$parts = explode( '.v', $ma );
$versions[$i]['version'] = ( end( $parts ) );
// if file with modified date exists, flag it in array as currently enabled version
( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 );
}
$versions = array_reverse( $versions );
foreach( $versions as $key => $value ) {
// flag the first matched file in array (which will have latest modification date) as current version
if ( $value['fileMatch'] ) {
$value['cur'] = 1;
break;
}
}
$versions = array_reverse( $versions );
// only show the newest commits
if( $count != 0 and ( count( $versions )>$count ) ) {
$versions = array_slice( $versions, count( $versions ) - $count );
}
return( $versions );
} else {
// if versioning isn't enabled then return an empty array
return( array() );
}
}
/**
* @brief Erase a file's versions which exceed the set quota
*/
public static function expire($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
$versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
$matches = glob( $versionsName.'.v*' );
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
$numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS );
// delete old versions of a file
$deleteItems = array_slice( $matches, 0, $numberToDelete );
foreach( $deleteItems as $de ) {
unlink( $versionsName.'.v'.$de );
}
}
}
}
/**
* @brief Erase all old versions of all user files
* @return true/false
*/
public function expireAll() {
$view = \OCP\Files::getStorage('files_versions');
return $view->deleteAll('', true);
}
}

View File

@ -29,7 +29,7 @@
<p><label for="ldap_cache_ttl">Cache Time-To-Live</label><input type="text" id="ldap_cache_ttl" name="ldap_cache_ttl" value="<?php echo $_['ldap_cache_ttl']; ?>" title="<?php echo $l->t('in seconds. A change empties the cache.');?>" /></p>
<p><label for="home_folder_naming_rule">User Home Folder Naming Rule</label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" value="<?php echo $_['home_folder_naming_rule']; ?>" title="<?php echo $l->t('Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute.');?>" /></p>
</fieldset>
<input type="submit" value="Save" /> <button id="ldap_action_test_connection" name="ldap_action_test_connection">Test Configuration</button> <a href="http://owncloud.org/support/ldap-backend/" target="_blank"><img src="<?php echo OCP\Util::imagePath('','actions/info.png'); ?>" style="height:1.75ex" /> <?php echo $l->t('Help');?></a>
<input type="submit" value="Save" /> <button id="ldap_action_test_connection" name="ldap_action_test_connection">Test Configuration</button> <a href="http://owncloud.org/support/ldap-backend/" target="_blank"><img src="<?php echo OCP\Util::imagePath('', 'actions/info.png'); ?>" style="height:1.75ex" /> <?php echo $l->t('Help');?></a>
</div>
</form>

View File

@ -476,7 +476,7 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common
$definition['unique'] = true;
$count = count($column_names);
for ($i=0; $i<$count; ++$i) {
$column_name = strtok($column_names[$i]," ");
$column_name = strtok($column_names[$i], " ");
$collation = strtok(" ");
$definition['fields'][$column_name] = array(
'position' => $i+1

View File

@ -397,8 +397,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common
}
if ($this->fix_assoc_fields_names ||
$this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES)
{
$this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) {
$this->connection->exec("PRAGMA short_column_names = 1");
$this->fix_assoc_fields_names = true;
}

View File

@ -130,8 +130,7 @@ class OC_Archive_TAR extends OC_Archive{
if( $file == $header['filename']
or $file.'/' == $header['filename']
or '/'.$file.'/' == $header['filename']
or '/'.$file == $header['filename'])
{
or '/'.$file == $header['filename']) {
return $header;
}
}

View File

@ -40,7 +40,7 @@ class OC_BackgroundJob{
* @param $type execution type
* @return boolean
*
* This method sets the execution type of the background jobs. Possible types
* This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
*/
public static function setExecutionType( $type ) {

View File

@ -524,8 +524,7 @@ class OC{
}
$file_ext = substr($param['file'], -3);
if ($file_ext != 'php'
|| !self::loadAppScriptFile($param))
{
|| !self::loadAppScriptFile($param)) {
header('HTTP/1.0 404 Not Found');
}
}
@ -595,8 +594,7 @@ class OC{
if(!isset($_COOKIE["oc_remember_login"])
|| !isset($_COOKIE["oc_token"])
|| !isset($_COOKIE["oc_username"])
|| !$_COOKIE["oc_remember_login"])
{
|| !$_COOKIE["oc_remember_login"]) {
return false;
}
OC_App::loadApps(array('authentication'));
@ -621,9 +619,9 @@ class OC{
OC_Util::redirectToDefaultPage();
// doesn't return
}
// if you reach this point you have changed your password
// if you reach this point you have changed your password
// or you are an attacker
// we can not delete tokens here because users may reach
// we can not delete tokens here because users may reach
// this point multiple times after a password change
OC_Log::write('core', 'Authentication cookie rejected for user '.$_COOKIE['oc_username'], OC_Log::WARN);
}

View File

@ -2,7 +2,7 @@
/**
* This plugin check user quota and deny creating files when they exceeds the quota.
*
*
* @copyright Copyright (C) 2012 entreCables S.L. All rights reserved.
* @author Sergio Cambra
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
@ -10,9 +10,9 @@
class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
/**
* Reference to main server object
*
* @var Sabre_DAV_Server
* Reference to main server object
*
* @var Sabre_DAV_Server
*/
private $server;
@ -23,8 +23,8 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
* addPlugin is called.
*
* This method should set up the requires event subscriptions.
*
* @param Sabre_DAV_Server $server
*
* @param Sabre_DAV_Server $server
* @return void
*/
public function initialize(Sabre_DAV_Server $server) {
@ -37,10 +37,10 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
/**
* This method is called before any HTTP method and forces users to be authenticated
*
*
* @param string $method
* @throws Sabre_DAV_Exception
* @return bool
* @return bool
*/
public function checkQuota($uri, $data = null) {
$expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');

View File

@ -38,9 +38,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{
if(in_array($user, $this->userQuota)) {
return $this->userQuota[$user];
}
$userQuota=OC_Preferences::getValue($user,'files','quota', 'default');
$userQuota=OC_Preferences::getValue($user, 'files', 'quota', 'default');
if($userQuota=='default') {
$userQuota=OC_AppConfig::getValue('files','default_quota', 'none');
$userQuota=OC_AppConfig::getValue('files', 'default_quota', 'none');
}
if($userQuota=='none') {
$this->userQuota[$user]=0;

View File

@ -6,7 +6,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
protected $datadir;
public function __construct($arguments) {
$this->datadir=$arguments['datadir'];
if(substr($this->datadir,-1)!=='/') {
if(substr($this->datadir, -1)!=='/') {
$this->datadir.='/';
}
}
@ -20,7 +20,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
return opendir($this->datadir.$path);
}
public function is_dir($path) {
if(substr($path,-1)=='/') {
if(substr($path, -1)=='/') {
$path=substr($path, 0, -1);
}
return is_dir($this->datadir.$path);
@ -86,11 +86,11 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
}
public function rename($path1, $path2) {
if (!$this->isUpdatable($path1)) {
OC_Log::write('core','unable to rename, file is not writable : '.$path1, OC_Log::ERROR);
OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, OC_Log::ERROR);
return false;
}
if(! $this->file_exists($path1)) {
OC_Log::write('core','unable to rename, file does not exists : '.$path1, OC_Log::ERROR);
OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, OC_Log::ERROR);
return false;
}

View File

@ -209,48 +209,48 @@ class OC_Filesystem{
}
static private function loadSystemMountPoints($user) {
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
$mountConfig=include OC::$SERVERROOT.'/config/mount.php';
if(isset($mountConfig['global'])) {
foreach($mountConfig['global'] as $mountPoint=>$options) {
self::mount($options['class'], $options['options'], $mountPoint);
}
}
if(isset($mountConfig['group'])) {
foreach($mountConfig['group'] as $group=>$mounts) {
if(OC_Group::inGroup($user, $group)) {
foreach($mounts as $mountPoint=>$options) {
$mountPoint=self::setUserVars($mountPoint, $user);
foreach($options as &$option) {
$option=self::setUserVars($option, $user);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
}
}
}
if(isset($mountConfig['user'])) {
foreach($mountConfig['user'] as $user=>$mounts) {
if($user==='all' or strtolower($user)===strtolower($user)) {
foreach($mounts as $mountPoint=>$options) {
$mountPoint=self::setUserVars($mountPoint, $user);
foreach($options as &$option) {
$option=self::setUserVars($option, $user);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
}
}
}
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
$previousMTime=OC_Appconfig::getValue('files','mountconfigmtime', 0);
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
OC_FileCache::triggerUpdate();
OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime);
}
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
$mountConfig=include OC::$SERVERROOT.'/config/mount.php';
if(isset($mountConfig['global'])) {
foreach($mountConfig['global'] as $mountPoint=>$options) {
self::mount($options['class'], $options['options'], $mountPoint);
}
}
if(isset($mountConfig['group'])) {
foreach($mountConfig['group'] as $group=>$mounts) {
if(OC_Group::inGroup($user, $group)) {
foreach($mounts as $mountPoint=>$options) {
$mountPoint=self::setUserVars($mountPoint, $user);
foreach($options as &$option) {
$option=self::setUserVars($option, $user);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
}
}
}
if(isset($mountConfig['user'])) {
foreach($mountConfig['user'] as $user=>$mounts) {
if($user==='all' or strtolower($user)===strtolower($user)) {
foreach($mounts as $mountPoint=>$options) {
$mountPoint=self::setUserVars($mountPoint, $user);
foreach($options as &$option) {
$option=self::setUserVars($option, $user);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
}
}
}
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
$previousMTime=OC_Appconfig::getValue('files', 'mountconfigmtime', 0);
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
OC_FileCache::triggerUpdate();
OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime);
}
}
}
@ -312,7 +312,7 @@ class OC_Filesystem{
return false;
}
}else{
OC_Log::write('core','storage backend '.$class.' not found', OC_Log::ERROR);
OC_Log::write('core', 'storage backend '.$class.' not found', OC_Log::ERROR);
return false;
}
}

View File

@ -57,7 +57,7 @@ class OC_Installer{
*/
public static function installApp( $data = array()) {
if(!isset($data['source'])) {
OC_Log::write('core','No source specified when installing app', OC_Log::ERROR);
OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR);
return false;
}
@ -65,13 +65,13 @@ class OC_Installer{
if($data['source']=='http') {
$path=OC_Helper::tmpFile();
if(!isset($data['href'])) {
OC_Log::write('core','No href specified when installing app from http', OC_Log::ERROR);
OC_Log::write('core', 'No href specified when installing app from http', OC_Log::ERROR);
return false;
}
copy($data['href'], $path);
}else{
if(!isset($data['path'])) {
OC_Log::write('core','No path specified when installing app from local file', OC_Log::ERROR);
OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR);
return false;
}
$path=$data['path'];
@ -86,7 +86,7 @@ class OC_Installer{
rename($path, $path.'.tgz');
$path.='.tgz';
}else{
OC_Log::write('core','Archives of type '.$mime.' are not supported', OC_Log::ERROR);
OC_Log::write('core', 'Archives of type '.$mime.' are not supported', OC_Log::ERROR);
return false;
}

View File

@ -47,7 +47,7 @@ class OC_Log {
//ob_end_clean();
self::write('PHP', $error['message'] . ' at ' . $error['file'] . '#' . $error['line'], self::FATAL);
} else {
return true;
return true;
}
}

View File

@ -611,7 +611,7 @@ class OC_Migrate{
if( file_exists( $db ) ) {
// Connect to the db
if(!self::connectDB( $db )) {
OC_Log::write('migration','Failed to connect to migration.db', OC_Log::ERROR);
OC_Log::write('migration', 'Failed to connect to migration.db', OC_Log::ERROR);
return false;
}
} else {

View File

@ -205,7 +205,7 @@ class OC_Migration_Content{
}
closedir($dirhandle);
} else {
OC_Log::write('admin_export',"Was not able to open directory: " . $dir, OC_Log::ERROR);
OC_Log::write('admin_export', "Was not able to open directory: " . $dir, OC_Log::ERROR);
return false;
}
return true;

View File

@ -162,7 +162,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
OC_Log::write('core','Unable to parse OCS content', OC_Log::FATAL);
OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);
@ -200,7 +200,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
OC_Log::write('core','Unable to parse OCS content', OC_Log::FATAL);
OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);
@ -238,7 +238,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
OC_Log::write('core','Unable to parse knowledgebase content', OC_Log::FATAL);
OC_Log::write('core', 'Unable to parse knowledgebase content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);

View File

@ -62,7 +62,7 @@ class BackgroundJob {
* @param $type execution type
* @return boolean
*
* This method sets the execution type of the background jobs. Possible types
* This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
*/
public static function setExecutionType( $type ) {

View File

@ -28,7 +28,7 @@ namespace OCP;
/**
* This class provides the ability for apps to share their content between users.
* Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
*
*
* It provides the following hooks:
* - post_shared
*/

View File

@ -61,7 +61,7 @@ class Util {
*/
public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='') {
// call the internal mail class
\OC_MAIL::send( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='');
\OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '');
}
/**

View File

@ -199,7 +199,7 @@ class OC_Template{
$mode='tablet';
}elseif(stripos($_SERVER['HTTP_USER_AGENT'], 'iphone')>0) {
$mode='mobile';
}elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'], 'nokia')>0)) {
}elseif((stripos($_SERVER['HTTP_USER_AGENT'], 'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'], 'nokia')>0)) {
$mode='mobile';
}else{
$mode='default';

View File

@ -133,7 +133,7 @@ class OC_User {
self::useBackend($backend);
$_setupedBackends[]=$i;
}else{
OC_Log::write('core','User backend '.$class.' not found.', OC_Log::ERROR);
OC_Log::write('core', 'User backend '.$class.' not found.', OC_Log::ERROR);
}
}
}

View File

@ -559,7 +559,7 @@ class OC_Util {
// creating a test file
$testfile = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$filename;
if(file_exists($testfile)){// already running this test, possible recursive call
if(file_exists($testfile)) {// already running this test, possible recursive call
return false;
}

View File

@ -3,22 +3,22 @@
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* 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
* 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
*
* 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/>.
*
*
*/
require_once '../lib/base.php';

View File

@ -3,22 +3,22 @@
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* 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
* 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
*
* 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/>.
*
*
*/
require_once '../lib/base.php';

View File

@ -16,8 +16,7 @@ if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
$userstatus = 'subadmin';
}
if(OC_User::getUser() === $username) {
if (OC_User::checkPassword($username, $oldPassword))
{
if (OC_User::checkPassword($username, $oldPassword)) {
$userstatus = 'user';
} else {
if (!OC_Util::isUserVerified()) {

View File

@ -43,9 +43,9 @@ try {
}
OC_Group::addToGroup( $username, $i );
}
OC_JSON::success(array("data" =>
array(
"username" => $username,
OC_JSON::success(array("data" =>
array(
"username" => $username,
"groups" => implode( ", ", OC_Group::getUserGroups( $username )))));
} catch (Exception $exception) {
OC_JSON::error(array("data" => array( "message" => $exception->getMessage())));

View File

@ -12,5 +12,5 @@ $offset=(isset($_GET['offset']))?$_GET['offset']:0;
$entries=OC_Log_Owncloud::getEntries($count, $offset);
OC_JSON::success(array(
"data" => OC_Util::sanitizeHTML($entries),
"data" => OC_Util::sanitizeHTML($entries),
"remain"=>(count(OC_Log_Owncloud::getEntries(1, $offset + $offset)) != 0) ? true : false));

View File

@ -32,9 +32,9 @@ if (OC_Group::inGroup(OC_User::getUser(), 'admin')) {
$batch = OC_User::getUsers('', 10, $offset);
foreach ($batch as $user) {
$users[] = array(
'name' => $user,
'groups' => join(', ', OC_Group::getUserGroups($user)),
'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)),
'name' => $user,
'groups' => join(', ', OC_Group::getUserGroups($user)),
'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)),
'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
}
} else {
@ -42,8 +42,8 @@ if (OC_Group::inGroup(OC_User::getUser(), 'admin')) {
$batch = OC_Group::usersInGroups($groups, '', 10, $offset);
foreach ($batch as $user) {
$users[] = array(
'name' => $user,
'groups' => join(', ', OC_Group::getUserGroups($user)),
'name' => $user,
'groups' => join(', ', OC_Group::getUserGroups($user)),
'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
}
}

View File

@ -95,11 +95,11 @@ if ( $remoteApps ) {
foreach ( $remoteApps AS $key => $remote ) {
if (
if (
$app['name'] == $remote['name']
// To set duplicate detection to use OCS ID instead of string name,
// enable this code, remove the line of code above,
// and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app:
// To set duplicate detection to use OCS ID instead of string name,
// enable this code, remove the line of code above,
// and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app:
// OR $app['ocs_id'] == $remote['ocs_id']
) {

View File

@ -3,7 +3,7 @@
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
return array(
'bg_BG'=>'български език',
'ca'=>'Català',

View File

@ -1,4 +1,4 @@
<?php
<?php
/**
* 2012 Frank Karlitschek frank@owncloud.org
* This file is licensed under the Affero General Public License version 3 or later.
@ -12,8 +12,7 @@
<?php
$url=OC_Helper::linkTo( "settings", "help.php" ).'?page=';
$pageNavi=OC_Util::getPageNavi($_['pagecount'], $_['page'], $url);
if($pageNavi)
{
if($pageNavi) {
$pageNavi->printPage();
}
?>

View File

@ -142,7 +142,7 @@ var isadmin = <?php echo $_['isadmin']?'true':'false'; ?>;
</div>
</td>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>
<?php if($user['name']!=OC_User::getUser()):?>
<a href="#" class="action delete" original-title="<?php echo $l->t('Delete')?>">
<img src="<?php echo image_path('core', 'actions/delete.svg') ?>" />
</a>

View File

@ -31,7 +31,7 @@ if($isadmin) {
foreach($accessibleusers as $i) {
$users[] = array(
"name" => $i,
"name" => $i,
"groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
'quota'=>OC_Preferences::getValue($i, 'files', 'quota', 'default'),
'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
@ -42,7 +42,7 @@ foreach( $accessiblegroups as $i ) {
$groups[] = array( "name" => $i );
}
$quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB');
$quotaPreset=explode(',',$quotaPreset);
$quotaPreset=explode(',', $quotaPreset);
foreach($quotaPreset as &$preset) {
$preset=trim($preset);
}

View File

@ -181,7 +181,7 @@ class Test_Share extends UnitTestCase {
$this->assertEquals($message, $exception->getMessage());
}
// Owner grants share and update permission
// Owner grants share and update permission
OC_User::setUserId($this->user1);
$this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_SHARE));
@ -375,7 +375,7 @@ class Test_Share extends UnitTestCase {
$this->assertTrue(in_array('test.txt', $to_test));
$this->assertTrue(in_array('test1.txt', $to_test));
// Valid reshare
// Valid reshare
$this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE));
OC_User::setUserId($this->user4);
$this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));

View File

@ -23,10 +23,10 @@
/**
* Abstract class to provide the basis of backend-specific unit test classes.
*
* All subclasses MUST assign a backend property in setUp() which implements
* 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
*/

View File

@ -10,7 +10,7 @@ class Test_Util extends UnitTestCase {
// Constructor
function Test_Util() {
date_default_timezone_set("UTC");
date_default_timezone_set("UTC");
}
function testFormatDate() {
@ -36,10 +36,10 @@ class Test_Util extends UnitTestCase {
$goodString = "This is an harmless string.";
$result = OC_Util::sanitizeHTML($goodString);
$this->assertEquals("This is an harmless string.", $result);
}
}
function testGenerate_random_bytes() {
$result = strlen(OC_Util::generate_random_bytes(59));
$this->assertEquals(59, $result);
}
}
}

View File

@ -1,15 +1,15 @@
<?php
$CONFIG = array (
"appstoreenabled" => false,
'apps_paths' =>
'apps_paths' =>
array (
0 =>
0 =>
array (
'path' => OC::$SERVERROOT.'/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
1 =>
array (
'path' => OC::$SERVERROOT.'/apps2',
'url' => '/apps2',