This commit is contained in:
tomas 2004-07-23 00:22:13 +00:00
parent 2949dbe982
commit 13ecac28d0
29 changed files with 5181 additions and 0 deletions

View file

@ -0,0 +1,126 @@
<?php
// $Id: alibExCls.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
require_once"alibExTestAuth.php";
if(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; $list=false; }
else $list=true;
// prefill data structure for template
if($list){
$d = array(
'cls' => $alib->getClasses(),
'loggedAs' => $login,
);
}else{
$d = array(
'rows' => $alib->listClass($id),
'id' => $id,
'loggedAs' => $login,
'cname' => $alib->getClassName($id),
'cls' => $alib->getClasses(),
'objs' => $alib->getSubTree(null, true)
);
}
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - class editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#menu { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
#parent, #parent a { background-color:#888; font-weight:bold; color:white; }
#tree { width:60%; }
-->
</style>
</head><body>
<div id="menu">
Logged as: <span class="b"><?php echo$d['loggedAs']?></span><br>
<a href="alibHttp.php?act=logout">logout</a><br>
<a href="alibExTree.php">Tree editor</a><br>
<?php if(!$list){?>
<a href="alibExPerms.php?id=<?php echo$d['id']?>">Perm editor</a><br>
<?php }?>
<a href="alibExSubj.php">User/Group editor</a><br>
</div>
<h1>Class editor</h1>
<?php if($list){?>
<h3>All classes:</h3>
<table id="tree" border="0" cellpadding="5">
<?php if(is_array($d['cls'])&&count($d['cls'])>0) foreach($d['cls'] as $k=>$c) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td><?php echo$c['id']?></td>
<td class="b"><a href="alibExCls.php?id=<?php echo$c['id']?>"><?php echo$c['cname']?></a></td>
<?php # <td><?php echo$c['cond']? ></td>?>
<td>
<a class="lnkbutt" href="alibHttp.php?act=removeClass&id=<?php echo$c['id']?>">delete</a>
<a class="lnkbutt" href="alibExPerms.php?id=<?php echo$c['id']?>&reid=<?php echo$d['id']?>">permissions</a>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="3">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add class with name
<input type="text" name="name" value="" size="10">
<input type="hidden" name="act" value="addClass">
<input type="submit" value="Do it!">
</form>
<?php }else{?>
<h2>Objects in class <?php echo$d['cname']?>:</h2>
<table id="tree" border="0" cellpadding="5">
<tr id="parent">
<td colspan="4">
<a href="alibExCls.php">All classes</a>
</td>
</tr>
<?php if(is_array($d['rows'])&&count($d['rows'])>0) foreach($d['rows'] as $k=>$row) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td><?php echo$row['id']?></td>
<td class="b"><a href="alibExTree.php?id=<?php echo$row['id']?>"><?php echo$row['name']?></a></td>
<td><?php echo$row['type']?></td>
<td>
<a class="lnkbutt" href="alibHttp.php?act=removeObjFromClass&oid=<?php echo$row['id']?>&id=<?php echo$d['id']?>">removeFromClass</a>
<?php /*?> <a class="lnkbutt" href="alibExPerms.php?id=<?php echo$row['id']?>&reid=<?php echo$d['id']?>">permissions</a><?php */?>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="4">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add object
<select name="oid">
<?php if(is_array($d['objs'])) foreach($d['objs'] as $k=>$row) {?>
<option value="<?php echo$row['id']?>"><?php echo str_repeat('&nbsp;', $row['level'])?><?php echo$row['name']?></option>
<?php }?>
</select>
to class <?php echo$d['cname']?>
<input type="hidden" name="act" value="addObj2Class">
<input type="hidden" name="id" value="<?php echo$d['id']?>">
<input type="submit" value="Do it!">
</form>
<?php }?>
<?php if($d['msg']){?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script>
<?php }?>
</body></html>

View file

