Example #1
0
File: index.php Project: sk/gnumed
<?
// LDAP - PHP interface for Wagtail
// v0.2
include("config.php");
include("functions.php");

// Login dn and password set as cookies
$login_dn = (isset( $_COOKIE['login_dn'] ) and $_COOKIE['login_dn']!="" )? $_COOKIE['login_dn'] : "anon";
$login_pass = isset( $_COOKIE['login_pass'] ) ? $_COOKIE['login_pass'] : null;
$Command=$_REQUEST['Command'];
$region=$_REQUEST['region'];

// Need to set new cookies before any text sent
if($_REQUEST['Command']=='Log In'){
	$uid=$_REQUEST['uid'];
	$ldapuser=getUserFromUID($uid);
	$login_pass=$_REQUEST['pw'];
	// See if can bind with those values
	$ldapConn = ldap_connect($ldapServer);
	ldap_set_option( $ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3 );
	$ldapBind = ldap_bind($ldapConn,$ldapuser,$login_pass);
	if ($ldapBind){
		setcookie('login_dn', $ldapuser);
		setcookie('login_pass', $login_pass);
		$login_dn=$ldapuser;
		$login_pass=$_REQUEST['pw'];
	}
	else{
		print "Unable to connect to $ldapServer as $ldapuser with that password<p>";
	}
<?php

//This file is for organization functions
//Calls methods to save or retrieve org details
include "functions.php";
$transaction = $_GET["transaction"];
//echo $transaction;
if ($transaction == '2') {
    $orgname = $_POST["orgname"];
    $phone = $_POST["phone"];
    $address = $_POST["address"];
    saveOrg($orgname, $phone, $address);
} else {
    getOrg();
}