<?
//-- Telefon Rehberi --
// modify.php
// LDAP uzerinde degisiklik icin form uretir.
// Yazan: Mustafa Hadi Dilek, Subat 2000
//-------------
  
require("common.php");

  if (!
ValidateHOST()) {
    
CommonHeader("LDAP Kaydı Değiştirme"); 
    echo 
"Üzgünüz. LDAP bilgileri ancak Ulakbim içindeki bilgisayarlardan değiştirilebilir...";
    
CommonFooter($footer_links);
    exit;
  }

  if (empty(
$user) || empty($pwd)) {
    if (empty(
$user))
     @
header("Location: login.php?empty=YES");
    else
     @
header("Location: login.php?user=".$user."&empty=YES");
    exit;
  }

  
$footer_links["rehber.php"] ="Ulakbim Telefon Rehberi";
  
$footer_links["login.php"]  ="Baska Bir Kullaniciya Gec";
  
  
$my_con = @ldap_connect(_LDAP_HOST,_LDAP_PORT);

  if (!
$my_con) {
    
CommonHeader("LDAP Kaydı Değiştirme"); 
    echo 
"Hata. LDAP sunucu baglantısı saglanamadı.<BR>Sorun yetkililere iletildi...";
    
mail(getenv("SERVER_ADMIN"), // Target address
    
"Ulakbim Telefon Rehberi'nde hata!!!",  // Subject
    
"LDAP sunucusuna erisim basarisiz. Script: "._FILE_."\nErisim parametreleri:\nSunucu: "._LDAP_HOST."\nPort:" ._LDAP_PORT."\nSunucu calismiyor olabilir ya da erisim parametrelerinde hata var..."// Message body
    
"From: ".getenv("SERVER_ADMIN")."\nX-Mailer: PHP/" phpversion());
    
CommonFooter($footer_links);
    exit;
  }

  
$dn "uid=".$user.","._ORG;
        
  if (!(
$r = @ldap_bind($my_con$dn$pwd))) {
    @
header("Location: login.php?unauth=YES");
    exit;
  }

  
setcookie("user"$user);
  
setcookie("pwd" $pwd);

  
$base_dn    _ORG;
  
$filter     "uid=".$user;
  
$search_res ldap_search($my_con$base_dn$filter);
  
$entries    ldap_get_entries($my_con$search_res);
  
$info       $entries[0];

  
CommonHeader("LDAP Kaydı Değiştirme"); 
//-------------
?>
<FORM ACTION="modify_res.php" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
<?
//-------------
  
echo "<TABLE WIDTH=\""._WIDTH."\" BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\">\n";
    
  
reset($ldap_attr_str);
  while(list(
$key$val)=each($ldap_attr_str)) {
    if (!
in_array($keyarray_keys($info))) {
      echo 
"Kullanıcının ".$val." özelliği yok...<BR>\n";
      continue;
      }
//-------------
?>
<TR>
  <TD CLASS="formlabel"><? echo $val?>:&nbsp</TD>
  <TD CLASS="formvalue">
<?
//-------------
    
if (in_array($key,$ldap_attr_changeable)) {
      echo 
"<INPUT NAME=\"".$key."\" TYPE=\"Text\" VALUE=\"".GetAttr(@$info[$key])."\"></INPUT>";
    }
      else {
      echo 
GetAttr(FormatLinks(@$info[$key]));
      }
//-------------
?>
  </TD>
</TR>
<?
//-------------
  
//while
//-------------
?>
<TR>
  <TD CLASS="formlabel">&nbsp;</TD>
  <TD CLASS="formvalue">
    <INPUT NAME="submit_change" TYPE="Submit" VALUE="Değiştir"></INPUT>
    <INPUT NAME="submit_cancel" TYPE="Submit" VALUE="İptal"></INPUT>
  </TD>
</TR>
</TABLE>
</FORM>
<?
//-------------
  
ldap_close($my_con);

  
$footer_links["login.php"] ="Başka Bir Kullanıcıya Gec";
  
CommonFooter($footer_links);
?>