packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/functions.php
author Dan Fuhry <dan@fuhry.us>
Tue, 08 Jan 2013 23:21:25 -0500
changeset 2 700d61d93b1b
parent 0 3906ca745819
child 3 a044870a9d3d
permissions -rw-r--r--
Fix accidentally hardcoded ldap basedn

<?php

function redirect($url)
{
	header('HTTP/1.1 302 Found');
	header("Location: $url");
	exit;
}

/**
 * Queue a message that will be displayed in a box on the next page load
 * @param int Message type (E_NOTICE, E_WARNING, E_ERROR)
 * @param string Message string
 */

function queue_message($code, $message)
{
	$_SESSION['messages'][] = array(
			'code' => $code
			, 'message' => $message
		);
}

function smarty_function_get_next_uid()
{
	return get_next_available_uid();
}

function load_credentials()
{
	$config = yaml_parse_file("/usr/local/etc/ssoinabox/webcreds.yml");
	$keys = array('LDAP_BASEDN', 'UID_MIN', 'GID_MIN', 'ldap_server', 'ldap_manager', 'ldap_user_basedn', 'ldap_group_basedn', 'kerberos_admin', 'PHONE_EXT_MIN');
	
	foreach ( $keys as $key )
	{
		if ( !isset($config[$key]) )
			die("Config key $key is not set");
		
		if ( preg_match('/^[A-Z_]+$/', $key) )
			define($key, $config[$key]);
		else
			$GLOBALS[$key] = $config[$key];
	}
}