index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // Setup includes to work right. Much of this is duped in Config.inc, but gotta get this info to include it, so..
  3. $user_info = posix_getpwuid(posix_geteuid());
  4. $dir = ( $user_info['dir'] ? $user_info['dir'] : '/var/www/' );
  5. $basedir = ( file_exists( $dir . "/.tCMS_basedir") ? file_get_contents("$dir/.tCMS_basedir") : "$dir/.tCMS" );
  6. set_include_path(get_include_path() . PATH_SEPARATOR . "$basedir/lib");
  7. require_once "tCMS/Config.inc";
  8. // Get the config, set the theme (also set the basedir so we don't have to fetch it again).
  9. $conf_obj = new Config;
  10. $conf_obj->set_base_dir($basedir);
  11. $config = $conf_obj->get();
  12. $theme = ( !array_key_exists( 'theme', $config ) || empty($config['theme']) ? 'default' : $config['theme'] );
  13. $themedir = "$basedir/templates/$theme";
  14. if(empty($config)) {
  15. # XXX Need to have manual be hosted in repo under sys/admin/manual
  16. include( "$themedir/notconfigured.tmpl" );
  17. die();
  18. }
  19. $docroot = realpath( __DIR__ );
  20. $nav = ( !empty($_GET['nav'] ) ) ? $_GET['nav'] : '';
  21. $post = ( !empty($_GET['post'] ) ) ? $_GET['post'] : '';
  22. // Not sure if I'll ever really even need to localize (see html tag attrs).
  23. ?>
  24. <!doctype html>
  25. <html dir="ltr" lang="en-US">
  26. <?php include "$themedir/header.tmpl"; ?>
  27. <body>
  28. <div id="topkek">
  29. <?php
  30. //Site's Titlebar comes in here
  31. include "$themedir/nav.inc";
  32. ?>
  33. </div>
  34. <div id="littlemenu">
  35. </div>
  36. <div id="kontainer">
  37. <div id="leftbar" class="kontained">
  38. <?php include "$themedir/leftbar.inc"; ?>
  39. </div>
  40. <div id="kontent" class="kontained">
  41. <?php
  42. // Home should refer to a template.
  43. $home = ( array_key_exists( 'home', $config ) && !empty($config['home']) ? $config['home'] : "blog" );
  44. $home_map = [ 'blog' => 3, 'microblog' => 2, 'fileshare' => 1 ];
  45. $destinations = [
  46. $config['home'], "$docroot/sys/fileshare/showfiles.inc", "$docroot/sys/microblog.inc",
  47. "$docroot/sys/blogroll.inc", "$docroot/sys/fileshare/showpost.inc", "$docroot/sys/fileshare/showcode.inc",
  48. "$docroot/sys/fileshare/showaudio.inc", "$docroot/sys/fileshare/showvideo.inc", "$docroot/sys/fileshare/showimg.inc",
  49. "$docroot/sys/fileshare/showdoc.inc",
  50. ];
  51. if ( empty($nav) || $nav == 0 ) {
  52. $nav = $home_map[$home];
  53. }
  54. if ( $nav === 1 || $nav > 4 ) {
  55. $pwd = $post;
  56. include 'sys/fileshare/sanitize.inc';
  57. }
  58. //Main Content Display Frame goes below
  59. include $destinations[$nav];
  60. ?>
  61. </div>
  62. <div id="rightbar" class="kontained">
  63. <?php
  64. include "$themedir/rightbar.inc";
  65. ?>
  66. </div>
  67. </div>
  68. <div id="footbar">
  69. <?php
  70. include "$themedir/footbar.inc";
  71. ?>
  72. </div>
  73. </body>
  74. </html>