@ -0,0 +1,112 @@
<?php
// $Id: alibExLogin.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
// prefill data structure for template
$d = array(
'users' => $alib->getSubjects(),
'actions' => $alib->getAllActions(),
'objects' => $alib->getAllObjects(),
'msg' => $_SESSION['alertMsg']
);
unset($_SESSION['alertMsg']);
// forms prefill:
if(is_array($_SESSION['lastPost'])) $d = array_merge($d, array(
'lastSubj' => $_SESSION['lastPost']['subj'],
'lastAction'=> $_SESSION['lastPost']['permAction'],
'lastObj' => $_SESSION['lastPost']['obj']
));
unset($_SESSION['lastPost']);
#header("Content-type: text/plain"); print_r($d); exit;
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - example login</title>
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#help { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
-->
</style>
<script type="text/javascript">
<!--
function preloadLogin(u, p)
{
var f=document.getElementById('loginform');
f.login.value=u;
f.pass.value=p;
}
-->
</script>
</head><body>
<div id="help">
Test accounts/pass:
<ul style="margin:1px 0px">
<li><a href="javascript:preloadLogin('root', 'q')">root/q</a></li>
<li><a href="javascript:preloadLogin('test1', 'a')">test1/a</a></li>
<li><a href="javascript:preloadLogin('test2', 'a')">test2/a</a></li>
<li><a href="javascript:preloadLogin('test3', 'a')">test3/a</a></li>
<li><a href="javascript:preloadLogin('test4', 'a')">test4/a</a></li>
</ul>
</div>
<h1>ALib - tests/example</h1>
<form action="alibHttp.php" method="post" id="loginform">
<table>
<tr><td>Login:</td><td><input type="text" name="login"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td colspan="2"><input type="hidden" name="act" value="login">
<input type="submit" value="Go!">
</td></tr>
</table>
</form>
<hr>
<form action="alibHttp.php" method="post">
Permission test:<br>
Subject: <select name="subj">
<?php if(is_array($d['users'])) foreach($d['users'] as $k=>$u) {?>
<option value="<?php echo$u['id']?>"<?php echo($d['lastSubj']==$u['id'] ? ' selected':'')?>><?php echo$u['login']?></option>
<?php }?>
</select>
action: <select name="permAction">
<?php if(is_array($d['actions'])) foreach($d['actions'] as $k=>$a) {?>
<option value="<?php echo$a?>"<?php echo($d['lastAction']==$a ? ' selected':'')?>><?php echo$a?></option>
<?php }?>
</select>
object: <select name="obj">
<?php if(is_array($d['objects'])) foreach($d['objects'] as $k=>$o) {?>
<option value="<?php echo$o['id']?>"<?php echo($d['lastObj']==$o['id'] ? ' selected':'')?>><?php echo$o['name']?></option>
<?php }?>
</select>
<input type="hidden" name="act" value="checkPerm">
<input type="submit" value="Go!">
</form>
<hr>
<form action="alibExPMatrix.php" method="get">
Permission matrix for subject: <select name="subj">
<?php if(is_array($d['users'])) foreach($d['users'] as $k=>$u) {?>
<option value="<?php echo$u['id']?>"<?php echo($d['lastSubj']==$u['id'] ? ' selected':'')?>><?php echo$u['login']?></option>
<?php }?>
</select>
<input type="submit" value="Go!">
</form>
<hr>
<a href="../install.php?ak=inst">reset db + test all</a><br/>
<?php if($d['msg']){ //error message printing: ?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script>
<?php }?>
<body></html>

View file

