943,083 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 957
  • PHP RSS
Feb 19th, 2008
0

page loading problem

Expand Post »
Hi,
Could someone please tell me what is wrong with this code because i have tried loading it but it's not giving me any error to know where the problem lies.

php Syntax (Toggle Plain Text)
  1. <?php
  2. /**
  3.  *
  4.  * Global configuration file for CAPAT
  5.  */
  6.  
  7. // Site Setup
  8. error_reporting(0);
  9.  
  10. session_start();
  11.  
  12.  
  13.  
  14. // Turn off warning about possible session & globals compatibility problem
  15. ini_set('session.bug_compat_warn', 0);
  16.  
  17.  
  18.  
  19. /*
  20.  * Configuration
  21.  */
  22.  
  23.  
  24.  
  25. //Application information
  26.  
  27.  
  28. define('APP__NAME', 'CAPAT OS');
  29. define('APP__TITLE', 'CAPAT OS : Online Peer Assessment System');
  30. define('APP__WWW', 'http://localhost/capat');
  31. define('APP__ID', 'capat');
  32. define('APP__VERSION', '1.0.0.0');
  33. define('APP__DESCRIPTION','CAPAT, an online peer assessment system.');
  34. define('APP__KEYWORDS','peer assessment, online, peer, assessment, tools');
  35. define('APP__MD5_SALT', 'PF46ALC9Z1');
  36.  
  37. //Database information
  38. define('APP__DB_TYPE', 'MySQLDAO');
  39. define('APP__DB_HOST', 'localhost:3306');
  40.  
  41. // If on a non-standard port, use this format: <server>:<port>
  42. define('APP__DB_USERNAME', 'root');
  43. define('APP__DB_PASSWORD', 'justified');
  44. define('APP__DB_DATABASE', 'pa');
  45. define('APP__DB_PERSISTENT', false);
  46. define('APP__DB_CLIENT_FLAGS', 2);
  47.  
  48. // Contact info
  49. define('APP__EMAIL_INFO', 'dami2cuteforever@yahoo.com');
  50. define('APP__EMAIL_HELP', 'dami2cuteforever@yahoo.com');
  51. define('APP__EMAIL_TECH', 'dami2cuteforever@yahoo.com');
  52.  
  53. // Includes
  54. define ('DOC__ROOT', 'c:/xampp/htdocs/capat');
  55. require_once(DOC__ROOT.'/library/functions/lib_common.php');
  56. require_once(DOC__ROOT.'/library/classes/class_dao.php');
  57. require_once(DOC__ROOT.'/library/classes/class_user.php');
  58. require_once(DOC__ROOT.'/library/classes/class_cookie.php');
  59. require_once(DOC__ROOT.'/library/classes/class_engcis.php');
  60. require_once(DOC__ROOT.'/include/classes/class_ui2.php');
  61.  
  62.  
  63. //define the authentication to be used
  64. define('AUTH__CLASS', 'DBAuthentication');
  65.  
  66. //LDAP Authentication is 'LDAPAuthenticator' and database authentication is 'DBAuthentication'
  67.  
  68.  
  69. // Old config compatibility
  70. $_config['app_id'] = APP__ID;
  71. $_config['app_www'] = APP__WWW;
  72.  
  73. // Initialisation
  74.  
  75. // Magic quotes workaround
  76. set_magic_quotes_runtime(0);
  77.  
  78. if (get_magic_quotes_gpc()) {
  79. function stripslashes_deep($value) {
  80. return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
  81.  
  82. }
  83. //NW added in request as well
  84. $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
  85.  
  86. $_GET = array_map('stripslashes_deep', $_GET);
  87.  
  88. $_POST = array_map('stripslashes_deep', $_POST);
  89.  
  90. $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
  91.  
  92. }
  93.  
  94. // Initialise DB object
  95.  
  96. $DB = new DAO( APP__DB_HOST, APP__DB_USERNAME, APP__DB_PASSWORD, APP__DB_DATABASE);
  97.  
  98. $DB->set_debug(true);
  99.  
  100.  
  101. // Initialise The EngCIS Handler object
  102.  
  103. $CIS = new EngCIS();
  104.  
  105.  
  106. // Initialise User Object
  107.  
  108. $_user = null;
  109.  
  110.  
  111. // Initialise the cookie
  112. $_cookie = new Cookie();
  113.  
  114.  
  115. // Get info from the session
  116. $_user_id = fetch_SESSION('_user_id', null);
  117.  
  118.  
  119. // If there's no user in the session, but there is in the cookie, use that
  120. if ( (!$_user_id) && ($_cookie->validate()) && (array_key_exists('user_id',$_cookie->vars)) ) {
  121. $_user_id = $_cookie->vars['user_id'];
  122.  
  123. }
  124.  
  125. // If we found a user to load, load 'em!
  126. if ($_user_id){
  127.  
  128. $_user_info = $CIS->get_user($_user_id);
  129.  
  130.  
  131. // Actually create the user object
  132. $_user = new User();
  133.  
  134. $_user->load_from_row($_user_info);
  135.  
  136. $_user_info = null;
  137. // We're done with the data, so clear it
  138.  
  139. // save session data
  140. $_SESSION['_user_id'] = $_user->id;
  141.  
  142.  
  143. // Save cookie data
  144. $_cookie->vars['user_id'] = $_user->id;
  145.  
  146.  
  147. $_cookie->save();
  148.  
  149. }
  150.  
  151. // Initialise UI Object
  152.  
  153. $UI = new UI($_user);
  154.  
  155.  
  156. // Global Functions
  157.  
  158. /**
  159. * Check if the user is logged in and is a user of the given type
  160. * If not, it logs the user out
  161. * @param string $_user
  162. * @param string $user_type
  163. */
  164. function check_user($_user, $user_type = null) {
  165.  
  166. // Is the user valid?
  167. if ($_user) {
  168.  
  169. // if we're not checking the user type, or we are checking and it matches, return OK
  170. if ( (!$user_type) || ($_user->type == $user_type) ) {
  171. return true;
  172.  
  173. }
  174. }else{
  175. return false;
  176.  
  177. }
  178.  
  179.  
  180. // If we didn't call 'return' then the user is denied access
  181.  
  182. // If they tried to access the main index page, assume they haven't logged in and go to the login page directly
  183. if ($_SERVER['PHP_SELF']=='/index.php') {
  184. header('Location: '. APP__WWW .'/login.php');
  185.  
  186. } else { // log them out and give the DENIED message
  187. header('Location:'. APP__WWW .'/logout.php?msg=denied');
  188.  
  189. }
  190. exit;
  191.  
  192. }
  193.  
  194.  
  195. /**
  196.  * Function for the debug print out
  197.  * @param string $var
  198.  */
  199. function debug_print($var) {
  200. echo('<pre>');
  201.  
  202. print_r($var);
  203.  
  204. echo('</pre>');
  205.  
  206. }
  207.  
  208.  
  209. ?>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006
