[Openupload-svn-update] SF.net SVN: openupload:[25] trunk
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-16 16:57:26
|
Revision: 25
http://openupload.svn.sourceforge.net/openupload/?rev=25&view=rev
Author: tsdogs
Date: 2008-10-16 16:57:18 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Complete administration (it needs a better organization though)
Modified Paths:
--------------
trunk/lib/classes.inc.php
trunk/lib/main.inc.php
trunk/lib/modules/db/mysql.inc.php
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/files.inc.php
trunk/plugins/banned.inc.php
trunk/templates/default/modules/admin/groups.tpl
trunk/templates/default/modules/admin/plugins.tpl
trunk/templates/default/modules/admin/rights.tpl
trunk/templates/default/modules/admin/users.tpl
trunk/www/templates/default/main.css
Added Paths:
-----------
trunk/templates/default/modules/admin/files.tpl
trunk/templates/default/modules/admin/pluginoptions.tpl
trunk/templates/default/modules/admin/pluginsacl.tpl
trunk/www/templates/default/img/admin/ban.png
Modified: trunk/lib/classes.inc.php
===================================================================
--- trunk/lib/classes.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/lib/classes.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -163,6 +163,9 @@
redirect('?action='.$action.'&step='.$step);
}
+ function fileaction() {
+ }
+
function init() {
}
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/lib/main.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -146,7 +146,7 @@
$pname = $plugin."Plugin";
$newp = new $pname();
$newp->name = $plugin;
- $this->plugins[] = $newp;
+ $this->plugins[$plugin] = $newp;
} else {
$this->error(tr('plugin include file not found: %1',$plugin));
}
Modified: trunk/lib/modules/db/mysql.inc.php
===================================================================
--- trunk/lib/modules/db/mysql.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/lib/modules/db/mysql.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -98,9 +98,9 @@
function addFile(&$finfo) {
$e = 'mysql_real_escape_string';
- $sql = 'insert into '.$this->prefix.'files (id,name,mime,description,size,remove,user_id,upload_date)
+ $sql = 'insert into '.$this->prefix.'files (id,name,mime,description,size,remove,user_id,ip,upload_date)
values ("'.$e($finfo['id']).'","'.$e($finfo['name']).'","'.$e($finfo['mime']).'","'.$e($finfo['description']).
- '","'.$e($finfo['size']).'","'.$e($finfo['remove']).'","'.$_SESSION['user']['id'].'",now())';
+ '","'.$e($finfo['size']).'","'.$e($finfo['remove']).'","'.$finfo['user_id'].'","'.$finfo['ip'].'",now())';
/* now ask the plugins for additional options */
mysql_query($sql);
return $finfo['id'];
@@ -143,13 +143,17 @@
return $plugins;
}
- function loadTable($tbl,$sort = '') {
+ function loadTable($tbl,$sort = '',$limit = '',$key = '') {
$sql = 'select * from '.$this->prefix.$tbl;
if ($sort!='') $sql .= ' order by '.$sort;
+ if ($limit!='') $sql .= ' limit '.$limit;
$res = mysql_query($sql);
$result = array();
while ($row = mysql_fetch_assoc($res)) {
- $result[] = $row;
+ if ($key!='')
+ $result[$row[$key]] = $row;
+ else
+ $result[] = $row;
}
mysql_free_result($res);
return $result;
@@ -191,6 +195,14 @@
$sql = 'delete from '.$this->prefix.$tbl.' where '.$key.'="'.$val.'"';
mysql_query($sql);
}
+
+ function countRecords($tbl) {
+ $sql = 'select count(*) as num from '.$this->prefix.$tbl;
+ $res = mysql_query($sql);
+ $row = mysql_fetch_assoc($res);
+ mysql_free_result($res);
+ return $row['num'];
+ }
}
?>
\ No newline at end of file
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -10,12 +10,20 @@
),
"adminplugins" => array (
1 => "plugins",
+ ),
+ "adminpluginsacl" => array (
+ 1 => "pluginsacl",
2 => "pluginadd",
3 => "pluginedit",
4 => "plugindel",
),
+ "adminpluginsoptions" => array (
+ 1 => "pluginoptions",
+ ),
"adminfiles" => array (
1 => "files",
+ 2 => "filedel",
+ 3 => "filesplugin",
),
"adminusers" => array (
1 => "users",
@@ -279,19 +287,54 @@
/* should check if sub users exsist */
if (isset($_GET['id'])) {
app()->db->deleteRecord('acl','id',$_GET['id']);
+ $this->nextStep(1);
}
- $this->nextStep(1);
}
function files() {
+ $NUM = 50;
+ $page = 1;
+ if (isset($_GET['page'])) {
+ $page=$_GET['page'];
+ }
+ $limit = ($NUM*($page-1)).','.$NUM;
+ $count = app()->db->countRecords('files');
+ $this->tpl->assign('pages',ceil($count / $NUM)+1);
+ $this->tpl->assign('pagen',$page);
+ $users = app()->db->loadTable('users','login','','id');
+ $this->tpl->assign('users',$users);
+ $files = app()->db->loadTable('files','upload_date desc',$limit);
+ $this->tpl->assign('files',$files);
}
+ function filedel() {
+ global $_GET;
+
+ if ($_GET['id']!='') {
+ app()->db->deleteFile($_GET['id']);
+ /* TODO: remove the file */
+ }
+ }
+
+ function filesplugin() {
+ global $_GET;
+ if (isset($_GET['plugin'])) {
+ if (isset(app()->plugins[$_GET['plugin']])) {
+ app()->plugins[$_GET['plugin']]->fileaction();
+ }
+ }
+ $this->nextStep(1);
+ }
+
function plugins() {
- /* */
+ }
+
+ function pluginsacl() {
$plugins = app()->db->loadTable('plugin_acl','plugin');
$this->tpl->assign('plugins_acl',$plugins);
}
+
function pluginadd() {
global $_POST;
@@ -346,6 +389,9 @@
$this->nextStep(1);
}
+ function pluginoptions() {
+ }
+
function settings() {
$this->tpl->assign('config',app()->config);
}
Modified: trunk/lib/modules/default/files.inc.php
===================================================================
--- trunk/lib/modules/default/files.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/lib/modules/default/files.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -61,6 +61,7 @@
function uploadOptions() {
global $_SESSION;
global $_FILES;
+ global $_SERVER;
if (isset($_FILES['upload'])) {
/* prepare the file */
@@ -70,6 +71,8 @@
$_SESSION['user']['u']['mime']=$_FILES['upload']['type'];
$_SESSION['user']['u']['name']=$_FILES['upload']['name'];
$_SESSION['user']['u']['size']=$_FILES['upload']['size'];
+ $_SESSION['user']['u']['ip']=$_SERVER['REMOTE_ADDR'];
+ $_SESSION['user']['u']['user_id']=app()->user->userInfo('id');
$this->nextStep(app()->step);
} else if (!isset($_SESSION['user']['u'])) {
redirect();
Modified: trunk/plugins/banned.inc.php
===================================================================
--- trunk/plugins/banned.inc.php 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/plugins/banned.inc.php 2008-10-16 16:57:18 UTC (rev 25)
@@ -87,5 +87,22 @@
else
return false;
}
+
+ function fileaction() {
+ global $_GET;
+ if (isset($_GET['ip'])) {
+ $ban = app()->db->getRecord('banned','ip',$_GET['ip']);
+ if ($ban['ip']!=$_GET['ip']) {
+ $ban['id']='';
+ $ban['priority']='1'; /* maybe a bigger one is better */
+ $ban['ip']=$_GET['ip'];
+ $ban['access']='deny';
+ app()->db->insertRecord('banned',$ban);
+ app()->message(tr('IP %1 has been banned!',$_GET['ip']));
+ } else {
+ app()->error(tr('IP %1 was already in state: %2!',$_GET['ip'],$ban['access']));
+ }
+ }
+ }
}
?>
\ No newline at end of file
Added: trunk/templates/default/modules/admin/files.tpl
===================================================================
--- trunk/templates/default/modules/admin/files.tpl (rev 0)
+++ trunk/templates/default/modules/admin/files.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -0,0 +1,38 @@
+{include file="default/modules/admin/adminmenu.tpl"}
+<br>
+{if $pages>2}
+<center>{section name=page loop=$pages start=1 max=20}
+{if $pagen==$smarty.section.page.index}
+<b style="font-size: 12pt">{$smarty.section.page.index}</b>
+{else}
+<a style="font-size: 12pt" href="{$script}?action={$action}&page={$smarty.section.page.index}">{$smarty.section.page.index}</a>
+{/if}
+
+{/section} </center>
+{/if}
+<br>
+<table border="0" id="dbtable">
+<tr>
+ <th width="10">S</th>
+ <th width="50">Id</th> <AZ
+ <th width="200">Name</th>
+ <th width="100">User</th>
+ <th width="100">IP</th>
+ <th width="200">Upload Date</th>
+ <th width="100">Actions</th>
+</tr>
+{foreach from=$files item=f}
+{cycle values="row1,row2" advance=true assign=rid}
+<tr>
+ <td id="{$rid}"><input type="checkbox" name="file_{$f.id}" value="1"></td>
+ <td id="{$rid}">{$f.id}</td>
+ <td id="{$rid}">{$f.name}</td>
+ <td id="{$rid}">{$users[$f.user_id].login}</td>
+ <td id="{$rid}" style="text-align: left"><a title="ban IP {$f.ip}" href="{$script}?action={$action}&step=3&plugin=banned&ip={$f.ip}">
+ <img align="right" src="{$page.template}/img/admin/ban.png" ></a>{$f.ip} </td>
+ <td id="{$rid}">{$f.upload_date}</td>
+ <td id="{$rid}">
+ <a title="delete" href="{$script}?action={$action}&step=4&id={$f.id}"><img src="{$page.template}/img/admin/delete.png"></a></td>
+</tr>
+{/foreach}
+</table>
\ No newline at end of file
Modified: trunk/templates/default/modules/admin/groups.tpl
===================================================================
--- trunk/templates/default/modules/admin/groups.tpl 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/templates/default/modules/admin/groups.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -12,11 +12,12 @@
<th width="100">Actions</th>
</tr>
{foreach from=$groups item=g}
+{cycle values="row1,row2" advance=true assign=rid}
<tr>
- <td id="row1"><input type="checkbox" name="group_{$g.name}" value="1"></td>
- <td id="row1" style="text-align:left"><a href="{$script}?action=admingroups&step=3&id={$g.name}">{$g.name}</a></td>
- <td id="row1">{$g.description}</td>
- <td id="row1">
+ <td id="{$rid}"><input type="checkbox" name="group_{$g.name}" value="1"></td>
+ <td id="{$rid}" style="text-align:left"><a href="{$script}?action=admingroups&step=3&id={$g.name}">{$g.name}</a></td>
+ <td id="{$rid}">{$g.description}</td>
+ <td id="{$rid}">
<a href="{$script}?action={$action}&step=3&id={$g.name}"><img src="{$page.template}/img/admin/edit_group.png"></a>
<a href="{$script}?action={$action}&step=4&id={$g.name}"><img src="{$page.template}/img/admin/delete_group.png"></a></td>
Added: trunk/templates/default/modules/admin/pluginoptions.tpl
===================================================================
--- trunk/templates/default/modules/admin/pluginoptions.tpl (rev 0)
+++ trunk/templates/default/modules/admin/pluginoptions.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -0,0 +1,3 @@
+{include file="default/modules/admin/adminmenu.tpl"}
+<br>
+<h1>To be implemented!!!</h1>
\ No newline at end of file
Modified: trunk/templates/default/modules/admin/plugins.tpl
===================================================================
--- trunk/templates/default/modules/admin/plugins.tpl 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/templates/default/modules/admin/plugins.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -1,29 +1,9 @@
{include file="default/modules/admin/adminmenu.tpl"}
-<div id="toolbar">
-<a href="{$script}?action={$action}&step=2&id={$u.id}"><img src="{$page.template}/img/admin/plugins.png"></a>
-<img src="{$page.template}/img/admin/tdelete.png">
-</div>
<br>
-<table border="0" id="dbtable">
+<table border="0" width="400" height="200">
<tr>
- <th width="10">S</th>
- <th width="30">ID</th>
- <th width="100">Plugin</th>
- <th width="100">Group</th>
- <th width="100">Access</th>
- <th width="100">Actions</th>
+ <td align="center"><a href="{$script}?action=adminpluginsacl"><img src="{$page.template}/img/admin/plugins.png" border="0" ><br>{tr}Plugins ACL{/tr}</a></td>
+ <td align="center"><a href="{$script}?action=adminpluginsoptions"><img src="{$page.template}/img/admin/plugins.png" border="0" align="center"><br>{tr}Plugins Options{/tr}</a></td>
</tr>
-{foreach from=$plugins_acl item=p}
-<tr>
- <td id="row1"><input type="checkbox" name="p_{$p.id}" value="1"></td>
- <td id="row1" style="text-align:left"><a href="{$script}?action={$action}&step=3&id={$p.id}">{$p.id}</a></td>
- <td id="row1">{$p.plugin}</td>
- <td id="row1">{$p.group_id}</td>
- <td id="row1">{$p.access}</td>
- <td id="row1">
- <a href="{$script}?action={$action}&step=3&id={$p.id}"><img src="{$page.template}/img/admin/edit_plugin.png"></a>
-
- <a href="{$script}?action={$action}&step=4&id={$p.id}"><img src="{$page.template}/img/admin/delete.png"></a></td>
-</tr>
-{/foreach}
+{$plugins}
</table>
\ No newline at end of file
Added: trunk/templates/default/modules/admin/pluginsacl.tpl
===================================================================
--- trunk/templates/default/modules/admin/pluginsacl.tpl (rev 0)
+++ trunk/templates/default/modules/admin/pluginsacl.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -0,0 +1,30 @@
+{include file="default/modules/admin/adminmenu.tpl"}
+<div id="toolbar">
+<a href="{$script}?action={$action}&step=2&id={$u.id}"><img src="{$page.template}/img/admin/plugins.png"></a>
+<img src="{$page.template}/img/admin/tdelete.png">
+</div>
+<br>
+<table border="0" id="dbtable">
+<tr>
+ <th width="10">S</th>
+ <th width="30">ID</th>
+ <th width="100">Plugin</th>
+ <th width="100">Group</th>
+ <th width="100">Access</th>
+ <th width="100">Actions</th>
+</tr>
+{foreach from=$plugins_acl item=p}
+{cycle values="row1,row2" advance=true assign=rid}
+<tr>
+ <td id="{$rid}"><input type="checkbox" name="p_{$p.id}" value="1"></td>
+ <td id="{$rid}" style="text-align:left"><a href="{$script}?action={$action}&step=3&id={$p.id}">{$p.id}</a></td>
+ <td id="{$rid}">{$p.plugin}</td>
+ <td id="{$rid}">{$p.group_id}</td>
+ <td id="{$rid}">{$p.access}</td>
+ <td id="{$rid}">
+ <a href="{$script}?action={$action}&step=3&id={$p.id}"><img src="{$page.template}/img/admin/edit_plugin.png"></a>
+
+ <a href="{$script}?action={$action}&step=4&id={$p.id}"><img src="{$page.template}/img/admin/delete.png"></a></td>
+</tr>
+{/foreach}
+</table>
\ No newline at end of file
Modified: trunk/templates/default/modules/admin/rights.tpl
===================================================================
--- trunk/templates/default/modules/admin/rights.tpl 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/templates/default/modules/admin/rights.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -15,14 +15,15 @@
<th width="100">Actions</th>
</tr>
{foreach from=$rights item=r}
+{cycle values="row1,row2" advance=true assign=rid}
<tr>
- <td id="row1"><input type="checkbox" name="right_{$r.id}" value="1"></td>
- <td id="row1"><a href="{$script}?action={$action}&step=3&id={$r.id}">{$r.id}</a></td>
- <td id="row1">{$r.group_id}</td>
- <td id="row1">{$r.module}</td>
- <td id="row1">{$r.action}</td>
- <td id="row1">{$r.access}</td>
- <td id="row1">
+ <td id="{$rid}"><input type="checkbox" name="right_{$r.id}" value="1"></td>
+ <td id="{$rid}"><a href="{$script}?action={$action}&step=3&id={$r.id}">{$r.id}</a></td>
+ <td id="{$rid}">{$r.group_id}</td>
+ <td id="{$rid}">{$r.module}</td>
+ <td id="{$rid}">{$r.action}</td>
+ <td id="{$rid}">{$r.access}</td>
+ <td id="{$rid}">
<a href="{$script}?action={$action}&step=3&id={$r.id}"><img src="{$page.template}/img/admin/edit_right.png"></a>
<a href="{$script}?action={$action}&step=4&id={$r.id}"><img src="{$page.template}/img/admin/delete.png"></a></td>
Modified: trunk/templates/default/modules/admin/users.tpl
===================================================================
--- trunk/templates/default/modules/admin/users.tpl 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/templates/default/modules/admin/users.tpl 2008-10-16 16:57:18 UTC (rev 25)
@@ -15,17 +15,18 @@
<th width="100">Actions</th>
</tr>
{foreach from=$users item=u}
+{cycle values="row1,row2" advance=true assign=rid}
<tr>
- <td id="row1"><input type="checkbox" name="user_{$u.login}" value="1"></td>
- <td id="row1"><a href="{$script}?action={$action}&step=3&id={$u.login}">{$u.login}</a></td>
- <td id="row1">{$u.name}</td>
- <td id="row1">{$u.group_id}</td>
- <td id="row1">{$u.email}</td>
- <td id="row1"><a href="{$script}?action={$action}&step=5&id={$u.login}&active={$u.active}">
+ <td id="{$rid}"><input type="checkbox" name="user_{$u.login}" value="1"></td>
+ <td id="{$rid}"><a href="{$script}?action={$action}&step=3&id={$u.login}">{$u.login}</a></td>
+ <td id="{$rid}">{$u.name}</td>
+ <td id="{$rid}">{$u.group_id}</td>
+ <td id="{$rid}">{$u.email}</td>
+ <td id="{$rid}"><a href="{$script}?action={$action}&step=5&id={$u.login}&active={$u.active}">
<img src="{$page.template}/img/admin/active{$u.active}.png">
</a>
</td>
- <td id="row1">
+ <td id="{$rid}">
<a href="{$script}?action={$action}&step=3&id={$u.login}"><img src="{$page.template}/img/admin/edit_user.png"></a>
<a href="{$script}?action={$action}&step=4&id={$u.login}"><img src="{$page.template}/img/admin/delete_user.png"></a></td>
Added: trunk/www/templates/default/img/admin/ban.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/ban.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/www/templates/default/main.css
===================================================================
--- trunk/www/templates/default/main.css 2008-10-16 11:23:11 UTC (rev 24)
+++ trunk/www/templates/default/main.css 2008-10-16 16:57:18 UTC (rev 25)
@@ -150,8 +150,11 @@
padding: 2px;
background-color: #fafafa;
text-align: center;
+ vertical-align: center;
}
-#datatable #row2 {
- background-color: #adadad;
+#dbtable #row2 {
+ padding: 2px;
+ background-color: #ededed;
text-align: center;
+ vertical-align: center;
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|