@ -0,0 +1,75 @@
<?php
// $Id: alibExPList.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
require_once"alibExTestAuth.php";
if(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; }
else $id=1;
// prefill data structure for template
$d = array(
'rows' => $alib->getSubjPerms($id),
'id' => $id,
'loggedAs' => $login,
'actions' => $alib->getAllActions(),
'name' => $alib->getSubjName($id)
);
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - permission list</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#menu { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
#parent, #parent a { background-color:#888; font-weight:bold; color:white; }
#tree { width:60%; }
-->
</style>
</head><body>
<div id="menu">
Logged as: <span class="b"><?php echo$d['loggedAs']?></span><br>
<a href="alibHttp.php?act=logout">logout</a><br>
<a href="alibExTree.php">Tree editor</a><br>
<a href="alibExCls.php">Class editor</a><br>
<a href="alibExSubj.php">User/group editor</a><br>
</div>
<h1>Subject permission list</h1>
<h2>Permissions for subject <?php echo$d['name']?>:</h2>
<table id="tree" border="0" cellpadding="5">
<tr id="parent">
<td colspan="4">
<a href="alibExSubj.php">All subjects</a>
</td>
</tr>
<?php if(is_array($d['rows'])&&count($d['rows'])>0) foreach($d['rows'] as $k=>$row) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td><a class="b" href="alibExPerms.php?id=<?php echo$row['obj']?>"><?php echo$row['name']?></a>
(<?php echo($row['otype']=='C' ? 'class' : $row['otype'])?>)
</td
<td class="b"><?php echo$row['action']?></td>
<td><?php echo($row['type']=='A' ? 'allow' : ($row['type']=='D' ? '<b>deny</b>' : $row['type']))?></td>
<td>
<a class="lnkbutt" href="alibHttp.php?act=removePerm&permid=<?php echo$row['permid']?>&oid=<?php echo$row['obj']?>&reurl=plist&reid=<?php echo$d['id']?>">delete</a>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="4">none</td></tr>
<?php }?>
</table>
<?php if($d['msg']){?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script>
<?php }?>
</body></html>

View file

@ -0,0 +1,44 @@
<?php
// $Id: alibExPMatrix.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
$sid=$_GET['subj'];
foreach($alib->getAllObjects() as $it){
$aa=array();
foreach($alib->getAllActions() as $a){
$aa[$a]=$alib->checkPerm($sid, $a, $it['id']);
# if(PEAR::isError($aa[$a])){ errCallback($aa[$a]); }
}
$m[]=array($it['name'], $aa);
}
$u=$alib->getSubjName($sid);
?>
<html><head>
<title>ALib - permission matrix</title>
<link rel="stylesheet" type="text/css" href="default.css">
</head><body>
<h2>Permission matrix</h2>
<h2>User: <?php echo$u?></h2>
<table style="border:1px solid black">
<tr class="ev"><th>object</th>
<?php foreach($alib->getAllActions() as $a){?>
<th><?php echo$a?></th>
<?php }?>
</tr>
<?php if(is_array($m)) foreach($m as $k=>$v){ list($obj, $aa)=$v;?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td><?php echo$obj?></td>
<?php foreach($aa as $pr){?>
<td><?php echo($pr ? 'Y' : '-')?></td>
<?php }?>
</tr>
<?php }?>
</table>
<a href="javascript:back()">Back</a>
<hr>
Tree dump:
<pre><?php echo$alib->dumpTree()?></pre>
</body></html>

View file

