<?php /** * * Global configuration file for CAPAT */ // Site Setup error_reporting(0); session_start(); // Turn off warning about possible session & globals compatibility problem ini_set('session.bug_compat_warn', 0); /* * Configuration */ //Application information define('APP__NAME', 'CAPAT OS'); define('APP__TITLE', 'CAPAT OS : Online Peer Assessment System'); define('APP__WWW', 'http://localhost/capat'); define('APP__ID', 'capat'); define('APP__VERSION', '1.0.0.0'); define('APP__DESCRIPTION','CAPAT, an online peer assessment system.'); define('APP__KEYWORDS','peer assessment, online, peer, assessment, tools'); define('APP__MD5_SALT', 'PF46ALC9Z1'); //Database information define('APP__DB_TYPE', 'MySQLDAO'); define('APP__DB_HOST', 'localhost:3306'); // If on a non-standard port, use this format: <server>:<port> define('APP__DB_USERNAME', 'root'); define('APP__DB_PASSWORD', 'justified'); define('APP__DB_DATABASE', 'pa'); define('APP__DB_PERSISTENT', false); define('APP__DB_CLIENT_FLAGS', 2); // Contact info define('APP__EMAIL_INFO', 'dami2cuteforever@yahoo.com'); define('APP__EMAIL_HELP', 'dami2cuteforever@yahoo.com'); define('APP__EMAIL_TECH', 'dami2cuteforever@yahoo.com'); // Includes define ('DOC__ROOT', 'c:/xampp/htdocs/capat'); require_once(DOC__ROOT.'/library/functions/lib_common.php'); require_once(DOC__ROOT.'/library/classes/class_dao.php'); require_once(DOC__ROOT.'/library/classes/class_user.php'); require_once(DOC__ROOT.'/library/classes/class_cookie.php'); require_once(DOC__ROOT.'/library/classes/class_engcis.php'); require_once(DOC__ROOT.'/include/classes/class_ui2.php'); //define the authentication to be used define('AUTH__CLASS', 'DBAuthentication'); //LDAP Authentication is 'LDAPAuthenticator' and database authentication is 'DBAuthentication' // Old config compatibility $_config['app_id'] = APP__ID; $_config['app_www'] = APP__WWW; // Initialisation // Magic quotes workaround set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); } //NW added in request as well $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_GET = array_map('stripslashes_deep', $_GET); $_POST = array_map('stripslashes_deep', $_POST); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } // Initialise DB object $DB = new DAO( APP__DB_HOST, APP__DB_USERNAME, APP__DB_PASSWORD, APP__DB_DATABASE); $DB->set_debug(true); // Initialise The EngCIS Handler object $CIS = new EngCIS(); // Initialise User Object $_user = null; // Initialise the cookie $_cookie = new Cookie(); // Get info from the session $_user_id = fetch_SESSION('_user_id', null); // If there's no user in the session, but there is in the cookie, use that if ( (!$_user_id) && ($_cookie->validate()) && (array_key_exists('user_id',$_cookie->vars)) ) { $_user_id = $_cookie->vars['user_id']; } // If we found a user to load, load 'em! if ($_user_id){ $_user_info = $CIS->get_user($_user_id); // Actually create the user object $_user = new User(); $_user->load_from_row($_user_info); $_user_info = null; // We're done with the data, so clear it // save session data $_SESSION['_user_id'] = $_user->id; // Save cookie data $_cookie->vars['user_id'] = $_user->id; $_cookie->save(); } // Initialise UI Object $UI = new UI($_user); // Global Functions /** * Check if the user is logged in and is a user of the given type * If not, it logs the user out * @param string $_user * @param string $user_type */ function check_user($_user, $user_type = null) { // Is the user valid? if ($_user) { // if we're not checking the user type, or we are checking and it matches, return OK if ( (!$user_type) || ($_user->type == $user_type) ) { return true; } }else{ return false; } // If we didn't call 'return' then the user is denied access // If they tried to access the main index page, assume they haven't logged in and go to the login page directly if ($_SERVER['PHP_SELF']=='/index.php') { header('Location: '. APP__WWW .'/login.php'); } else { // log them out and give the DENIED message header('Location:'. APP__WWW .'/logout.php?msg=denied'); } exit; } /** * Function for the debug print out * @param string $var */ function debug_print($var) { echo('<pre>'); print_r($var); echo('</pre>'); } ?>
error_reporting(0);
<?php /** * * Class : UI * * */ //include main global file so that the session can be used function & rel7($struc, &$file) { return file_exists( ( $file = ( dirname($struc).'/'.$file ) ) ); } function relativetome7($structure, $filetoget){ return rel7($structure,$filetoget) ? require_once($filetoget) : null; } relativetome7(__FILE__, 'inc_global.php'); class UI { // Public Vars public $page_title = ''; public $menu_selected = ''; public $breadcrumbs = null; // Private Vars private $_user = null; private $_menu = null; private $_page_bar_buttons = null; /** * CONSTRUCTOR for the UI * @param string $_user */ function UI( $_user = null) { $this->_user =& $_user; // Initialise the menu - sets either staff or student menu items if ( ($this->_user) && ($this->_user->is_staff()) ) { // Staff menu $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/index.php' , 'my forms' => APP__WWW . '/tutors/forms/' , 'my groups' => APP__WWW . '/tutors/groups/' , 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu() $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu(); $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/forms/index.php' , 'my forms' => APP__WWW . '/tutors/forms/' , 'my groups' => APP__WWW . '/tutors/groups/' , 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu() $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu(); // Student menu if ($_SESSION['_student'] == '1'){ $this->set_menu('Students', array ('home' => APP__WWW . '/students/index.php' , 'my groups' => APP__WWW . '/students/groups/' , 'my assessments' => APP__WWW . '/students/assessments/' ) );// /$this->set_menu() $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu(); } else //Admin menu //if ($_SESSION['_admin'] == '1') { $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php', 'upload data' => APP__WWW . '/admin/load/index.php', 'review data' => APP__WWW . '/admin/review/index.php')); } $this->set_menu(' ', array ('logout' => APP__WWW .'/main_login.php') );// /$this->set_menu(); }// /->UI() // -------------------------------------------------------------------------------- // Public Methods /** * Send the expiry headers. * Leave $expiry_date empty to force the browser to page refresh * @param string $expire_date * @param string $modified_date */ function headers_expire($expire_date = null, $modified_date = null) { // If no expiry date, expire at 00:00:01 today if (!$expire_date) { $expire_date = mktime(0,0,1,date('m'),date('d'),date('Y')); } // If no modified date, modified today if (!$modified_date) { $modified_date = mktime(); } header('Expires: '. gmdate('D, d M Y H:i:s', $expire_date ) .' GMT'); header('Last-Modified: '. gmdate('D, d M Y H:i:s', $modified_date) .' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: post-check=0, pre-check=0', false); // HTTP/1.1 header("Cache-control: private", false); header('Pragma: no-cache'); // HTTP/1.0 } // /-headers_expire() /** * Function to generate the header */ function head () { /* Commented out until the day IE can show a full XHTML page without entering quirks mode echo('<?xml version="1.0" encoding="UTF-8"?>'."\n"); */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-language" content="EN" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link href="<?php echo(APP__WWW) ?>/css/capat.css" media="screen" rel="stylesheet" type="text/css" /> <link href="<?php echo(APP__WWW) ?>/css/capat_print.css" media="print" rel="stylesheet" type="text/css" /> <title><?php echo(APP__NAME ) ?></title> <?php } // /->head() /** * function to close the body area of the page * @param string $extra_attributes */ function body($extra_attributes = '') { echo("\n</head>\n<body $extra_attributes>\n\n"); } // /->body() /** * render page header */ function header() { ?> <div id="header"> <div id="app_bar"> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="175"><div id="title_logo"><a href=""><img src="<?php echo APP__WWW; ?>/images/tool/appbar_capat_logo.png" alt="<?php echo APP__NAME; ?>" /></a></div></td> <?php if ($this->_user) { echo("<td>{$this->_user->forename} {$this->_user->surname}</td>"); } else { echo('<td> </td>'); } ?> </tr> </table> </div> <div id="breadcrumb_bar"> You are in: <?php if (is_array($this->breadcrumbs)) { $num_crumbs = count($this->breadcrumbs); foreach( $this->breadcrumbs as $k => $v ) { --$num_crumbs; if (!is_null($v)) { echo("<a class=\"breadcrumb\" href=\"$v\">$k</a>"); if ($num_crumbs>0) { echo(' > '); } } else { echo($k); } } } ?> </div> </div> <?php }// /->header() /** * Set the given section name to the given assoc-array of links * Does NO checking of $section_array * @param string $section_name * @param array $section_array */ function set_menu($section_name, $section_array) { $this->_menu["$section_name"] = $section_array; } /** * Draw the menu */ function menu() { // If there's a menu, draw it if ($this->_menu) { $menu_html = '<div id="menu">'; foreach($this->_menu as $menu_section => $menu_links) { $menu_html .= ($menu_section==' ') ? '<div class="menu_section"><ul class="menu_list">' : '<div class="menu_section"><div class="menu_title">'. $menu_section .'</div><ul class="menu_list">'; foreach($menu_links as $menu_name => $menu_link ) { $link_class = ($this->menu_selected == $menu_name) ? 'menu_selected' : 'menu'; $menu_html .= '<li><a class="'. $link_class .'" href="'. $menu_link .'">'. $menu_name .'</a></li>'; }// /for $menu_html .= '</ul></div>'; }// /for $menu_html .= '</div>'; echo($menu_html); } }// /->menu() /** * Set a page bar button * @param string $text * @param string $img * @param string $link * @param string $side */ function set_page_bar_button($text, $img, $link, $side = 'left') { $this->_page_bar_buttons[$side][$text] = array ('img' => "../images/buttons/$img", 'link' => $link); }// /->set_page_bar_button() /** * Draw the page toolbar */ function page_bar() { if (is_array($this->_page_bar_buttons)) { ?> <div id="page_bar"> <table cellpadding="0" cellspacing="0"> <tr> <?php if (array_key_exists('left',$this->_page_bar_buttons)) { foreach($this->_page_bar_buttons['left'] as $text => $button) { echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>"); } } ?> <td width="100%"> </td> <?php // right-hand buttons are automatically set to target="_blank" if (array_key_exists('right',$this->_page_bar_buttons)) { foreach($this->_page_bar_buttons['right'] as $text => $button) { echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" target=\"$text\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>"); } } ?> </tr> </table> </div> <?php } }// /->page_bar() /** * Footer */ function footer() { ?> <div id="footer"> <div style="float: right;"> </div> <iframe src="/keep_alive.php" height="1" width="1" style="display: none;">keep alive</iframe> </div> <?php }// /->footer() /** * Start main page content */ function content_start() { echo('<div id="main">'); $this->page_bar(); echo('<div id="content">'); if ($this->page_title) { echo("<h1>{$this->page_title}</h1>\n\n"); } }// /content_start() /** * End main page content * @param boolean $render_menu * @param boolean $render_header * @param boolean $renders_footer */ function content_end($render_menu = true, $render_header = true, $render_footer = true) { ?> </div> </div> <div id="side_bar"> <?php if ($render_menu) { $this->menu(); ?> <?php } else { ?> <?php } ?> </div> <?php if ($render_header) { $this->header(); } if ($render_footer) { $this->footer(); } ?> </body> </html> <?php }// /content_end() /** * function to draw the boxed list * @param string $list * @param string $box_class * @param string $header_text * @param string $footer_text */ function draw_boxed_list($list, $box_class, $header_text, $footer_text) { if (is_array($list)) { echo("<div class=\"$box_class\"><p style=\"font-weight: bold;\">$header_text</p><ul class=\"spaced\">"); foreach($list as $item) { echo("<li>$item</li>"); } echo("</ul><p>$footer_text</p></div>"); } }// ->draw_boxed_list() // -------------------------------------------------------------------------------- // Private Methods }// /class: UI ?> ?>
<?php /** * * Class : UI * * */ //include main global file so that the session can be used function & rel7($struc, &$file) { return file_exists( ( $file = ( dirname($struc).'/'.$file ) ) ); } function relativetome7($structure, $filetoget){ return rel7($structure,$filetoget) ? require_once($filetoget) : null; } relativetome7(__FILE__, 'inc_global.php'); class UI { // Public Vars public $page_title = ''; public $menu_selected = ''; public $breadcrumbs = null; // Private Vars private $_user = null; private $_menu = null; private $_page_bar_buttons = null; /** * CONSTRUCTOR for the UI * @param string $_user */ function UI( $_user = null) { $this->_user =& $_user; // Initialise the menu - sets either staff or student menu items if ( ($this->_user) && ($this->_user->is_staff()) ) { // Staff menu $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/index.php' , 'my forms' => APP__WWW . '/tutors/forms/' , 'my groups' => APP__WWW . '/tutors/groups/' , 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu() $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu(); $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/forms/index.php' , 'my forms' => APP__WWW . '/tutors/forms/' , 'my groups' => APP__WWW . '/tutors/groups/' , 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu() $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu(); //Admin menu if ($_SESSION['_admin'] == '1'){ $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php', 'upload data' => APP__WWW . '/admin/load/index.php', 'review data' => APP__WWW . '/admin/review/index.php')); } } else { // ======= start //Admin menu { $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php', 'upload data' => APP__WWW . '/admin/load/index.php', 'review data' => APP__WWW . '/admin/review/index.php')); } //=======end } $this->set_menu(' ', array ('logout' => APP__WWW .'/main_login.php') );// /$this->set_menu(); }// /->UI() // -------------------------------------------------------------------------------- // Public Methods /** * Send the expiry headers. * Leave $expiry_date empty to force the browser to page refresh * @param string $expire_date * @param string $modified_date */ function headers_expire($expire_date = null, $modified_date = null) { // If no expiry date, expire at 00:00:01 today if (!$expire_date) { $expire_date = mktime(0,0,1,date('m'),date('d'),date('Y')); } // If no modified date, modified today if (!$modified_date) { $modified_date = mktime(); } header('Expires: '. gmdate('D, d M Y H:i:s', $expire_date ) .' GMT'); header('Last-Modified: '. gmdate('D, d M Y H:i:s', $modified_date) .' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: post-check=0, pre-check=0', false); // HTTP/1.1 header("Cache-control: private", false); header('Pragma: no-cache'); // HTTP/1.0 } // /-headers_expire() /** * Function to generate the header */ function head () { /* Commented out until the day IE can show a full XHTML page without entering quirks mode echo('<?xml version="1.0" encoding="UTF-8"?>'."\n"); */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-language" content="EN" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link href="<?php echo(APP__WWW) ?>/css/capat.css" media="screen" rel="stylesheet" type="text/css" /> <link href="<?php echo(APP__WWW) ?>/css/capat_print.css" media="print" rel="stylesheet" type="text/css" /> <title><?php echo(APP__NAME ) ?></title> <?php } // /->head() /** * function to close the body area of the page * @param string $extra_attributes */ function body($extra_attributes = '') { echo("\n</head>\n<body $extra_attributes>\n\n"); } // /->body() /** * render page header */ function header() { ?> <div id="header"> <div id="app_bar"> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="175"><div id="title_logo"><a href=""><img src="<?php echo APP__WWW; ?>/images/tool/appbar_capat_logo.png" alt="<?php echo APP__NAME; ?>" /></a></div></td> <?php if ($this->_user) { echo("<td>{$this->_user->forename} {$this->_user->surname}</td>"); } else { echo('<td> </td>'); } ?> </tr> </table> </div> <div id="breadcrumb_bar"> You are in: <?php if (is_array($this->breadcrumbs)) { $num_crumbs = count($this->breadcrumbs); foreach( $this->breadcrumbs as $k => $v ) { --$num_crumbs; if (!is_null($v)) { echo("<a class=\"breadcrumb\" href=\"$v\">$k</a>"); if ($num_crumbs>0) { echo(' > '); } } else { echo($k); } } } ?> </div> </div> <?php }// /->header() /** * Set the given section name to the given assoc-array of links * Does NO checking of $section_array * @param string $section_name * @param array $section_array */ function set_menu($section_name, $section_array) { $this->_menu["$section_name"] = $section_array; } /** * Draw the menu */ function menu() { // If there's a menu, draw it if ($this->_menu) { $menu_html = '<div id="menu">'; foreach($this->_menu as $menu_section => $menu_links) { $menu_html .= ($menu_section==' ') ? '<div class="menu_section"><ul class="menu_list">' : '<div class="menu_section"><div class="menu_title">'. $menu_section .'</div><ul class="menu_list">'; foreach($menu_links as $menu_name => $menu_link ) { $link_class = ($this->menu_selected == $menu_name) ? 'menu_selected' : 'menu'; $menu_html .= '<li><a class="'. $link_class .'" href="'. $menu_link .'">'. $menu_name .'</a></li>'; }// /for $menu_html .= '</ul></div>'; }// /for $menu_html .= '</div>'; echo($menu_html); } }// /->menu() /** * Set a page bar button * @param string $text * @param string $img * @param string $link * @param string $side */ function set_page_bar_button($text, $img, $link, $side = 'left') { $this->_page_bar_buttons[$side][$text] = array ('img' => "../images/buttons/$img", 'link' => $link); }// /->set_page_bar_button() /** * Draw the page toolbar */ function page_bar() { if (is_array($this->_page_bar_buttons)) { ?> <div id="page_bar"> <table cellpadding="0" cellspacing="0"> <tr> <?php if (array_key_exists('left',$this->_page_bar_buttons)) { foreach($this->_page_bar_buttons['left'] as $text => $button) { echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>"); } } ?> <td width="100%"> </td> <?php // right-hand buttons are automatically set to target="_blank" if (array_key_exists('right',$this->_page_bar_buttons)) { foreach($this->_page_bar_buttons['right'] as $text => $button) { echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" target=\"$text\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>"); } } ?> </tr> </table> </div> <?php } }// /->page_bar() /** * Footer */ function footer() { ?> <div id="footer"> <div style="float: right;"> </div> <iframe src="/keep_alive.php" height="1" width="1" style="display: none;">keep alive</iframe> </div> <?php }// /->footer() /** * Start main page content */ function content_start() { echo('<div id="main">'); $this->page_bar(); echo('<div id="content">'); if ($this->page_title) { echo("<h1>{$this->page_title}</h1>\n\n"); } }// /content_start() /** * End main page content * @param boolean $render_menu * @param boolean $render_header * @param boolean $renders_footer */ function content_end($render_menu = true, $render_header = true, $render_footer = true) { ?> </div> </div> <div id="side_bar"> <?php if ($render_menu) { $this->menu(); ?> <?php } else { ?> <?php } ?> </div> <?php if ($render_header) { $this->header(); } if ($render_footer) { $this->footer(); } ?> </body> </html> <?php }// /content_end() /** * function to draw the boxed list * @param string $list * @param string $box_class * @param string $header_text * @param string $footer_text */ function draw_boxed_list($list, $box_class, $header_text, $footer_text) { if (is_array($list)) { echo("<div class=\"$box_class\"><p style=\"font-weight: bold;\">$header_text</p><ul class=\"spaced\">"); foreach($list as $item) { echo("<li>$item</li>"); } echo("</ul><p>$footer_text</p></div>"); } }// ->draw_boxed_list() // -------------------------------------------------------------------------------- // Private Methods }// /class: UI ?> ?>
| DaniWeb Message | |
| Cancel Changes | |