Location: PHPKode > scripts > Todolist.php > Todolist.php-0.9.15.4/include/header.inc.php
<? 
   /* vim: set si tw=110 ts=4 sw=4: */

if (strtolower($DATABASE) == "mysql")
   include "include/db_mysql.inc.php";

$db = new DB_Sql();
$db->Host		= "$DB_SERVER";
$db->Database	= "$DB_INSTANCE";
$db->User		= "$DB_USER";
$db->Password	= "$DB_PASS";

session_start();

define('TOP',0);
define('BOTTOM',1);

if ($DEBUG)
  $db->Debug=1;

if (isset ($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action']== 'logout') {
	// Free all session-variables
	// raus wg dbsessions
	session_unset();
	unset ($HTTP_SESSION_VARS);
	// Now remove Cookie (Start new session)
    session_destroy();
    setcookie(session_name(),"",0,"/");
}

// FIXME: Remove this dirty hack for the feedback if task added. Maybe do a replace on the string...
if (isset($HTTP_POST_VARS['text'])) {
	$text = $HTTP_POST_VARS['text'];
} else {
	$text = '';
}

/* initialize $TEXT-Variables with english test.
   --> This is the "complete" file...
   The preferred language of the user is loaded after authentication. */
include 'include/lang/lang-en.inc.php';

// Is this really a valid user?
if (!isset($HTTP_SESSION_VARS['usr']) || $HTTP_SESSION_VARS['usr']->userid == false){
	// Set the $TEXT-Variables with the correct language... This is for the login-screen.
	// Its done again for the user later...
	if (strtolower($LANGUAGE) != "en")
	{
		include "include/lang/lang-" . strtolower($LANGUAGE) . ".inc.php";
	}
    if(!isset($HTTP_POST_VARS['todouser'])) {
        authenticate();
    } else {
        $username=strtolower($HTTP_POST_VARS['todouser']);
		if (isset($HTTP_POST_VARS['remember_me']) &&
			(!isset($HTTP_COOKIE_VARS['userkeks']) || $HTTP_COOKIE_VARS['userkeks'] != $username)) {
			// Save the username in a cookie. Lifetime: one week.
			setcookie ("userkeks", "$username", time() + 604800);
			// allready used by authenticate so...
			$HTTP_COOKIE_VARS['userkeks'] = $username;
		} else {
			// delete cookie if exists...
			setcookie ('userkeks');
		}
        $db->query("SELECT * FROM todo_users WHERE login_name='$username'");
        
        if($db->num_rows()) {
            $db->next_record();
			if ($db->f("wrong_logins") < $MAX_LOGIN_TRIES) {

				global $usr;
				$usr = new User();
				session_register(serialize($usr));
				$HTTP_SESSION_VARS['usr'] = &$usr;

				global $history;
				$history = new History();
				session_register(serialize($history));
				$HTTP_SESSION_VARS['history'] = &$history;

				if ($db->f("password") == md5($HTTP_POST_VARS['todopass'])){
					$HTTP_SESSION_VARS['usr']->userid=$db->f("usernr");

					$HTTP_SESSION_VARS['usr']->lang=$db->f("language");

					$HTTP_SESSION_VARS['usr']->primary_project=$db->f("primary_project");
					$HTTP_SESSION_VARS['usr']->selected_project=$db->f("primary_project");

					$show_icons=$db->f("show_icons");
					$HTTP_SESSION_VARS['usr']->show_icons=$db->f("show_icons");

					$HTTP_SESSION_VARS['usr']->is_admin=$db->f("admin");

					$HTTP_SESSION_VARS['usr']->my_tasks=$db->f("my_tasks");

					$HTTP_SESSION_VARS['usr']->realname=$db->f("first_name") . ' ' . $db->f("last_name");

					if ($db->f('visible_columns') != '') {
						$HTTP_SESSION_VARS['usr']->setColumns(explode (',', $db->f('visible_columns')));
					}

					$db->query("UPDATE todo_users
							SET wrong_logins=0
							WHERE login_name='$username'");

					// Cache the projects a user is member in. Format '(proj1,proj2,..)'
					$query='SELECT project_id
					FROM todo_project_members
					WHERE member_id=' . $HTTP_SESSION_VARS['usr']->userid;
					$db->query($query);

					if ($db->num_rows() == 0 ) {
						$feedback = $TEXT_LOGIN_NO_PROJECT;
						session_destroy();
						authenticate();
					}

					$my_projects = '(';
					while ($db->next_record()){
						$my_projects .= $db->f("project_id") . ",";
					}
					$my_projects = substr($my_projects, 0, -1) . ')';
					$HTTP_SESSION_VARS['usr']->my_projects = $my_projects;

					// Check if the user is still member of his preferred project! Set to all if he isn't.
					if (!$HTTP_SESSION_VARS['usr']->isMemberOfProject($HTTP_SESSION_VARS['usr']->selected_project)) {
						$HTTP_SESSION_VARS['usr']->primary_project="all";
						$HTTP_SESSION_VARS['usr']->selected_project="all";
						$db->query("UPDATE todo_users SET primary_project='".$HTTP_SESSION_VARS['usr']->primary_project."'
								WHERE usernr=".$HTTP_SESSION_VARS['usr']->userid);
					}

				} else {
					// wrong PW
					$wrong_logins = $db->f("wrong_logins") +1 ;
					$feedback = $TEXT_LOGIN_WRONG_PW . ' ('.$wrong_logins.'/'.$GLOBALS['MAX_LOGIN_TRIES'].')';
					$db->query("UPDATE todo_users
							SET wrong_logins=$wrong_logins
							WHERE login_name='$username'");
					authenticate();
				}
			} else {
				// too many login_failures --> Account disabled...
				$feedback = $TEXT_LOGIN_DISABLED;
				authenticate();
			}
        } else {
			// user doesn't exist
			$feedback = $TEXT_LOGIN_USER_UNKNOWN;
            authenticate();
        }
    }
}

// ---  Load the "right" language ------------------------------
if ((!isset($HTTP_POST_VARS['new_language'])) || ($HTTP_POST_VARS['page'] == ADMINPAGE)) {
	if ($HTTP_SESSION_VARS['usr']->lang != "") {
		$selected_lang=$HTTP_SESSION_VARS['usr']->lang;
	} else {
		$selected_lang=$LANGUAGE;
	}
} else {
	if ($HTTP_POST_VARS['page']==PREFPAGE) { 
		$selected_lang=$HTTP_POST_VARS['new_language']; 
		// also update session-variable 

		$HTTP_SESSION_VARS['usr']->lang=$HTTP_POST_VARS['new_language']; 
	} else { 
		$selected_lang=$LANGUAGE; 
	} 
}
// Set the $TEXT-Variables with the correct language...
if (strtolower($selected_lang) != "en")
{
	include "include/lang/lang-" . strtolower($selected_lang) . ".inc.php";
}
// ---  the "right" language has been loaded. ------------------------------

$date=date("Y-m-d H:i");
$very_important_date = date("Y-m-d H:i", mktime() + (86400 * $VERY_IMPORTANT_DAYS));
$most_important_date = date("Y-m-d H:i", mktime() - (86400 * $MOST_IMPORTANT_DAYS));

// FIXME: This should go to constants.php or whatever...
// Stati >5 are "end-stati".
$stati = array (
		0	=> "$TEXT_STATUS_OPEN",
		1	=> "$TEXT_STATUS_IN_PROGRESS",
     	2   => "$TEXT_STATUS_ON_TRACK",
     	3   => "$TEXT_STATUS_DIFFICULTIES",
     	4   => "$TEXT_STATUS_DERAILED",
     	6   => "$TEXT_STATUS_SUSPENDED",
     	7   => "$TEXT_STATUS_POSTPONED",
     	8   => "$TEXT_STATUS_CANCELLED",
		9	=> "$TEXT_STATUS_OBSOLETE",
		10	=> "$TEXT_STATUS_DONE",
		);

/**
 * genearates the header of every page
 *
 * @param $title	string	The title of the page
 * @param $page		int		the page for which this header is
 * @return string HTML content
 */
function page_top($title,$page){
global  $db,$BACKGROUND_IMAGE,$BACKGROUND_COLOR,$TEXT_NEW, $TEXT_SEARCH,
$VERY_IMPORTANT_DAYS, $TEXT_TODO ,$TEXT_ADMIN, $TEXT_BACK, $TEXT_RELOAD, $TEXT_PRINTLAYOUT,
$REFRESH_MAIN, $TEXT_PREFERENCES, $date, $TEXT_TASKS_MY, $TEXT_TASKS_ALL, $id;
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $GLOBALS;

$PHP_SELF	= &$HTTP_SERVER_VARS['PHP_SELF'];

$str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
	<head>
    <meta http-equiv="Content-Type" content="text/html charset='.$GLOBALS['CHARSET'].'"/>
    <title>'.strip_tags($title).'</title>
';
    if (!$GLOBALS['DEBUG']) {
	
		if ($page == THELIST || $page == ACTIONS) {
			$str .= '<meta http-equiv="refresh" content="'.$REFRESH_MAIN.'; URL='.$PHP_SELF;
			if (isset($HTTP_GET_VARS['order_by']))
				$str .='?order_by='.$HTTP_GET_VARS['order_by'];
			$str .= '"/>';
		}
	}
	
    // Javascripts
    if ($page == THELIST || $page == ADDFORM){
		// Javascript for project-select (main-page)
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function selectproject() {
			  window.location.href="'.$PHP_SELF.'?'.session_name().'='.session_id().'&';
		if (isset($HTTP_GET_VARS['order_by'])) {
			$str .= 'order_by='.$HTTP_GET_VARS['order_by'].'&';
		}
		$str .= 'selected_project=" + document.projectform.selected_project.options[window.document.projectform.selected_project.selectedIndex].value
		}
                function showdone() {
                          window.location.href="'.$PHP_SELF.'?'.session_name().'='.session_id().'&show_done=" + document.projectform.show_done.options[window.document.projectform.show_done.selectedIndex].value
                }
		// -->
		</script>';
		// Javascript for project-select (add form)
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function updateaddbox() {
			var Url = "'.$PHP_SELF.'?'.session_name().'='.session_id().'&';
			if (isset($HTTP_GET_VARS['order_by'])) {
				$str .= 'order_by='.$HTTP_GET_VARS['order_by'].'&';
			}
			$str .= 'add_project=" + document.addform.project.options[window.document.addform.project.selectedIndex].value';
			$str .= '+"\&add_text=" + document.addform.text.value';
			$str .= '+"\&add_prio=" + document.addform.priority.selectedIndex';
			$str .= '+"#todoSearchForm"';
			if (isset ($HTTP_GET_VARS['route'])) {
				$str .= '+"\&route='.$HTTP_GET_VARS['route'];
			}
			$str .= ';
			window.location.href=Url.replace(/#/,";RAUTE;");
		}
		// -->
		</script>';
		// Javascript for project-select (search form)
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function updatesearchbox() {
			var Url = "'.$PHP_SELF.'?'.session_name().'='.session_id().'&';
			if (isset($HTTP_GET_VARS['order_by'])) {
				$str .= 'order_by='.$HTTP_GET_VARS['order_by'].'&';
			}
			$str .= 'search_project=" + document.searchform.search_project.options[window.document.searchform.search_project.selectedIndex].value';
			$str .= '+"\&abfrage=" + document.searchform.abfrage.value';
			$str .= '+"\&wildcards=" + document.searchform.wildcards.value';
			$str .= '+"\&date_min=" + document.searchform.date_min.value';
			$str .= '+"\&date_max=" + document.searchform.date_max.value';
			$str .= '+"\&add_prio=" + document.addform.priority.selectedIndex';
			$str .= '+"#todoAddForm"';
			if (isset ($HTTP_GET_VARS['route'])) {
				$str .= '+"\&route='.$HTTP_GET_VARS['route'];
			}
			$str .= ';
			window.location.href=Url.replace(/#/,";RAUTE;");
		}
		// -->
		</script>';
    }
    if (($page == THELIST) || ($page == SEARCHPAGE) || ($page == DETPAGE)){
		$jetzt = getdate(time());
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function showCalendar(form,field)
		{
			var calenderWin =  window.open("calendar.php?m='.$jetzt['mon'].'&dj='.$jetzt['year'].'&form="+form+"&field="+field, "","width=210,height=210");
			/*calenderWin.moveTo(screen.width-210,0);*/
			calenderWin.focus();
		}
		// -->
		</script>
		';
	}
    if ($page == DETPAGE){
		// Javascript for project-select (add form)
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function updatedetails() {
			  window.location.href="'.$PHP_SELF.'?'.session_name().'='.session_id().'&';
		$str .= 'route='.DETAILS.'&id=';
		if (isset($HTTP_GET_VARS['id'])) {
			$str .= $HTTP_GET_VARS['id'];
		} else {
			$str .= $HTTP_POST_VARS['parent_task'];
		}
		$str .='&feedback='.urlencode($GLOBALS['TEXT_DATASET_CHANGED']).'&';
		$str .= 'detail_project=" + document.detailform.project.options[window.document.detailform.project.selectedIndex].value
		}';

		//sets the status to done if percentage_completed=100 is selected.
		$str .='
		function updatestatus() {
			if (document.detailform.percentage_completed.options[document.detailform.percentage_completed.selectedIndex].value == 100 ) {
				document.detailform.status.selectedIndex=document.detailform.status.options.length-1;
			}
		}';

		//sets percentage_completed=100 if status is set to done.
		$str .='
		function updatepercentage() {
			if (document.detailform.status.options[document.detailform.status.options.selectedIndex].value==10) {
				document.detailform.percentage_completed.selectedIndex = document.detailform.percentage_completed.options.length-1;
			}
		}';
		$str .='
		// -->
		</script>';
    }
    if ($page == LOGIN){
		/* Javascript for Login-Form
		 * No plan why I have to do focus() after the select but konqui seems to need it?!?!
		 */
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function focusNameField() {
			document.loginForm.todouser.focus();
			document.loginForm.todouser.select();
		}
			';
		$str .='
		// -->
		</script>';
	}
    if ($page == PREFPAGE){
		// Javascript for project-select (pref-page)
		$str .= '
		<script type="text/javascript" language="JavaScript">
		<!--
		function adminproject() {
			var location = "'.$PHP_SELF.'?'.session_name().'='.session_id().'&route='.ADMIN.'&page='.PREFPAGE.'&adm='.ADMIN_PROJECTS.'";
			location += "&project=" + document.projectadminform.project.options[window.document.projectadminform.project.selectedIndex].value
			window.location.href=location;
		}
		// -->
		</script>';
	}
    $str .= '
    <link rel="stylesheet" type="text/css" href="include/todo.css"/>
    </head>
	<body background="'.$BACKGROUND_IMAGE.'" bgcolor="'.$BACKGROUND_COLOR.'" ';
	if ($page==LOGIN) {
		$str.= 'onload="focusNameField()"';
	}
	$str .= '>
		<a name="top" />

		<table summary="header" width="100%"><tr><td width="33%">
		<p align="left" />
		';
	if ($page != LOGIN && !isset($HTTP_GET_VARS['printlayout'])) {
	$str .= makeBackLink(TOP, $page);

	if ($HTTP_SESSION_VARS['usr']->showIcons()) {
		$str .= '<br/><a href="'.$PHP_SELF.'#todoAddForm" accesskey="n">
			<img border="0" src="include/img/new.png" alt="'.$TEXT_NEW.'" /></a>';
		/*
		 // maybe somewhen...
		$str .= '<br/><a target="_blank" href="'.$PHP_SELF.'?route='.ADDFORM.'" accesskey="n">
			<img border="0" src="include/img/new.png" alt="'.$TEXT_NEW.'" /></a>';
			*/
		$str .= ' <a href="'.$PHP_SELF.'#todoSearchForm" accesskey="s">
			<img border="0" src="include/img/find.png" alt="'.$TEXT_SEARCH.'" /></a>';
	} else {
		$str .= '<br/><a href="'.$PHP_SELF.'#todoAddForm" accesskey="n">'.$TEXT_NEW .'</a> / ';
		$str .= '<a href="'.$PHP_SELF.'#todoSearchForm" accesskey="s">'.$TEXT_SEARCH.'</a>';
	}

    if (!isset($HTTP_GET_VARS['printlayout']) && ($page!=DETPAGE) && ($page!=ADMINPAGE) && ($page!=PREFPAGE))
    {
		if ($HTTP_SERVER_VARS['QUERY_STRING']=="") {
			if ($HTTP_SESSION_VARS['usr']->showIcons()) {
				$str .= '<a target="_blank" href="'.$PHP_SELF.'?printlayout=true">';
				$str .= '<img border="0" src="include/img/print.png" alt="'.$TEXT_PRINTLAYOUT.'" /></a>';
			} else
				$str .= '/ <a target="_blank" href="'.$PHP_SELF.'?printlayout=true" accesskey="p">'.
					$TEXT_PRINTLAYOUT."</a>";
		} else {
			if ($HTTP_SESSION_VARS['usr']->showIcons())
				$str .= '<a target="_blank" href="'.$PHP_SELF.'?'.$HTTP_SERVER_VARS['QUERY_STRING'].'&printlayout=true" accesskey="p">
					<img border="0" src="include/img/print.png" alt="'.$TEXT_PRINTLAYOUT.'" /></a>';
			else
				$str .= '/ <a target="_blank" href="'.$PHP_SELF.'?'.$HTTP_SERVER_VARS['QUERY_STRING'].'&printlayout=true" accesskey="p">'.
					$TEXT_PRINTLAYOUT."</a>";
		}
    }
    if ((!isset($HTTP_GET_VARS['printlayout'])) && ($HTTP_SESSION_VARS['usr']->isAdmin()) && ($page != ADMINPAGE)) {
		if ($HTTP_SESSION_VARS['usr']->showIcons())
			$str .=  ' <a href="'.$PHP_SELF.'?route='.ADMIN.'" accesskey="a">
				<img border="0" src="include/img/admin.png" alt="'.$TEXT_ADMIN.'"/></a>';
		else
			$str .=  ' / <a href="'.$PHP_SELF.'?route='.ADMIN.'" accesskey="a">'.$TEXT_ADMIN.'</a>';
    }
	if ($page != PREFPAGE) {
		if ($HTTP_SESSION_VARS['usr']->showIcons())
			$str .=' <a href="'.$PHP_SELF.'?route='.PREFERENCES.'" accesskey="p">
				<img border="0" src="include/img/preferences.png" alt="'.$TEXT_PREFERENCES.'"/></a>';
		else
			$str .=' / <a href="'.$PHP_SELF.'?route='.PREFERENCES.'" accesskey="p">'.$TEXT_PREFERENCES.'</a>';
	}
}
$str .= '
</td>
<td width="33%">
<h1 align="center">'.$title.'</h1>
</td>
';
if ($page == THELIST) {
    // How many things in this project aren't finished yet?
    $query = 'SELECT count(distinct(todo_todos.todo_id)) AS anzahl_jobs
	            FROM todo_todos, todo_project_members, todo_responsible_persons
				WHERE status <= 5';
				//WHERE todo_priority IN (1,2,3)";
				//AND project_id=$selected_project");

	if ($HTTP_SESSION_VARS['usr']->selected_project != "all") {
		$query .= ' AND todo_todos.project_id='.$HTTP_SESSION_VARS['usr']->selected_project;
	} else {
		$query .=' AND todo_todos.project_id in ' . $HTTP_SESSION_VARS['usr']->my_projects;

	}

	if ($HTTP_SESSION_VARS['usr']->showMyTasks()) {
		$query .= ' AND todo_responsible_persons.user_id = '. $HTTP_SESSION_VARS['usr']->userid .'
			AND todo_todos.todo_id = todo_responsible_persons.todo_id';
	}

    $db->query($query);
    $db->next_record();
    $anzahl_jobs = $db->f("anzahl_jobs");
}

$str .= '<td width="33%" align="right">'. convDate($date) . "<br/>";
if (isset($anzahl_jobs)) {
   $str .= '<font size="-1">'.$anzahl_jobs . " " .$TEXT_TODO.' </font>';
}

if (($page != LOGIN) && ($page != DETPAGE) && ($page != ADMINPAGE) && ($page != PREFPAGE) &&
		($page != NEWPROJECT) ) {
	if (!isset($HTTP_GET_VARS['printlayout'])) {
		$str .= '
		<form method="post" action="'.$PHP_SELF.'" name="mytasksform">
		<input type="hidden" name="route" value="'.FRONTPAGE.'"/>';
		$str .= '<select name="my_tasks" onChange="self.location=this.options[this.selectedIndex].value">';
		$str .= '<option value="'.$HTTP_SERVER_VARS['PHP_SELF'].'?my_tasks=1" ';
		if ($HTTP_SESSION_VARS['usr']->showMyTasks()) {
			$str .= 'selected="selected"';
		}
		$str .= '>'.$TEXT_TASKS_MY.'</option>';
		$str .= '<option value="'.$HTTP_SERVER_VARS['PHP_SELF'].'?my_tasks=0" ';
		if (!$HTTP_SESSION_VARS['usr']->showMyTasks()) {
			$str .= 'selected="selected"';
		}
		$str .= '>'.$TEXT_TASKS_ALL.'</option>';
		$str .= '</select>';
		$str .= '</form>';
		$str .= '
		<form method="get" action="'.$PHP_SELF.'" name="projectform">
		<input type="hidden" name="route" value="'.FRONTPAGE.'"/>';
		$str .= makeProjectDropdown("selected_project",$HTTP_SESSION_VARS['usr']->selected_project, true, "selectproject()");
		$str .= '<br>';
		$str .= makeShowDone($HTTP_SESSION_VARS['usr']->show_done);
		$str .= '</form>';
	} else {
		if ($HTTP_SESSION_VARS['usr']->showMyTasks()) {
			$str .= '<br />'.$TEXT_TASKS_MY;
		} else {
			$str .= '<br />'.$TEXT_TASKS_ALL;
		}
		
	}
}
$str .= '
</td></tr>
</table>';
	if (isset($GLOBALS['feedback'])) {
		$str .= '<p class="feedback">'.$GLOBALS['feedback'].'</p>';
	}
return $str;
} // end page_top


/**
 * genearates the footer of every page
 *
 * @param $page		int		the page for which this header is
 * @return string HTML content
 */
function page_foot($page=''){
	global $TEXT_TOP,$TEXT_BACK, $TEXT_LOGOUT, $TEXT_TASKS_MY, $TEXT_TASKS_ALL;
	global $HTTP_SESSION_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS;


	/* FIXME:
	if (isset($HTTP_SESSION_VARS['history'])) {
		echo var_dump($HTTP_SESSION_VARS['history']->getAll()) . "<br>";
	}
	*/
	?>
		<hr noshade="noshade" />
		<table summary="footer" width="100%" cellpadding="0" cellspacing="0">
		<tr>
		<td class="fot" width="33%" align="left" valign="top">
		<?php echo makeBackLink(BOTTOM, $page); ?>
		</td>
		<td class="fot" width="33%" align="center">
		<a class="fot" href="http://todolist.sourceforge.net/" target="_blank">Todolist.php v<? echo VERSION; ?></a><br />
		&copy; 1999-2004 <a class="fot" href="mailto:hide@address.com">J&ouml;rg Menke</a>
		</td>
		<?php
		if ((isset($HTTP_SESSION_VARS['usr']) && !$HTTP_SESSION_VARS['usr']->userid == false ) &&
			!isset($HTTP_GET_VARS['printlayout'])) {
			echo '<td class="fot" align="right" valign="top">';
			echo $HTTP_SESSION_VARS['usr']->getRealName() . " (";
			if ($HTTP_SESSION_VARS['usr']->showMyTasks()) {
				echo $TEXT_TASKS_MY;
			} else {
				echo $TEXT_TASKS_ALL;
			}
			echo ')<br />';
			echo convDate(date("Y-m-d H:i"));
			echo '</td><td class="fot" align="right" valign="top">';
			if ($HTTP_SESSION_VARS['usr']->showIcons()) {
				echo ' <a href="'.$HTTP_SERVER_VARS['PHP_SELF'].'?action=logout">
					<img border="0" src="include/img/exit.png" alt="'.$TEXT_LOGOUT.'"/></a><br />';
			} else {
				echo '<a href="'.$HTTP_SERVER_VARS['PHP_SELF'].'?action=logout">'.$TEXT_LOGOUT.'</a><br/>';
			}
		} else {
			// Login-Maske...
			echo '<td class="fot" width="33%">';
		}
	?>
		</td>

		</tr>
		</table>
		</body></html>
		<?
} // end page_foot

/**
 * generates the back link for page_top() and page_bottom
 *
 * @param	position constants TOP or BOTTOM 
 * @param	page the page
 * @todo	replace witch JavaScript maybe
 * @return	HTML for the back-link
 */
function makeBackLink($position, $page) {
	global $TEXT_RELOAD, $TEXT_BACK, $TEXT_TOP;
	global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $GLOBALS;

	$PHP_SELF	= &$HTTP_SERVER_VARS['PHP_SELF'];
	$history = &$HTTP_SESSION_VARS['history'];

	$str = '';

	if (isset($HTTP_GET_VARS['printlayout']))
		return;

	if (!is_object($history)) {
		return '';
	}
	switch ($history->getPage(1))
	{
		case THELIST: 
			if ($position == TOP) {
				if ($HTTP_SESSION_VARS['usr']->showIcons()) {
					$str .= '<a href="'.$PHP_SELF.'">
						<img border="0" src="include/img/reload.png" alt="'.$TEXT_RELOAD.'"/></a>';
				} else {
					$str .= '<a href="'.$PHP_SELF.'">'.$TEXT_RELOAD.'</a>';
				}
			} else {
				if ($HTTP_SESSION_VARS['usr']->showIcons()) {
					echo '<a href="#top">';
					echo '<img border="0" src="include/img/up.png" alt="'.$TEXT_TOP.'"/></a>';
				} else
					echo "  <a href=\"#top\">$TEXT_TOP</a>";
			}
			break;

		/*
		case ADMINPAGE: 
			if ((isset($HTTP_GET_VARS['module']) && $HTTP_GET_VARS['module']=='newuser') || isset($HTTP_GET_VARS['user'])) {
				if ($HTTP_SESSION_VARS['usr']->showIcons()) {
					$str .= '<a href="'.$PHP_SELF.'?route='.ADMIN."&adm=".ADMIN_USERS.'">
						<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'" /></a>';
				} else {
					$str.= '<a href="'.$PHP_SELF.'?route='.ADMIN."&adm=".ADMIN_USERS.'">'.$TEXT_BACK.'</a>';
				}
				break;
			} elseif (isset($HTTP_GET_VARS['adm'])) {
				if ($HTTP_SESSION_VARS['usr']->showIcons()) {
					$str.= '<a href="'.$PHP_SELF.'?route='.ADMIN.'&page='.$page.'">
						<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'" /></a>';
					$str.= '<a href="'.$PHP_SELF.'">
						<img border="0" src="include/img/main.png" alt="'.$GLOBALS['TEXT_MAIN_PAGE'].'"/></a>';
				} else {
					$str.= '<a href="'.$PHP_SELF.'?route='.ADMIN.'&page='.$page.'">'.$TEXT_BACK.'</a>';
					$str .= '<a href="'.$PHP_SELF.'">'.$GLOBALS['TEXT_MAIN_PAGE'].'</a>';
				}
			} else {
				if ($HTTP_SESSION_VARS['usr']->showIcons()) {
					//$str.= '<a href="javascript:history.back()">
					$str.= '<a href="'.$PHP_SELF.'">
						<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'"/></a>';
				} else {
					$str .= '<a href="'.$PHP_SELF.'">'.$TEXT_BACK.'</a>';
				}
			}
			break;

		case DETPAGE:
				if($history->getPage(2) == THELIST) {
					if ($HTTP_SESSION_VARS['usr']->showIcons()) {
						$str.= '<a href="'.$PHP_SELF.'">
							<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'"/></a>';
					} else {
						$str.= '<a href="'.$PHP_SELF.'">'.$TEXT_BACK.'</a>';
					}
				} else {
					if($HTTP_SESSION_VARS['usr']->showIcons()) {
						//$str.= '<a href="javascript:history.back()">
						$str.= '<a href="'.$PHP_SELF.'">
							<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'"/></a>';
						$str.= '<a href="'.$PHP_SELF.'">
							<img border="0" src="include/img/main.png" alt="'.$GLOBALS['TEXT_MAIN_PAGE'].'"/></a>';
					} else {
						$str .= '<a href="'.$PHP_SELF.'">'.$TEXT_BACK.'</a>';
						$str .= '<a href="'.$PHP_SELF.'">'.$GLOBALS['TEXT_MAIN_PAGE'].'</a>';
					}
				}
			break;

		case PREFPAGE: 
			if ($HTTP_SESSION_VARS['usr']->showIcons()) {
				//$str.= '<a href="javascript:history.back()">
				$str.= '<a href="'.$PHP_SELF.'">
					<img border="0" src="include/img/back.png" alt="'.$TEXT_BACK.'"/></a>';
			} else {
				$str .= '<a href="'.$PHP_SELF.'">'.$TEXT_BACK.'</a>';
			}
			if($history->getPage(2) != THELIST) {
				if($HTTP_SESSION_VARS['usr']->showIcons()) {
					$str.= '<a href="'.$PHP_SELF.'">
						<img border="0" src="include/img/main.png" alt="'.$GLOBALS['TEXT_MAIN_PAGE'].'"/></a>';
				} else {
					$str .= '<a href="'.$PHP_SELF.'">'.$GLOBALS['TEXT_MAIN_PAGE'].'</a>';
				}
			}
			break;
			*/
		case LOGIN:
			// no back link on login-page!
			break;

		default:
			if ($HTTP_SESSION_VARS['usr']->showIcons()) {
				$str.= '<a href="'.$PHP_SELF.'">
					<img border="0" src="include/img/gohome.png" alt="'.$GLOBALS['TEXT_MAIN_PAGE'].'"/></a>';
			} else {
				$str .= '<a href="'.$PHP_SELF.'">'.$GLOBALS['TEXT_MAIN_PAGE'].'</a>';
			}
	} //switch

	return $str;
}
Return current item: Todolist.php