我有这段代码可以获取计算机的标签、操作系统和 lastlogon 时间戳。
问题是我无法显示时间戳代码,以便人们可以理解它。
有没有办法在这段代码中实现这一点?
<?php
header('Content-Type: text/html; charset=iso-8859-1');
$host = "ldap://server.server.net";
$user = "domain\user";
$pswd = "passw";
$ad = ldap_connect($host)
or die( "Could not connect!" );
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3)
or die ("Could not set ldap protocol");
// Binding to ldap server
$bd = ldap_bind($ad, $user, $pswd)
or die ("Could not bind");
// Create the DN
$dn = "OU=NotebookM2,OU=WorkstationsM2,OU=PT1,DC=heiway,DC=net";
$attrs = array("cn","operatingsystem","lastlogon");
// Create the filter from the search parameters
$filter = $_POST['filter']."=".$_POST['keyword']."*";
$search = ldap_search($ad, $dn, $filter, $attrs)
or die ("ldap search failed");
$entries = ldap_get_entries($ad, $search);
if ($entries["count"] > 0) {
echo "<table border='1' width='100%'>";
echo "<tr>";
echo "<td>TAG:</td>";
echo "<td>OS:</td>";
echo "<td>Last Logon:</td>";
echo "</tr>";
for ($i=0; $i<$entries["count"]; $i++) {
echo "<tr>";
echo "<td>".$entries[$i]["cn"][0]."</td>";
echo "<td>".$entries[$i]["operatingsystem"][0]."</td>";
echo "<td>".$entries[$i]["lastlogon"][0]."</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo iconv("UTF-8", "ISO-8859-1","<p>Ops Nothing Found</p>");
}
ldap_unbind($ad);
?>