<?php	
	$followlog = $db->get('followlog')->result_array();
	
	$blogurl = array();
	
	foreach ($followlog AS $key => $item)
	{
		if (!$blogurl[$item['followid']])
		{
			$follow = $db->query("SELECT blogurl FROM follow WHERE id = " . $item['followid'])->result_array();
			
			$blogurl[$item['followid']] = $follow['blogurl'];
		}
		
		$entryinfo = @json_decode(file_get_contents($blogurl[$item['followid']] . 'httprequest.php?act=follow_entry_check&entryid=' . $item['entryid']), TRUE);
		
		if ($entryinfo['entryid'] == 'deleted')
		{
			$db->query("DELETE FROM followlog WHERE id = " . $item['id']);
		}
		else if ($entryinfo['entryid'] AND $entryinfo['message'] != $item['message'])
		{
			$message = strip_tags(Format::Safe(str_ireplace(array('<br />', '<br/>', '<br>'), "\n", str_replace(array("\r", "\n"), '', $entryinfo['message']))));
			
			$db->update('followlog', array(
				'entryid' => intval($entryinfo['entryid']),
				'message' => $message,
				'from' => strip_tags($entryinfo['from']),
				'time' => intval($entryinfo['time']),
				'picture' => $entryinfo['picture']
			), array('id' => $item['id']));
		}
	}