<?php

include_once "/var/www/php/sql_connect.php";
$token = $_POST["token"];
sleep(0.5);
echo getUserPermissions($token);
<?php

include_once "/var/www/php/sql_connect.php";
$token = $_POST["token"];
if (getUserPermissions($token) === 1) {
    echo setRoundToZero();
} else {
    echo "Insufficient privilege";
}
Beispiel #3
0
<?php

include_once "/var/www/php/sql_connect.php";
$token = $_POST["token"];
$newA = $_POST["annon"];
$options = $_POST["options"];
$perms = getUserPermissions($token);
if ($perms === 1) {
    if (strlen($newA) !== 0) {
        $warn = fopen("warn.txt", "w");
        fwrite($warn, $options . $newA);
        fclose($warn);
        echo "Update successful.";
    } else {
        echo "Update not applied";
    }
}
?>

Beispiel #4
0
function populate($userId)
{
    // This will contain all of the permissions the user has been specified
    $permissions = array();
    // assuming that $identity has an id column
    $userPermissions = getUserPermissions();
    //$db->query("SELECT * FROM UsersPermissions WHERE UserId = @0", $identity->id);
    // Go through each user explicit permission
    foreach ($userPermissions as $permissionName => $values) {
        // $permission["name"] could be something like "Article1"
        // $permission["values"] could be something like ""View:true,NewTopic:true,Reply:true,EditSelf:true""
        // These are all the access permissions with that permission name
        $access = array();
        // Store that array of permissions in the overall array
        $permissions[$permissionName] = $values;
    }
    // These are all of the permissions specified to the user by roles
    $rolesPermissions = array();
    // Get the permissions on the chains of roles the user is in
    $roles = getUserRoles($userId);
    foreach ($roles as $role) {
        // This is the overall result for the heirarchy of the current role
        // Something like
        // [article1] =>
        //				[view] => [true]
        //				[edit] => [true]
        //				[delete] => [true]
        $roleAccess = array();
        $parents = getHierarchy($role);
        foreach ($parents as $parent) {
            // Foreach node closer to the role the user is in
            // get the permission
            //while($permission = getRolesPermissions($parent);
            $rolePermissions = getRolePermissions($parent);
            //$db->query("SELECT * FROM RolesPermissions WHERE roleId = @0", $parent);
            if ($rolePermissions != null) {
                foreach ($rolePermissions as $name => $values) {
                    // If this key hasn't been initialized, then do it
                    if (!isset($rolesPermissions[$name])) {
                        $rolesPermissions[$name] = array();
                    }
                    foreach ($values as $key => $value) {
                        $rolesPermissions[$name][$key] = $value;
                    }
                }
            }
        }
    }
    //	var_dump($permissions);
    //	var_dump($rolesPermissions);
    // Right now if we get two different answers from different chains, then the result is not gaurenteed.
    // Aka: Dont have ambiguous ACL trees
    foreach ($permissions as $name => $values) {
        if (!isset($rolesPermissions[$name])) {
            $rolesPermissions[$name] = array();
        }
        foreach ($values as $key => $value) {
            $rolesPermissions[$name][$key] = $value;
        }
    }
    return $rolesPermissions;
    //echo "\n";
    //	var_dump($rolesPermissions);
    //	echo "\n\n\n";
    //return $permissions;
}