index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. $args = ( $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET );
  3. $user_info = posix_getpwuid(posix_geteuid());
  4. // Probably the 'sanest' default I could think of when you have no homedir
  5. $dir = ( $user_info['dir'] ? $user_info['dir'] : '/var/www/' );
  6. $basedir = ( file_exists( $dir . "/.tCMS_basedir") ? file_get_contents("$dir/.tCMS_basedir") : "$dir/.tCMS" );
  7. if( !empty($args['app']) && $args['app'] == 'login' ) {
  8. include("login.inc");
  9. die();
  10. } elseif( !empty($args['app']) && $args['app'] == 'logout' ) {
  11. include("logout.inc");
  12. die();
  13. } else {
  14. include_once("$basedir/lib/auth.inc");
  15. $auth = new auth;
  16. $auth->ensure_auth();
  17. }
  18. if( empty($args['app']) || $args['app'] == 'config' ) {
  19. $kontent = "settings.inc";
  20. } elseif ($args['app'] == 'blog') {
  21. $kontent = "bengine.inc";
  22. } elseif ($args['app'] == 'microblog') {
  23. $kontent = "mbengine.inc";
  24. } elseif ($args['app'] == 'users' ) {
  25. $kontent = "users.inc";
  26. } else {
  27. $kontent = "settings.inc";
  28. }
  29. ?>
  30. <!doctype html>
  31. <html dir="ltr" lang="en-US">
  32. <head>
  33. <meta charset="utf-8" />
  34. <meta name="description" content="tCMS Control Panel"/>
  35. <meta name="viewport" content="width=device-width">
  36. <link rel="stylesheet" type="text/css" href="../../css/structure.css" />
  37. <link rel="stylesheet" type="text/css" href="../../css/screen.css" media="screen" />
  38. <link rel="stylesheet" type="text/css" href="../../css/print.css" media="print" />
  39. <?php
  40. if(file_exists('../../css/custom/avatars.css')) {
  41. echo '<link rel="stylesheet" type="text/css" href="../../css/custom/avatars.css" />';
  42. } else {
  43. echo '<link rel="stylesheet" type="text/css" href="../../css/avatars.css" />';
  44. }
  45. ?>
  46. <link rel="icon" type="image/vnd.microsoft.icon" href="../../img/icon/favicon.ico" />
  47. <title>tCMS Admin</title>
  48. <?php
  49. $config = @json_decode(@file_get_contents("$basedir/config/main.json"),true);
  50. ?>
  51. </head>
  52. <body>
  53. <div id="topkek" style="text-align: center; vertical-align: middle;">
  54. <button title="Menu" id="clickme">&#9776;</button>
  55. <span id="configbar">
  56. <a class="topbar" title="Edit Various Settings" href="index.php?app=config">Settings</a>
  57. <a class="topbar" title="Blog Writer" href="index.php?app=blog">Blog Writer</a>
  58. <a class="topbar" title="Pop off about Stuff" href="index.php?app=microblog">MicroBlogger</a>
  59. <a class="topbar" title="Logout" href="index.php?app=logout">Logout</a>
  60. </span>
  61. </div>
  62. <div id="kontent" style="display: block;">
  63. <?php
  64. include $kontent;
  65. ?>
  66. </div>
  67. </body>
  68. </html>