switch ($ci_content_type) { case 'Post': case 'Thread': $ci_content = fetch_postinfo($ci_urls_data[$key]['contentid']); $ci_manager =& datamanager_init($ci_content_type, $vbulletin, ERRTYPE_STANDARD, 'threadpost'); $ci_manager->set_existing($ci_content); $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size'])); $ci_manager->save(); break; case 'SocialGroupMessage': case 'SocialGroupDiscussion': $ci_content = fetch_groupmessageinfo($ci_urls_data[$key]['contentid']); $ci_manager =& datamanager_init('GroupMessage', $vbulletin); $ci_manager->set_existing($ci_content); $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size'])); $ci_manager->save(); break; case 'BlogEntry': case 'BlogComment': $ci_content = fetch_blog_textinfo($ci_urls_data[$key]['contentid']); $ci_manager =& datamanager_init('BlogText', $vbulletin, ERRTYPE_STANDARD, 'blog'); $ci_manager->set_existing($ci_content); $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size'])); $ci_manager->save(); break; } } $vbulletin->db->query_write("\n UPDATE " . TABLE_PREFIX . "rcd_imagequeue\n SET attempts = {$ci_url_check_attempts},\n nextcheck = {$ci_next_check},\n status = '{$ci_url_queue_status}'\n WHERE imagequeueid = {$key}\n "); } } log_cron_action('', $nextitem, 1);
/** * Find all IMG tags in message and check size. If size exceed the limit or this is not a image replace them to URL tag. * If URL is inaccessible it appended to $ci_image_queue global array ('key' => 'url') because we cannot save it now - lack of contentid. * * @param string &$message Message where need to check & replace. * @return array $ci_postponed_urls URLs which need to check later. */ function ci_fix_images_in_msg(&$message) { $ci_postponed_urls = array(); // If message contains IMG tags if (preg_match_all('#\\[img\\]\\s*(https?://([^*\\r\\n]+|[a-z0-9/\\._\\- !]+))\\[/img\\]#iUe', $message, $ci_img_tags)) { // Filter ut ll data-uris foreach ($ci_img_tags[1] as $idx => $url) { if (preg_match('/;base64,[A-Za-z0-9+/]{2}[A-Za-z0-9+/=]{2,}$/', $url)) { // got data uri - remove whole string $message = str_ireplace($ci_img_tags[0][$idx], '', $message); // and remove it from matching groups foreach ($ci_img_tags as $i => $arr) { unset($ci_img_tags[$i][$idx]); } } } // Get status of each url $ci_urls_status = ci_check_urls($ci_img_tags[1]); foreach ($ci_urls_status as $key => $url_data) { switch ($url_data['status']) { case 'REPLACE': $message = ci_replace_img_tag($message, $ci_img_tags[1][$key], $url_data['size']); break; case 'PROCESSING': // Now we cannot save URL because lack of contentid, // it will be inserted in table via _postsave hook $ci_postponed_urls[] = $ci_img_tags[1][$key]; break; } } } return $ci_postponed_urls; }