PHP: Typical Index Page


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. /**************************************
  3.  seesaw associates | http://seesaw.net
  4.  
  5.  client:
  6.  file: index.php
  7.  description: main handler
  8.  
  9.  Copyright (C) 2008 Matt Kenefick(.com)
  10. **************************************/
  11.  
  12.  
  13. ###################
  14. ## BASIC CONFIGS ##
  15. ###################
  16.  
  17. //start session
  18. session_cache_expire(1140); // 24 hours
  19. session_name("Client");
  20.  
  21.  
  22.  
  23. // turn of pages cache
  24. header("Cache-control: private, no-cache");
  25. header("Expires: Mon, 26 Jun 1997 05:00:00 GMT");
  26. header("Pragma: no-cache");
  27. header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
  28. header("Content-Type: text/html");
  29.  
  30. // main configuration
  31. require_once("includes/functions.php");
  32.  
  33. // load mysql etc libraries
  34. require_once("includes/classes/class.mysql.php");
  35. require_once("smarty/Smarty.class.php");
  36.  
  37.  
  38. ###################################
  39. ## CREATE MYSQL CONN / VALIDATOR ##
  40. ###################################
  41.  
  42. $db = new DB;
  43. $db->init('localhost', 'user', 'pass', 'database');
  44. $db->settings('fixSlashes',true);
  45.  
  46.  
  47. # CHECK SESSIONS / SETTINGS
  48.  
  49. require_once("includes/settings.php");
  50.  
  51.  
  52. ########################
  53. ## CHECK CURRENT PAGE ##
  54. ########################
  55.  
  56. $smarty = new Smarty;
  57.  
  58. $smarty->template_dir = "./includes/skin/";
  59. $smarty->compile_dir = "./includes/skincache/";
  60. $smarty->debugging = false;
  61. $smarty->use_sub_dirs = false;
  62.  
  63. // get page
  64. $p = isset($_REQUEST['p'])?$_REQUEST['p']:'home';
  65.  
  66. // get support
  67. if( file_exists('includes/public/page.'.$p.'.php') )
  68. require_once('includes/public/page.'.$p.'.php');
  69.  
  70. $smarty->display('index.html');
  71.  
  72. $db->done();
  73.  
  74. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.