** Creates a folder
******************************************************************************/
function sqimap_mailbox_create ($imap_stream, $mailbox, $type) {
+ global $delimiter;
if (strtolower($type) == "noselect") {
- $dm = sqimap_get_delimiter($imap_stream);
- $mailbox = $mailbox.$dm;
+ $mailbox = $mailbox.$delimiter;
}
fputs ($imap_stream, sqimap_session_id() . " CREATE \"$mailbox\"\r\n");
$read_ary = sqimap_read_data($imap_stream, sqimap_session_id(), true, $response, $message);
** unformatted-disp - unformatted without $folder_prefix
**
******************************************************************************/
- function sqimap_mailbox_parse ($line, $line_lsub, $dm) {
- global $folder_prefix;
+ function sqimap_mailbox_parse ($line, $line_lsub) {
+ global $folder_prefix, $delimiter;
// Process each folder line
for ($g=0; $g < count($line); $g++) {
$boxes[$g]["raw"] = "";
- // Count number of delimiters ($dm) in folder name
+ // Count number of delimiters ($delimiter) in folder name
$mailbox = trim($line_lsub[$g]);
- $dm_count = countCharInString($mailbox, $dm);
- if (substr($mailbox, -1) == $dm)
+ $dm_count = countCharInString($mailbox, $delimiter);
+ if (substr($mailbox, -1) == $delimiter)
$dm_count--; // If name ends in delimiter - decrement count by one
// Format folder name, but only if it's a INBOX.* or have
// a parent.
$boxesbyname[$mailbox] = $g;
- $parentfolder = readMailboxParent($mailbox, $dm);
+ $parentfolder = readMailboxParent($mailbox, $delimiter);
if((strtolower(substr($mailbox, 0, 5)) == "inbox") ||
(substr($mailbox, 0, strlen($folder_prefix)) == $folder_prefix) ||
(isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
- $indent = $dm_count - (countCharInString($folder_prefix, $dm));
+ $indent = $dm_count - (countCharInString($folder_prefix, $delimiter));
if ($indent > 0)
$boxes[$g]["formatted"] = str_repeat(" ", $indent);
else
$boxes[$g]["formatted"] = '';
- $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+ $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
} else {
$boxes[$g]["formatted"] = $mailbox;
}
$boxes[$g]['unformatted-dm'] = $mailbox;
- if (substr($mailbox, -1) == $dm)
+ if (substr($mailbox, -1) == $delimiter)
$mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
$boxes[$g]['unformatted'] = $mailbox;
if (substr($mailbox,0,strlen($folder_prefix))==$folder_prefix)
global $data_dir, $username, $list_special_folders_first;
global $folder_prefix, $trash_folder, $sent_folder, $draft_folder;
global $move_to_trash, $move_to_sent, $save_as_draft;
+ global $delimiter;
$inbox_in_list = false;
$inbox_subscribed = false;
require_once('../src/load_prefs.php');
require_once('../functions/array.php');
- $dm = sqimap_get_delimiter ($imap_stream);
-
/** LSUB array **/
fputs ($imap_stream, sqimap_session_id() . " LSUB \"$folder_prefix\" \"*\"\r\n");
$lsub_ary = sqimap_read_data ($imap_stream, sqimap_session_id(), true, $response, $message);
/** LIST array **/
$sorted_list_ary = array();
for ($i=0; $i < count($sorted_lsub_ary); $i++) {
- if (substr($sorted_lsub_ary[$i], -1) == $dm)
+ if (substr($sorted_lsub_ary[$i], -1) == $delimiter)
$mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
else
$mbx = $sorted_lsub_ary[$i];
$sorted_lsub_ary[] = find_mailbox_name($inbox_ary[0]);
}
- $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
+ $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary);
/** Now, lets sort for special folders **/
$boxesnew = Array();
for ($i = 0 ; $i < count($boxes) ; $i++) {
if ($move_to_trash &&
eregi('^' . quotemeta($trash_folder) . '(' .
- quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+ quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
$boxesnew[] = $boxes[$i];
$used[$i] = true;
}
for ($i = 0 ; $i < count($boxes) ; $i++) {
if ($move_to_sent &&
eregi('^' . quotemeta($sent_folder) . '(' .
- quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+ quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
$boxesnew[] = $boxes[$i];
$used[$i] = true;
}
for ($i = 0 ; $i < count($boxes) ; $i++) {
if ($save_as_draft &&
eregi('^' . quotemeta($draft_folder) . '(' .
- quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+ quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
$boxesnew[] = $boxes[$i];
$used[$i] = true;
}
******************************************************************************/
function sqimap_mailbox_list_all ($imap_stream) {
global $list_special_folders_first, $folder_prefix;
-
+ global $delimiter;
+
if (!function_exists ("ary_sort"))
include_once('../functions/array.php');
-
- $dm = sqimap_get_delimiter ($imap_stream);
$ssid = sqimap_session_id();
$lsid = strlen( $ssid );
// Store the raw IMAP reply
$boxes[$g]["raw"] = $read_ary[$i];
- // Count number of delimiters ($dm) in folder name
+ // Count number of delimiters ($delimiter) in folder name
$mailbox = find_mailbox_name($read_ary[$i]);
- $dm_count = countCharInString($mailbox, $dm);
- if (substr($mailbox, -1) == $dm)
+ $dm_count = countCharInString($mailbox, $delimiter);
+ if (substr($mailbox, -1) == $delimiter)
$dm_count--; // If name ends in delimiter - decrement count by one
// Format folder name, but only if it's a INBOX.* or have
// a parent.
$boxesbyname[$mailbox] = $g;
- $parentfolder = readMailboxParent($mailbox, $dm);
- if((eregi('^inbox'.quotemeta($dm), $mailbox)) ||
+ $parentfolder = readMailboxParent($mailbox, $delimiter);
+ if((eregi('^inbox'.quotemeta($delimiter), $mailbox)) ||
(ereg('^'.$folder_prefix, $mailbox)) ||
( isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
if ($dm_count)
$boxes[$g]["formatted"] = str_repeat(" ", $dm_count);
else
$boxes[$g]["formatted"] = '';
- $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+ $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
} else {
$boxes[$g]["formatted"] = $mailbox;
}
$boxes[$g]["unformatted-dm"] = $mailbox;
- if (substr($mailbox, -1) == $dm)
+ if (substr($mailbox, -1) == $delimiter)
$mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
$boxes[$g]["unformatted"] = $mailbox;
$boxes[$g]["unformatted-disp"] = ereg_replace('^' . $folder_prefix, '', $mailbox);
}
}
- function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $dm, $topFolderName) {
- global $trash_folder;
+ function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
+ global $trash_folder, $delimiter;
- $position = strrpos($topFolderName, $dm) + 1;
+ $position = strrpos($topFolderName, $delimiter) + 1;
$subFolderName = substr($tree[$index]['value'], $position);
if ($tree[$index]['doIHaveChildren']) {
- sqimap_mailbox_create($imap_stream, $trash_folder . $dm . $subFolderName, "");
+ sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
$messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
if ($messageCount > 0)
- sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $dm . $subFolderName);
+ sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
- walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $dm, $topFolderName);
+ walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
} else {
- sqimap_mailbox_create($imap_stream, $trash_folder . $dm . $subFolderName, '');
+ sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
$messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
if ($messageCount > 0)
- sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $dm . $subFolderName);
+ sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
}
}
echo $tree[$index]['value'] . '<br>';
}
}
-?>
\ No newline at end of file
+?>
$mailbox = $trash_folder;
$boxes = sqimap_mailbox_list($imap_stream);
- $dm = sqimap_get_delimiter($imap_stream);
+ global $delimiter;
// According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
// so lets go through the list of subfolders and remove them before removing the
// on the end of the $mailbox string, and compare to that.
$j = 0;
for ($i = 0;$i < count($boxes);$i++) {
- if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
+ if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
}
}
header ("Location: $location/left_main.php");
sqimap_logout($imap_stream);
-?>
\ No newline at end of file
+?>
require_once('../functions/display_messages.php');
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- $dm = sqimap_get_delimiter($imapConnection);
+ global $delimiter;
if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
- strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
+ strpos($folder_name, "'") || strpos($folder_name, "$delimiter")) {
echo "<html><body bgcolor=$color[4]>";
plain_error_message(_("Illegal folder name. Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
sqimap_logout($imapConnection);
}
if (isset($contain_subs) && $contain_subs == true)
- $folder_name = "$folder_name$dm";
+ $folder_name = "$folder_name$delimiter";
- if ($folder_prefix && (substr($folder_prefix, -1) != $dm)) {
- $folder_prefix = $folder_prefix . $dm;
+ if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
+ $folder_prefix = $folder_prefix . $delimiter;
}
if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
$subfolder_orig = $subfolder;
if (trim($subfolder_orig) == '') {
sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
} else {
- sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
+ sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, "");
}
$location = get_location();
header ("Location: $location/folders.php?success=create");
sqimap_logout($imapConnection);
-?>
\ No newline at end of file
+?>
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
$boxes = sqimap_mailbox_list ($imap_stream);
- $dm = sqimap_get_delimiter($imap_stream);
+ global $delimiter;
- if (substr($mailbox, -1) == $dm)
+ if (substr($mailbox, -1) == $delimiter)
$mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
else
$mailbox_no_dm = $mailbox;
// on the end of the $mailbox string, and compare to that.
$j = 0;
for ($i = 0;$i < count($boxes);$i++) {
- if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
+ if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $delimiter)) == ($mailbox_no_dm . $delimiter)) {
addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
}
}
/** Lets start removing the folders and messages **/
if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
- walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox);
+ walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $mailbox);
walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
} else { /** if they do NOT wish to move messages to the trash (or cannot)**/
walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
echo "</BODY></HTML>";
*/
-?>
\ No newline at end of file
+?>
}
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- $dm = sqimap_get_delimiter($imapConnection);
+ global $delimiter;
- if (strpos($orig, $dm))
- $old_dir = substr($orig, 0, strrpos($orig, $dm));
+ if (strpos($orig, $delimiter))
+ $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
else
$old_dir = "";
if ($old_dir != "")
- $newone = "$old_dir$dm$new_name";
+ $newone = "$old_dir$delimiter$new_name";
else
$newone = "$new_name";
// Renaming a folder doesn't renames the folder but leaves you unsubscribed
// at least on Cyrus IMAP servers.
if (isset($isfolder)) {
- $newone = $newone.$dm;
- $orig = $orig.$dm;
+ $newone = $newone.$delimiter;
+ $orig = $orig.$delimiter;
}
sqimap_unsubscribe($imapConnection, $orig);
sqimap_subscribe($imapConnection, $newone);
sqimap_logout($imapConnection);
$location = get_location();
header ("Location: $location/folders.php?success=rename");
-?>
\ No newline at end of file
+?>
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- $dm = sqimap_get_delimiter($imapConnection);
- if (substr($old, strlen($old) - strlen($dm)) == $dm) {
+ global $delimiter;
+ if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
$isfolder = true;
$old = substr($old, 0, strlen($old) - 1);
}
- if (strpos($old, $dm)) {
- $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
- $old_parent = substr($old, 0, strrpos($old, $dm));
+ if (strpos($old, $delimiter)) {
+ $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
+ $old_parent = substr($old, 0, strrpos($old, $delimiter));
} else {
$old_name = $old;
$old_parent = "";
/** Log out this session **/
sqimap_logout($imapConnection);
-?>
\ No newline at end of file
+?>
require_once('../functions/display_messages.php');
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
- $dm = sqimap_get_delimiter($imapConnection);
$location = get_location();
if ($method == "sub") {
define('SM_BOX_UNCOLLAPSED', 0);
define('SM_BOX_COLLAPSED', 1);
+ global $delimiter;
+
// open a connection on the imap port (143)
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
session_register('auto_create_done');
}
- function formatMailboxName($imapConnection, $box_array, $delimeter) {
+ function formatMailboxName($imapConnection, $box_array) {
global $folder_prefix, $trash_folder, $sent_folder;
global $color, $move_to_sent, $move_to_trash;
global $unseen_notify, $unseen_type, $collapse_folders;
echo '<SMALL>(<A HREF="../src/left_main.php" TARGET="left">';
echo _("refresh folder list");
echo '</A>)</SMALL></CENTER><BR>';
- $delimeter = sqimap_get_delimiter($imapConnection);
/* Lastly, display the folder list. */
if (isset($collapse_folders) && $collapse_folders) {
for ($i = 0;$i < count($boxes); $i++) {
if ($boxes[$i]['visible'] == true) {
$mailbox = $boxes[$i]['formatted'];
- $mblevel = substr_count($boxes[$i]['unformatted'], $delimeter) + 1;
+ $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1;
/* Create the prefix for the folder name and link. */
$prefix = str_repeat(' ',$mblevel);
}
$line .= '</FONT>';
} else {
- $line .= formatMailboxName($imapConnection, $boxes[$i], $delimeter);
+ $line .= formatMailboxName($imapConnection, $boxes[$i]);
}
/* Put the final touches on our folder line. */
* This simple function checks if a box is another box's parent.
*/
function is_parent_box($curbox_name, $parbox_name) {
- global $delimeter;
+ global $delimiter;
/* Extract the name of the parent of the current box. */
- $curparts = explode($delimeter, $curbox_name);
+ $curparts = explode($delimiter, $curbox_name);
$curname = array_pop($curparts);
- $actual_parname = implode($delimeter, $curparts);
+ $actual_parname = implode($delimiter, $curparts);
$actual_parname = substr($actual_parname,0,strlen($parbox_name));
/* Compare the actual with the given parent name. */
$delimiter = sqimap_get_delimiter ($imapConnection);
}
sqimap_logout($imapConnection);
+ session_register('delimiter');
$username = $login_username;
session_register ('username');
setcookie('key', $key, 0, $base_uri);
- setcookie('delimiter', $delimiter, 0, $base_uri);
do_hook ('login_verified');
}
do_hook('logout');
setcookie('username', '', 0, $base_uri);
setcookie('key', '', 0, $base_uri);
- setcookie('delimiter', '', 0, $base_uri);
session_destroy();
if ($signout_page) {