@ -0,0 +1,118 @@
<?php
// $Id: alibExPerms.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
require_once"alibExTestAuth.php";
if(isset($_GET['id']) && is_numeric($_GET['id'])){
$id = $_GET['id'];
}else{
$id = $alib->getRootNode();
}
// prefill data structure for template
if(!$alib->isClass($id)){
$d = array(
'path' => $alib->getPath($id, 'id,name'),
'perms' => $alib->getObjPerms($id),
'actions' => $alib->getAllowedActions($alib->getObjType($id)),
'subjects' => $alib->getSubjects(),
'id' => $id,
'loggedAs' => $login
);
}else{
$d = array(
'path' => '',
'name' => $alib->getClassName($id),
'perms' => $alib->getObjPerms($id),
'actions' => $alib->getAllowedActions('_class'),
'subjects' => $alib->getSubjects(),
'id' => $id,
'loggedAs' => $login
);
}
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - permission editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#menu { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
#tbl { width:60%; }
-->
</style>
</head><body>
<div id="menu">
Logged as: <span class="b"><?php echo$d['loggedAs']?></span><br>
<a href="alibHttp.php?act=logout">Logout</a><br>
<?php if(is_array($d['path'])){?>
<a href="alibExTree.php?id=<?php echo$d['id']?>">Tree editor</a><br>
<?php }else{?>
<a href="alibExTree.php">Tree editor</a><br>
<?php }?>
<a href="alibExCls.php">Class editor</a><br>
<a href="alibExSubj.php">User/Group editor</a><br>
</div>
<h1>Permission editor</h1>
<?php if(is_array($d['path'])){?>
<h2><a href="alibExTree.php?id=<?php echo$d['id']?>" title="Tree editor">Path</a>:
<?php foreach($d['path'] as $k=>$it) {?>
<a <?php if($it["id"]!=$id){?>href="?id=<?php echo $it["id"]?>"<?php }?>><?php echo$it["name"]?></a><span class="slash">/</span>
<?php }?>
<?php }else{?>Class <a href="alibExCls.php?id=<?php echo$d['id']?>"><?php echo$d['name']?></a>
<?php }?>
</h2>
<table id="tbl" border="0" cellpadding="5">
<?php if(is_array($d['perms'])&&count($d['perms'])>0) foreach($d['perms'] as $k=>$row) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td class="b"><a href="alibExPList.php?id=<?php echo$row['subj']?>"><?php echo$row['login']?></a></td>
<td class="b"><?php echo$row['action']?></td>
<td><?php echo($row['type']=='A' ? 'allow' : ($row['type']=='D' ? '<b>deny</b>' : $row['type']))?></td>
<td>
<a class="lnkbutt" href="alibHttp.php?act=removePerm&permid=<?php echo$row['permid']?>&oid=<?php echo$d['id']?>&reid=<?php echo$d['id']?>">delete</a>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="4">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add permission
<select name="allowDeny">
<option value="A">Allow</option>
<option value="D">Deny</option>
</select>
for action
<select name="permAction">
<option value="_all">all</option>
<?php if(is_array($d['actions'])) foreach($d['actions'] as $k=>$it) {?>
<option value="<?php echo$it?>"><?php echo$it?></option>
<?php }?>
</select>
to subject
<select name="subj">
<?php if(is_array($d['subjects'])) foreach($d['subjects'] as $k=>$it) {?>
<option value="<?php echo$it['id']?>"><?php echo$it['login']?></option>
<?php }?>
</select>
<input type="hidden" name="act" value="addPerm">
<input type="hidden" name="reid" value="<?php echo$d['id']?>">
<input type="hidden" name="id" value="<?php echo$d['id']?>">
<input type="submit" value="Do it!">
</form>
<?php if($d['msg']){?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script><noscript><hr><b><?php echo$d['msg']?></b></hr></noscript>
<?php }?>
</body></html>

View file

