- if (strpos($ent_id, '0') || strpos($ent_id, '0') == 0) {
- $str = substr($structure, $end+1 );
- $startprop = strrpos($str,'(');
- $endprop = strrpos($str,')');
- $propstr = substr($str, $startprop + 1, ($endprop - $startprop)-1);
-
- $type1 = trim(substr($str,0, $startprop));
- $pos = strrpos($type1,' ');
- $type1 = strtolower(trim(substr($type1,$pos +1)));
- $cnt = strlen($type1);
- $type1 = substr($type1,0,$cnt-1);
-
- $properties = mime_get_props($properties, $propstr);
+ if ($ent == '0') {
+ /* new entity levels have information about the type (type1) and
+ * the properties. This information is situated at the end of the
+ * structure string like for example (example between the brackets)
+ * [ "RELATED" ("BOUNDARY" "myboundary" "TYPE" "plain/html") ]
+ */
+
+ /* get the involved properties for parsing to mime_get_properties */
+ $startprop = strrpos($structure,'(');
+ $properties_str = substr($structure,$startprop);
+ $endprop = mime_match_parenthesis ($startprop, $structure);
+ $propstr = substr($structure, $startprop + 1, ($endprop - $startprop)-1);
+ /* cut off the used properties */
+ if ($startprop) {
+ $structure_end = substr($structure, $endprop+2);
+ $structure = trim(substr($structure,0,$startprop));
+ }
+
+ /* get type1 */
+ $pos = strrpos($structure,' ');
+ $type1 = strtolower(substr($structure, $pos+2, (count($structure)-2)));
+
+ /* cut off type1 */
+ if ($pos && $startprop) {
+ $structure = trim(substr($structure, 0, $pos));
+ }
+
+ /* process the found information */
+ $properties = mime_get_props($properties, $properties_str);