Thread: [Openupload-svn-update] SF.net SVN: openupload:[62] trunk/lib/modules/default/admin.inc.php
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-23 12:52:49
|
Revision: 62
http://openupload.svn.sourceforge.net/openupload/?rev=62&view=rev
Author: tsdogs
Date: 2008-10-23 10:29:08 +0000 (Thu, 23 Oct 2008)
Log Message:
-----------
Add banned ip administration
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-23 10:26:33 UTC (rev 61)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-23 10:29:08 UTC (rev 62)
@@ -44,6 +44,12 @@
3 => "rightedit",
4 => "rightdel",
),
+ "adminbanned" => array (
+ 1 => "banned",
+ 2 => "bannedadd",
+ 3 => "bannededit",
+ 4 => "banneddel",
+ ),
);
var $page;
@@ -405,6 +411,101 @@
function settings() {
$this->tpl->assign('config',app()->config);
}
+
+ function banned() {
+ $NUM = 50;
+
+ $page = 1;
+ if (isset($_GET['page'])) {
+ $page=$_GET['page'];
+ }
+ $limit = ($NUM*($page-1)).','.$NUM;
+ $count = app()->db->count('banned');
+ $this->tpl->assign('pages',ceil($count / $NUM)+1);
+ $this->tpl->assign('pagen',$page);
+ $banned = app()->db->read('banned',array(),array('priority'),$limit);
+ $this->tpl->assign('banned',$banned);
+ }
+
+ function bannedadd() {
+ global $_GET;
+ global $_POST;
+
+ if (isset($_GET['ip'])) {
+ $ip = $_GET['ip'];
+ $ban = app()->db->read('banned',array('ip' => $ip));
+ $ban = $ban[0];
+ if ($ban['ip']!=$ip) {
+ $ban['id']='';
+ $ban['priority']='10'; /* maybe a bigger one is better */
+ $ban['ip']=$ip;
+ $ban['access']='deny';
+ app()->db->insert('banned',$ban);
+ app()->message(tr('IP %1 has been banned!',$ip));
+ if (isset($_GET['nextaction']))
+ redirect('?action='.$_GET['nextaction']);
+ } else {
+ app()->error(tr('IP %1 was already in state: %2!',$ip,$ban['access']));
+ if (isset($_GET['newaction']))
+ redirect('?action='.$_GET['newaction']);
+ }
+ } else if (isset($_POST['addbannedip'])) {
+ $ip = $_POST['addbannedip'];
+ $ban = app()->db->read('banned',array('ip' => $ip));
+ $ban = $ban[0];
+ if ($ban['ip']!=$ip) {
+ $ban['id']='';
+ $ban['priority']=$_POST['addbannedpriority'];
+ $ban['ip']=$ip;
+ $ban['access']=$_POST['addbannedaccess'];
+ app()->db->insert('banned',$ban);
+ $this->nextStep(1);
+ } else {
+ app()->error(tr('IP %1 was already in state: %2!',$ip,$ban['access']));
+ }
+ } else {
+ $ban['access']='deny';
+ }
+ $this->tpl->assign('access',array('allow' => tr('Allow'), 'deny' => tr('Deny')));
+ $this->tpl->assign('banned',$ban);
+ }
+
+ function bannededit() {
+ global $_GET;
+ global $_POST;
+
+ if (isset($_GET['id'])) {
+ $id = $_GET['id'];
+ $ban = app()->db->read('banned',array('id' => $id));
+ $ban = $ban[0];
+ if ($ban['id']!=$id) {
+ $this->nextStep(1);
+ }
+ } else if (isset($_POST['editbannedid'])) {
+ $id = $_POST['editbannedid'];
+ $ban = app()->db->read('banned',array('id' => $id));
+ $ban = $ban[0];
+ if ($ban['id']==$id) {
+ $ban['priority']=$_POST['editbannedpriority'];
+ $ban['ip']=$_POST['editbannedip'];
+ $ban['access']=$_POST['editbannedaccess'];
+ app()->db->update('banned',$ban,array('id' => $ban['id']));
+ }
+ $this->nextStep(1);
+ }
+ $this->tpl->assign('access',array('allow' => tr('Allow'), 'deny' => tr('Deny')));
+ $this->tpl->assign('banned',$ban);
+ }
+
+ function banneddel() {
+ app()->db->delete('banned',array('id' => $_GET['id']));
+ $this->nextStep(1);
+ }
+
+ function bannedup() {
+ }
+ function banneddown() {
+ }
}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-10-31 16:40:11
|
Revision: 96
http://openupload.svn.sourceforge.net/openupload/?rev=96&view=rev
Author: tsdogs
Date: 2008-10-31 16:40:01 +0000 (Fri, 31 Oct 2008)
Log Message:
-----------
fix registration bug for renamed functions
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-31 16:39:45 UTC (rev 95)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-31 16:40:01 UTC (rev 96)
@@ -264,7 +264,6 @@
$right['action']='*';
$right['access']='deny';
if (isset($_POST['addrightgroup'])) {
- $right['id']='';
$right['group_name']=$_POST['addrightgroup'];
$right['module']=$_POST['addrightmodule'];
$right['action']=$_POST['addrightaction'];
@@ -366,7 +365,6 @@
$this->tpl->assign('access',$access);
$plugin['access']='disable';
if (isset($_POST['addplugingroup'])) {
- $plugin['id']='';
$plugin['group_name']=$_POST['addplugingroup'];
$plugin['plugin']=$_POST['addpluginplugin'];
$plugin['access']=$_POST['addpluginaccess'];
@@ -441,7 +439,6 @@
$ban = app()->db->read('banned',array('ip' => $ip));
$ban = $ban[0];
if ($ban['ip']!=$ip) {
- $ban['id']='';
$ban['priority']='10'; /* maybe a bigger one is better */
$ban['ip']=$ip;
$ban['access']='deny';
@@ -459,7 +456,6 @@
$ban = app()->db->read('banned',array('ip' => $ip));
$ban = $ban[0];
if ($ban['ip']!=$ip) {
- $ban['id']='';
$ban['priority']=$_POST['addbannedpriority'];
$ban['ip']=$ip;
$ban['access']=$_POST['addbannedaccess'];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-06 12:39:12
|
Revision: 119
http://openupload.svn.sourceforge.net/openupload/?rev=119&view=rev
Author: tsdogs
Date: 2008-11-06 12:39:02 +0000 (Thu, 06 Nov 2008)
Log Message:
-----------
Add initial language administration
fix bug #2225762 (group editing)
fix bug #2229204 (user password change admin)
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-11-06 12:36:44 UTC (rev 118)
+++ trunk/lib/modules/default/admin.inc.php 2008-11-06 12:39:02 UTC (rev 119)
@@ -51,6 +51,13 @@
3 => "bannededit",
4 => "banneddel",
),
+ "adminlangs" => array (
+ 1 => "langs",
+ 2 => "langadd",
+ 3 => "langedit",
+ 4 => "langdel",
+ 5 => "langtoggle",
+ ),
);
var $page;
@@ -156,8 +163,9 @@
$groups = app()->auth->groupinfo();
$this->tpl->assign('groups',$groups);
if (isset($_POST['login'])) {
+ $pwd = false;
$user = app()->auth->userinfo($_POST['login']);
- $user = $user[0];
+ //$user = $user[0];
$user['name']=$_POST['editusername'];
$user['group_name']=$_POST['editusergroup'];
$user['email']=$_POST['edituseremail'];
@@ -172,15 +180,17 @@
app()->error('Passwords do not correspond!');
$error = true;
}
- if (!$error)
- $user['password']=crypt($_POST['edituserpassword']);
+ if (!$error) {
+ $user['password']=$_POST['edituserpassword'];
+ $pwd = true;
+ }
}
if (!validEmail($_POST['edituseremail'])) {
app()->error('e-mail is not a valid address!');
$error = true;
}
if (!$error) {
- app()->auth->useredit($user);
+ app()->auth->useredit($user,$pwd);
/* redirect */
$this->nextStep(1);
}
@@ -202,31 +212,40 @@
function groupadd() {
global $_POST;
- if (isset($_POST['addgroupname'])) {
- $group['name']=$_POST['addgroupname'];
- $group['description']=$_POST['addgroupdescription'];
- if ($group['name']!='') {
- app()->auth->groupadd($group);
- $this->nextStep(1);
- } else {
- app()->error(tr('Please provide a valid group name!'));
+ if (app()->auth->features['groupadmin']=='yes') {
+ if (isset($_POST['addgroupname'])) {
+ $group['name']=$_POST['addgroupname'];
+ $group['description']=$_POST['addgroupdescription'];
+ if ($group['name']!='') {
+ app()->auth->groupadd($group);
+ $this->nextStep(1);
+ } else {
+ app()->error(tr('Please provide a valid group name!'));
+ }
}
+ app()->tpl->assign('group',$group);
+ } else {
+ app()->error(tr('Group administration not supported by Auth Module'));
}
- app()->tpl->assign('group',$group);
}
function groupedit() {
global $_POST;
global $_GET;
- $group = app()->auth->groupinfo();
- $group = $group[0];
- if (isset($_POST['editgroupname'])) {
- $group['name']=$_POST['editgroupname'];
- $group['description']=$_POST['editgroupdescription'];
- $this->nextStep(1);
+ if (app()->auth->features['groupadmin']=='yes') {
+ $id = isset($_POST['editgroupname'])?$_POST['editgroupname']:$_GET['id'];
+ $group = app()->auth->groupinfo($id);
+ if (isset($_POST['editgroupname'])) {
+ $group['name']=$_POST['editgroupname'];
+ $group['description']=$_POST['editgroupdescription'];
+ app()->auth->groupedit($group);
+ $this->nextStep(1);
+ }
+ app()->tpl->assign('group',$group);
+ } else {
+ app()->error(tr('Group administration not supported by Auth Module'));
}
- app()->tpl->assign('group',$group);
}
function groupdel() {
@@ -562,6 +581,53 @@
}
function banneddown() {
}
-
+
+ function langs() {
+ $langs = app()->db->read('langs');
+ $this->tpl->assign('langlist',$langs);
+ }
+
+ function langadd() {
+ }
+
+ function langedit() {
+ global $_GET;
+
+ if (isset($_POST['id'])) {
+ $lang = app()->db->read('langs',array('id' => $_POST['id']));
+ $lang = $lang[0];
+ $lang['name']=$_POST['editlangname'];
+ $lang['locale']=$_POST['editlanglocale'];
+ $lang['browser']=$_POST['editlangbrowser'];
+ $lang['charset']=$_POST['editlangcharset'];
+ $lang['active']=isset($_POST['editlangactive'])?1:0;
+ //$this->tpl->assign('lang' , $lang[0]);
+ app()->db->update('langs',$lang,array('id' => $_POST['id']));
+ $this->nextStep(1);
+ } else if (isset($_GET['id'])) {
+ $lang = app()->db->read('langs',array('id' => $_GET['id']));
+ $this->tpl->assign('lang', $lang[0]);
+ } else {
+ $this->nextStep(1);
+ }
+ }
+
+ function langdel() {
+ }
+
+ function langtoggle() {
+ global $_GET;
+
+ if (isset($_GET['id'])) {
+ $active=$_GET['active']==1?0:1;
+ $lang = app()->db->read('langs',array('id' => $_GET['id']));
+ $lang = $lang[0];
+ if ($lang['id']==$_GET['id']) {
+ $lang['active']=$active;
+ app()->db->update('langs',$lang,array('id' => $_GET['id']),array('active'));
+ }
+ }
+ $this->nextStep(1);
+ }
}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-14 19:13:18
|
Revision: 147
http://openupload.svn.sourceforge.net/openupload/?rev=147&view=rev
Author: tsdogs
Date: 2008-11-14 19:13:14 +0000 (Fri, 14 Nov 2008)
Log Message:
-----------
remove not needed line
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-11-14 19:12:18 UTC (rev 146)
+++ trunk/lib/modules/default/admin.inc.php 2008-11-14 19:13:14 UTC (rev 147)
@@ -166,7 +166,6 @@
if (isset($_POST['login'])) {
$pwd = false;
$user = app()->auth->userinfo($_POST['login']);
- //$user = $user[0];
$user['name']=$_POST['editusername'];
$user['group_name']=$_POST['editusergroup'];
$user['email']=$_POST['edituseremail'];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-12-09 17:07:04
|
Revision: 172
http://openupload.svn.sourceforge.net/openupload/?rev=172&view=rev
Author: tsdogs
Date: 2008-12-09 17:07:00 +0000 (Tue, 09 Dec 2008)
Log Message:
-----------
Add delete confirmation and multi delete options to admin
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-12-09 17:06:42 UTC (rev 171)
+++ trunk/lib/modules/default/admin.inc.php 2008-12-09 17:07:00 UTC (rev 172)
@@ -17,6 +17,7 @@
2 => "pluginadd",
3 => "pluginedit",
4 => "plugindel",
+ 5 => "pluginmultidel",
),
"adminpluginsoptions" => array (
1 => "pluginoptions",
@@ -29,6 +30,7 @@
1 => "files",
2 => "filedel",
3 => "filesplugin",
+ 4 => "filemultidel",
),
"adminusers" => array (
1 => "users",
@@ -36,12 +38,14 @@
3 => "useredit",
4 => "userdel",
5 => "useractivate",
+ 6 => "usermultidel",
),
"admingroups" => array (
1 => "groups",
2 => "groupadd",
3 => "groupedit",
4 => "groupdel",
+ 5 => "groupmultidel",
),
"adminrights" => array (
1 => "rights",
@@ -52,6 +56,7 @@
2 => "bannedadd",
3 => "bannededit",
4 => "banneddel",
+ 5 => "bannedmultidel",
),
"adminlangs" => array (
1 => "langs",
@@ -59,6 +64,7 @@
3 => "langedit",
4 => "langdel",
5 => "langtoggle",
+ 6 => "langmultidel",
),
"adminlogs" => array (
1 => "logs",
@@ -147,6 +153,18 @@
$this->nextStep(1);
}
+ function usermultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'user_'))!==FALSE) {
+ $user = substr($k,5,strlen($k)-5);
+ app()->auth->userdel($user);
+ }
+ }
+ $this->nextStep(1);
+ }
+
function useractivate() {
global $_GET;
@@ -264,6 +282,21 @@
$this->nextStep(1);
}
+ function groupmultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'group_'))!==FALSE) {
+ $group = substr($k,6,strlen($k)-6);
+ app()->auth->groupdel($group);
+ /* delete all the rights of the group */
+ app()->db->delete('acl',array('group_name' => $group));
+ app()->db->delete('plugin_acl',array('group_name' => $group));
+ }
+ }
+ $this->nextStep(1);
+ }
+
function rights() {
$groups = app()->auth->groupinfo();
array_unshift($groups,array('name' => '*','description' => tr('Any group')));
@@ -388,12 +421,30 @@
$f = app()->db->read('files',array('id'=>$_GET['id']));
if ($f[0]['id']==$_GET['id']) {
app()->db->delete('files',array('id' => $_GET['id']));
+ app()->db->delete('file_options',array('file_id' => $_GET['id']));
unlink(app()->config['DATA_PATH'].'/'.$_GET['id']);
}
}
$this->nextStep(1);
}
+ function filemultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'file_'))!==FALSE) {
+ $fid = substr($k,5,strlen($k)-5);
+ $f = app()->db->read('files',array('id'=>$fid));
+ if ($f[0]['id']==$fid) {
+ app()->db->delete('files',array('id' => $fid));
+ app()->db->delete('file_options',array('file_id' => $fid));
+ unlink(app()->config['DATA_PATH'].'/'.$fid);
+ }
+ }
+ }
+ $this->nextStep(1);
+ }
+
function filesplugin() {
global $_GET;
if (isset($_GET['plugin'])) {
@@ -467,6 +518,18 @@
$this->nextStep(1);
}
+ function pluginmultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'p_'))!==FALSE) {
+ $p = substr($k,2,strlen($k)-2);
+ app()->db->delete('plugin_acl',array('id' => $p));
+ }
+ }
+ $this->nextStep(1);
+ }
+
function pluginoptions() {
/* list the plugins */
foreach (app()->config['plugins'] as $p) {
@@ -724,6 +787,19 @@
$this->nextStep(1);
}
+ function bannedmultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'ban_'))!==FALSE) {
+ $ban = substr($k,4,strlen($k)-4);
+ /* delete all the rights of the group */
+ app()->db->delete('banned',array('id' => $ban));
+ }
+ }
+ $this->nextStep(1);
+ }
+
function bannedup() {
}
function banneddown() {
@@ -805,6 +881,18 @@
$this->nextStep(1);
}
+ function langmultidel() {
+ global $_POST;
+
+ foreach ($_POST as $k => $v) {
+ if (($v == 1) and (strpos($k,'lang_'))!==FALSE) {
+ $lang = substr($k,5,strlen($k)-5);
+ app()->db->delete('langs',array('id' => $lang));
+ }
+ }
+ $this->nextStep(1);
+ }
+
function langtoggle() {
global $_GET;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-03-07 19:05:50
|
Revision: 291
http://openupload.svn.sourceforge.net/openupload/?rev=291&view=rev
Author: tsdogs
Date: 2009-03-07 19:05:46 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
fix missing tr function in error messages! (Peter Velan)
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2009-03-07 19:01:42 UTC (rev 290)
+++ trunk/lib/modules/default/admin.inc.php 2009-03-07 19:05:46 UTC (rev 291)
@@ -120,18 +120,18 @@
$user['lang']=$_POST['adduserlang'];
$error = false;
if (strlen($_POST['adduserlogin'])<5) {
- app()->error('login name must be at least 5 char long!');
+ app()->error(tr('Login name must be at least 5 char long!'));
$error = true;
}
if (strlen($_POST['adduserpassword'])<5) {
- app()->error('password must be at least 5 char long!');
+ app()->error(tr('Password must be at least 5 char long!'));
$error = true;
} else if ($_POST['adduserpassword']!=$_POST['adduserrepassword']) {
- app()->error('Passwords do not correspond!');
+ app()->error(tr('Passwords do not correspond!'));
$error = true;
}
if (!validEmail($_POST['adduseremail'])) {
- app()->error('e-mail is not a valid address!');
+ app()->error(tr('e-mail is not a valid address!'));
$error = true;
}
if (!$error) {
@@ -207,10 +207,10 @@
$error = false;
if ($_POST['edituserpassword']!='') {
if (strlen($_POST['edituserpassword'])<5) {
- app()->error('password must be at least 5 char long!');
+ app()->error(tr('password must be at least 5 char long!'));
$error = true;
} else if ($_POST['edituserpassword']!=$_POST['edituserrepassword']) {
- app()->error('Passwords do not correspond!');
+ app()->error(tr('Passwords do not correspond!'));
$error = true;
}
if (!$error) {
@@ -219,7 +219,7 @@
}
}
if (!validEmail($_POST['edituseremail'])) {
- app()->error('e-mail is not a valid address!');
+ app()->error(tr('e-mail is not a valid address!'));
$error = true;
}
if (!$error) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-04 18:46:37
|
Revision: 107
http://openupload.svn.sourceforge.net/openupload/?rev=107&view=rev
Author: tsdogs
Date: 2008-11-04 18:46:28 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
Change rights administration
delete files now works
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-11-04 18:00:26 UTC (rev 106)
+++ trunk/lib/modules/default/admin.inc.php 2008-11-04 18:46:28 UTC (rev 107)
@@ -19,6 +19,9 @@
),
"adminpluginsoptions" => array (
1 => "pluginoptions",
+ 2 => "pluginoptionadd",
+ 3 => "pluginoptionedit",
+ 4 => "pluginoptiondelete",
),
"adminfiles" => array (
1 => "files",
@@ -40,9 +43,7 @@
),
"adminrights" => array (
1 => "rights",
- 2 => "rightadd",
- 3 => "rightedit",
- 4 => "rightdel",
+ 2 => "rightedit",
),
"adminbanned" => array (
1 => "banned",
@@ -242,73 +243,104 @@
function rights() {
$groups = app()->auth->groupinfo();
+ array_unshift($groups,array('name' => '*','description' => tr('Any group')));
$this->tpl->assign('groups',$groups);
- $rights = app()->db->read('acl',array(),array('group_name','module'));
+ $rights = app()->db->read('acl',array(),array('group_name','module'),'',array('group_name','module','action'));
$this->tpl->assign('rights',$rights);
}
- function rightadd() {
- global $_POST;
-
- $modules = app()->config['modules'];
- $modules['*']='*';
- $this->tpl->assign('modules',$modules);
- $groups = app()->auth->groupinfo();
- $groups[]='*';
- $this->tpl->assign('groups',$groups);
- $access['allow']=tr('Allow');
- $access['deny']=tr('Deny');
- $this->tpl->assign('access',$access);
- $right['module']='*';
- $right['group_name']='*';
- $right['action']='*';
- $right['access']='deny';
- if (isset($_POST['addrightgroup'])) {
- $right['group_name']=$_POST['addrightgroup'];
- $right['module']=$_POST['addrightmodule'];
- $right['action']=$_POST['addrightaction'];
- $right['access']=$_POST['addrightaccess'];
- app()->db->insert('acl',$right);
- $this->nextStep(1);
+ function checkAcl($acl,$group,$module,$action,&$comb) {
+ $result = 'deny'; /* not defined are denyed by default */
+ $comb['group']=$group;
+ $comb['module']=$module;
+ $comb['action']=$action;
+ if (isset($acl[$group][$module][$action])) {
+ $result = $acl[$group][$module][$action]['access'];
+ } else if (isset($acl[$group][$module]['*'])) {
+ $result = $acl[$group][$module]['*']['access'];
+ $comb['action']='*';
+ } else if (isset($acl[$group]['*']['*'])) {
+ $result = $acl[$group]['*']['*']['access'];
+ $comb['module']='*';
+ $comb['action']='*';
+ } else if (isset($acl['*'][$module][$action])) {
+ $result = $acl['*'][$module][$action];
+ $comb['group']='*';
+ } else if (isset($acl['*'][$module]['*'])) {
+ $result = $acl['*'][$module]['*']['access'];
+ $comb['group']='*';
+ $comb['action']='*';
+ } else if (isset($acl['*']['*']['*'])) {
+ $result = $acl['*']['*']['*']['access']; /* this should be avoided imho */
+ $comb['group']='*';
+ $comb['module']='*';
+ $comb['action']='*';
}
- app()->tpl->assign('right',$right);
+ return $result;
}
function rightedit() {
+ global $_GET;
global $_POST;
- global $_GET;
- $right = app()->db->read('acl',array('id' => $_GET['id']));
- $right = $right[0];
- $modules = app()->config['modules'];
- $modules['*']='*';
+
+ if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+ foreach ($_POST as $k => $v) {
+ if (strpos($k,'right_')!==FALSE) {
+ $key = explode('_',$k);
+ /* delete and reinsert the right */
+ app()->db->delete('acl',array('group_name' => $id, 'module' => $key[1], 'action' => $key[2]));
+ if ($v != '') {
+ $acl['group_name']=$id;
+ $acl['module']=$key[1];
+ $acl['action']=$key[2];
+ $acl['access']=$v;
+ app()->db->insert('acl',$acl);
+ }
+ }
+ }
+ redirect('?action=adminrights&step=2&id='.$id);
+ } else {
+ $id = $_GET['id'];
+ }
+ $this->tpl->assign('group',$id);
+ $tmpmodules = app()->config['modules'];
+ foreach ($tmpmodules as $k => $m) {
+ if ($m != 'admin') {
+ $modules[$m]['name'] = $m;
+ $modules[$m]['actions'] = array_merge(app()->modules[$m]->actions,array('*' => array()));
+ }
+ }
+ $modules['admin']['name'] = 'admin';
+ $modules['admin']['actions'] = array('*' => array());
+ $modules = array_merge($modules,array('*'=> array('name' => '['.tr('ANY').']','actions' => array('*'=> array()))));
$this->tpl->assign('modules',$modules);
- $groups = app()->auth->groupinfo();
- $groups[]='*';
- $this->tpl->assign('groups',$groups);
+ $access['']='-';
$access['allow']=tr('Allow');
$access['deny']=tr('Deny');
$this->tpl->assign('access',$access);
- if (isset($_POST['editaclid'])) {
- $right = app()->db->read('acl',array('id' => $_POST['editaclid']));
- $right = $right[0];
- $right['group_name']=$_POST['editrightgroup'];
- $right['module']=$_POST['editrightmodule'];
- $right['action']=$_POST['editrightaction'];
- $right['access']=$_POST['editrightaccess'];
- app()->db->update('acl',$right,array('id' => $_POST['editaclid']));
- $this->nextStep(1);
- }
- app()->tpl->assign('right',$right);
- }
- function rightdel() {
- global $_GET;
- /* should check if sub users exsist */
- if (isset($_GET['id'])) {
- app()->db->delete('acl',array('id' => $_GET['id']));
- $this->nextStep(1);
+ $acl = array_merge(app()->db->read('acl',array('group_name' => $id),array('module','action'),'',
+ array('group_name','module','action')),
+ app()->db->read('acl',array('group_name' => '*'),array('module','action'),'',
+ array('group_name','module','action')));
+ foreach ($modules as $mk => $m) {
+ foreach ($m['actions'] as $a => $av) {
+ $res = $this->checkAcl($acl,$id,$mk,$a,$comb);
+ if ($res == 'allow') {
+ $rightlist[$id][$mk][$a]['access']=$acl[$id][$mk][$a]['access'];
+ $rightlist[$id][$mk][$a]['result']=tr('Allow');
+ $rightlist[$id][$mk][$a]['comb']=$comb;
+ } else {
+ $rightlist[$id][$mk][$a]['access']=$acl[$id][$mk][$a]['access'];
+ $rightlist[$id][$mk][$a]['result']=tr('Deny');
+ $rightlist[$id][$mk][$a]['comb']=$comb;
+ }
+ }
}
+ $this->tpl->assign('rights',$rightlist);
+ $this->tpl->assign('defaultgroup',app()->config['nologingroup']);
}
function files() {
@@ -330,9 +362,13 @@
global $_GET;
if ($_GET['id']!='') {
- app()->db->delete('files',array('id' => $_GET['id']));
- /* TODO: remove the file */
+ $f = app()->db->read('files',array('id'=>$_GET['id']));
+ if ($f[0]['id']==$_GET['id']) {
+ app()->db->delete('files',array('id' => $_GET['id']));
+ unlink(app()->config['DATA_PATH'].'/'.$_GET['id']);
+ }
}
+ $this->nextStep(1);
}
function filesplugin() {
@@ -409,8 +445,27 @@
}
function pluginoptions() {
+ /* list the plugins */
+ foreach (app()->config['plugins'] as $p) {
+ $list[$p]['name']=$p;
+ $list[$p]['description']=app()->plugins[$p]->description;
+ }
+ $this->tpl->assign('pluginlist',$list);
}
+ function pluginoptiondetail() {
+ }
+
+
+ function pluginoptionadd() {
+ }
+
+ function pluginoptionedit() {
+ }
+
+ function pluginoptiondelete() {
+ }
+
function settings() {
$this->tpl->assign('config',app()->config);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-12-11 11:03:28
|
Revision: 183
http://openupload.svn.sourceforge.net/openupload/?rev=183&view=rev
Author: tsdogs
Date: 2008-12-11 11:03:20 +0000 (Thu, 11 Dec 2008)
Log Message:
-----------
added maintenance option for files
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-12-11 11:02:38 UTC (rev 182)
+++ trunk/lib/modules/default/admin.inc.php 2008-12-11 11:03:20 UTC (rev 183)
@@ -32,6 +32,10 @@
3 => "filesplugin",
4 => "filemultidel",
),
+ "adminmaintenance" => array (
+ 1 => "maintenance",
+ 2 => "maintenancerun",
+ ),
"adminusers" => array (
1 => "users",
2 => "useradd",
@@ -414,15 +418,19 @@
$this->tpl->assign('files',$files);
}
+ function filedelete($id) {
+ app()->db->delete('files',array('id' => $id));
+ app()->db->delete('file_options',array('file_id' => $id));
+ unlink(app()->config['DATA_PATH'].'/'.$id);
+ }
+
function filedel() {
global $_GET;
if ($_GET['id']!='') {
$f = app()->db->read('files',array('id'=>$_GET['id']));
if ($f[0]['id']==$_GET['id']) {
- app()->db->delete('files',array('id' => $_GET['id']));
- app()->db->delete('file_options',array('file_id' => $_GET['id']));
- unlink(app()->config['DATA_PATH'].'/'.$_GET['id']);
+ $this->filedelete($_GET['id']);
}
}
$this->nextStep(1);
@@ -455,6 +463,79 @@
$this->nextStep(1);
}
+ function maintenance() {
+ global $_SESSION;
+
+ /* check if expired plugin is loaded */
+ if (isset(app()->plugins['expire'])) {
+ $this->tpl->assign('expireplugin','yes');
+ }
+ if (app()->auth->features['useradmin']!='no') {
+ $users = app()->auth->users();
+ $this->tpl->assign('users',$users);
+ }
+ $this->tpl->assign('criteria',$_SESSION['user']['del']['criteria']);
+ }
+
+ function maintenancerun() {
+ global $_POST;
+ global $_SESSION;
+
+ if (isset($_POST['expire'])) {
+ /* get all the files which have an expire date */
+ $files = app()->db->readex('file_options',array(array(array('name','=','expire'),
+ array('value','<=',date('Y-m-d',time()-(24 * 60 * 60))))));
+ $result = array();
+ foreach ($files as $f) {
+ $result[]['id']=$f['file_id'];
+ }
+ $this->tpl->assign('files',$result);
+ $_SESSION['user']['del']['files']=$result;
+ } else if (isset($_POST['run'])) {
+ $criteria = array();
+ foreach ($_POST as $k => $p) {
+ $_SESSION['user']['del']['criteria']=$_POST;
+ if (strpos($k,'c_')!==FALSE) {
+ $n = substr($k,2,strlen($k)-2);
+ if ($_POST[$n]!='') {
+ switch ($n) {
+ case 'login': $criteria[] = array ('user_login','=',$_POST[$n]);
+ break;
+ case 'older': $criteria[] = array('upload_date','<', date('Y-m-d',time()-($_POST[$n] * 24 * 60 * 60)));
+ break;
+ case 'date': $criteria[] = array('upload_date','=', $_POST[$n]);
+ break;
+ case 'size': $criteria[] = array('size','>', $_POST[$n]*1024*1024);
+ break;
+ }
+ } else {
+ app()->error(tr('Specified criteria is not valid!'));
+ $this->nextStep();
+ }
+ }
+ }
+ if (count($criteria)>0) {
+ $files = app()->db->readex('files',array($criteria));
+ $this->tpl->assign('files',$files);
+ $_SESSION['user']['del']['files']=$files;
+ } else {
+ app()->error(tr('Please specify at least one criteria!'));
+ $this->nextStep(1);
+ }
+ } else if (isset($_POST['delete'])) {
+ if (count($_SESSION['user']['del']['files'])<=0) {
+ unset($_SESSION['user']['del']['files']);
+ $this->nextStep(1);
+ }
+ foreach ($_SESSION['user']['del']['files'] as $f) {
+ $this->filedelete($f['id']);
+ }
+ $this->tpl->assign('deleted','true');
+ $this->tpl->assign('files',$_SESSION['user']['del']['files']);
+ unset($_SESSION['user']['del']);
+ }
+ }
+
function plugins() {
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-02-07 14:15:26
|
Revision: 256
http://openupload.svn.sourceforge.net/openupload/?rev=256&view=rev
Author: tsdogs
Date: 2009-02-07 14:15:24 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
fix wrong template settings.
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2009-02-07 14:00:49 UTC (rev 255)
+++ trunk/lib/modules/default/admin.inc.php 2009-02-07 14:15:24 UTC (rev 256)
@@ -800,7 +800,7 @@
$config['site']['webmaster']=$_POST['webmaster'];
$config['site']['email']=$_POST['email'];
$config['registration']['email_confirm']=isset($_POST['confirmregistration'])?'yes':'no';
- $config['template']=$_POST['template'];
+ $config['site']['template']=$_POST['template'];
$config['multiupload']=$_POST['multiupload'];
$config['max_upload_size']=$_POST['max_upload_size'];
$config['use_short_links']=isset($_POST['use_short_links'])?'yes':'no';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|