index.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. set_include_path(get_include_path() . PATH_SEPARATOR .
  3. dirname(__FILE__) ."/include");
  4. require_once "functions.php";
  5. require_once "sessions.php";
  6. require_once "sanity_check.php";
  7. require_once "version.php";
  8. require_once "config.php";
  9. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  10. init_connection($link);
  11. login_sequence($link);
  12. header('Content-Type: text/html; charset=utf-8');
  13. $user_theme = get_user_theme_path($link);
  14. ?>
  15. <!DOCTYPE html>
  16. <head>
  17. <title>Tiny Tiny IRC</title>
  18. <?php stylesheet_tag("tt-irc.css") ?>
  19. <?php stylesheet_tag("lib/bootstrap/bootstrap.min.css") ?>
  20. <?php if (file_exists("local.css")) stylesheet_tag("local.css") ?>
  21. <?php if (!$user_theme && file_exists("local_notheme.css"))
  22. stylesheet_tag("local_notheme.css") ?>
  23. <link id="favicon" rel="shortcut icon" type="image/png" href="images/favicon.png" />
  24. <link rel="icon" type="image/png" sizes="72x72"
  25. href="images/icon-hires.png" />
  26. <?php
  27. foreach (array("lib/prototype.js",
  28. "lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls",
  29. "lib/knockout.js") as $jsfile) {
  30. javascript_tag($jsfile);
  31. } ?>
  32. <?php if (file_exists("local.js")) javascript_tag("local.js") ?>
  33. <script type="text/javascript">
  34. var _user_theme = "<?php echo $user_theme ?>";
  35. <?php
  36. init_js_translations();
  37. print get_minified_js(array("tt-irc",
  38. "functions", "prefs", "users"));
  39. ?>
  40. </script>
  41. <?php
  42. if ($user_theme) {
  43. stylesheet_tag("$user_theme/theme.css");
  44. if (file_exists("$user_theme/theme.js"))
  45. javascript_tag("$user_theme/theme.js");
  46. }
  47. ?>
  48. <?php print_user_css($link); ?>
  49. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  50. <script type="text/javascript">
  51. Event.observe(window, 'load', function() {
  52. init();
  53. });
  54. Event.observe(window, 'focus', function() {
  55. set_window_active(true);
  56. });
  57. Event.observe(window, 'blur', function() {
  58. set_window_active(false);
  59. });
  60. </script>
  61. </head>
  62. <body class="main" user-theme="<?php echo $user_theme ?>">
  63. <div id="overlay" style="display : block">
  64. <div id="overlay_inner">
  65. <?php echo __("Loading, please wait...") ?>
  66. <div id="l_progress_o">
  67. <div id="l_progress_i"></div>
  68. </div>
  69. <noscript>
  70. <p><?php print_error(__("Your browser doesn't support Javascript, which is required
  71. for this application to function properly. Please check your
  72. browser settings.")) ?></p>
  73. </noscript>
  74. </div>
  75. </div>
  76. <div id="errorBox" class="modal" style="display : none">
  77. <div class="modal-header"><?php echo __('Fatal Exception') ?></div>
  78. <div id="errorBody" class="modal-body">&nbsp;</div>
  79. <div class="modal-footer">
  80. <button class="btn btn-primary" onclick="window.location.reload()">
  81. <?php echo __('Try again') ?></button>
  82. </div>
  83. </div>
  84. <div style="display : none" class="modal" id="infoBox">&nbsp;</div>
  85. <div id="main">
  86. <div id="header">
  87. <img id="spinner" style="display : none"
  88. alt="spinner" title="Loading..."
  89. src="<?php echo theme_image($link, 'images/indicator_tiny.gif') ?>"/>
  90. <img id="net-alert" style="display : none"
  91. title="<?php echo __("Communication problem with the server.") ?>"
  92. src="<?php echo theme_image($link, 'images/alert.png') ?>"/>
  93. <?php if (!SINGLE_USER_MODE) { ?>
  94. <span class="hello"><?php echo __('Hello,') ?> <b><?php echo $_SESSION["name"] ?></b></span> |
  95. <?php } ?>
  96. <a href="#" onclick="show_prefs()"><?php echo __('Preferences') ?></a>
  97. <?php if ($_SESSION["access_level"] >= 10) { ?>
  98. | <a href="#" onclick="show_users()"><?php echo __('Users') ?></a>
  99. <?php } ?>
  100. | <a href="#" onclick="join_channel()"><?php echo __('Join channel') ?></a>
  101. <?php if (!SINGLE_USER_MODE) { ?>
  102. | <a href="backend.php?op=logout"><?php echo __('Logout') ?></a>
  103. <?php } ?>
  104. </div>
  105. <div id="tabs">
  106. <div id="tabs-inner">
  107. <ul id="tabs-list" data-bind="foreach: connections">
  108. <li channel="---" tab_type="S" data-bind="attr: { id: 'tab-' + id(), connection_id: id() }, css: { selected: selected }" onclick="change_tab(this)">
  109. <span data-bind="attr: { id: 'cimg-' + id() }, css: { 'conn-img': true, connected: connected, attention: unread() > 0 }"> </span>
  110. <div data-bind="text: title"></div>
  111. </li>
  112. <ul class="sub-tabs" data-bind="foreach: channels, attr: { id: 'tabs-' + id() }">
  113. <li onclick="change_tab(this)" data-bind="attr: { id: 'tab-' + title() + ':' + $parent.id(), connection_id: $parent.id(), channel: title(), tab_type: type() }, css: { selected: selected, highlight: highlight, offline: offline, attention: unread() > 0 }">
  114. <span onclick="close_tab(this)" title="Close this tab" class="close-img"
  115. data-bind="attr: { tab_id: 'tab-' + title() + ':' + $parent.id() }">&times;</span>
  116. <span class="unread" data-bind="visible: unread, text: unread"></span>
  117. <div class="indented" data-bind="text: title"></div>
  118. </li>
  119. </ul>
  120. </ul>
  121. </div>
  122. </div>
  123. <div id="content">
  124. <div id="topic"><div class="wrapper">
  125. <div data-bind="html: activeTopicFormatted, attr: { title: activeTopic }, css: { 'uneditable-input': true, disabled: activeTopicDisabled }" id="topic-input" onclick="prepare_change_topic(this)"></div>
  126. <input onkeypress="change_topic_real(this, event)" onblur="hide_topic_input()" type="text"
  127. id="topic-input-real" style="display : none"/>
  128. </div>
  129. </div>
  130. <div id="log" data-bind="with: activeChannel" >
  131. <ul id="log-list" data-bind="foreach: lines">
  132. <li data-bind="html: format, css: { row: true, HL: is_hl }"> </li>
  133. </ul>
  134. </div>
  135. <div id="sidebar">
  136. <div id="sidebar-inner">
  137. <!-- fuck you very much, MSIE team -->
  138. <form action="javascript:void(null);" method="post" class="connect-form">
  139. <div id="connect"><button class="btn"
  140. id="connect-btn" data-bind="enable: toggleConnection, text: connectBtnLabel, click: toggleConnection"> </button>
  141. </div>
  142. </form>
  143. <div id="userlist">
  144. <div data-bind="with: activeChannel" id="userlist-inner">
  145. <ul id="userlist-list" data-bind="foreach: nicklist">
  146. <li>
  147. <span data-bind="css: { 'user-img': true, op: $root.nickIsOp($data), voice: $root.nickIsVoiced($data) }"> </span>
  148. <span onclick="query_user(this)"
  149. data-bind="text: $root.stripNickPrefix($data),
  150. css: { away: $root.isUserAway($root.activeChannel().connection_id(), $data) },
  151. attr: { nick: $root.stripNickPrefix($data),
  152. title: $root.getNickHost($root.activeChannel().connection_id(), $data) }"></span>
  153. </li>
  154. </ul>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <div id="nick" onclick="change_nick()" data-bind="text: activeNick, css: { away: isAway }"></div>
  160. <div id="input"><div class="wrapper">
  161. <textarea data-bind="enable: activeStatus() == 2" disabled="true" rows="1" id="input-prompt" oninput="input_filter_cr(this, event)" onkeypress="send(this, event)"/></textarea>
  162. <div style="display : none" id="emoticons"><?php echo render_emoticons($link) ?></div>
  163. </div></div>
  164. <a class="btn" onclick="Element.toggle('emoticons')" id="emoticon-prompt">:(</a>
  165. </div>
  166. </div>
  167. </body>
  168. </html>