function login($email, $password)
{
    // check username and password with db
    // if yes, return true
    // else throw exception
    // connect to db
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    $sql = generateUserVerificationSql($email, $password);
    // check if username is unique
    $result = mysql_query($sql, $dbLink);
    if (!$result || mysql_num_rows($result) == 0) {
        // The username and password did not match.
        // Check to see if the user exists.
        if (findUsername($email)) {
        } else {
        }
    }
    if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
        $currentUser = new user_info();
        $currentUser->setId($row['id']);
        $currentUser->setFirstName($row['first_name']);
        $currentUser->setLastName($row['last_name']);
        $currentUser->setEmail($row['email']);
        $currentUser->setHunterId($row['hunter_id']);
        $currentUser->setLoggedIn(true);
        $_SESSION['current_user'] = $currentUser;
        $_SESSION['roles'] = getRoles($currentUser);
        return $currentUser;
    } else {
        throw new Exception('no user found 2');
    }
}
 function getAdminAddEditFormStructure($p_sMode = 'create')
 {
     $structure = array('fields' => array('first_name' => array('type' => 'text', 'label' => 'First name', 'size' => 30), 'last_name' => array('type' => 'text', 'label' => 'Last name', 'size' => 30), 'email' => array('type' => 'text', 'label' => 'Email address', 'size' => 30), 'role_id' => array('type' => 'dropdown', 'label' => 'Role', 'options' => array()), 'password' => array('type' => 'password', 'label' => 'Enter Password', 'size' => 30), 'password2' => array('type' => 'password', 'label' => 'Confirm Password', 'size' => 30), 'submit' => array('type' => 'submit', 'label' => '', 'value' => 'Register')), 'rules' => array('first_name' => array('type' => 'required', 'message' => 'First name cannot be blank'), 'last_name' => array('type' => 'required', 'message' => 'Last name cannot be blank'), 'email' => array(array('type' => 'required', 'message' => 'Email address is required'), array('type' => 'email', 'message' => 'You must enter a valid email address'), array('type' => 'minlength', 'message' => 'Your email must consist of at least 5 characters', 'value' => 5)), 'password' => array('type' => 'required', 'message' => 'Please enter your password'), 'password2' => array(array('type' => 'required', 'message' => 'Please confirm your password'), array('type' => 'minlength', 'message' => 'Your password must consist of at least 5 characters', 'value' => 5), array('type' => 'compare', 'message' => 'Your passwords do not match', 'comparee' => 'password'))));
     // --------------- ROLES ---------------
     // Get the values in the form of val => label
     $aRoles = getRoles();
     unset($aRoles['guest']);
     // Remove developer role assignment if the logged in user is not a developer
     if ($this->getSession()->getAuthData(false)->role_name !== 'developer') {
         unset($aRoles['developer']);
     }
     $aRoles = array_flip($aRoles);
     // Apply massage function to each role to make it pretty for output in a dropdown
     array_walk($aRoles, array($this, 'massageUserRoles'));
     // Assign values to Role dropdown.
     $structure['fields']['role_id']['options'] = $aRoles;
     // --------------- ROLES ---------------
     // Remove confirm password box for edit mode
     if ($p_sMode !== 'create') {
         unset($structure['fields']['password']);
         unset($structure['fields']['password2']);
         unset($structure['rules']['password2']);
         unset($structure['rules']['password']);
         $structure['fields']['submit']['value'] = 'Update';
     }
     return $structure;
 }
Exemple #3
0
 public static function isOfType($type, $uid = '')
 {
     global $user;
     if ($uid) {
         return in_array($type, getRoles($uid));
     } else {
         return in_array($type, $user->roles);
     }
 }
Exemple #4
0
 public function createRoleSelectHtml()
 {
     global $connection;
     $roles = getRoles($connection);
     $content = '';
     foreach ($roles as $key => $value) {
         $content = $content . '<option>' . $value['role'] . '</option>';
     }
     return $content;
 }
Exemple #5
0
function roleNameToID($p_sName)
{
    if (!isset(PPI_Helper::getConfig()->system->roleMapping)) {
        throw new PPI_Exception('Trying to perform roleIDToName when no roleMapping information was found.');
    }
    $aRoles = getRoles();
    if (!isset($aRoles[$p_sName])) {
        throw new PPI_Exception('Unable to find role: ' . $p_sName);
    }
    return $aRoles[$p_sName];
}
Exemple #6
0
$DEV = strpos($_SERVER['REQUEST_URI'], '~') != 0;
set_include_path(get_include_path() . PATH_SEPARATOR . ($DEV ? '/home/mgorman/public_html/_resources/php' : '/var/www/php.iwu.edu/htdocs/_resources/php'));
require_once '_class.IWU_DB.php';
require_once '_class.IWU_DataRow.php';
require_once '_class.IWU_Auth.php';
require_once '_class.IWU_Template.php';
require_once '_class.IWU_Paginate.php';
require_once '_db.php';
IWU_Auth::forceAuthentication();
if (userHasRole(IWU_Auth::getUser(), 'admin') && isset($_GET['impersonate'])) {
    $user = $_GET['impersonate'];
} else {
    $user = IWU_Auth::getUser();
}
$roles = getRoles($user);
class Channel
{
    protected $slug = '';
    protected $heading = '';
    protected $styles = array();
    protected $classes = array('highlight');
    protected $context = '';
    protected $contexts = array();
    protected $contentHTML = '';
    public function __construct($slug, $heading, $content = '', $max_height = NULL)
    {
        $this->slug = $slug;
        $this->heading = $heading;
        $this->contentHTML = $content;
        if ($max_height !== NULL) {
Exemple #7
0
<?php

include '../scripts/funciones.php';
if (!haIniciadoSesion()) {
    header('Location: ../index.php');
}
$roles = getRoles();
?>
<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Listado de roles</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- Bootstrap theme -->
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css">

    <!-- Custom styles for this template -->
    <link href="../css/theme.css" rel="stylesheet">

  </head>

  <body role="document">

    <?php 
require 'menuAdmin.php';
<?php

header('Content-type: application/json');
require_once "../configuration.php";
require_once "../include.php";
if ($AUTO_ESCAPE) {
    $google_token = stripslashes($_GET["googletoken"]);
} else {
    $google_token = $_GET["googletoken"];
}
$google_id = getGoogleId($google_token);
if ($google_id == null) {
    die("-1");
}
$con = mysql_connect($MYSQL_HOSTNAME, $MYSQL_USERNAME, $MYSQL_PASSWORD);
if (!$con) {
    die("-2");
}
if (!mysql_select_db($MYSQL_DATABASE, $con)) {
    mysql_close($con);
    die("-3");
}
addRole($google_id, "ROLE_USER", $con);
echo json_encode(getRoles($google_id, $con));
mysql_close($con);
Exemple #9
0
// Get list of all users or one in particualr if the id is given
include_once '../include/headers.php';
include_once '../include/dbutils.php';
include_once '../include/main.php';
include_once 'domain/users.php';
db_connect();
$sellerCountry = isset($_GET['sellerCountry']) ? $_GET['sellerCountry'] : null;
if (isset($_GET['existsNewDispatch'])) {
    $value = existsNewDispatch($_GET['id']);
} else {
    if (isset($_GET['id'])) {
        $value = getUser($_GET['id']);
    } else {
        if (isset($_GET['roles'])) {
            $value = getRoles();
        } else {
            if (isset($_GET['plotter'])) {
                $value = getPlotterUsers();
            } else {
                if (isset($_GET['sellerCodes'])) {
                    $value = getSellerCodes();
                } else {
                    $value = getUsers();
                }
            }
        }
    }
}
//return JSON array
exit(json_encode($value));
Exemple #10
0
 /**
  * Convert the role name by specifying the role id
  *
  * @static
  * @throws PPI_Exception
  * @param  integer $p_iRoleID The Role ID
  * @return string
  */
 static function getRoleNameFromID($p_iRoleID)
 {
     $oConfig = PPI_Helper::getConfig();
     $aRoles = array_flip(getRoles());
     if (array_key_exists($p_iRoleID, $aRoles)) {
         return $aRoles[$p_iRoleID];
     }
     throw new PPI_Exception('Unknown Role Type: ' . $p_sRoleName);
 }
Exemple #11
0
 public function head()
 {
     $vhost_name = $GLOBALS['setting_cfg']['vhost_name']['value'];
     if ($vhost_name == "") {
         $vhost_name = "虚拟主机";
     }
     $menus = array(array('首页', '/'), array($vhost_name, '?c=host&a=index'));
     $mproduct_group = daocall('mproductgroup', 'getMproductgroup', array());
     if (is_array($mproduct_group)) {
         foreach ($mproduct_group as $mproduct) {
             $menus[] = array($mproduct['name'], '?c=mproduct&a=index&refer=' . $mproduct['id']);
         }
     }
     $menus[] = array('会员中心', '?c=user&a=index');
     $menus[] = array('联系我们', '?c=public&a=contact');
     $menus[] = array('使用帮助', '?c=help&a=index');
     if (UC_START == 'on') {
         $menus[] = array('论坛', '/bbs/');
     }
     $this->_tpl->assign("menus", $menus);
     $this->_tpl->assign('role', getRoles());
     return $this->_tpl->fetch("public/head.html");
 }
Exemple #12
0
function isUserARoleMember($user, $targetRoleName)
{
    $rolesArray = getRoles($user);
    $foundRole = isRoleMemberFromArray($rolesArray, $targetRoleName);
    return $foundRole;
}
Exemple #13
0
}
function isMarked($resource, $privilege, $resourcePrivileges)
{
    $flag = false;
    for ($i = 0; $i < count($resourcePrivileges); ++$i) {
        if ($resource == $resourcePrivileges[$i]['resource_id'] && $privilege == $resourcePrivileges[$i]['privilege_id']) {
            $flag = true;
            break;
        } else {
            $flag = false;
        }
    }
    return $flag;
}
if (isset($_SESSION['pk_admin'])) {
    $roles = getRoles($connection);
    $resources = getResources($connection);
    $privileges = getPrivileges($connection);
    if (isset($_POST['role'])) {
        $roleId = getId('role', $_POST['role'], 'roles');
        $resourcePrivileges = getResourcePrivileges($connection, $roleId);
    } else {
        $resourcePrivileges = getResourcePrivileges($connection, 1);
    }
    // draw a table for the page
    $content = '<thead><tr><th></th>';
    // draw table header (row 1)
    foreach ($privileges as $key => $value) {
        $content = $content . '<th>' . $value['privilege'] . '</th>';
    }
    $content = $content . '</tr></thead>';
Exemple #14
0
					</div>
                </div>
				<div class="row">
					<div id="editFieldsButtonGroup">
						<button class="btn btn-primary pull-right" style="margin-right:15px" id="editButton">Edit</button>
					</div>
				</div>
				<br>
				<div class="row">
					<div class="col-lg-6">
						<div class="panel panel-default">
							<div class="panel-heading">Current Roles</div>
							<div class="panel-body">
								<div class="panel-group" id="accordion">
									<?php 
getRoles();
?>
								</div>
							</div>
						</div>
					</div>
					<div class="col-lg-6">
						<div class="panel panel-default">
							<div class="panel-heading">
								Current Projects
							</div>
							<div class="panel-body">
								<p id="currentProjects"></p>
							</div>
						</div>
					</div>