Feb 19th, 2008
0

Re: page loading problem

The question is, do you actually get anything at all or do you just get a white screen? Or does the status bar continually act like it is trying to load for the whole time?

with
PHP Syntax (Toggle Plain Text)
  1. error_reporting(0);
if memory serves me correctly, this command actually turns off all levels of error reporting.
Try commenting that out and then going to your page, you may see where your errors are.

When working with PHP, sometimes it is a good idea to to view the source of the page which is rendered (the outputted html, xhtml or xml). If you see any code there at all, you could look through it to see if perhaps there are some tag close issues or whatever.
I could be off base with the above function, but I think I remember this being the case.
Sage
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
sagedavis is offline Offline
86 posts
since Nov 2007
Feb 19th, 2008
0

Re: page loading problem

Hi dami,

sagedavis is right, error_reporting(0) turns off all error reports, therefore you will not get any errors on that page, instead replace that line with this:

ini_set('error_reporting', E_ALL);

Then load the page, you should see errors then
Reputation Points: 19
Solved Threads: 11
Junior Poster
richie513 is offline Offline
158 posts
since Feb 2008
Feb 20th, 2008
0

Re: page loading problem

Thanks, I got 2 errors. I'm not too sure where the error is because it's not making any sense. The errors are
Notice: Only variable references should be returned by reference in C:\xampp\htdocs\capat\library\classes\class_engcis.php on line 9

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\xampp\htdocs\capat\include\classes\class_ui2.php on line 336

