| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/Helpdesk/application/models/ |
Upload File : |
<?php
class UsersModel
{
function __construct($db) {
$this->db = $db;
}
public function getUser($id)
{
$id = $this->db->strip($id);
$user = $this->db->select("* FROM users WHERE id=".$id, 'firstrow');
return $user;
}
public function authenticateUser($username,$password)
{
$ds = ldap_connect(LDAP_HOST, LDAP_PORT) or die("Could not connect to DS");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$r = ldap_bind($ds,LDAP_USER,LDAP_PASS) or die("Could not connect to DS");
$baseDn = LDAP_DN;
$filter = "(uid=".$_POST["username"].")";
$sr = ldap_search($ds, $baseDn, $filter);
$info = ldap_get_entries($ds, $sr);
$ldapbind = @ldap_bind($ds,$info[0]["dn"],$_POST["password"]);
if ($ldapbind != null) {
$_SESSION["username"] = $_POST["username"];
if ($info[0]["cn;lang-el"][0]!="")
$_SESSION["fullname"] = $info[0]["cn;lang-el"][0];
else
$_SESSION["fullname"] = $info[0]["cn"][0];
if (in_array("student", $info[0]["edupersonaffiliation"]))
$_SESSION["idiotita"] = "Σπουδαστής";
if (in_array("employee", $info[0]["edupersonaffiliation"]))
$_SESSION["idiotita"] = "Συνεργάτης";
if (in_array("staff", $info[0]["edupersonaffiliation"]))
$_SESSION["idiotita"] = "Διοικητικός Υπάλληλος";
if (in_array("faculty", $info[0]["edupersonaffiliation"]))
$_SESSION["idiotita"] = "Εκπαιδευτικό Προσωπικό";
/*
if ($info[0]["edupersonaffiliation"][0]=="student") {
$_SESSION["idiotita"] = "Σπουδαστής";
} else if ($info[0]["edupersonaffiliation"][0]=="staff")
$_SESSION["idiotita"] = "Διοικητικός Υπάλληλος";
else if ($info[0]["edupersonaffiliation"][0]=="faculty")
$_SESSION["idiotita"] = "Εκπαιδευτικό Προσωπικό";
else if ($info[0]["edupersonaffiliation"][0]=="employee")
$_SESSION["idiotita"] = "Συνεργάτης";
*/
if (!empty($info[0]["postaladdress"][0]))
$_SESSION["email"] = $_SESSION["username"]."@ihu.gr";
else if (!empty($info[0]["mail"][0]))
$_SESSION["email"] = $info[0]["mail"][0];
else
$_SESSION["email"] = "";
if (!empty($info[0]["mobile"][0]))
$_SESSION["mobile"] = $info[0]["mobile"][0];
return true;
} else {
return false;
}
}
}
?>