@ -0,0 +1,141 @@
<?php
// $Id: alibExSubj.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
require_once"alibExTestAuth.php";
if(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; $list=false; }
else $list=true;
// prefill data structure for template
if($list){
$d = array(
'subj' => $alib->getSubjectsWCnt(),
'loggedAs' => $login
);
}else{
$d = array(
'rows' => $alib->listGroup($id),
'id' => $id,
'loggedAs' => $login,
'gname' => $alib->getSubjName($id),
'subj' => $alib->getSubjects()
);
}
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - subjects editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#menu { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
#parent, #parent a { background-color:#888; font-weight:bold; color:white; }
#tree { width:60%; }
-->
</style>
</head><body>
<div id="menu">
Logged as: <span class="b"><?php echo$d['loggedAs']?></span><br>
<a href="alibHttp.php?act=logout">logout</a><br>
<a href="alibExTree.php">Tree editor</a><br>
<?php if(!$list){?>
<a href="alibExPList.php?id=<?php echo$d['id']?>">Perms editor</a><br>
<?php }?>
<a href="alibExCls.php">Class editor</a><br>
</div>
<h1>User/Group editor</h1>
<?php if($list){?>
<h3>Subjects:</h3>
<table id="tree" border="0" cellpadding="5">
<?php if(is_array($d['subj'])&&count($d['subj'])>0) foreach($d['subj'] as $k=>$c) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd':'ev')?>">
<td><?php echo$c['id']?></td>
<td class="b">
<?php if($c['type']=='G'){?>
<a href="alibExSubj.php?id=<?php echo$c['id']?>"><?php echo$c['login']?></a>
<?php }else{?><?php echo$c['login']?>
<?php }?>
</td
<td><?php if($c['type']=='G'){?>(G:<?php echo$c['cnt']?>)<?php }else{?> (U)<?php }?></td>
<td>
<a class="lnkbutt" href="alibHttp.php?act=removeSubj&login=<?php echo urlencode($c['login'])?>">delete</a>
<?php /*?> <a class="lnkbutt" href="alibExPerms.php?id=<?php echo$c['id']?>&reid=<?php echo$d['id']?>">permissions</a><?php */?>
<a class="lnkbutt" href="alibExPMatrix.php?subj=<?php echo$c['id']?>">permsMatrix</a>
<a class="lnkbutt" href="alibExPList.php?id=<?php echo$c['id']?>">permsList</a>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="4">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add subject with name: <input type="text" name="login" value="" size="10">
[and password: <input type="password" name="pass" value="" size="10">]
<input type="hidden" name="act" value="addSubj">
<input type="submit" value="Do it!">
</form>
<?php }else{?>
<h2>Subjects in group <?php echo$d['gname']?>:</h2>
<table id="tree" border="0" cellpadding="5">
<tr id="parent">
<td colspan="5">
<a href="alibExSubj.php">All subjects</a>
</td>
</tr>
<?php if(is_array($d['rows'])&&count($d['rows'])>0) foreach($d['rows'] as $k=>$row) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd':'ev')?>">
<td><?php echo$row['id']?></td>
<td class="b">
<?php if($row['type']=='G'){?>
<a href="alibExSubj.php?id=<?php echo$row['id']?>"><?php echo$row['login']?></a>
<?php }else{?><?php echo$row['login']?>
<?php }?>
</td
<td><?php if($row['type']=='G'){?> (G)<?php }else{?> (U)<?php }?></td>
<td>
<a class="lnkbutt"
href="alibHttp.php?act=removeSubjFromGr&login=<?php echo urlencode($row['login'])?>&gname=<?php echo urlencode($d['gname'])?>&reid=<?php echo$d['id']?>">
removeFromGroup
</a>
<?php /*?> <a class="lnkbutt" href="alibExPerms.php?id=<?php echo$row['id']?>&reid=<?php echo$d['id']?>">permissions</a><?php */?>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="3">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add subject
<select name="login">
<?php if(is_array($d['subj'])) foreach($d['subj'] as $k=>$row) {?>
<option value="<?php echo$row['login']?>"><?php echo$row['login']?></option>
<?php }?>
</select>
to group <?php echo$d['gname']?>
<input type="hidden" name="act" value="addSubj2Gr">
<input type="hidden" name="reid" value="<?php echo$d['id']?>">
<input type="hidden" name="gname" value="<?php echo$d['gname']?>">
<input type="submit" value="Do it!">
</form>
<?php }?>
<?php if($d['msg']){?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script>
<?php }?>
</body></html>

View file

@ -0,0 +1,9 @@
<?php
// $Id: alibExTestAuth.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
$login = $alib->getSessLogin($_REQUEST['alibsid']);
if(!isset($login)||$login==''){
$_SESSION['alertMsg'] = "Login required";
header("Location: alibExLogin.php");
exit;
}
?>

View file

