. */ require_once(ROOTPATH . "include/classes/AbstractLayout.php"); class Layout extends AbstractLayout { protected function startSession() { session_name("AEGEE_Statutory"); session_set_cookie_params(0, "/", preg_replace('/\w+\/\.\.\//', '', $_SERVER['HTTP_HOST']), false); session_start(); } protected function tryAndHandleLogin($user, $password) { if( $this->getLdap()->auth(stripslashes($user), stripslashes($password)) ) { // Ok session_regenerate_id(true); $_SESSION['sess_uid'] = -10; $_SESSION['sess_name'] = stripslashes($user); $_SESSION['sess_groups'] = $this->getLdap()->getBoardGroups(); $_SESSION['access_user'] = true; $ldapTranslation = $this->getLdapTranslation(); $search = array_keys($ldapTranslation); if( $res = $this->getLdap()->getData($search) ) { for( $i=0; $iwarn("Failed retrieving data via LDAP for '".$_SESSION['sess_name']."', creating name from login name."); $h = strpos($_SESSION['sess_name'], " "); if( $h>0 ) { $_SESSION['user_FirstName'] = substr($_SESSION['sess_name'], 0, $h); $_SESSION['user_LastName'] = substr($_SESSION['sess_name'], $h+1); }else { $this->error("Aarrgg, there is even not a space in username for '".$_SESSION['sess_name']."', leaving LastName empty."); $_SESSION['user_FirstName'] = $_SESSION['sess_name']; } } // Do some repairs if( isset($_SESSION['user_Phone']) && substr($_SESSION['user_Phone'], 0, 1)=="+" ) $_SESSION['user_Phone'] = substr($_SESSION['user_Phone'], 1); if( isset($_SESSION['user_Mobile']) && substr($_SESSION['user_Mobile'], 0, 1)=="+" ) $_SESSION['user_Mobile'] = substr($_SESSION['user_Mobile'], 1); if( isset($_SESSION['user_Fax']) && substr($_SESSION['user_Fax'], 0, 1)=="+" ) $_SESSION['user_Fax'] = substr($_SESSION['user_Fax'], 1); if( isset($_SESSION['user_CountryCode']) && strlen($_SESSION['user_CountryCode'])>0 ) { $query="SELECT `Code` FROM `CountryCodes` WHERE `ISO_2`='".addslashes($_SESSION['user_CountryCode'])."' OR `ISO_3`='".addslashes($_SESSION['user_CountryCode'])."' OR `Postal`='".addslashes($_SESSION['user_CountryCode'])."'"; if( $GLOBALS['sql']->query($query) && $GLOBALS['sql']->getNumRows()==1 ) { $row = $GLOBALS['sql']->fetchAssoc(); $_SESSION['user_CountryCode'] = $row['Code']; }else { unset($_SESSION['user_CountryCode']); } } }else { $this->error("Login failed for '".$user."' from ".$_SERVER['REMOTE_ADDR']); $this->displayLogin(); exit(); } $_SERVER['REQUEST_METHOD'] = "GET"; } protected function displayTop() { $this->layoutItem("top"); if( defined("EVENT_ID") ) { $this->displayMenuEvent(); }else { $this->displayMenuMain(); } $this->displayAccount(); $this->layoutItem("page-top"); $this->echoln("        Home > "); $this->echoln("Statutory"); if( defined("EVENT_TITLE") ) { $this->echoln(" > ".EVENT_TITLE.""); } $this->echoln("

"); } protected function displayBottom() { $this->layoutItem("page-bottom"); $this->layoutItem("bottom"); } protected function displayLogin() { $this->layoutItem("login"); } protected function afterLogout() { if( substr($_SERVER['PHP_SELF'], -9)=="apply.php" || substr($_SERVER['PHP_SELF'], -9)=="board.php" ) { header("location: index.php"); exit(); } } private function displayMenuMain() { $this->layoutMenu("Home"); $this->layoutMenu("Latest Agora"); $this->layoutMenu("Latest EBM"); $this->layoutMenu("About"); } private function displayMenuEvent() { $this->layoutMenu("Home"); $this->layoutMenu("Chair news"); if( $setup['SetupWSNumber']>0 ) { $this->layoutMenu("Workshops"); } if( isset($_SESSION['access_user']) && $_SESSION['access_user']==true ) { $this->layoutMenu("My application"); }elseif( $setup['PromoteAnonymousApplication'] || $setup['AuthSystem']=="None" ) { $this->layoutMenu("My application"); }else { $this->layoutMenu("My application"); } if( $setup['SetupBoardApproval']=="yes" ) { if( $setup['PromoteAnonymousApplication'] || $setup['AuthSystem']=="None" ) { $this->layoutMenu("Boards"); }else { $this->layoutMenu("Boards"); } } if( $setup['CandidateAdminOpen'] ) { $this->layoutMenu("Candidates"); } $this->layoutMenu("For Contacts"); $this->layoutMenu("Participants list"); #if( is_after("EventDateStart") ) { # $this->layoutMenu("Photos"); #} #$this->layoutMenu("Downloads"); $this->layoutMenu("Statistics"); $this->layoutMenu("Priv. statement"); $this->layoutMenu("About"); } private function displayAccount() { $this->layoutItem("account-top"); if( isset($_SESSION['sess_uid']) && $_SESSION['sess_uid']!=0 && AUTH_SYSTEM!="None" ) { $this->layoutItem("account-loggedin"); }else { $this->layoutItem("account-anonymous"); if( AUTH_SYSTEM!="None" ) { echo "
login"; } } if( !isset($_SERVER['HTTPS']) ) { echo "

"; echo " Certificate error?"; echo "

"; } $this->layoutItem("account-bottom"); } private function layoutImg($img) { $imgs = array(); $imgs[] = "previous.gif"; $imgs[] = "next.gif"; $imgs[] = "list.gif"; if( in_array($img, $imgs) ) { return "./layout/".$_SESSION['layout']."/image/".$img; }else { // Not valid return ""; } } private function layoutMenu($item) { $this->layoutItem("menu-top"); echo $item; $this->layoutItem("menu-bottom"); } } ?>