One more thing: in case you don't have a PHP IDE application, I strongly suggest you use one, it makes troubleshooting much easier - ex forgot a ';' somewhere or some brackets not closed. I love PHP Designer (freeware).
Printable View
One more thing: in case you don't have a PHP IDE application, I strongly suggest you use one, it makes troubleshooting much easier - ex forgot a ';' somewhere or some brackets not closed. I love PHP Designer (freeware).
Thanks for your advice about the IDE, the function
ldap_get_logonhours
doesn't seems to work properly it resets everything and returns only " 0 "s
I know this thread is super old but I'm having the same issue as uchi. Anyone ever figure this out? And if so, can anyone show me an example of the $hrs variable that goes into the ldap_get_logonhours array?
Thanks!
Anyone out there looking for an answer here's what I figured out:
$eighthourchunks = str_split($hourshex, 2);
foreach ($eighthourchunks as $chunk){
$i++;
$bytes .= strrev(sprintf('%08d',decbin(hexdec('0x' . $chunk))));
}
$bytesbegin = substr($bytes, 0, 5);
$bytesend = substr($bytes, 5);
$bytes_tz_corrected = $bytesend . $bytesbegin;
$daysarr = str_split($bytes_tz_corrected, 24);
$dowMap = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
$i = 0;
foreach ($daysarr as $day){
echo $dowMap[$i];
echo ' : ' . $day . '<br>';
$i++;
}
Hopefully I don't piss too many people off for tacking on to this post.. It just seemed like a good idea to keep this all together.
So I took the data generated from my last post and created a table. I then used javascript to control that table to recreate functionality similar to what we are all used to seeing in Active Directory where the blue cells represent permitted hours and the gray ones are blocked off hours. Javascript then uses AJAX with post method to return the binary data back to php and php uses pack("C", bindec(strrev($chunk))) in a foreach loop to format it correctly for active directory. My only problem is that I intermittently get the error "Server unwilling to perform 53" and I think it's due to the formatting I'm using. Is there something I should tack on to pack("C", bindec(strrev($chunk))) for it to consistently work?