This is the code again that i have adjusted

php Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3. /**
  4.  *
  5.  * Class : UI
  6.  *
  7.  *
  8.  */
  9.  
  10. //include main global file so that the session can be used
  11. function & rel7($struc, &$file) {
  12. return file_exists( ( $file = ( dirname($struc).'/'.$file ) ) );
  13. }
  14.  
  15. function relativetome7($structure, $filetoget){
  16. return rel7($structure,$filetoget) ? require_once($filetoget) : null;
  17. }
  18.  
  19. relativetome7(__FILE__, 'inc_global.php');
  20.  
  21. class UI {
  22. // Public Vars
  23. public $page_title = '';
  24. public $menu_selected = '';
  25. public $breadcrumbs = null;
  26.  
  27. // Private Vars
  28. private $_user = null;
  29. private $_menu = null;
  30. private $_page_bar_buttons = null;
  31.  
  32. /**
  33. * CONSTRUCTOR for the UI
  34. * @param string $_user
  35. */
  36. function UI( $_user = null) {
  37. $this->_user =& $_user;
  38.  
  39. // Initialise the menu - sets either staff or student menu items
  40. if ( ($this->_user) && ($this->_user->is_staff()) ) {
  41. // Staff menu
  42. $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/index.php' ,
  43. 'my forms' => APP__WWW . '/tutors/forms/' ,
  44. 'my groups' => APP__WWW . '/tutors/groups/' ,
  45. 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu()
  46.  
  47. $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu();
  48.  
  49. $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/forms/index.php' ,
  50. 'my forms' => APP__WWW . '/tutors/forms/' ,
  51. 'my groups' => APP__WWW . '/tutors/groups/' ,
  52. 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu()
  53.  
  54. $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu();
  55.  
  56. // Student menu
  57. if ($_SESSION['_student'] == '1'){
  58. $this->set_menu('Students', array ('home' => APP__WWW . '/students/index.php' ,
  59. 'my groups' => APP__WWW . '/students/groups/' ,
  60. 'my assessments' => APP__WWW . '/students/assessments/' ) );// /$this->set_menu()
  61.  
  62. $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu();
  63.  
  64. } else //Admin menu
  65. //if ($_SESSION['_admin'] == '1')
  66. {
  67. $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php',
  68. 'upload data' => APP__WWW . '/admin/load/index.php',
  69. 'review data' => APP__WWW . '/admin/review/index.php'));
  70. }
  71.  
  72.  
  73.  
  74. $this->set_menu(' ', array ('logout' => APP__WWW .'/main_login.php') );// /$this->set_menu();
  75. }// /->UI()
  76.  
  77.  
  78. // --------------------------------------------------------------------------------
  79. // Public Methods
  80.  
  81. /**
  82. * Send the expiry headers.
  83. * Leave $expiry_date empty to force the browser to page refresh
  84. * @param string $expire_date
  85. * @param string $modified_date
  86. */
  87. function headers_expire($expire_date = null, $modified_date = null) {
  88. // If no expiry date, expire at 00:00:01 today
  89. if (!$expire_date) { $expire_date = mktime(0,0,1,date('m'),date('d'),date('Y')); }
  90.  
  91. // If no modified date, modified today
  92. if (!$modified_date) { $modified_date = mktime(); }
  93.  
  94. header('Expires: '. gmdate('D, d M Y H:i:s', $expire_date ) .' GMT');
  95. header('Last-Modified: '. gmdate('D, d M Y H:i:s', $modified_date) .' GMT');
  96. header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  97. header('Cache-Control: post-check=0, pre-check=0', false); // HTTP/1.1
  98. header("Cache-control: private", false);
  99. header('Pragma: no-cache'); // HTTP/1.0
  100. } // /-headers_expire()
  101.  
  102.  
  103. /**
  104. * Function to generate the header
  105. */
  106. function head () {
  107. /*
  108. Commented out until the day IE can show a full XHTML page without entering quirks mode
  109. echo('<?xml version="1.0" encoding="UTF-8"?>'."\n");
  110. */
  111. ?>
  112. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  113. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  114. <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  115. <head>
  116. <meta http-equiv="content-language" content="EN" />
  117. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  118. <link href="<?php echo(APP__WWW) ?>/css/capat.css" media="screen" rel="stylesheet" type="text/css" />
  119. <link href="<?php echo(APP__WWW) ?>/css/capat_print.css" media="print" rel="stylesheet" type="text/css" />
  120. <title><?php echo(APP__NAME ) ?></title>
  121. <?php
  122. } // /->head()
  123.  
  124.  
  125. /**
  126. * function to close the body area of the page
  127. * @param string $extra_attributes
  128. */
  129. function body($extra_attributes = '') {
  130. echo("\n</head>\n<body $extra_attributes>\n\n");
  131.  
  132. } // /->body()
  133.  
  134.  
  135. /**
  136. * render page header
  137. */
  138. function header() {
  139. ?>
  140. <div id="header">
  141. <div id="app_bar">
  142. <table cellpadding="0" cellspacing="0" width="100%">
  143. <tr>
  144. <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>
  145. <?php
  146. if ($this->_user) {
  147. echo("<td>{$this->_user->forename} {$this->_user->surname}</td>");
  148. } else {
  149. echo('<td>&nbsp;</td>');
  150. }
  151. ?>
  152. </tr>
  153. </table>
  154. </div>
  155. <div id="breadcrumb_bar">
  156. You are in: <?php
  157. if (is_array($this->breadcrumbs)) {
  158. $num_crumbs = count($this->breadcrumbs);
  159. foreach( $this->breadcrumbs as $k => $v ) {
  160. --$num_crumbs;
  161. if (!is_null($v)) {
  162. echo("<a class=\"breadcrumb\" href=\"$v\">$k</a>");
  163. if ($num_crumbs>0) { echo(' &gt; '); }
  164. } else { echo($k); }
  165. }
  166. }
  167. ?>
  168. </div>
  169. </div>
  170. <?php
  171. }// /->header()
  172.  
  173.  
  174. /**
  175. * Set the given section name to the given assoc-array of links
  176. * Does NO checking of $section_array
  177. * @param string $section_name
  178. * @param array $section_array
  179. */
  180. function set_menu($section_name, $section_array) {
  181. $this->_menu["$section_name"] = $section_array;
  182. }
  183.  
  184. /**
  185. * Draw the menu
  186. */
  187. function menu() {
  188. // If there's a menu, draw it
  189. if ($this->_menu) {
  190. $menu_html = '<div id="menu">';
  191.  
  192. foreach($this->_menu as $menu_section => $menu_links) {
  193. $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">';
  194.  
  195. foreach($menu_links as $menu_name => $menu_link ) {
  196. $link_class = ($this->menu_selected == $menu_name) ? 'menu_selected' : 'menu';
  197. $menu_html .= '<li><a class="'. $link_class .'" href="'. $menu_link .'">'. $menu_name .'</a></li>';
  198. }// /for
  199.  
  200. $menu_html .= '</ul></div>';
  201. }// /for
  202.  
  203. $menu_html .= '</div>';
  204. echo($menu_html);
  205. }
  206. }// /->menu()
  207.  
  208.  
  209. /**
  210. * Set a page bar button
  211. * @param string $text
  212. * @param string $img
  213. * @param string $link
  214. * @param string $side
  215. */
  216. function set_page_bar_button($text, $img, $link, $side = 'left') {
  217. $this->_page_bar_buttons[$side][$text] = array ('img' => "../images/buttons/$img", 'link' => $link);
  218. }// /->set_page_bar_button()
  219.  
  220.  
  221. /**
  222. * Draw the page toolbar
  223. */
  224. function page_bar() {
  225. if (is_array($this->_page_bar_buttons)) {
  226. ?>
  227. <div id="page_bar">
  228. <table cellpadding="0" cellspacing="0">
  229. <tr>
  230. <?php
  231. if (array_key_exists('left',$this->_page_bar_buttons)) {
  232. foreach($this->_page_bar_buttons['left'] as $text => $button) {
  233. echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>");
  234. }
  235. }
  236. ?>
  237. <td width="100%">&nbsp;</td>
  238. <?php
  239. // right-hand buttons are automatically set to target="_blank"
  240. if (array_key_exists('right',$this->_page_bar_buttons)) {
  241. foreach($this->_page_bar_buttons['right'] as $text => $button) {
  242. echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" target=\"$text\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>");
  243. }
  244. }
  245. ?>
  246. </tr>
  247. </table>
  248. </div>
  249. <?php
  250. }
  251. }// /->page_bar()
  252.  
  253.  
  254. /**
  255. * Footer
  256. */
  257. function footer() {
  258. ?>
  259. <div id="footer">
  260. <div style="float: right;">
  261. </div>
  262.  
  263.  
  264. <iframe src="/keep_alive.php" height="1" width="1" style="display: none;">keep alive</iframe>
  265. </div>
  266. <?php
  267. }// /->footer()
  268.  
  269.  
  270. /**
  271. * Start main page content
  272. */
  273. function content_start() {
  274. echo('<div id="main">');
  275. $this->page_bar();
  276. echo('<div id="content">');
  277. if ($this->page_title) { echo("<h1>{$this->page_title}</h1>\n\n"); }
  278. }// /content_start()
  279.  
  280.  
  281. /**
  282. * End main page content
  283. * @param boolean $render_menu
  284. * @param boolean $render_header
  285. * @param boolean $renders_footer
  286. */
  287. function content_end($render_menu = true, $render_header = true, $render_footer = true) {
  288. ?>
  289. </div>
  290. </div>
  291.  
  292. <div id="side_bar">
  293. <?php
  294. if ($render_menu) {
  295. $this->menu();
  296. ?>
  297. <?php
  298. } else {
  299. ?>
  300. <?php
  301. }
  302. ?>
  303. </div>
  304. <?php
  305. if ($render_header) { $this->header(); }
  306. if ($render_footer) { $this->footer(); }
  307. ?>
  308. </body>
  309. </html>
  310. <?php
  311. }// /content_end()
  312.  
  313.  
  314. /**
  315. * function to draw the boxed list
  316. * @param string $list
  317. * @param string $box_class
  318. * @param string $header_text
  319. * @param string $footer_text
  320. */
  321. function draw_boxed_list($list, $box_class, $header_text, $footer_text) {
  322. if (is_array($list)) {
  323. echo("<div class=\"$box_class\"><p style=\"font-weight: bold;\">$header_text</p><ul class=\"spaced\">");
  324. foreach($list as $item) { echo("<li>$item</li>"); }
  325. echo("</ul><p>$footer_text</p></div>");
  326. }
  327. }// ->draw_boxed_list()
  328.  
  329.  
  330. // --------------------------------------------------------------------------------
  331. // Private Methods
  332.  
  333. }// /class: UI
  334.  
  335.  
  336. ?>
  337.  
  338.  
  339. ?>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006
