require_once '../local_lib/HTML_DietMarco.php';
require_once '../local_lib/HTML_Login.php';
require_once 'DB.php';
if(isset($_POST['usuario']))
{
$userid = $_POST['usuario'];
$ds = @ldap_connect( "ldapdist.mecon.ar" )
or $ds = @ldap_connect( "ldapmaster.mecon.ar" );
if (! $ds) {
//error connecting - return false
echo "Error conectando!\n";
}
list( $uid, $domain ) = split( "@", $userid );
$r = @ldap_bind($ds, "uid=$uid,ou=Personas,o=$domain,o=gov.ar", $_POST['password']);
if ($r) {
$sr = @ldap_search($ds, "ou=Personas,o=$domain,o=gov.ar", "uid=$uid");
$info = @ldap_get_entries($ds, $sr);
}
ldap_close($ds);
if (!isset($sr)) {
//error reading / authenticating - return false
echo "Error leyendo!\n";
}
else
{
$_SESSION['usuario'] = $_POST['usuario'];
$_SESSION['documento'] = $info[0]['uidnumber'][0];
}
}else{
if(!isset($_SESSION['usuario']))
{
$m = new HTML_DietMarco('servicios');
$m->addTitle('Servicios');
$login = new HTML_Login();
$t = new HTML_Table(array('width' => 760,
'align' => 'center',
'cellspacing' => 0,
'cellpadding' => 0,
'border' => 0,
'valign' => 'middle',
'height' => 200));
$t->addRow(array($login));
$m->addStyleSheet($login->getCSS());
$m->addBodyContent($t);
$m->display();
}
}
if(isset($_SESSION['usuario']) && (isset($_POST['redirect']) || isset($_GET['redirect'])))
{
$db = DB::Connect('mysql://intranet:intranet@bal747f/intranet');
$query = "SELECT link
FROM servicio
WHERE servicio = ";
if(isset($_POST['redirect']))
$query .= $_POST['redirect'];
else
$query .= $_GET['redirect'];
$link = $db->getOne($query);
header('location: '.$link);
}
?>