note 61471 added to function.imap-getmailboxes
| From: | emielbom at hotmail dot com | Date: | Sat, 04 Feb 2006 15:09:52 +0000 |
| Subject: | note 61471 added to function.imap-getmailboxes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102995@lists.php.net to get a copy of this message | ||
i was looking for a function to test the attributes.
and it was hard to find an answer or code.
Maybe there is a function availeble, but i couldn't find it.
the first function: returns all mailboxes in on the server
The second function: returns a bitstring from the attr_number returned by getmailboxes()
The tirth function: returns an array with the active attributes on the specific mailbox
Last Line: is a combination of the functions: the output is, any map witch can hold no mail but only
sub boxes...
function getFolders($mailbox, $serverString) {
$list = imap_getmailboxes($mailbox, $serverString, "*");
if (is_array($list)) {
foreach ($list as $key => $val) {
$mapname = str_replace($serverString, "", imap_utf7_decode($val->name));
if ($mapname[0] != ".") {
$list_folders[$key]['name'] = $mapname;
$list_folders[$key]['delimiter'] = $val->delimiter;
$list_folders[$key]['attributes'] = $val->attributes;
}
}
} else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
return $list_folders;
}
function IntToBin($number) {
$BitWaarde = 1;
$IntNum = $number;
$BinString = "";
if ($IntNum > 0) {
// bepaal de max bitwaarde aan de hand van $IntNum
while ($IntNum > $BitWaarde) {
$BitWaarde = $BitWaarde * 2;
}
// maken van een binaire string.
while ($BitWaarde >= 1 ) {
if ($IntNum < $BitWaarde) {
if ($BinString != "") $BinString .= "0";
} else {
$BinString .= "1";
$IntNum = $IntNum-$BitWaarde;
}
$BitWaarde = $BitWaarde / 2;
}
}
return $BinString;
}
function Attributes($BinString) {
$BinInt = (int)$BinString;
if ($BinInt >=1000){
$setAttribute['LATT_UNMARKED'] = true;
$BinInt = $BinInt-1000;
} else $setAttribute['LATT_UNMARKED'] = false;
if ($BinInt >=100){
$setAttribute['LATT_MARKED'] = true;
$BinInt = $BinInt-100;
} else $setAttribute['LATT_MARKED'] = false;
if ($BinInt >=10){
$setAttribute['LATT_NOSELECT'] = true;
$BinInt = $BinInt-10;
} else $setAttribute['LATT_NOSELECT'] = false;
if ($BinInt >=1){
$setAttribute['LATT_NOINFERIORS'] = true;
$BinInt = $BinInt-1;
} else $setAttribute['LATT_NOINFERIORS'] = false;
return $setAttribute;
}
foreach (getFolders($mailbox, $config['Server_string']) as $key => $val) {
$Attr = Attributes(IntToBin((int)$val['attributes']));
if (!$Attr['LATT_NOINFERIORS']) {
echo "<option
value='".$val['name']."'>".$val['name']."</option>";
}
}
----
Server IP: 83.137.20.120
Probable Submitter: 80.126.90.216
----
Manual Page -- http://www.php.net/manual/en/function.imap-getmailboxes.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61471
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61471&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61471&report=yes
Search -- http://master.php.net/manage/user-notes.php