Rights Management Page body>
Please select User:<select id= "user" ><?PHPinclude("dbda.php");$db=NewDbda ();$sql= "SELECT * from Users";$attr=$db->query ($sql); for($i= 0;$i<Count($attr);$i++){Echo"<option value= ' {$attr[$i][0]} ' >{$attr[$i][2]}</option> "}?></select></div><div> Please select the role: </DIV><DIV><?PHP$SQLJ= "SELECT * FROM Juese";$ATTRJ=$db->query ($SQLJ); for($i= 0;$i<Count($ATTRJ);$i++){ Echo"<input class= ' js ' type= ' checkbox ' value= ' {$ATTRJ[$i][1]} '/>{$ATTRJ[$i][1]}&NBSP ";}? ></div><div><input id= "Sure" type= "button" value= "OK"/></div></body>
<script type= "Text/javascript" >
$ (document). Ready (function (e) {
Showjs ();
$ ("#user"). Change (function () {
Showjs ();
})
$ ("#sure"). Click (function () {
var uid = $ ("#user"). Val ();
var js= "";
var cks = $ (". js");
for (Var i=0;i<cks.length;i++)
{
if (Cks.eq (i) [0].checked)
{
Js=js+cks.eq (i). Val () + "|";
}
}
JS = Js.substr (0,js.length-1);
$.ajax ({
URL: "add.php",
DATA:{UID:UID,JUESE:JS},
Type: "POST",
DataType: "TEXT",
Success:function (data) {
alert (data);
}
});
})
function Showjs ()
{
var uid = $ ("#user"). Val ();
$.ajax ({
URL: "juesechuli.php",
Data:{uid:uid},
Type: "POST",
DataType: "TEXT",
Success:function (data) {
var ck = $ (". js");
for (Var j=0;j<ck.length;j++)
{
Ck.eq (j). Removeattr ("checked");
}
if (Data.trim () = "") //trim () Remove space
{
var hang = data.split ("|");
for (var i =0;i{
var lie = hang[i].split ("^");
var ck = $ (". js");
for (Var j=0;j<ck.lenght;j++)
{
if (Ck.eq (j). Val () ==lie[2])
{
Ck.eq (j). Prop ("checked", true);
}
}
}
}
}
});
}
});
</script>
juesechuli.php
<? PHP $uid $_post ["UID"]; include ("dbda.php"); $db New Dbda (); $sql = "SELECT * from Userinjuese where UserId = ' {$uid} '"; Echo $db->strquery ($sql);
add.php
$uid=$_post["UID"];$juese=$_post["Juese"];include("dbda.php");$db=NewDbda ();$sqld= "Delete from Userinjuese where userid= ' {$uid}‘";$db->query ($sqld, 0);$js=Explode("|",$juese);$isok=true; for($i= 0;$i<Count($js);$i++){$sql= "INSERT into Userinjuese values ('", ' {$uid}‘,‘{$js[$i]}‘)";$isok=$isok&&$db->query ($sql, 0);}if($isok){Echo"OK";}Else{Echo"No";}
loginchuli.php
<?PHPSession_Start()$uid=$_post["UID"];$pwd=$_post["PWD"];include("dbda.php");$db=NewDbda ();$sql= "SELECT count (*) from Users where uid= ' {$uid} ' and pwd= ' {$pwd}‘";if($db->strquery ($sql) = = "1"){$_session["UID"]=$uid;Header("location:main.php")}Else{Header("location:login.php");}
main.php
<body><?PHPSession_Start();if(!Empty($_session["UID"])){$uid=$_session["UID"];}Else{Header("location:login.php");}include("dbda.php");$db-NewDbda ();//check roles based on user name$sql= "SELECT * from Userinjuese where userid= ' {$uid}‘";$ATTRJ=$db->query ($SQLJ);//array for storing function codes$attr=Array(); for($i= 0;$i<Count($ATTRJ);$i++){//based on role check function$js=$ATTRJ[$i][2];$SQLR= "Select RuleId from Juesewithrules where jueseid= ' {$js}‘";$STRR=$db->strquery ($SQLR);$ATTRR=Explode("|",$STRR);//merging the arrays$attr=Array_merge($attr,$ATTRR);}//Go heavy$attr=Array_unique($attr);//Check function name according to function code and display in Div for($j= 0;$j<Count($attr);$j++){$SQLG= "Select Name from Rules where code= ' {$attr[$j]}‘";$name=$db->strquery ($SQLG);Echo"<div class = ' Menu ' >{$name}</div> "}?></body>
PHP Language-Permissions