-
-}
-
-// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
-// is identical to the code in include/conversation.php
-if (! function_exists('item_extract_images')) {
-function item_extract_images($body) {
-
- $saved_image = array();
- $orig_body = $body;
- $new_body = '';
-
- $cnt = 0;
- $img_start = strpos($orig_body, '[img');
- $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while(($img_st_close !== false) && ($img_end !== false)) {
-
- $img_st_close++; // make it point to AFTER the closing bracket
- $img_end += $img_start;
-
- if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
- // This is an embedded image
-
- $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
- $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
-
- $cnt++;
- } else
- $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
-
- $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
-
- if ($orig_body === false) // in case the body ends on a closing image tag
- $orig_body = '';
-
- $img_start = strpos($orig_body, '[img');
- $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);