@ -0,0 +1,111 @@
<?php
// $Id: alibExTree.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
require_once"alibExTestAuth.php";
if(isset($_GET['id']) && is_numeric($_GET['id'])) $id = $_GET['id'];
else $id = $alib->getRootNode();
// prefill data structure for template
$d = array(
'parid' => $alib->getParent($id),
'oname' => $alib->getObjName($id),
'path' => $alib->getPath($id, 'id, name'),
'rows' => $alib->getDir($id, 'id, name, type'),
'addtypes' => $alib->getAllowedChildTypes($alib->getObjType($id)),
'dump' => $alib->dumpTree($id),
'id' => $id,
'loggedAs' => $login
);
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
require_once"alib_f.php";
// template follows:
?>
<html><head>
<title>Alib - tree editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
<!--
#menu { float:right; margin-right:1em; border:1px solid black; background-color:#ddd; padding:2px 1ex; }
#current { background-color:#aaa; }
#parent, #parent a { background-color:#888; font-weight:bold; color:white; }
#tree { width:60%; }
-->
</style>
</head><body>
<div id="menu">
Logged as: <span class="b"><?php echo$d['loggedAs']?></span><br>
<a href="alibHttp.php?act=logout">logout</a><br>
<?php /*?> <a href="alibExPerms.php?id=<?php echo$d['id']?>">Permission editor</a><br><?php */?>
<a href="alibExCls.php">Class editor</a><br>
<a href="alibExSubj.php">User/Group editor</a><br>
</div>
<h1>Tree editor</h1>
<h3>Path:
<?php if(is_array($d['path'])) foreach($d['path'] as $k=>$it) {?>
<a <?php if($it["id"]!=$id){?>href="alibExTree.php?id=<?php echo $it["id"]?>"<?php }?>><?php echo$it["name"]?></a><span class="slash">/</span><?php }?>
</h3>
<table id="tree" border="0" cellpadding="5">
<tr id="current">
<td colspan="2">Current node: <b><?php echo $d['oname']?></b></dt>
<td>
<a class="lnkbutt" href="alibExPerms.php?id=<?php echo$d['id']?>&reid=<?php echo$d['id']?>">permissions</a>
</td>
</tr>
<tr id="parent">
<td colspan="3">
<?php if(is_numeric($d['parid'])){?><a href="alibExTree.php?id=<?php echo$d['parid']?>">Parent: ..</a>
<?php }else{?>/<?php }?>
</dt>
</tr>
<?php if(is_array($d['rows'])&&count($d['rows'])>0) foreach($d['rows'] as $k=>$row) {?>
<tr class="<?php echo(($o=1-$o) ? 'odd' : 'ev')?>">
<td><?php echo$row['id']?></td>
<td><a href="alibExTree.php?id=<?php echo$row['id']?>" class="b"><?php echo$row['name']?></a> (<?php echo$row['type']?>)</td>
<td>
<a class="lnkbutt" href="alibHttp.php?act=deleteNode&id=<?php echo$row['id']?>&reid=<?php echo$d['id']?>">delete</a>
<a class="lnkbutt" href="alibExPerms.php?id=<?php echo$row['id']?>&reid=<?php echo$d['id']?>">permissions</a>
</td>
</tr>
<?php }else{?>
<tr class="odd"><td colspan="3">none</td></tr>
<?php }?>
</table>
<form action="alibHttp.php" method="post">
Add object of type
<select name="type">
<?php if(is_array($d['addtypes'])) foreach($d['addtypes'] as $k=>$row) {?>
<option value="<?php echo$row?>"><?php echo$row?></option>
<?php }?>
</select>
with name
<input type="text" name="name" value="" size="10">
<select name="position">
<option value="<?php echo$d['id']?>">as first node</option>
<?php if(is_array($d['rows'])) foreach($d['rows'] as $k=>$row) {?>
<option value="<?php echo$row['id']?>">after <?php echo$row['name']?></option>
<?php }?>
<option value="<?php echo$row['id']?>" selected>as last node</option>
</select>
<input type="hidden" name="act" value="addNode">
<input type="hidden" name="id" value="<?php echo$d['id']?>">
<input type="hidden" name="reid" value="<?php echo$d['id']?>">
<input type="submit" value="Do it!">
</form>
<pre><b>Subtree dump:</b><br><?php echo$d['dump']?></pre>
<?php #php echo"pre">; print_r($d); echo"</pre>";?>
<?php if($d['msg']){?>
<script type="text/javascript">
<!--
alert('<?php echo$d['msg']?>');
-->
</script>
<?php }?>
</body></html>

View file

