PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Keith   Permissions   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example of how to use the permissions class
Class: Permissions
Manipulate user access permission using bit masks
Author: By
Last change:
Date: 19 years ago
Size: 2,222 bytes


Class file image Download
Copyright (C) 2003 Keith Ganger

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

You can find more information about GPL licence at:


//this code is used to provide an example of how
//a programmer would use the permissions class.
//include the file
//instanciate the class.
$perms = new permissions();

//the first example shows how you would use the class to set permissions for a user
//echo "bitmask for read and delete= ". $bitmask ."<br>";
$sql ="insert into user_permissions (userid,docid,permission) values($userid,$docid,$bitmask)";
//you would then execute code to insert your sql.

//the second example shows you how to use the bitmask to get the users permissions.
//you would execute some sql to retrieve the bitmask from the database like
//select bitmask from user_permissions where docid=$docid and userid=$userid
//$bitmask = $row["bitmask"];
//I will just set this to a hardcoded value of 5 (as used in all the examples
"read permissions<br>";
//print array to show values