index.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // Begin dispatch
  15. $args = ( $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET );
  16. if( !empty($args['app']) && $args['app'] == 'login' ) {
  17. include "$themedir/admin/login.inc";
  18. die();
  19. } elseif( !empty($args['app']) && $args['app'] == 'logout' ) {
  20. include "$themedir/admin/logout.inc";
  21. die();
  22. } else {
  23. require_once "tCMS/Auth.inc";
  24. $auth = new Auth;
  25. $auth->ensure_auth();
  26. }
  27. if( empty($args['app']) || $args['app'] == 'config' ) {
  28. $kontent = "$themedir/admin/settings.inc";
  29. } elseif ($args['app'] == 'blog') {
  30. $kontent = "$themedir/admin/bengine.inc";
  31. } elseif ($args['app'] == 'microblog') {
  32. $kontent = "$themedir/admin/mbengine.inc";
  33. } elseif ($args['app'] == 'users' ) {
  34. $kontent = "$themedir/admin/users.inc";
  35. } else {
  36. $kontent = "$themedir/admin/settings.inc";
  37. }
  38. ?>
  39. <!doctype html>
  40. <html dir="ltr" lang="en-US">
  41. <head>
  42. <meta charset="utf-8" />
  43. <meta name="description" content="tCMS Control Panel"/>
  44. <meta name="viewport" content="width=device-width">
  45. <?php
  46. $links = '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/structure.css" />';
  47. $links .= '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/screen.css" media="screen" />';
  48. $links .= '<link rel="stylesheet" type="text/css" href="../../themed/' . $theme . '/css/print.css" media="print" />';
  49. $links .= '<link rel="icon" type="image/vnd.microsoft.icon" href="../../themed/' . $theme . '/img/icon/favicon.ico" />';
  50. echo $links;
  51. // TODO inject avatars these via style tags based on config
  52. ?>
  53. <title>tCMS Admin</title>
  54. <?php
  55. ?>
  56. </head>
  57. <body>
  58. <div id="topkek" style="text-align: center; vertical-align: middle;">
  59. <button title="Menu" id="clickme">&#9776;</button>
  60. <span id="configbar">
  61. <a class="topbar" title="Edit Various Settings" href="index.php?app=config">Settings</a>
  62. <a class="topbar" title="Blog Writer" href="index.php?app=blog">Blog Writer</a>
  63. <a class="topbar" title="Pop off about Stuff" href="index.php?app=microblog">MicroBlogger</a>
  64. <a class="topbar" title="Logout" href="index.php?app=logout">Logout</a>
  65. </span>
  66. </div>
  67. <div id="kontent" style="display: block;">
  68. <?php
  69. include $kontent;
  70. ?>
  71. </div>
  72. </body>
  73. </html>