@ -0,0 +1,125 @@
<?php
// $Id: alibHttp.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
require_once"alib_h.php";
#header("Content-type: text/plain"); echo"GET:\n"; print_r($_GET); echo"POST:\n"; print_r($_POST); exit;
function getPGval($vn, $dfl='')
{
return (isset($_POST[$vn])?$_POST[$vn]:(isset($_GET[$vn])?$_GET[$vn]:$dfl));
}
$userid = $alib->getSessUserId($_REQUEST['alibsid']);
$login = $alib->getSessLogin($_REQUEST['alibsid']);
$redirUrl="alibExTree.php".(($reid=getPGval('reid', '')) ? "?id=$reid":"");
$act = getPGval('act', 'nop');
switch($act)
{
case"login";
if($sessid = $alib->login($_POST['login'], $_POST['pass'])){
setcookie('alibsid', $sessid);
$redirUrl="alibExTree.php";
}else{ $redirUrl="alibExLogin.php"; $_SESSION['alertMsg']='Login failed.'; }
break;
case"logout";
$r = $alib->logout($_REQUEST['alibsid']);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage().", ".$r->getUserInfo();
setcookie('alibsid', '');
$redirUrl="alibExLogin.php";
break;
case"addNode";
if($alib->checkPerm($userid, 'addChilds', $_POST['id'])
&& $_POST['type']!=''
&& $_POST['name']!=''
){
$oid = $alib->addObj($_POST['name'], $_POST['type'], $_POST['id'], $_POST['position']);
$alib->addPerm($userid, '_all', $oid);
}else $_SESSION['alertMsg']='Access denied.';
break;
case"deleteNode";
if($alib->checkPerm($userid, 'delete', $_REQUEST['id']))
$alib->removeObj($_GET['id']);
else $_SESSION['alertMsg']='Access denied.';
break;
case"addPerm";
$a = $alib->isClass($_POST['id']) ? 'classes':'editPerms';
$id = $alib->isClass($_POST['id']) ? '':$_POST['id'];
if($alib->checkPerm($userid, $a, $id))
$alib->addPerm($_POST['subj'], $_POST['permAction'], $_POST['id'], $_POST['allowDeny']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExPerms.php".(($reid=getPGval('reid', '')) ? "?id=$reid":"");
break;
case"removePerm";
$a = $alib->isClass($_REQUEST['oid']) ? 'classes':'editPerms';
$oid = $alib->isClass($_REQUEST['oid']) ? '':$_REQUEST['oid'];
if($alib->checkPerm($userid, $a, $oid))
$alib->removePerm($_GET['permid']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl=($_REQUEST['reurl']==plist ? "alibExPList.php":"alibExPerms.php").(($reid=getPGval('reid', '')) ? "?id=$reid":"");
break;
case"checkPerm";
$res = $alib->checkPerm($_POST['subj'], $_POST['permAction'], $_POST['obj']);
$_SESSION['alertMsg'] = ($res ? "permitted: ":"DENIED: ").
" {$_POST['permAction']} for ".$alib->getSubjName($_POST['subj']).
" on ".$alib->getObjName($_POST['obj']);
$_SESSION['lastPost']=$_POST;
$redirUrl="alibExLogin.php";
break;
case"addClass";
if($alib->checkPerm($userid, 'classes'))
$alib->addClass($_POST['name']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExCls.php";
break;
case"removeClass";
if($alib->checkPerm($userid, 'classes'))
$alib->removeClassById($_GET['id']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExCls.php";
break;
case"addSubj";
if($alib->checkPerm($userid, 'subjects'))
$alib->addSubj($_POST['login'], $_POST['pass']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExSubj.php";
break;
case"removeSubj";
if($alib->checkPerm($userid, 'subjects'))
$alib->removeSubj($_GET['login']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExSubj.php";
break;
case"addSubj2Gr";
if($alib->checkPerm($userid, 'subjects'))
$alib->addSubj2Gr($_POST['login'], $_POST['gname']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExSubj.php".(($id=getPGval('reid', '')) ? "?id=$reid":"");
break;
case"removeSubjFromGr";
if($alib->checkPerm($userid, 'subjects'))
$alib->removeSubjFromGr($_GET['login'], $_GET['gname']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExSubj.php".(($id=getPGval('reid', '')) ? "?id=$reid":"");
break;
case"addObj2Class";
if($alib->checkPerm($userid, 'classes'))
$alib->addObj2Class($_POST['id'], $_POST['oid']);
else $_SESSION['alertMsg']='Access denied. X1';
$redirUrl="alibExCls.php".(($id=getPGval('id', '')) ? "?id=$id":"");
break;
case"removeObjFromClass";
$id=getPGval('id', '');
if($alib->checkPerm($userid, 'classes'))
$alib->removeObjFromClass($_GET['oid'], $id);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="alibExCls.php".($id ? "?id=$id":"");
break;
default:
$_SESSION['alertMsg']="Unknown method: $act";
}
require_once"alib_f.php";
header("Location: $redirUrl");
?>

View file

@ -0,0 +1,4 @@
<?
// $Id: alib_f.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
$dbc->disconnect();
?>

View file

@ -0,0 +1,31 @@
<?
// $Id: alib_h.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
session_start();
require_once 'conf.php';
require_once 'DB.php';
require_once '../alib.php';
#PEAR::setErrorHandling(PEAR_ERROR_RETURN);
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
#PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
PEAR::setErrorHandling(PEAR_ERROR_DIE);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallback');
function errCallback($err)
{
if(assert_options(ASSERT_ACTIVE)==1) return;
echo "<pre>\n";
echo "request: "; print_r($_REQUEST);
echo "\ngm:\n".$err->getMessage()."\nui:\n".$err->getUserInfo()."\n";
echo "<hr>BackTrace:\n";
print_r($err->backtrace);
echo "</pre>\n";
exit;
}
$dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$alib =& new Alib($dbc, $config);
?>

View file

@ -0,0 +1,32 @@
<?php
// $Id: conf.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
$config = array(
'dsn' => array( // data source definition
'username' => 'tomash',
'password' => '',
'hostspec' => 'localhost',
'phptype' => 'pgsql',
'database' => 'mdlf'
),
'tblNamePrefix' => 'al_',
# 'tblNamePrefix' => 'gb_',
'RootNode' =>'RootNode',
'objtypes' => array(
'RootNode' => array('Publication'),
'Publication' => array('Issue'),
'Issue' => array('Title', 'Section'),
'Section' => array('Title', 'Image', 'Par')
),
'allowedActions'=> array(
'RootNode' => array('addChilds', 'editPerms', 'read', 'edit', 'delete', 'classes', 'subjects'),
'Publication' => array('addChilds', 'editPerms', 'read', 'edit', 'delete'),
'Issue' => array('addChilds', 'editPerms', 'read', 'edit', 'delete'),
'Section' => array('addChilds', 'editPerms', 'read', 'edit', 'delete'),
'Title' => array('editPerms', 'read', 'edit', 'delete'),
'Image' => array('editPerms', 'read', 'edit', 'delete'),
'Par' => array('editPerms', 'read', 'edit', 'delete'),
'_class' => array('addChilds', 'editPerms', 'read', 'edit', 'delete')
),
'allActions'=> array('editPerms', 'addChilds', 'read', 'edit', 'delete', 'classes', 'subjects')
);
?>

View file

@ -0,0 +1,15 @@
<!--
/* $Id: default.css,v 1.1 2004/07/23 00:22:13 tomas Exp $ */
body { font-family:'Arial CE', 'Helvetica CE', Arial, helvetica, sans-serif; background-color:#fff; }
h1 { border:0px solid black; margin-bottom:2px; font-size:x-large; }
h2 { border:0px solid black; margin-bottom:2px; margin-top:2px; font-size:large; }
h3 { border:0px solid black; margin-bottom:2px; margin-top:2px; font-size:medium; font-weight:bold; }
table { border-collapse:collapse; margin:1ex 0px; }
tr.odd { background-color:#ccc; }
tr.ev { background-color:#bbb; }
td { border:0px solid black; padding:2px 1em; }
pre { border:solid black; border-width:1px 0px; padding:1em 1px;}
.b { font-weight:bold; }
.slash { padding:0px 2px; font-weigt:bolder; }
.lnkbutt { padding:0px 4px; font-weigt:bolder; }
-->

View file

@ -0,0 +1,7 @@
<?php
// $Id: index.php,v 1.1 2004/07/23 00:22:13 tomas Exp $
header ("location: alibExLogin.php");
die;
?>