index.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. # Get protocol bits, etc.
  3. $protocol = ( !empty($_SERVER["HTTPS"] ) ) ? 'https' : 'http';
  4. $nav = ( !empty($_GET['nav'] ) ) ? $_GET['nav'] : '';
  5. $post = ( !empty($_GET['post'] ) ) ? $_GET['post'] : '';
  6. # DOCUMENT_ROOT can be misconfigured, __FILE__, __DIR__, etc. can't be
  7. $docroot = realpath( __DIR__ );
  8. # Grab the main configuration file. We need to see where that lives first though.
  9. if( file_exists( "$docroot/basedir" ) ) {
  10. $fh = fopen( "$docroot/basedir" );
  11. $basedir = trim(fgets( $fh )); # I only want the first line
  12. fclose($fh);
  13. }
  14. if( empty( $basedir ) ) {
  15. $basedir = posix_getpwuid(posix_geteuid())['dir'] . "/.tCMS";
  16. }
  17. if(!file_exists("$basedir/conf/main.json")) {
  18. # XXX Need to have manual be hosted in repo under sys/admin/manual
  19. include( "$basedir/templates/default/notconfigured.tmpl" );
  20. die();
  21. }
  22. $config = json_decode(file_get_contents("$basedir/conf/main.json"),true);
  23. // Not sure if I'll ever really even need to localize (see html tag attrs).
  24. ?>
  25. <!doctype html>
  26. <html dir="ltr" lang="en-US">
  27. <?php include("$basedir/templates/" . $config['theme'] . "/header.tmpl"); ?>
  28. <body>
  29. <div id="topkek">
  30. <?php
  31. //Site's Titlebar comes in here
  32. include("$basedir/templates/" . $config['theme'] . "/nav.inc");
  33. ?>
  34. </div>
  35. <div id="littlemenu">
  36. </div>
  37. <div id="kontainer">
  38. <div id="leftbar" class="kontained">
  39. <?php include $config['leftbar']; ?>
  40. </div>
  41. <div id="kontent" class="kontained">
  42. <?php
  43. //XXX fileshare, etc. shouldn't be a config value. Home should refer to a template.
  44. $destinations = [
  45. $config['home'], $config['fileshare'], $config['microblog'], $config['blog'], $config['postloader'],
  46. $config['codeloader'], $config['audioloader'], $config['videoloader'], $config['imgloader'],
  47. $config['docloader']
  48. ];
  49. if ( empty($nav) ) $nav = 0;
  50. if ( $nav === 1 || $nav > 4 ) {
  51. $pwd = $post;
  52. include 'sys/fileshare/sanitize.inc';
  53. }
  54. //Main Content Display Frame goes below
  55. include $destinations[$nav];
  56. ?>
  57. </div>
  58. <div id="rightbar" class="kontained">
  59. <?php
  60. include $config['rightbar'];
  61. ?>
  62. </div>
  63. </div>
  64. <div id="footbar">
  65. <?php
  66. include $config['footbar'];
  67. ?>
  68. </div>
  69. </body>
  70. </html>