Feb 20th, 2008
0

Re: page loading problem

you have 2 ?> in the end of the line.Try to comment out that is in line 336.
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Feb 20th, 2008
0

Re: page loading problem

still giving me the same error
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006
Feb 20th, 2008
0

Re: page loading problem

Notices can be ignored. Notices can be turned off by changing the error_reporting setting in your php.ini.
Anyway, as ryan_vietnow has already mentioned, there are 2 ?>. And then, the } for the class UI is missing.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Feb 20th, 2008
0

Re: page loading problem

ok now im having another error. It's giving me this:
references should be returned by reference in C:\xampp\htdocs\capat\include\classes\class_ui2.php on line 12

this is the code for it but i can't still find anything wrong

class_ui2.php
php Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3. /**
  4.  *
  5.  * Class : UI
  6.  *
  7.  *
  8.  */
  9.  
  10. //include main global file so that the session can be used
  11. function & rel7($struc, &$file) {
  12. return file_exists( ( $file = ( dirname($struc).'/'.$file ) ) );
  13. }
  14.  
  15. function relativetome7($structure, $filetoget){
  16. return rel7($structure,$filetoget) ? require_once($filetoget) : null;
  17. }
  18.  
  19. relativetome7(__FILE__, 'inc_global.php');
  20.  
  21. class UI {
  22. // Public Vars
  23. public $page_title = '';
  24. public $menu_selected = '';
  25. public $breadcrumbs = null;
  26.  
  27. // Private Vars
  28. private $_user = null;
  29. private $_menu = null;
  30. private $_page_bar_buttons = null;
  31.  
  32. /**
  33. * CONSTRUCTOR for the UI
  34. * @param string $_user
  35. */
  36. function UI( $_user = null) {
  37. $this->_user =& $_user;
  38.  
  39. // Initialise the menu - sets either staff or student menu items
  40. if ( ($this->_user) && ($this->_user->is_staff()) ) {
  41. // Staff menu
  42. $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/index.php' ,
  43. 'my forms' => APP__WWW . '/tutors/forms/' ,
  44. 'my groups' => APP__WWW . '/tutors/groups/' ,
  45. 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu()
  46.  
  47. $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu();
  48.  
  49. $this->set_menu('Tutors', array ('home' => APP__WWW . '/tutors/forms/index.php' ,
  50. 'my forms' => APP__WWW . '/tutors/forms/' ,
  51. 'my groups' => APP__WWW . '/tutors/groups/' ,
  52. 'my assessments' => APP__WWW . '/tutors/assessments/' ,) );// /$this->set_menu()
  53.  
  54. $this->set_menu('Support', array ('contact' => APP__WWW . '/contact/') );// /$this->set_menu();
  55.  
  56. //Admin menu
  57. if ($_SESSION['_admin'] == '1'){
  58. $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php',
  59. 'upload data' => APP__WWW . '/admin/load/index.php',
  60. 'review data' => APP__WWW . '/admin/review/index.php'));
  61. }
  62. } else {
  63.  
  64. // ======= start
  65. //Admin menu
  66. {
  67. $this->set_menu('Admin', array('home' => APP__WWW .'/admin/index.php',
  68. 'upload data' => APP__WWW . '/admin/load/index.php',
  69. 'review data' => APP__WWW . '/admin/review/index.php'));
  70. }
  71.  
  72.  
  73.  
  74. //=======end
  75. }
  76.  
  77.  
  78. $this->set_menu(' ', array ('logout' => APP__WWW .'/main_login.php') );// /$this->set_menu();
  79. }// /->UI()
  80.  
  81.  
  82. // --------------------------------------------------------------------------------
  83. // Public Methods
  84.  
  85. /**
  86. * Send the expiry headers.
  87. * Leave $expiry_date empty to force the browser to page refresh
  88. * @param string $expire_date
  89. * @param string $modified_date
  90. */
  91. function headers_expire($expire_date = null, $modified_date = null) {
  92. // If no expiry date, expire at 00:00:01 today
  93. if (!$expire_date) { $expire_date = mktime(0,0,1,date('m'),date('d'),date('Y')); }
  94.  
  95. // If no modified date, modified today
  96. if (!$modified_date) { $modified_date = mktime(); }
  97.  
  98. header('Expires: '. gmdate('D, d M Y H:i:s', $expire_date ) .' GMT');
  99. header('Last-Modified: '. gmdate('D, d M Y H:i:s', $modified_date) .' GMT');
  100. header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  101. header('Cache-Control: post-check=0, pre-check=0', false); // HTTP/1.1
  102. header("Cache-control: private", false);
  103. header('Pragma: no-cache'); // HTTP/1.0
  104. } // /-headers_expire()
  105.  
  106.  
  107. /**
  108. * Function to generate the header
  109. */
  110. function head () {
  111. /*
  112. Commented out until the day IE can show a full XHTML page without entering quirks mode
  113. echo('<?xml version="1.0" encoding="UTF-8"?>'."\n");
  114. */
  115. ?>
  116. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  117. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  118. <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  119. <head>
  120. <meta http-equiv="content-language" content="EN" />
  121. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  122. <link href="<?php echo(APP__WWW) ?>/css/capat.css" media="screen" rel="stylesheet" type="text/css" />
  123. <link href="<?php echo(APP__WWW) ?>/css/capat_print.css" media="print" rel="stylesheet" type="text/css" />
  124. <title><?php echo(APP__NAME ) ?></title>
  125. <?php
  126. } // /->head()
  127.  
  128.  
  129. /**
  130. * function to close the body area of the page
  131. * @param string $extra_attributes
  132. */
  133. function body($extra_attributes = '') {
  134. echo("\n</head>\n<body $extra_attributes>\n\n");
  135.  
  136. } // /->body()
  137.  
  138.  
  139. /**
  140. * render page header
  141. */
  142. function header() {
  143. ?>
  144. <div id="header">
  145. <div id="app_bar">
  146. <table cellpadding="0" cellspacing="0" width="100%">
  147. <tr>
  148. <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>
  149. <?php
  150. if ($this->_user) {
  151. echo("<td>{$this->_user->forename} {$this->_user->surname}</td>");
  152. } else {
  153. echo('<td>&nbsp;</td>');
  154. }
  155. ?>
  156. </tr>
  157. </table>
  158. </div>
  159. <div id="breadcrumb_bar">
  160. You are in: <?php
  161. if (is_array($this->breadcrumbs)) {
  162. $num_crumbs = count($this->breadcrumbs);
  163. foreach( $this->breadcrumbs as $k => $v ) {
  164. --$num_crumbs;
  165. if (!is_null($v)) {
  166. echo("<a class=\"breadcrumb\" href=\"$v\">$k</a>");
  167. if ($num_crumbs>0) { echo(' &gt; '); }
  168. } else { echo($k); }
  169. }
  170. }
  171. ?>
  172. </div>
  173. </div>
  174. <?php
  175. }// /->header()
  176.  
  177.  
  178. /**
  179. * Set the given section name to the given assoc-array of links
  180. * Does NO checking of $section_array
  181. * @param string $section_name
  182. * @param array $section_array
  183. */
  184. function set_menu($section_name, $section_array) {
  185. $this->_menu["$section_name"] = $section_array;
  186. }
  187.  
  188. /**
  189. * Draw the menu
  190. */
  191. function menu() {
  192. // If there's a menu, draw it
  193. if ($this->_menu) {
  194. $menu_html = '<div id="menu">';
  195.  
  196. foreach($this->_menu as $menu_section => $menu_links) {
  197. $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">';
  198.  
  199. foreach($menu_links as $menu_name => $menu_link ) {
  200. $link_class = ($this->menu_selected == $menu_name) ? 'menu_selected' : 'menu';
  201. $menu_html .= '<li><a class="'. $link_class .'" href="'. $menu_link .'">'. $menu_name .'</a></li>';
  202. }// /for
  203.  
  204. $menu_html .= '</ul></div>';
  205. }// /for
  206.  
  207. $menu_html .= '</div>';
  208. echo($menu_html);
  209. }
  210. }// /->menu()
  211.  
  212.  
  213. /**
  214. * Set a page bar button
  215. * @param string $text
  216. * @param string $img
  217. * @param string $link
  218. * @param string $side
  219. */
  220. function set_page_bar_button($text, $img, $link, $side = 'left') {
  221. $this->_page_bar_buttons[$side][$text] = array ('img' => "../images/buttons/$img", 'link' => $link);
  222. }// /->set_page_bar_button()
  223.  
  224.  
  225. /**
  226. * Draw the page toolbar
  227. */
  228. function page_bar() {
  229. if (is_array($this->_page_bar_buttons)) {
  230. ?>
  231. <div id="page_bar">
  232. <table cellpadding="0" cellspacing="0">
  233. <tr>
  234. <?php
  235. if (array_key_exists('left',$this->_page_bar_buttons)) {
  236. foreach($this->_page_bar_buttons['left'] as $text => $button) {
  237. echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>");
  238. }
  239. }
  240. ?>
  241. <td width="100%">&nbsp;</td>
  242. <?php
  243. // right-hand buttons are automatically set to target="_blank"
  244. if (array_key_exists('right',$this->_page_bar_buttons)) {
  245. foreach($this->_page_bar_buttons['right'] as $text => $button) {
  246. echo("<td><a class=\"page_bar_link\" href=\"{$button['link']}\" target=\"$text\" title=\"$text\"><img src=\"{$button['img']}\" alt=\"$text\" height=\"50\" /></a></td>");
  247. }
  248. }
  249. ?>
  250. </tr>
  251. </table>
  252. </div>
  253. <?php
  254. }
  255. }// /->page_bar()
  256.  
  257.  
  258. /**
  259. * Footer
  260. */
  261. function footer() {
  262. ?>
  263. <div id="footer">
  264. <div style="float: right;">
  265. </div>
  266.  
  267.  
  268. <iframe src="/keep_alive.php" height="1" width="1" style="display: none;">keep alive</iframe>
  269. </div>
  270. <?php
  271. }// /->footer()
  272.  
  273.  
  274. /**
  275. * Start main page content
  276. */
  277. function content_start() {
  278. echo('<div id="main">');
  279. $this->page_bar();
  280. echo('<div id="content">');
  281. if ($this->page_title) { echo("<h1>{$this->page_title}</h1>\n\n"); }
  282. }// /content_start()
  283.  
  284.  
  285. /**
  286. * End main page content
  287. * @param boolean $render_menu
  288. * @param boolean $render_header
  289. * @param boolean $renders_footer
  290. */
  291. function content_end($render_menu = true, $render_header = true, $render_footer = true) {
  292. ?>
  293. </div>
  294. </div>
  295.  
  296. <div id="side_bar">
  297. <?php
  298. if ($render_menu) {
  299. $this->menu();
  300. ?>
  301. <?php
  302. } else {
  303. ?>
  304. <?php
  305. }
  306. ?>
  307. </div>
  308. <?php
  309. if ($render_header) { $this->header(); }
  310. if ($render_footer) { $this->footer(); }
  311. ?>
  312. </body>
  313. </html>
  314. <?php
  315. }// /content_end()
  316.  
  317.  
  318. /**
  319. * function to draw the boxed list
  320. * @param string $list
  321. * @param string $box_class
  322. * @param string $header_text
  323. * @param string $footer_text
  324. */
  325. function draw_boxed_list($list, $box_class, $header_text, $footer_text) {
  326. if (is_array($list)) {
  327. echo("<div class=\"$box_class\"><p style=\"font-weight: bold;\">$header_text</p><ul class=\"spaced\">");
  328. foreach($list as $item) { echo("<li>$item</li>"); }
  329. echo("</ul><p>$footer_text</p></div>");
  330. }
  331. }// ->draw_boxed_list()
  332.  
  333.  
  334. // --------------------------------------------------------------------------------
  335. // Private Methods
  336.  
  337. }// /class: UI
  338.  
  339.  
  340. ?>
  341.  
  342.  
  343. ?>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Getting Username from login from
Next Thread in PHP Forum Timeline: phpmyadmin issue





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC