Example #1
0
function validate_session($credential_store = 'credential')
{
    $pk_entity = -1;
    if (is_missing($_SESSION, $credential_store)) {
        # Server has no session credentials stored.
    }
    if (is_missing_or_empty($_SESSION, $credential_store)) {
        error_log("db_lib/validate_session() credential exists, but is empty");
        return -1;
    }
    $entity_record = $_SESSION[$credential_store];
    $pk_entity = intval($entity_record['entity']);
    if ($pk_entity <= 0) {
        return -1;
    }
    if (is_false($entity_record, 'entity')) {
        $pk_entity = null;
        return -1;
    }
    return $pk_entity;
}
Example #2
0
function is_missing()
{
    $params = func_get_args();
    $count = func_num_args();
    if ($count === 0) {
        return true;
    }
    if ($count === 1) {
        $value = $params[0];
        if (is_null($value) || empty($value) || !isset($value)) {
            return true;
        }
    }
    if ($count >= 2) {
        $array = $params[0];
        $key = $params[1];
        if (is_missing($array) || is_missing(key)) {
            return true;
        }
        if (is_array($array) && !is_array($key)) {
            $value = $array[$key];
            return is_missing($value);
        }
        return true;
    }
    return false;
}