commit
0f13cbb47d
@ -0,0 +1,18 @@ |
||||
<?php |
||||
|
||||
OC::$CLASSPATH['OC_Admin_Audit_Hooks_Handlers'] = 'apps/admin_audit/lib/hooks_handlers.php'; |
||||
|
||||
OCP\Util::connectHook('OCP\User', 'pre_login', 'OC_Admin_Audit_Hooks_Handlers', 'pre_login'); |
||||
OCP\Util::connectHook('OCP\User', 'post_login', 'OC_Admin_Audit_Hooks_Handlers', 'post_login'); |
||||
OCP\Util::connectHook('OCP\User', 'logout', 'OC_Admin_Audit_Hooks_Handlers', 'logout'); |
||||
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, 'OC_Admin_Audit_Hooks_Handlers', 'rename'); |
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, 'OC_Admin_Audit_Hooks_Handlers', 'create'); |
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_Admin_Audit_Hooks_Handlers', 'copy'); |
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, 'OC_Admin_Audit_Hooks_Handlers', 'write'); |
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_read, 'OC_Admin_Audit_Hooks_Handlers', 'read'); |
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, 'OC_Admin_Audit_Hooks_Handlers', 'delete'); |
||||
|
||||
OCP\Util::connectHook('OC_Share', 'public', 'OC_Admin_Audit_Hooks_Handlers', 'share_public'); |
||||
OCP\Util::connectHook('OC_Share', 'public-download', 'OC_Admin_Audit_Hooks_Handlers', 'share_public_download'); |
||||
OCP\Util::connectHook('OC_Share', 'user', 'OC_Admin_Audit_Hooks_Handlers', 'share_user'); |
||||
@ -0,0 +1,10 @@ |
||||
<?xml version="1.0"?> |
||||
<info> |
||||
<id>admin_audit</id> |
||||
<name>Log audit info</name> |
||||
<version>0.1</version> |
||||
<licence>AGPL</licence> |
||||
<author>Bart Visscher</author> |
||||
<require>2</require> |
||||
<description>Audit user actions in Owncloud</description> |
||||
</info> |
||||
@ -0,0 +1,72 @@ |
||||
<?php |
||||
|
||||
class OC_Admin_Audit_Hooks_Handlers { |
||||
static public function pre_login($params) { |
||||
$path = $params['uid']; |
||||
self::log('Trying login '.$user); |
||||
} |
||||
static public function post_login($params) { |
||||
$path = $params['uid']; |
||||
self::log('Login '.$user); |
||||
} |
||||
static public function logout($params) { |
||||
$user = OCP\User::getUser(); |
||||
self::log('Logout '.$user); |
||||
} |
||||
|
||||
static public function rename($params) { |
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath]; |
||||
$newpath = $params[OC_Filesystem::signal_param_newpath]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user); |
||||
} |
||||
static public function create($params) { |
||||
$path = $params[OC_Filesystem::signal_param_path]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Create "'.$path.'" by '.$user); |
||||
} |
||||
static public function copy($params) { |
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath]; |
||||
$newpath = $params[OC_Filesystem::signal_param_newpath]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user); |
||||
} |
||||
static public function write($params) { |
||||
$path = $params[OC_Filesystem::signal_param_path]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Write "'.$path.'" by '.$user); |
||||
} |
||||
static public function read($params) { |
||||
$path = $params[OC_Filesystem::signal_param_path]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Read "'.$path.'" by '.$user); |
||||
} |
||||
static public function delete($params) { |
||||
$path = $params[OC_Filesystem::signal_param_path]; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Delete "'.$path.'" by '.$user); |
||||
} |
||||
static public function share_public($params) { |
||||
$path = $params['source']; |
||||
$token = $params['token']; |
||||
$user = OCP\User::getUser(); |
||||
self::log('Shared "'.$path.'" with public, token="'.$token.'" by '.$user); |
||||
} |
||||
static public function share_public_download($params) { |
||||
$path = $params['source']; |
||||
$token = $params['token']; |
||||
$user = $_SERVER['REMOTE_ADDR']; |
||||
self::log('Download of shared "'.$path.'" token="'.$token.'" by '.$user); |
||||
} |
||||
static public function share_user($params) { |
||||
$path = $params['source']; |
||||
$permissions = $params['permissions']; |
||||
$with = $params['with']; |
||||
$user = OCP\User::getUser(); |
||||
$rw = $permissions & OC_Share::WRITE ? 'w' : 'o'; |
||||
self::log('Shared "'.$path.'" (r'.$rw.') with user "'.$with.'" by '.$user); |
||||
} |
||||
static protected function log($msg) { |
||||
OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO); |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
OC::$CLASSPATH['OC_Files_Sharing_Log'] = 'apps/files_sharing_log/log.php'; |
||||
|
||||
$l=new OC_L10N('files_sharing_log'); |
||||
OCP\App::addNavigationEntry( array( |
||||
'id' => 'files_sharing_log_index', |
||||
'order' => 5, |
||||
'href' => OCP\Util::linkTo( 'files_sharing_log', 'index.php' ), |
||||
'icon' => OCP\Util::imagePath( 'files_sharing_log', 'icon.png' ), |
||||
'name' => $l->t('Shared files log')) |
||||
); |
||||
|
||||
OCP\Util::connectHook('OC_Filestorage_Shared', 'fopen', 'OC_Files_Sharing_Log', 'fopen'); |
||||
OCP\Util::connectHook('OC_Filestorage_Shared', 'file_get_contents', 'OC_Files_Sharing_Log', 'file_get_contents'); |
||||
OCP\Util::connectHook('OC_Filestorage_Shared', 'file_put_contents', 'OC_Files_Sharing_Log', 'file_put_contents'); |
||||
@ -0,0 +1,44 @@ |
||||
<?xml version="1.0" encoding="ISO-8859-1" ?> |
||||
<database> |
||||
<name>*dbname*</name> |
||||
<create>true</create> |
||||
<overwrite>false</overwrite> |
||||
<charset>latin1</charset> |
||||
<table> |
||||
<name>*dbprefix*sharing_log</name> |
||||
<declaration> |
||||
<field> |
||||
<name>user_id</name> |
||||
<type>text</type> |
||||
<notnull>true</notnull> |
||||
<length>64</length> |
||||
</field> |
||||
<field> |
||||
<name>source</name> |
||||
<type>text</type> |
||||
<notnull>true</notnull> |
||||
<length>128</length> |
||||
</field> |
||||
<field> |
||||
<name>uid_who</name> |
||||
<type>text</type> |
||||
<notnull>true</notnull> |
||||
<length>64</length> |
||||
</field> |
||||
<field> |
||||
<name>when</name> |
||||
<type>integer</type> |
||||
<default></default> |
||||
<notnull>false</notnull> |
||||
<unsigned>true</unsigned> |
||||
<length>4</length> |
||||
</field> |
||||
<field> |
||||
<name>mode</name> |
||||
<type>text</type> |
||||
<notnull>true</notnull> |
||||
<length>4</length> |
||||
</field> |
||||
</declaration> |
||||
</table> |
||||
</database> |
||||
@ -0,0 +1,10 @@ |
||||
<?xml version="1.0"?> |
||||
<info> |
||||
<id>files_sharing_log</id> |
||||
<name>File Shared access logging app</name> |
||||
<description>Log access to shared files</description> |
||||
<licence>AGPL</licence> |
||||
<author>Bart Visscher</author> |
||||
<require>4</require> |
||||
<shipped>true</shipped> |
||||
</info> |
||||
@ -0,0 +1 @@ |
||||
0.1 |
||||
@ -0,0 +1,7 @@ |
||||
#files_sharing_log { |
||||
padding: 2em; |
||||
} |
||||
#files_sharing_log th, |
||||
#files_sharing_log td { |
||||
padding: 0 1em; |
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
OCP\User::checkLoggedIn(); |
||||
OCP\App::checkAppEnabled('files_sharing_log'); |
||||
|
||||
OCP\App::setActiveNavigationEntry('files_sharing_log_index'); |
||||
|
||||
OCP\Util::addStyle('files_sharing_log', 'style'); |
||||
|
||||
$query = OCP\DB::prepare('SELECT * FROM *PREFIX*sharing_log WHERE user_id = ?'); |
||||
$log = $query->execute(array(OCP\User::getUser()))->fetchAll(); |
||||
|
||||
$output = new OCP\Template('files_sharing_log', 'index', 'user'); |
||||
$output->assign('log', $log); |
||||
$output->printPage(); |
||||
@ -0,0 +1,34 @@ |
||||
<?php |
||||
|
||||
class OC_Files_Sharing_Log { |
||||
static public function fopen($arguments) { |
||||
$target = $arguments['target']; |
||||
$source = $arguments['source']; |
||||
$mode = $arguments['mode']; |
||||
self::log($target, $source, $mode); |
||||
} |
||||
|
||||
static public function file_get_contents($arguments) { |
||||
$target = $arguments['target']; |
||||
$source = $arguments['source']; |
||||
$mode = 'get'; |
||||
self::log($target, $source, $mode); |
||||
} |
||||
|
||||
static public function file_put_contents($arguments) { |
||||
$target = $arguments['target']; |
||||
$source = $arguments['source']; |
||||
$mode = 'put'; |
||||
self::log($target, $source, $mode); |
||||
} |
||||
|
||||
static public function log($target, $source, $mode) { |
||||
$query = OCP\DB::prepare("SELECT * FROM *PREFIX*sharing WHERE source = ? AND target = ?"); |
||||
$info = $query->execute(array($source, $target))->fetchAll(); |
||||
$info = $info[0]; |
||||
//var_dump($info); |
||||
$query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing_log VALUES (?,?,?,?,?)"); |
||||
$query->execute(array($info['uid_owner'], $source, OCP\User::getUser(), time(), $mode)); |
||||
//die; |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
<table id="files_sharing_log"> |
||||
<thead> |
||||
<tr> |
||||
<th><?php echo $l->t('File') ?></th>
|
||||
<th><?php echo $l->t('Who') ?></th>
|
||||
<th><?php echo $l->t('When') ?></th>
|
||||
<th><?php echo $l->t('What') ?></th>
|
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<?php foreach($_['log'] as $log): ?> |
||||
<tr> |
||||
<td> |
||||
<?php echo $log['source'] ?> |
||||
</td> |
||||
<td> |
||||
<?php echo $log['uid_who'] ?> |
||||
</td> |
||||
<td> |
||||
<?php echo date('Y-m-d H:i:s', $log['when']) ?> |
||||
</td> |
||||
<td> |
||||
<?php switch ($log['mode']): |
||||
case 'get': |
||||
echo $l->t('Read'); |
||||
break; |
||||
case 'put': |
||||
echo $l->t('Write'); |
||||
break; |
||||
default: |
||||
if (strpos('r', $log['mode']) !== false): |
||||
echo $l->t('Read'); |
||||
else: |
||||
echo $l->t('Write'); |
||||
endif; |
||||
endswitch; |
||||
?> |
||||
</td> |
||||
</tr> |
||||
<?php endforeach; ?> |
||||
</tbody> |
||||
</table> |
||||
@ -0,0 +1,41 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - user_migrate |
||||
* |
||||
* @author Sam Tuke |
||||
* @copyright 2012 Sam Tuke samtuke@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/>. |
||||
* |
||||
*/ |
||||
|
||||
// TODO: Allow admins to expire versions of any user |
||||
// TODO: Provide feedback as to how many versions were deleted |
||||
|
||||
// Check user and app status |
||||
OCP\JSON::checkLoggedIn(); |
||||
OCP\App::checkAppEnabled('files_versions'); |
||||
|
||||
if( OCA_Versions\Storage::expireAll() ){ |
||||
|
||||
OCP\JSON::success(); |
||||
die(); |
||||
|
||||
} else { |
||||
|
||||
OCP\JSON::error(); |
||||
die(); |
||||
|
||||
} |
||||
@ -0,0 +1,51 @@ |
||||
// $(document).ready(function(){
|
||||
// $('#versions').change( function(){
|
||||
// OC.msg.startSaving('#calendar .msg')
|
||||
// // Serialize the data
|
||||
// var post = $( '#timezone' ).serialize();
|
||||
// $.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){
|
||||
// //OC.msg.finishedSaving('#calendar .msg', data);
|
||||
// });
|
||||
// return false;
|
||||
// });
|
||||
// });
|
||||
|
||||
$(document).ready(function(){ |
||||
//
|
||||
$('#expireAllBtn').click(function(){ |
||||
|
||||
// Prevent page from reloading
|
||||
event.preventDefault(); |
||||
|
||||
// Show loading gif
|
||||
$('.expireAllLoading').show(); |
||||
|
||||
$.getJSON( |
||||
OC.filePath('files_versions','ajax','expireAll.php'), |
||||
function(result){ |
||||
if (result.status == 'success') { |
||||
$('.expireAllLoading').hide(); |
||||
$('#expireAllBtn').html('Expiration successful'); |
||||
} else { |
||||
|
||||
// Cancel loading
|
||||
$('#expireAllBtn').html('Expiration failed'); |
||||
|
||||
// Show Dialog
|
||||
OC.dialogs.alert( |
||||
'Something went wrong, your files may not have been expired',
|
||||
'An error has occurred',
|
||||
function(){
|
||||
$('#expireAllBtn').html(t('files_versions', 'Expire all versions')+'<img style="display: none;" class="loading" src="'+OC.filePath('core','img','loading.gif')+'" />');
|
||||
} |
||||
|
||||
); |
||||
|
||||
} |
||||
} |
||||
|
||||
); |
||||
|
||||
}); |
||||
|
||||
}); |
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
|
||||
$tmpl = new OCP\Template( 'files_versions', 'settings-personal'); |
||||
|
||||
OCP\Util::addscript('files_versions','settings-personal'); |
||||
|
||||
return $tmpl->fetchPage(); |
||||
?> |
||||
@ -0,0 +1,9 @@ |
||||
<form id="versions"> |
||||
<fieldset class="personalblock"> |
||||
<legend> |
||||
<strong>Versions</strong><!-- translate using echo $l->t('foo'); --> |
||||
</legend> |
||||
<p>This will delete all existing backup versions of your files</p><!-- translate using echo $l->t('foo'); --> |
||||
<button id="expireAllBtn">Expire all versions<img style="display: none;" class="expireAllLoading" src="<?php echo OCP\Util::linkTo('core', 'img/loading.gif'); ?>" /></button>
|
||||
</fieldset> |
||||
</form> |
||||
Loading…
Reference in new issue