+ function parseStructure($read, &$i, $sub_msg = '') {
+ $msg = Message::parseBodyStructure($read, $i, $sub_msg);
+ if($msg) $msg->setEntIds($msg,false,0);
+ return $msg;
+ }
+
+ function setEntIds(&$msg,$init=false,$i=0) {
+ $iCnt = count($msg->entities);
+ if ($init !==false) {
+ $iEntSub = $i+1;
+ if ($msg->parent->type0 == 'message' &&
+ $msg->parent->type1 == 'rfc822' &&
+ $msg->type0 == 'multipart') {
+ $iEntSub = '0';
+ }
+ if ($init) {
+ $msg->entity_id = "$init.$iEntSub";
+ } else {
+ $msg->entity_id = $iEntSub;
+ }
+ } else if ($iCnt) {
+ $msg->entity_id='0';
+ } else {
+ $msg->entity_id='1';
+ }
+ for ($i=0;$i<$iCnt;++$i) {
+ $msg->entities[$i]->parent =& $msg;
+ if (strrchr($msg->entity_id, '.') != '.0') {
+ $msg->entities[$i]->setEntIds($msg->entities[$i],$msg->entity_id,$i);
+ } else {
+ $msg->entities[$i]->setEntIds($msg->entities[$i],$msg->parent->entity_id,$i);
+ }
+ }
+ }
+
+ function parseBodyStructure($read, &$i, $sub_msg = '') {