Location: PHPKode > projects > MobiLog! Mobile Weblogging Tool > mobilog-mobile-weblogging-tool/index.php
<?php

## 
## MobiLog! Moblog Management Tool v1.0.1
## 
## Project Web Site: http://www.accliptic.com/products/opensource/ml/
##
## For software usage and distribution terms, please see the 'LICENSE'
## document that came with it.
##

##################################################################
# Code 
##################################################################

	IncludeItem('configuration/main.inc.php');
	IncludeItem('themes/' . $GLOBALS['conf']['theme'] . '/theme.inc');

	$content = NULL;

	$db = DBConnect($GLOBALS['conf']['db_hostname'], $GLOBALS['conf']['db_username'], $GLOBALS['conf']['db_password'], $GLOBALS['conf']['db_database']);

	$entry_count	= GetEntryCount($db);
	$nav_array		= GenerateArchiveNavArray($db, $entry_count);

	$m	= $_REQUEST['m'];

	if ($m == NULL) {
		$m = 5;
	}

	if ($m == 'map') {
		# Entry map...
		$content = DisplayMap($db);
	} elseif ($m == 'prev') {
		# Go to previous individual entry viewer...
		SwitchToEntryViewer($db, 'prev');
	} elseif ($m == 'next') {
		# Go to next individual entry viewer...
		SwitchToEntryViewer($db, 'next');
	} elseif ($m == 'prevmonth') {
		# Go to previous month viewer...
		SwitchToMonthViewer($db, 'prev');
	} elseif ($m == 'nextmonth') {
		# Go to next month viewer...
		SwitchToMonthViewer($db, 'next');

	} elseif ($m == 'edit') {
		$html_editor		= DisplayEntryEditor($db);

		array_push($nav_array, array('',''));
		array_push($nav_array, array('edit','Edit...'));

		$content = $html_editor;
	} elseif ($m == 'admin') {
		$html_admin_menu	= DisplayAdminMenu($db);

		array_push($nav_array, array('',''));
		array_push($nav_array, array('admin','Admin...'));

		$content = $html_admin_menu;
	} elseif ($m == 'submitentry') {
		SubmitEntry($db);
	} else {
		# Display entry/entries by criteria...
		list ($content, $nav_addon_array) = DisplayEntryOrEntriesByCriteria($db, $m);
		foreach ($nav_addon_array as $nav_addon_array_item) {
			array_push($nav_array, $nav_addon_array_item);
		}
	}

	header("Content-type: text/html; charset=utf-8");

	$mobilog_sw_name	= 'MobiLog! v1.0.1';

	$nav_select			= CreateSelect($nav_array,'m',$m,'5');

	$main		= $GLOBALS['tmpl']['primary']['main'];
	$html_nav	= $GLOBALS['tmpl']['primary']['navigation'];
	$html_nav	= str_replace('__NAV_SELECT__',$nav_select,$html_nav);

	$main	= str_replace('__MOBILOG_GENERATOR__',$mobilog_sw_name,$main);
	$main	= str_replace('__MOBILOG_TITLE__',$GLOBALS['conf']['moblog_title'],$main);
	$main	= str_replace('__POWERED_BY__',"Powered by <a href='http://www.accliptic.com/products/opensource/ml/'>$mobilog_sw_name</a>",$main);
	$main	= str_replace('__MOBILOG_NAV__',$html_nav,$main);

	$main	= str_replace('__MOBILOG_CONTENT__',$content,$main);

	print $main;

	###############################################################################################
	# FUNCTIONS...                                                                                #
	###############################################################################################

	function DisplayEntryOrEntriesByCriteria($db, $m) {
		$nav_addon_array = array();

		$type			= NULL;
		$entries		= NULL;
		$limitclause	= NULL;
		$whereclause	= NULL;
		if (preg_match("/^[0-9]{1,2}$/", $m) > 0) {
			# A given number of entries: e1, e2, e3, etc ...
			$type			= 'number';
			$limitclause	= 'LIMIT ' . $m;
		} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $m) > 0) {
			# A date fragment: 2005-09 (for September), 2006-01 (for January), etc ...
			$type			= 'date';
			$whereclause	= 'WHERE DATE_ADD(entry_datetime, INTERVAL ' . $GLOBALS['conf']['time_zone_offset'] .' HOUR) LIKE "' . $m . '%"';
		} elseif (preg_match("/^e[0-9]*$/", $m) > 0) {
			# A specific entry (by ID)...
			array_push($nav_addon_array, array('',''));
			array_push($nav_addon_array, array($m,'Viewing entry...'));

			$type			= 'entryid';
			$whereclause	= 'WHERE entry_id = "' . str_replace('e','',$m) . '"';
		} else {
			exit;
		}

		$result = mysql_query("SELECT entry_id, DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%m.%d.%y - %I:%i %p'), entry_subject, entry_text, entry_attachment_mimetype, entry_attachment FROM mobilog_entries $whereclause ORDER BY entry_id DESC $limitclause", $db);
		while ($row = @mysql_fetch_row($result)) {
			$entry_id					= $row[0];
			$entry_datetime				= $row[1];
			$entry_subject				= PrepTextForDisplay($row[2]);
			$entry_text					= PrepTextForDisplay($row[3]);
			$entry_attachment_mimetype	= $row[4];
			$entry_attachment			= $row[5];

			$entry_text					= str_replace("\n",'<br />',$entry_text);

			if (strlen($entry_attachment) == 0) {
				$entry = $GLOBALS['tmpl']['primary']['text'];
			} else {
				$entry = $GLOBALS['tmpl']['primary']['image'];
			}

			if ($entry_attachment_mimetype == 'image/gif') {
				$entry_attachment_extension = '.gif';
			} elseif ($entry_attachment_mimetype == 'image/jpeg') {
				$entry_attachment_extension = '.jpg';
			} elseif ($entry_attachment_mimetype == 'image/png') {
				$entry_attachment_extension = '.png';
			}

			$entry_attachment_url 	= $GLOBALS['conf']['base_url'] . 'files/attachments/' . $entry_id . $entry_attachment_extension;

			$entry = str_replace('__ENTRY_SUBJECT__',$entry_subject,$entry);
			$entry = str_replace('__ENTRY_DATETIME__',$entry_datetime,$entry);
			$entry = str_replace('__ENTRY_TEXT__',$entry_text,$entry);
			$entry = str_replace('__ENTRY_ID__',$entry_id,$entry);
			$entry = str_replace('__ENTRY_ATTACHMENT_URL__',$entry_attachment_url,$entry);

			$entries = $entries . $entry;
		}

		if ($type == 'number') {
			$content = $entries;
		} elseif ($type == 'date') {
			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%M %Y') FROM mobilog_entries WHERE entry_id = '$entry_id' LIMIT 1", $db);
			$row = @mysql_fetch_row($result);
			$current_month			= $row[0];

			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') FROM mobilog_entries WHERE entry_id < '$entry_id' AND DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') != '$m' LIMIT 1", $db);
			$row = @mysql_fetch_row($result);
			$entry_datetime_prev	= $row[0];

			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') FROM mobilog_entries WHERE entry_id > '$entry_id' AND DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') != '$m' LIMIT 1", $db);
			$row = @mysql_fetch_row($result);
			$entry_datetime_next	= $row[0];

			$html_month	= $GLOBALS['tmpl']['primary']['month'];

			if ($entry_datetime_prev != NULL) {
				$html_month	= str_replace('__GO_TO_PREV__',"<a href='index.php?m=prevmonth&amp;current=$m'><span title='$entry_datetime_prev'>Prev. Month</span></a>",$html_month);
			} else {
				$html_month	= str_replace('__GO_TO_PREV__',"Prev. Month",$html_month);
			}

			if ($entry_datetime_next != NULL) {
				$html_month	= str_replace('__GO_TO_NEXT__',"<a href='index.php?m=nextmonth&amp;current=$m'><span title='$entry_datetime_next'>Next Month</span></a>",$html_month);
			} else {
				$html_month	= str_replace('__GO_TO_NEXT__',"Next Month",$html_month);
			}

			$html_month	= str_replace('__ENTRY_MONTH__',$current_month,$html_month);
			$html_month	= str_replace('__ENTRY_CONTENT__',$entries,$html_month);

			$content = $html_month;
		} else {
			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%m.%d.%y - %I:%i %p') FROM mobilog_entries WHERE entry_id < '$entry_id' LIMIT 1", $db);
			$row = @mysql_fetch_row($result);
			$entry_datetime_prev	= $row[0];

			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%m.%d.%y - %I:%i %p') FROM mobilog_entries WHERE entry_id > '$entry_id' LIMIT 1", $db);
			$row = @mysql_fetch_row($result);
			$entry_datetime_next	= $row[0];

			$html_individual_entry	= $GLOBALS['tmpl']['primary']['individual_entry'];

			if ($entry_datetime_prev != NULL) {
				$html_individual_entry	= str_replace('__GO_TO_PREV__',"<a href='index.php?m=prev&amp;current=$entry_id'><span title='$entry_datetime_prev'>Prev. Entry</span></a>",$html_individual_entry);
			} else {
				$html_individual_entry	= str_replace('__GO_TO_PREV__',"Prev. Entry",$html_individual_entry);
			}

			if ($entry_datetime_next != NULL) {
				$html_individual_entry	= str_replace('__GO_TO_NEXT__',"<a href='index.php?m=next&amp;current=$entry_id'><span title='$entry_datetime_next'>Next Entry</span></a>",$html_individual_entry);
			} else {
				$html_individual_entry	= str_replace('__GO_TO_NEXT__',"Next Entry",$html_individual_entry);
			}

			$html_individual_entry	= str_replace('__ENTRY_CONTENT__',$entries,$html_individual_entry);

			$content = $html_individual_entry;
		}

		return array ($content, $nav_addon_array);
	}

	function SwitchToEntryViewer($db, $direction) {
		$current	= $_GET['current'];

		if ($direction == 'next') {
			$result = mysql_query("SELECT entry_id FROM mobilog_entries WHERE entry_id > '$current' ORDER BY entry_id ASC LIMIT 1", $db);
		} elseif ($direction == 'prev') {
			$result = mysql_query("SELECT entry_id FROM mobilog_entries WHERE entry_id < '$current' ORDER BY entry_id DESC LIMIT 1", $db);
		} else {
			exit;
		}
		$row = @mysql_fetch_row($result);
		header('Location: ' . $_SERVER['PHP_SELF'] . '?m=e' . $row[0]);
		exit;
	}

	function SwitchToMonthViewer($db, $direction) {
		$current	= $_GET['current'];

		if ($direction == 'next') {
			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') FROM mobilog_entries WHERE DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') > '$current' ORDER BY entry_datetime ASC LIMIT 1", $db);
		} elseif ($direction == 'prev') {
			$result = mysql_query("SELECT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') FROM mobilog_entries WHERE DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m') < '$current' ORDER BY entry_datetime DESC LIMIT 1", $db);
		} else {
			exit;
		}
		$row = @mysql_fetch_row($result);
		header('Location: ' . $_SERVER['PHP_SELF'] . '?m=' . $row[0]);
		exit;
	}

	function GetEntryCount($db) {
		$result = mysql_query("SELECT count(*) FROM mobilog_entries", $db);
		$row = @mysql_fetch_row($result);
		$entry_count	= $row[0];

		return $entry_count;
	}

	function DisplayMap($db) {
		$result = mysql_query("SELECT entry_id, DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%m.%d.%y - %I:%i %p'), entry_subject, entry_attachment FROM mobilog_entries ORDER BY entry_datetime DESC", $db);
		while ($row = @mysql_fetch_row($result)) {
			$entry_id					= $row[0];
			$entry_datetime				= $row[1];
			$entry_subject				= PrepTextForDisplay($row[2]);
			$entry_attachment			= $row[3];

			$entry = $GLOBALS['tmpl']['primary']['map']['item'];

			if (trim($entry_subject) == NULL) {
				$entry_subject = '<i>(no title)</i>';
			}

			if (strlen($entry_attachment) == 0) {
				$entry_has_attachment = 'No';
			} else {
				$entry_has_attachment = 'Yes';
			}

			$entry = str_replace('__ENTRY_SUBJECT__',$entry_subject,$entry);
			$entry = str_replace('__ENTRY_DATETIME__',$entry_datetime,$entry);
			$entry = str_replace('__ENTRY_ID__',$entry_id,$entry);
			$entry = str_replace('__ENTRY_HAS_ATTACHMENT__',$entry_has_attachment,$entry);

			$entries = $entries . $entry;
		}

		$html_entry_map		= $GLOBALS['tmpl']['primary']['map']['listing'];
		$html_entry_map		= str_replace('__ENTRY_MAP_ITEMS__',$entries,$html_entry_map);

		$content = $html_entry_map;

		return $content;
	}

	function PrepTextForDBInsert($string) {
		if (get_magic_quotes_gpc() == 1) {
			return ($string);
		} else {
			return (addslashes($string));
		}
	}

	function SubmitEntry($db) {
		$delete						= PrepTextForDBInsert($_POST['delete']);

		$entry_id					= PrepTextForDBInsert($_POST['entry_id']);
		$entry_subject				= PrepTextForDBInsert($_POST['entry_subject']);
		$entry_text					= PrepTextForDBInsert($_POST['entry_text']);
		$entry_submission_password	= $_POST['entry_submission_password'];

		if ($entry_submission_password == $GLOBALS['conf']['moblog_password']) {
			# Entry submission password is correct...

			if(isset($_FILES['entry_attachment']) && $_FILES['entry_attachment']['size'] > 0) {
				# File exists and is larger than 0 bytes...

				$entry_attachment_tmp_name 	= $_FILES['entry_attachment']['tmp_name'];
				$entry_attachment_size		= $_FILES['entry_attachment']['size'];
				$entry_attachment_mimetype	= $_FILES['entry_attachment']['type'];

				$entry_attachment_fp		= fopen($entry_attachment_tmp_name, 'r');
				$entry_attachment_data		= fread($entry_attachment_fp, filesize($entry_attachment_tmp_name));
				$entry_attachment_data		= addslashes($entry_attachment_data);
				fclose($entry_attachment_fp);
			} else {
				$entry_attachment_mimetype	= NULL;
				$entry_attachment_data		= NULL;
			}

			if ($delete != NULL) {
				mysql_query("DELETE FROM mobilog_entries WHERE entry_id='$entry_id' LIMIT 1", $db);

				header('Location: ' . $_SERVER['PHP_SELF'] . '?m=map');
				exit;
			} else {
				if ($entry_id != NULL) {
					if ($entry_attachment_data != NULL && $entry_attachment_mimetype != NULL) {
						# Valid attachment was provided - update it...
						mysql_query("UPDATE mobilog_entries SET entry_subject='$entry_subject', entry_is_new='1', entry_text='$entry_text', entry_attachment_mimetype='$entry_attachment_mimetype', entry_attachment='$entry_attachment_data' WHERE entry_id='$entry_id' LIMIT 1", $db);
					} else {
						# No valid attachment was provided - don't update it...
						mysql_query("UPDATE mobilog_entries SET entry_subject='$entry_subject', entry_is_new='1', entry_text='$entry_text' WHERE entry_id='$entry_id' LIMIT 1", $db);
					}
				} else {
					if ($entry_attachment_data != NULL && $entry_attachment_mimetype != NULL) {
						# Valid attachment was provided - save it...
						mysql_query("INSERT INTO mobilog_entries VALUES (NULL, 1, UTC_TIMESTAMP(), '$entry_subject', '$entry_text', NULL, '$entry_attachment_mimetype', '$entry_attachment_data')", $db);
					} else {
						# No valid attachment was provided - don't save it...
						mysql_query("INSERT INTO mobilog_entries VALUES (NULL, 1, UTC_TIMESTAMP(), '$entry_subject', '$entry_text', NULL, NULL, NULL)", $db);
					}

					$result		= mysql_query("SELECT LAST_INSERT_ID()", $db);
					$row		= mysql_fetch_row($result);
					$entry_id	= $row[0];
				}
			}

			header('Location: ' . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/mobilog.pl');
		} else {
			# Incorrect entry submission password!
			header('Location: ' . $_SERVER['PHP_SELF']);
		}

		exit;
	}

	function DisplayEntryEditor($db) {
		$content	= $GLOBALS['tmpl']['primary']['admin']['editor'];

		$entry_id	= $_GET['entry_id'];

		$result	= mysql_query("SELECT entry_subject, entry_text, entry_attachment_mimetype, ROUND((BIT_LENGTH(entry_attachment) / 8 / 1024), 2) FROM mobilog_entries WHERE entry_id='$entry_id' LIMIT 1", $db);
		$row	= mysql_fetch_row($result);

		$entry_subject				= PrepTextForDisplay($row[0]);
		$entry_text					= PrepTextForDisplay($row[1]);
		$entry_attachment_mimetype	= PrepTextForDisplay($row[2]);
		$entry_attachment_size		= $row[3];

		if ($entry_attachment_mimetype != NULL) {
			$entry_attachment_size = $entry_attachment_size . 'k';

			$entry_attachment_info = '<i>' . $entry_attachment_mimetype . " ($entry_attachment_size)</i>";
		} else {
			$entry_attachment_info = '<i>none</i>';
		}

		$content = str_replace('__ENTRY_ID__',$entry_id,$content);
		$content = str_replace('__ENTRY_SUBJECT__',$entry_subject,$content);
		$content = str_replace('__ENTRY_TEXT__',$entry_text,$content);
		$content = str_replace('__ENTRY_ATTACHMENT_INFO__',$entry_attachment_info,$content);

		return ($content);
	}

	function DisplayEntryComposer($db) {
		$content	= $GLOBALS['tmpl']['primary']['admin']['composer'];

		return ($content);
	}

	function DisplayAdminMenu($db) {
		$content		= $GLOBALS['tmpl']['primary']['admin']['menu'];

		$entry_array		= GenerateAllEntriesArray($db);
		$entry_edit_select	= CreateSelect($entry_array,'entry_id',NULL,NULL);

		$content = str_replace('__ENTRY_EDIT_SELECT__',$entry_edit_select,$content);

		return ($content);
	}

	function GenerateArchiveNavArray($db, $entry_count) {
		$nav_array = array();

		if ($entry_count == 0) {
			# No entries!
			array_push($nav_array, array('','No entries yet!'));
		} elseif ($entry_count == 1) {
			# A single entry - how lonely!
			array_push($nav_array, array('','Last entry'));
		} elseif ($entry_count > 1 && $entry_count < 5) {
			# 2, 3, or 4 entries...
			array_push($nav_array, array($entry_count,'Last ' . $entry_count . ' entries'));
		} else {
			# 5 or more entries...
			if ($entry_count >= 5 && $entry_count < 10) {
				array_push($nav_array, array('5','Last 5 entries'));
			}
			if ($entry_count >= 10 && $entry_count < 15) {
				array_push($nav_array, array('10','Last 10 entries'));
			}
			if ($entry_count >= 15 && $entry_count < 20) {
				array_push($nav_array, array('15','Last 15 entries'));
			}
			if ($entry_count >= 20 && $entry_count < 25) {
				array_push($nav_array, array('20','Last 20 entries'));
			}
			if ($entry_count >= 25) {
				array_push($nav_array, array('25','Last 25 entries'));
			}
		}

		array_push($nav_array, array('',''));
		array_push($nav_array, array('map','Entry map'));
		array_push($nav_array, array('',''));

		$result = mysql_query("SELECT DISTINCT DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y-%m'), DATE_FORMAT(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR),'%Y - %M') FROM mobilog_entries ORDER BY entry_datetime DESC", $db);
		while ($row = @mysql_fetch_row($result)) {
			array_push($nav_array, array($row[0],$row[1]));
		}

		return ($nav_array);
	}

	function GenerateAllEntriesArray($db) {
		$entry_array = array();

		$result = mysql_query("SELECT entry_id, DATE(DATE_ADD(entry_datetime, INTERVAL " . $GLOBALS['conf']['time_zone_offset'] ." HOUR)), entry_subject FROM mobilog_entries ORDER BY entry_id DESC", $db);
		while ($row = @mysql_fetch_row($result)) {
			$entry_subject = PrepTextForDisplay($row[2]);
			if ($entry_subject == NULL) {
				$entry_subject = '(no title)';
			}
			array_push($entry_array, array($row[0],$row[1] . ' - ' . $entry_subject));
		}

		return ($entry_array);
	}

	function DBConnect($db_hostname, $db_username, $db_password, $db_database) {
		$db = @mysql_connect($db_hostname, $db_username, $db_password);

		if (!$db) {
			print "Could not connect to database! Please check configuration settings (hostname, username, password, etc).<br /><br />";
			exit;
		}

		if (!@mysql_select_db($db_database)) {
			print "Could not select database! Please check configuration settings (hostname, username, password, etc).<br /><br />";
			exit;
		}
		print mysql_error();

		return ($db);
	}

	function CreateSelect($selectoptions,$selectname,$selectedoption,$defaultoption) {
		$selectmenu = NULL;

		foreach($selectoptions as $selectoption) {
			if (is_array($selectedoption)) {
				if (in_array($selectoption[0], $selectedoption)) {
					$optionselected = 'selected=\'selected\'';
				} else {
					$optionselected = NULL;
				}
			} else {
				if ($selectoption[0] == $selectedoption && $selectedoption != NULL) {
					$optionselected = 'selected=\'selected\'';
				} else {
					$optionselected = NULL;
				}
			}

			$selectmenu = $selectmenu . "<option value='$selectoption[0]' $optionselected>$selectoption[1]</option>";
		}

		$selectmenu = "<select class='archive-nav-selectmenu' name='$selectname'>" . $selectmenu . '</select>';

		return ($selectmenu);
	}

	function IncludeItem($file_name) {
		# Read in file...
		$file_handle 	= fopen($file_name, 'rb');
		$file_contents 	= fread($file_handle, filesize($file_name));
		fclose($file_handle);

		# Remove PHP exit header, if any...
		$file_contents = str_replace('<?php exit; ?>',"",$file_contents);

		# Parse 'content' item...
		$file_contents = str_replace('<[/]>',"\nEOD;\n\n",$file_contents);
		$file_contents = preg_replace("/[\s]*<\[\[([0-9A-Za-z:\-_\]\[']*)\]\]>/", "\n\$GLOBALS[$1] = <<<EOD\n\n", $file_contents);

		# Parse 'preference' item...
		$file_contents = preg_replace("/<\[\[([0-9A-Za-z:\-_\]\[']*)\]:[\s]*(.*?)[\s]*\n/", "\n\$GLOBALS[$1] = \"$2\";\n\n", $file_contents);

		eval($file_contents);
	}

	function PrepTextForDisplay($text) { /* SF */
		$text	= htmlentities($text, ENT_QUOTES);
		$text	= str_replace('<',"&lt;",$text);
		$text	= str_replace('>',"&gt;",$text);

		return ($text);
	} /* EF */

?>
Return current item: MobiLog! Mobile Weblogging Tool