index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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'] : "$docroot/sys/blogroll.inc" );
  44. $destinations = [
  45. $config['home'], "$docroot/sys/fileshare/showfiles.inc", "$docroot/sys/microblog.inc",
  46. "$docroot/sys/blogroll.inc", "$docroot/sys/fileshare/showpost.inc", "$docroot/sys/fileshare/showcode.inc",
  47. "$docroot/sys/fileshare/showaudio.inc", "$docroot/sys/fileshare/showvideo.inc", "$docroot/sys/fileshare/showimg.inc",
  48. "$docroot/sys/fileshare/showdoc.inc",
  49. ];
  50. if ( empty($nav) ) $nav = 0;
  51. if ( $nav === 1 || $nav > 4 ) {
  52. $pwd = $post;
  53. include 'sys/fileshare/sanitize.inc';
  54. }
  55. //Main Content Display Frame goes below
  56. include $destinations[$nav];
  57. ?>
  58. </div>
  59. <div id="rightbar" class="kontained">
  60. <?php
  61. include "$themedir/rightbar.inc";
  62. ?>
  63. </div>
  64. </div>
  65. <div id="footbar">
  66. <?php
  67. include "$themedir/footbar.inc";
  68. ?>
  69. </div>
  70. </body>
  71. </html>