8fd99a9fde1346258be5d6f2019eb260a1496342
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This implements functions that manipulate messages
14 /* Copies specified messages to specified folder */
16 function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
18 $read = sqimap_run_command ($imap_stream, "COPY $start:$end \"$mailbox\"", true, $response, $message, $uid_support);
21 function sqimap_msgs_list_copy ($imap_stream, $id, $mailbox) {
23 $msgs_id = sqimap_message_list_squisher($id);
25 $read = sqimap_run_command ($imap_stream, "COPY $msgs_id \"$mailbox\"", true, $response, $message, $uid_support);
26 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, $uid_support);
30 /* Deletes specified messages and moves them to trash if possible */
32 function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
33 global $move_to_trash, $trash_folder, $auto_expunge, $uid_support;
35 if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
36 sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
38 sqimap_messages_flag ($imap_stream, $start, $end, "Deleted", true);
41 function sqimap_msgs_list_delete ($imap_stream, $mailbox, $id) {
42 global $move_to_trash, $trash_folder, $uid_support;
43 $msgs_id = sqimap_message_list_squisher($id);
44 if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
45 $read = sqimap_run_command ($imap_stream, "COPY $msgs_id \"$trash_folder\"", true, $response, $message, $uid_support);
47 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", $handle_errors, $response, $message, $uid_support);
51 /* Sets the specified messages with specified flag */
52 function sqimap_messages_flag ($imap_stream, $start, $end, $flag, $handle_errors) {
54 $read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", $handle_errors, $response, $message, $uid_support);
57 /* Remove specified flag from specified messages */
58 function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag, $handle_errors) {
60 $read = sqimap_run_command ($imap_stream, "STORE $start:$end -FLAGS (\\$flag)", $handle_errors, $response, $message, $uid_support);
63 function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) {
65 $msgs_id = sqimap_message_list_squisher($id);
66 $set_string = ($set ?
'+' : '-');
67 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id ".$set_string."FLAGS ($flag)", $handle_errors, $response, $message, $uid_support);
71 /* Returns some general header information -- FROM, DATE, and SUBJECT */
73 var $from = '', $subject = '', $date = '', $to = '',
74 $priority = 0, $message_id = 0, $cc = '', $uid = '';
77 function sqimap_get_small_header ($imap_stream, $id, $sent) {
78 $res = sqimap_get_small_header_list($imap_stream, array($id), $sent);
83 * Sort the message list and crunch to be as small as possible
84 * (overflow could happen, so make it small if possible)
86 function sqimap_message_list_squisher($messages_array) {
87 if( !is_array( $messages_array ) ) {
91 sort($messages_array, SORT_NUMERIC
);
93 while ($messages_array) {
94 $start = array_shift($messages_array);
96 while (isset($messages_array[0]) && $messages_array[0] == $end +
1) {
97 $end = array_shift($messages_array);
99 if ($msgs_str != '') {
103 if ($start != $end) {
104 $msgs_str .= ':' . $end;
110 /* returns the references header lines */
111 function get_reference_header ($imap_stream, $message) {
113 $responses = array ();
114 $sid = sqimap_session_id($uid_support);
117 $query = "$sid FETCH $message BODY[HEADER.FIELDS (References)]\r\n";
118 fputs ($imap_stream, $query);
119 $responses = sqimap_read_data_list($imap_stream, $sid, true, $responses, $message);
120 if (!eregi("^\\* ([0-9]+) FETCH", $responses[0][0], $regs)) {
121 $responses = array ();
127 /* get sort order from server and
128 * return it as the $id array for
132 function sqimap_get_sort_order ($imap_stream, $sort, $mbxresponse) {
133 global $default_charset, $thread_sort_messages,
134 $internal_date_sort, $server_sort_array,
135 $sent_folder, $mailbox, $uid_support;
137 if (sqsession_is_registered('server_sort_array')) {
138 sqsession_unregister('server_sort_array');
141 $sid = sqimap_session_id($uid_support);
144 $server_sort_array = array();
145 $sort_test = array();
150 if (isset($mbxresponse['UIDNEXT']) && $mbxresponse['UIDNEXT']) {
151 $uidnext = $mbxresponse['UIDNEXT']-1;
155 $uid_query = "$sid SEARCH UID 1:$uidnext\r\n";
156 fputs($imap_stream, $uid_query);
157 $uids = sqimap_read_data($imap_stream, $sid, true ,$response, $message);
158 if (isset($uids[0])) {
159 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
160 $server_sort_array = preg_split("/ /", trim($regs[1]));
163 if (!preg_match("/OK/", $response)) {
164 $server_sort_array = 'no';
167 $qty = $mbxresponse['EXISTS'];
168 $server_sort_array = range(1, $qty);
170 sqsession_register($server_sort_array, 'server_sort_array');
171 return $server_sort_array;
174 $sort_on = array (0=> 'DATE',
180 if ($internal_date_sort == true) {
181 $sort_on[0] = 'ARRIVAL';
182 $sort_on[1] = 'ARRIVAL';
184 if ($sent_folder == $mailbox) {
188 if (!empty($sort_on[$sort])) {
189 $sort_query = "$sid SORT ($sort_on[$sort]) ".strtoupper($default_charset)." ALL\r\n";
190 fputs($imap_stream, $sort_query);
191 $sort_test = sqimap_read_data($imap_stream, $sid, true ,$response, $message);
193 if (isset($sort_test[0])) {
194 if (preg_match("/^\* SORT (.+)$/", $sort_test[0], $regs)) {
195 $server_sort_array = preg_split("/ /", trim($regs[1]));
198 if ($sort == 0 ||
$sort == 2 ||
$sort == 4) {
199 $server_sort_array = array_reverse($server_sort_array);
201 if (!preg_match("/OK/", $response)) {
202 $server_sort_array = 'no';
204 sqsession_register($server_sort_array, 'server_sort_array');
205 return $server_sort_array;
209 function sqimap_get_php_sort_order ($imap_stream, $mbxresponse) {
212 if (sqsession_is_registered('php_sort_array')) {
213 sqsession_unregister('php_sort_array');
216 $sid = sqimap_session_id($uid_support);
217 $php_sort_array = array();
220 if (isset($mbxresponse['UIDNEXT']) && $mbxresponse['UIDNEXT']) {
221 $uidnext = $mbxresponse['UIDNEXT']-1;
225 $uid_query = "$sid SEARCH UID 1:$uidnext\r\n";
226 fputs($imap_stream, $uid_query);
227 $uids = sqimap_read_data($imap_stream, $sid, true ,$response, $message);
228 if (isset($uids[0])) {
229 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
230 $php_sort_array = preg_split("/ /", trim($regs[1]));
233 if (!preg_match("/OK/", $response)) {
234 $php_sort_array = 'no';
237 $qty = $mbxresponse['EXISTS'];
238 $php_sort_array = range(1, $qty);
240 sqsession_register($php_sort_array, 'php_sort_array');
241 return $php_sort_array;
245 /* returns an indent array for printMessageinfo()
246 this represents the amount of indent needed (value)
247 for this message number (key)
250 function get_parent_level ($imap_stream) {
251 global $sort_by_ref, $default_charset, $thread_new;
256 /* loop through the threads and take unwanted characters out
257 of the thread string then chop it up
259 for ($i=0;$i<count($thread_new);$i++
) {
260 $thread_new[$i] = preg_replace("/\s\(/", "(", $thread_new[$i]);
261 $thread_new[$i] = preg_replace("/(\d+)/", "$1|", $thread_new[$i]);
262 $thread_new[$i] = preg_split("/\|/", $thread_new[$i], -1, PREG_SPLIT_NO_EMPTY
);
264 $indent_array = array();
266 $thread_new = array();
268 /* looping through the parts of one message thread */
270 for ($i=0;$i<count($thread_new);$i++
) {
271 /* first grab the parent, it does not indent */
273 if (isset($thread_new[$i][0])) {
274 if (preg_match("/(\d+)/", $thread_new[$i][0], $regs)) {
278 $indent_array[$parent] = 0;
280 /* now the children, checking each thread portion for
281 ),(, and space, adjusting the level and space values
282 to get the indent level
289 for ($k=1;$k<(count($thread_new[$i]))-1;$k++
) {
290 $chars = count_chars($thread_new[$i][$k], 1);
291 if (isset($chars['40'])) { /* testing for ( */
292 $level = $level +
$chars['40'];
294 if (isset($chars['41'])) { /* testing for ) */
295 $level = $level - $chars['41'];
297 /* if we were faking lets stop, this portion
298 of the thread is over
300 if ($level == $cutoff) {
304 if (isset($chars['32'])) { /* testing for space */
305 if (!isset($spaces[$level])) {
308 $spaces[$level] = $spaces[$level] +
$chars['32'];
310 for ($x=0;$x<=$level;$x++
) {
311 if (isset($spaces[$x])) {
312 $spaces_total = $spaces_total +
$spaces[$x];
315 $indent = $level +
$spaces_total;
316 /* must have run into a message that broke the thread
317 so we are adjusting for that portion
320 $indent = $indent +
1;
322 if (preg_match("/(\d+)/", $thread_new[$i][$k], $regs)) {
325 /* the thread must be broken if $indent == 0
326 so indent the message once and start faking it
333 /* dont need abs but if indent was negative
336 $indent_array[$child] = abs($indent);
340 return $indent_array;
344 /* returns an array with each element as a string
345 representing one message thread as returned by
349 function get_thread_sort ($imap_stream) {
350 global $thread_new, $sort_by_ref, $default_charset, $server_sort_array, $uid_support;
351 if (sqsession_is_registered('thread_new')) {
352 sqsession_unregister('thread_new');
354 if (sqsession_is_registered('server_sort_array')) {
355 sqsession_unregister('server_sort_array');
357 $sid = sqimap_session_id($uid_support);
358 $thread_temp = array ();
359 if ($sort_by_ref == 1) {
360 $sort_type = 'REFERENCES';
363 $sort_type = 'ORDEREDSUBJECT';
365 $thread_query = "$sid THREAD $sort_type ".strtoupper($default_charset)." ALL\r\n";
366 fputs($imap_stream, $thread_query);
367 $thread_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
368 if (isset($thread_test[0])) {
369 if (preg_match("/^\* THREAD (.+)$/", $thread_test[0], $regs)) {
370 $thread_list = trim($regs[1]);
376 if (!preg_match("/OK/", $response)) {
377 $server_sort_array = 'no';
378 return $server_sort_array;
380 if (isset($thread_list)) {
381 $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
384 $t->parseThread($thread_list);
387 $char_count = count($thread_temp);
389 $thread_new = array();
392 for ($i=0;$i<$char_count;$i++
) {
393 if ($thread_temp[$i] != ')' && $thread_temp[$i] != '(') {
394 $thread_new[$k] = $thread_new[$k] . $thread_temp[$i];
396 elseif ($thread_temp[$i] == '(') {
397 $thread_new[$k] .= $thread_temp[$i];
400 elseif ($thread_temp[$i] == ')') {
402 $thread_new[$k] .= $thread_temp[$i];
403 $counter = $counter - 1;
406 $thread_new[$k] .= $thread_temp[$i];
408 $thread_new[$k] = "";
409 $counter = $counter - 1;
413 sqsession_register($thread_new, 'thread_new');
414 $thread_new = array_reverse($thread_new);
415 $thread_list = implode(" ", $thread_new);
416 $thread_list = str_replace("(", " ", $thread_list);
417 $thread_list = str_replace(")", " ", $thread_list);
418 $thread_list = preg_split("/\s/", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
419 $server_sort_array = $thread_list;
420 sqsession_register($server_sort_array, 'server_sort_array');
429 function addChild($id) {
430 $this->childs
[] = new thread();
433 function parseThread($thread_list, $i=0, $thread_cnt=0) {
436 for ($cnt = strlen($thread_list);$i<$cnt;++
$i) {
437 $char = $thread_list{$i};
445 $par->id
= $thread_id;
447 $res_a = $this->parseThread($thread,$i, $thread_cnt);
448 $par->childs
[] = $res_a[0];
454 $par->id
= $thread_id;
457 $par->thread_cnt
=$thread_cnt;
458 if (count($this->childs
)) {
459 return array($par, $i);
461 $this->childs
[] = $par;
472 function elapsedTime($start) {
473 $stop = gettimeofday();
474 $timepassed = 1000000 * ($stop['sec'] - $start['sec']) +
$stop['usec'] - $start['usec'];
478 function sqimap_get_small_header_list ($imap_stream, $msg_list) {
479 global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type;
482 /* Get the small headers for each message in $msg_list */
483 $sid = sqimap_session_id($uid_support);
485 $maxmsg = sizeof($msg_list);
486 $msgs_str = sqimap_message_list_squisher($msg_list);
488 $read_list = array();
490 * We need to return the data in the same order as the caller supplied
491 * in $msg_list, but IMAP servers are free to return responses in
492 * whatever order they wish... So we need to re-sort manually
494 for ($i = 0; $i < sizeof($msg_list); $i++
) {
495 $id2index[$msg_list[$i]] = $i;
498 $internaldate = getPref($data_dir, $username, 'internal_date_sort');
500 $query = "$sid FETCH $msgs_str (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
502 $query = "$sid FETCH $msgs_str (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
504 fputs ($imap_stream, $query);
505 $readin_list = sqimap_read_data_list($imap_stream, $sid, false, $response, $message);
507 foreach ($readin_list as $r) {
509 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH/iAU",$r[0], $regs)) {
510 set_up_language($squirrelmail_language);
511 echo '<br><b><font color=$color[2]>' .
512 _("ERROR : Could not complete request.") .
514 _("Unknown response from IMAP server: ") . ' 1.' .
515 $r[0] . "</font><br>\n";
516 } else if (! isset($id2index[$regs[1]]) ||
!count($id2index[$regs[1]])) {
517 set_up_language($squirrelmail_language);
518 echo '<br><b><font color=$color[2]>' .
519 _("ERROR : Could not complete request.") .
521 _("Unknown message number in reply from server: ") .
522 $regs[1] . "</font><br>\n";
524 $read_list[$id2index[$regs[1]]] = $r;
527 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH.*UID\s+([0-9]+)\s+/iAU",$r[0], $regs)) {
528 set_up_language($squirrelmail_language);
529 echo '<br><b><font color=$color[2]>' .
530 _("ERROR : Could not complete request.") .
532 _("Unknown response from IMAP server: ") . ' 1.' .
533 $r[0] . "</font><br>\n";
534 } else if (! isset($id2index[$regs[2]]) ||
!count($id2index[$regs[2]])) {
535 set_up_language($squirrelmail_language);
536 echo '<br><b><font color=$color[2]>' .
537 _("ERROR : Could not complete request.") .
539 _("Unknown message number in reply from server: ") .
540 $regs[2] . "</font><br>\n";
542 $read_list[$id2index[$regs[2]]] = $r;
543 $unique_id = $regs[2];
552 "/^X-Priority:(.*)\$/AUi",
555 "/^Subject:(.*)\$/AUi",
556 "/^Content-Type:(.*)\$/AUi"
560 for ($msgi = 0; $msgi < $maxmsg; $msgi++
) {
561 $subject = _("(no subject)");
562 $from = _("Unknown Sender");
572 $flag_answered = false;
573 $flag_deleted = false;
574 $flag_flagged = false;
575 $read = $read_list[$msgi];
578 foreach ($read as $read_part) {
579 //unfold multi-line headers
580 if ($prevline && strpos($read_part, "\t ") === true) {
581 $read_part = substr($prevline, 0, -2) . preg_replace('/(\t\s+)/',' ',$read_part);
583 $prevline = $read_part;
584 if ($read_part{0} == '*') {
586 if (preg_match ("/^.+INTERNALDATE\s+\"(.+)\".+/iUA",$read_part, $reg)) {
587 $tmpdate = trim($reg[1]);
588 $tmpdate = str_replace(' ',' ',$tmpdate);
589 $tmpdate = explode(' ',$tmpdate);
590 $date = str_replace('-',' ',$tmpdate[0]) . " " .
595 if (preg_match ("/^.+RFC822.SIZE\s+(\d+).+/iA",$read_part, $reg)) {
598 if (preg_match("/^.+FLAGS\s+\((.*)\).+/iUA", $read_part, $regs)) {
599 $flags = explode(' ',trim($regs[1]));
600 foreach ($flags as $flag) {
601 $flag = strtolower($flag);
602 if ($flag == '\\seen') {
604 } else if ($flag == '\\answered') {
605 $flag_answered = true;
606 } else if ($flag == '\\deleted') {
607 $flag_deleted = true;
608 } else if ($flag == '\\flagged') {
609 $flag_flagged = true;
613 if (preg_match ("/^.+UID\s+(\d+).+/iA",$read_part, $reg)) {
614 $unique_id = $reg[1];
617 $firstchar = $read_part{0};
618 if ($firstchar == 'T') {
619 $regpattern = $patterns[0];
621 } else if ($firstchar == 'F') {
622 $regpattern = $patterns[1];
624 } else if ($firstchar == 'X') {
625 $regpattern = $patterns[2];
627 } else if ($firstchar == 'C') {
628 if (strtolower($read_part{1}) == 'c') {
629 $regpattern = $patterns[3];
631 } else if (strtolower($read_part{1}) == 'o') {
632 $regpattern = $patterns[6];
635 } else if ($firstchar == 'D' && !$internaldate ) {
636 $regpattern = $patterns[4];
638 } else if ($firstchar == 'S') {
639 $regpattern = $patterns[5];
641 } else $regpattern = '';
644 if (preg_match ($regpattern, $read_part, $regs)) {
653 $priority = $regs[1];
662 $subject = htmlspecialchars(trim($regs[1]));
663 if ($subject == "") {
664 $subject = _("(no subject)");
668 $type = strtolower(trim($regs[1]));
669 if ($pos = strpos($type, ";")) {
670 $type = substr($type, 0, $pos);
672 $type = explode("/", $type);
673 if (!isset($type[1])) {
686 $header = new small_header
;
689 $header->uid
= $unique_id;
691 $header->uid
= $msg_list[$msgi];
693 $header->date
= $date;
694 $header->subject
= $subject;
696 $header->from
= $from;
697 $header->priority
= $priority;
698 $header->message_id
= $messageid;
700 $header->size
= $size;
701 $header->type0
= $type[0];
702 $header->type1
= $type[1];
703 $header->flag_seen
= $flag_seen;
704 $header->flag_answered
= $flag_answered;
705 $header->flag_deleted
= $flag_deleted;
706 $header->flag_flagged
= $flag_flagged;
707 $header->inrepto
= $inrepto;
713 function sqimap_get_headerfield($imap_stream, $field) {
714 $sid = sqimap_session_id(false);
717 $read_list = array();
719 $query = "$sid FETCH 1:* (UID BODY.PEEK[HEADER.FIELDS ($field)])\r\n";
720 fputs ($imap_stream, $query);
721 $readin_list = sqimap_read_data_list($imap_stream, $sid, false, $response, $message);
724 foreach ($readin_list as $r) {
726 /* first we unfold the header */
727 $r = str_replace(array("\r\n\t","\r\n\s"),array('',''),$r);
729 * now we can make a new header array with each element representing
732 $r = explode("\r\n" , $r);
734 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH/iAU",$r[0], $regs)) {
735 set_up_language($squirrelmail_language);
736 echo '<br><b><font color=$color[2]>' .
737 _("ERROR : Could not complete request.") .
739 _("Unknown response from IMAP server: ") . ' 1.' .
740 $r[0] . "</font><br>\n";
745 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH.*UID\s+([0-9]+)\s+/iAU",$r[0], $regs)) {
746 set_up_language($squirrelmail_language);
747 echo '<br><b><font color=$color[2]>' .
748 _("ERROR : Could not complete request.") .
750 _("Unknown response from IMAP server: ") . ' 1.' .
751 $r[0] . "</font><br>\n";
757 $field = substr($field,strlen($field)+
2);
758 $result[] = array($id,$field);
768 * Returns a message array with all the information about a message.
769 * See the documentation folder for more information about this array.
771 function sqimap_get_message ($imap_stream, $id, $mailbox) {
775 $read = sqimap_run_command ($imap_stream, "FETCH $id (FLAGS BODYSTRUCTURE)", true, $response, $message, $uid_support);
777 if (preg_match('/.+FLAGS\s\((.*)\)\s/AUi',$read[0],$regs)) {
778 if (trim($regs[1])) {
779 $flags = preg_split('/ /', $regs[1],-1,'PREG_SPLIT_NI_EMPTY');
783 echo "ERROR Yeah I know, not a very usefull errormessage (id = $id, mailbox = $mailbox sqimap_get_message)";
786 $bodystructure = implode('',$read);
787 $msg = mime_structure($bodystructure,$flags);
788 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, $uid_support);
789 $rfc822_header = new Rfc822Header();
790 $rfc822_header->parseHeader($read);
791 $msg->rfc822_header
= $rfc822_header;
795 /* Wrapper function that reformats the header information. */
796 function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
798 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, $uid_support);
799 $header = sqimap_get_header($imap_stream, $read);
801 $header->mailbox
= $mailbox;
805 /* Wrapper function that reformats the entity header information. */
806 function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
808 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[$ent.HEADER]", true, $response, $message, $uid_support);
809 $header = sqimap_get_header($imap_stream, $read);
811 $header->mailbox
= $mailbox;
816 /* Wrapper function that returns entity headers for use by decodeMime */
818 function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
819 $header = sqimap_get_header($imap_stream, $read);
820 $type0 = $header["TYPE0"];
821 $type1 = $header["TYPE1"];
822 $bound = $header["BOUNDARY"];
823 $encoding = $header["ENCODING"];
824 $charset = $header["CHARSET"];
825 $filename = $header["FILENAME"];
828 /* function to get the mime headers */
829 function sqimap_get_mime_ent_header ($imap_stream, $id, $mailbox, $ent) {
831 $read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.MIME]", true, $response, $message, $uid_support);
832 $header = sqimap_get_header($imap_stream, $read);
834 $header->mailbox
= $mailbox;
838 /* Returns the body of a message. */
839 function sqimap_get_message_body ($imap_stream, &$header) {
840 // return decodeMime($imap_stream, $header->id);