Location: PHPKode > projects > Wordlog > htdocs/include/functions.html.php
<?
	/***********************************************************************/
	/* http://wordlog.sourceforge.net        hide@address.com */
	/***********************************************************************/

	/* html_header --> prints html up to the beginning of the body */
	function html_header($title) {
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=<? echo HTML_CHARSET ?>">
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<? if (HTML_STYLESHEET) { ?><LINK REL="stylesheet" HREF="<? echo HTML_STYLESHEET ?>"><? } ?>

	<TITLE>
		<? echo $title ?>

	</TITLE>
</HEAD>

<?
	}

	/* html_footer --> returns footer information */
	function html_footer() {
		return format_wrap(HTML_COPYRIGHT,0).format_wrap(FOOTER_POWEREDBY." [LINK=\"http://wordlog.sourceforge.net\"]Wordlog-".REVISION."[/LINK]",0).format_line();
	}

	/* html_body --> returns colors to be put in the body tag */
	function html_body() {
		$TEXT    = HTML_TEXT;
		$BGCOLOR = HTML_BGCOLOR;
		$ALINK   = HTML_ALINK;
		$LINK    = HTML_LINK;
		$VLINK   = HTML_VLINK;

		$sql_result = mysql_query("SELECT * FROM ".SQL_TABLEPREFIX."userprefs WHERE user = '$_SESSION[LOGGED_IN]' AND field = 'BGCOLOR'");
		$sql_entry = mysql_fetch_array($sql_result);
		if ($sql_entry[2]) $BGCOLOR = $sql_entry[2];

		$sql_result = mysql_query("SELECT * FROM ".SQL_TABLEPREFIX."userprefs WHERE user = '$_SESSION[LOGGED_IN]' AND field = 'TEXTCOLOR'");
		$sql_entry = mysql_fetch_array($sql_result);
		if ($sql_entry[2]) $TEXT = $sql_entry[2];

		$sql_result = mysql_query("SELECT * FROM ".SQL_TABLEPREFIX."userprefs WHERE user = '$_SESSION[LOGGED_IN]' AND field = 'ALINK'");
		$sql_entry = mysql_fetch_array($sql_result);
		if ($sql_entry[2]) $ALINK = $sql_entry[2];

		$sql_result = mysql_query("SELECT * FROM ".SQL_TABLEPREFIX."userprefs WHERE user = '$_SESSION[LOGGED_IN]' AND field = 'LINK'");
		$sql_entry = mysql_fetch_array($sql_result);
		if ($sql_entry[2]) $LINK = $sql_entry[2];

		$sql_result = mysql_query("SELECT * FROM ".SQL_TABLEPREFIX."userprefs WHERE user = '$_SESSION[LOGGED_IN]' AND field = 'VLINK'");
		$sql_entry = mysql_fetch_array($sql_result);
		if ($sql_entry[2]) $VLINK = $sql_entry[2];

		return 'TEXT="'.$TEXT.'" BGCOLOR="'.$BGCOLOR.'" ALINK="'.$ALINK.'" LINK="'.$LINK.'" VLINK="'.$VLINK.'"';
	}

	/* html_menu --> returns a formatted menu */
	function html_menu($current_page) {
		$return = '';
		$navigation[menu] = explode("\n",TEMPLATE_MENU);
		$navigation[aliases] = explode("\n",NAVIGATION_ALIASES);

		/* SUB IN ALIASES */
		foreach ($navigation[aliases] as $alias) {
			$matches = explode(":",$alias);
			if ($matches[1] != $current_page && !$matches[2]) {
				for ($k = 0; $k < count($navigation[menu]); $k++) {
					$navigation[menu][$k] = str_replace("$matches[0]","<A HREF=\"$matches[1]\">$matches[0]</A>",$navigation[menu][$k]);
				}
			}	elseif ($matches[1] != $current_page && $matches[2]) {
				if ($matches[2] == 'USERS') {
					for ($k = 0; $k < count($navigation[menu]); $k++) {
						if (!$_SESSION[LOGGED_IN]) {
							$navigation[menu][$k] = str_replace("$matches[0]","<A HREF=\"javascript:void()\" ONCLICK=\"alert('You must first login.'); return false;\">$matches[0]</A>",$navigation[menu][$k]);
						}	else {
							$navigation[menu][$k] = str_replace("$matches[0]","<A HREF=\"$matches[1]\">$matches[0]</A>",$navigation[menu][$k]);
						}
					}
				}	elseif ($matches[2] == 'NONUSERS') {
					for ($k = 0; $k < count($navigation[menu]); $k++) {
						if ($_SESSION[LOGGED_IN]) {
							$navigation[menu][$k] = str_replace("$matches[0]","<A HREF=\"javascript:void()\" ONCLICK=\"alert('You are already logged in.'); return false;\">$matches[0]</A>",$navigation[menu][$k]);
						}	else {
							$navigation[menu][$k] = str_replace("$matches[0]","<A HREF=\"$matches[1]\">$matches[0]</A>",$navigation[menu][$k]);
						}
					}
				}
			}	else {
				for ($k = 0; $k < count($navigation[menu]); $k++) {
					$navigation[menu][$k] = str_replace("[ ] $matches[0]","[x] $matches[0]",$navigation[menu][$k]);
				}
			}
		}

		return implode("\n",$navigation[menu])."\n";
	}

	/* html_loggedin --> displays a special bar if the user is logged in */
	function html_loggedin($options) {
		$return = '';
		if ($_SESSION[LOGGED_IN]) {
			$return .= format_split(LOGIN_LOGGEDIN.' '.$_SESSION[LOGGED_IN],'[LINK="logout.php"]'.LOGIN_LOGOUT.'&gt;&gt;[/LINK]');
			if (is_user_admin()) {
				$admin_string .= "Admin: ";
				for ($i=0;$i<count($options);$i++) {
					preg_match("/^([^:]+)[:](.+)$/",$options[$i],$matches);
					if ($matches[1] && $matches[2]) {
						$admin_string .= "[[LINK=\"$matches[2]\"]$matches[1][/LINK]]";
					}	else {
						$admin_string .= "[]";
					}
				}
				$return .= format_wrap($admin_string,0);
			}
			$return .= format_line();
		}	else {
			$return .= 
				format_split(LOGIN_NOTLOGGEDIN,'[LINK="login_here.php"]'.LOGIN_LOGIN.'&gt;&gt;[/LINK]',0).format_line();
		}
		return $return;
	}

	/* html_spellcheck --> returns a button to spell check a text field */
	function html_spellcheck () {
		return "<INPUT TYPE=\"BUTTON\" VALUE=\"".SPELL_CHECKBUTTON."\" ONCLICK=\"window.open('spell.php', 'ispell', 'status=yes,width=550,height=370,resizable=yes')\">";
	}

	/* html_cancelbutton --> generic cancel button */
	function html_cancelbutton() {
		return"<INPUT TYPE=\"BUTTON\" NAME=\"".GENERIC_CANCEL."\" VALUE=\"".GENERIC_CANCEL."\" ONCLICK=\"location.href='$_SERVER[HTTP_REFERER]'\">";
	}

	/* html_confirm --> returns a pair of buttons to either confirm deletion or cancel */
	function html_confirm() {
		return GENERIC_CONFIRM."<BR><BR><INPUT TYPE=\"SUBMIT\" VALUE=\"".GENERIC_DELETE."\"> <INPUT TYPE=\"BUTTON\" VALUE=\"".GENERIC_CANCEL."\" ONCLICK=\"location.href='".$_SERVER[HTTP_REFERER]."'\">";
	}

	/* html_openwindow --> shortcut for opening popups */
	function html_openwin($url,$width,$height) {
		return "\"javascript:void()\" ONCLICK=\"window.open('$url','smallwin','toolbar=0,location=0,directories=0,left=50,top=50,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=$width,height=$height' ); return false;\"";
	}

	/* html_textformat --> text format box */
	function html_textformat() {
?>
			<INPUT TYPE="BUTTON" VALUE="BOLD" ONCLICK="javascript:document.forms[0].Message.value+='[BOLD]';document.forms[0].Message.focus()">
			<INPUT TYPE="BUTTON" VALUE="/BOLD" ONCLICK="javascript:document.forms[0].Message.value+='[/BOLD]';document.forms[0].Message.focus()">
			<INPUT TYPE="BUTTON" VALUE="LINK" ONCLICK="javascript:document.forms[0].Message.value+='[LINK=&quot;http://';document.forms[0].Message.focus()">
			<INPUT TYPE="BUTTON" VALUE="/LINK" ONCLICK="javascript:document.forms[0].Message.value+='[/LINK]';document.forms[0].Message.focus()"><BR>
<?
		return 1;
	}

	/* html_login --> displays a login box if not logged in */
	function html_login() {
		if (!$_SESSION[LOGGED_IN] && LOGIN_ATBOTTOM) { 
	?>
<FORM ACTION="login.php" METHOD="POST">
<? echo LOGIN_USERNAME ?>: <INPUT TYPE="text" NAME="w_user" SIZE="20"> <? echo LOGIN_PASSWORD ?>: <INPUT TYPE="password" NAME="w_pass" SIZE="20"> <INPUT TYPE="submit" VALUE="<? echo LOGIN_LOGIN ?>">
</FORM>
	<? } 
	}

	/* html_length --> returns the length of a line with special characters and html accounted for */
	function html_length($text) {
		return strlen(unhtmlspecialchars(preg_replace(WRAP_IGNORELENGTH,'',$text)));
	}
?>
Return current item: Wordlog