- $query = "SEARCH UID 1:$uidnext";
- $uids = sqimap_run_command ($imap_stream, $query, true, $response, $message, true);
- if (isset($uids[0])) {
- if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
- $server_sort_array = preg_split("/ /", trim($regs[1]));
- }
- }
- if (!preg_match("/OK/", $response)) {
- $server_sort_array = 'no';
- }
- } else {
- $qty = $mbxresponse['EXISTS'];
- $server_sort_array = range(1, $qty);
- }
- $server_sort_array = array_reverse($server_sort_array);
- sqsession_register($server_sort_array, 'server_sort_array');
- return $server_sort_array;
- }
-
- $sort_on = array (0=> 'DATE',
- 1=> 'DATE',
- 2=> 'FROM',
- 3=> 'FROM',
- 4=> 'SUBJECT',
- 5=> 'SUBJECT');
- if ($internal_date_sort == true) {
- $sort_on[0] = 'ARRIVAL';
- $sort_on[1] = 'ARRIVAL';
- }
- if ($sent_folder == $mailbox) {
- $sort_on[2] = 'TO';
- $sort_on[3] = 'TO';
- }
- if (!empty($sort_on[$sort])) {
- $query = "SORT ($sort_on[$sort]) ".strtoupper($default_charset).' ALL';
- $sort_test = sqimap_run_command ($imap_stream, $query, true, $response, $message, $uid_support);
- }
- if (isset($sort_test[0])) {
- for ($i=0,$iCnt=count($sort_test);$i<$iCnt;++$i) {
- if (preg_match("/^\* SORT (.+)$/", $sort_test[$i], $regs)) {
- $server_sort_array = preg_split("/ /", trim($regs[1]));
- break;