index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?php
  2. if (file_exists("install") && !file_exists("config.php")) {
  3. header("Location: install/");
  4. }
  5. if (!file_exists("config.php")) {
  6. print "<b>Fatal Error</b>: You forgot to copy
  7. <b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
  8. exit;
  9. }
  10. // we need a separate check here because functions.php might get parsed
  11. // incorrectly before 5.3 because of :: syntax.
  12. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  13. print "<b>Fatal Error</b>: PHP version 5.3.0 or newer required.\n";
  14. exit;
  15. }
  16. set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
  17. get_include_path());
  18. require_once "autoload.php";
  19. require_once "sessions.php";
  20. require_once "functions.php";
  21. require_once "sanity_check.php";
  22. require_once "version.php";
  23. require_once "config.php";
  24. require_once "db-prefs.php";
  25. require_once "lib/Mobile_Detect.php";
  26. $mobile = new Mobile_Detect();
  27. if (!init_plugins()) return;
  28. if (!$_REQUEST['mobile']) {
  29. if ($mobile->isTablet() && PluginHost::getInstance()->get_plugin("digest")) {
  30. header('Location: backend.php?op=digest');
  31. exit;
  32. } else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("mobile")) {
  33. header('Location: backend.php?op=mobile');
  34. exit;
  35. } else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("digest")) {
  36. header('Location: backend.php?op=digest');
  37. exit;
  38. }
  39. }
  40. login_sequence();
  41. header('Content-Type: text/html; charset=utf-8');
  42. ?>
  43. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  44. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  45. <html>
  46. <head>
  47. <title>Tiny Tiny RSS</title>
  48. <meta name="viewport" content="initial-scale=1,width=device-width" />
  49. <script type="text/javascript">
  50. var __ttrss_version = "<?php echo VERSION ?>"
  51. </script>
  52. <?php echo stylesheet_tag("lib/dijit/themes/claro/claro.css"); ?>
  53. <?php if ($_SESSION["uid"]) {
  54. $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
  55. if ($theme && theme_valid("$theme")) {
  56. echo stylesheet_tag(get_theme_path($theme));
  57. } else {
  58. echo stylesheet_tag("css/default.css");
  59. }
  60. }
  61. ?>
  62. <?php print_user_stylesheet() ?>
  63. <style type="text/css">
  64. <?php
  65. foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
  66. if (method_exists($p, "get_css")) {
  67. echo $p->get_css();
  68. }
  69. }
  70. ?>
  71. </style>
  72. <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
  73. <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
  74. <script>
  75. dojoConfig = {
  76. async: true,
  77. cacheBust: new Date(),
  78. packages: [
  79. { name: "fox", location: "../../js" },
  80. ]
  81. };
  82. </script>
  83. <?php
  84. foreach (array("lib/prototype.js",
  85. "lib/scriptaculous/scriptaculous.js?load=effects,controls",
  86. "lib/dojo/dojo.js",
  87. "lib/dojo/tt-rss-layer.js",
  88. "errors.php?mode=js") as $jsfile) {
  89. echo javascript_tag($jsfile);
  90. } ?>
  91. <script type="text/javascript">
  92. 'use strict';
  93. require({cache:{}});
  94. <?php
  95. print get_minified_js(["tt-rss.js",
  96. "functions.js", "feedlist.js", "viewfeed.js", "PluginHost.js", "grog.js"]);
  97. ?>
  98. </script>
  99. <script type="text/javascript">
  100. <?php
  101. foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
  102. if (method_exists($p, "get_js")) {
  103. echo "try {";
  104. echo JShrink\Minifier::minify($p->get_js());
  105. echo "} catch (e) {
  106. console.warn('failed to initialize plugin JS: $n');
  107. console.warn(e);
  108. }";
  109. }
  110. }
  111. init_js_translations();
  112. ?>
  113. </script>
  114. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  115. <meta name="referrer" content="no-referrer"/>
  116. <script type="text/javascript">
  117. Event.observe(window, 'load', function() {
  118. init();
  119. });
  120. </script>
  121. </head>
  122. <body class="claro ttrss_main">
  123. <div id="overlay" style="display : block">
  124. <div id="overlay_inner">
  125. <div class="insensitive"><?php echo __("Loading, please wait...") ?></div>
  126. <div dojoType="dijit.ProgressBar" places="0" style="width : 300px" id="loading_bar"
  127. progress="0" maximum="100">
  128. </div>
  129. <noscript><br/><?php print_error('Javascript is disabled. Please enable it.') ?></noscript>
  130. </div>
  131. </div>
  132. <div id="notify" class="notify"></div>
  133. <div id="cmdline" style="display : none"></div>
  134. <div id="main" dojoType="dijit.layout.BorderContainer">
  135. <div id="feeds-holder" dojoType="dijit.layout.ContentPane" region="leading" style="width : 20%" splitter="true">
  136. <div id="feeds-actions">
  137. <ul>
  138. <li onclick="quickMenuGo('qmcAddFeed');"> <button class="btn-primary" dojoType="dijit.form.Button">Add feed</button> </li>
  139. <li onclick="gotoPreferences('feedConfig');"> <button class="btn-secondary" dojoType="dijit.form.Button">Manage feeds</button> </li>
  140. <li onclick="configShare();"> <button class="btn-secondary" dojoType="dijit.form.Button">Publishing options</button> </li>
  141. </ul>
  142. </div>
  143. <div id="feedlistLoading">
  144. <img src='images/indicator_tiny.gif'/>
  145. <?php echo __("Loading, please wait..."); ?></div>
  146. <div id="feedTree"></div>
  147. </div>
  148. <div dojoType="dijit.layout.BorderContainer" region="center" id="header-wrap" gutters="false">
  149. <div dojoType="dijit.layout.BorderContainer" region="center" id="content-wrap">
  150. <div id="toolbar" dojoType="dijit.layout.ContentPane" region="top">
  151. <div id="main-toolbar" dojoType="dijit.Toolbar">
  152. <?php
  153. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_MAIN_TOOLBAR_BUTTON) as $p) {
  154. echo $p->hook_main_toolbar_button();
  155. }
  156. ?>
  157. <form id="headlines-toolbar" action="" onsubmit='return false'>
  158. </form>
  159. <form id="main_toolbar_form" action="" onsubmit='return false'>
  160. <div dojoType="dijit.form.DropDownButton">
  161. <span><?php echo __('Show only'); ?></span>
  162. <input name="view_mode" style="display: none;" value="adaptive"></input>
  163. <div dojoType="dijit.Menu" style="display: none">
  164. <div onclick="document.getElementsByName('view_mode')[0].value = 'all_articles'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('All') ?></div>
  165. <div onclick="document.getElementsByName('view_mode')[0].value = 'marked'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Starred') ?></div>
  166. <div onclick="document.getElementsByName('view_mode')[0].value = 'published'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Published') ?></div>
  167. <div onclick="document.getElementsByName('view_mode')[0].value = 'unread'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Unread') ?></div>
  168. </div>
  169. </div>
  170. <div dojoType="dijit.form.DropDownButton">
  171. <span><?php echo __('Sort'); ?></span>
  172. <input name="order_by" style="display: none;" value="default"></input>
  173. <div dojoType="dijit.Menu" style="display: none">
  174. <div onclick="document.getElementsByName('order_by')[0].value = 'default'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Default') ?></div>
  175. <div onclick="document.getElementsByName('order_by')[0].value = 'feed_dates'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Newest first') ?></div>
  176. <div onclick="document.getElementsByName('order_by')[0].value = 'date_reverse'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Oldest first') ?></div>
  177. <div onclick="document.getElementsByName('order_by')[0].value = 'title'; viewModeChanged()" dojoType="dijit.MenuItem" ><?php echo __('Title') ?></div>
  178. </div>
  179. </div>
  180. <div dojoType="dijit.form.ComboButton" onclick="catchupCurrentFeed()">
  181. <span><?php echo __('Mark as read') ?></span>
  182. <div dojoType="dijit.DropDownMenu">
  183. <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1day')">
  184. <?php echo __('Older than one day') ?>
  185. </div>
  186. <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1week')">
  187. <?php echo __('Older than one week') ?>
  188. </div>
  189. <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('2week')">
  190. <?php echo __('Older than two weeks') ?>
  191. </div>
  192. </div>
  193. </div>
  194. </form>
  195. <div class="actionChooser">
  196. <?php
  197. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
  198. echo $p->hook_toolbar_button();
  199. }
  200. ?>
  201. <button id="net-alert" dojoType="dijit.form.Button" style="display : none" disabled="true"
  202. title="<?php echo __("Communication problem with server.") ?>">
  203. <img src="images/error.png" />
  204. </button>
  205. <div dojoType="dijit.form.DropDownButton">
  206. <span><?php echo __('Actions...') ?></span>
  207. <div dojoType="dijit.Menu" style="display: none">
  208. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcPrefs')"><?php echo __('Preferences...') ?></div>
  209. <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
  210. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
  211. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
  212. <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
  213. <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
  214. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
  215. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
  216. <?php
  217. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
  218. echo $p->hook_action_item();
  219. }
  220. ?>
  221. <?php if (!$_SESSION["hide_logout"]) { ?>
  222. <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout') ?></div>
  223. <?php } ?>
  224. </div>
  225. </div>
  226. <button id="updatesIcon" dojoType="dijit.form.Button" style="display : none">
  227. <img src="images/new_version.png" title="<?php echo __('Updates are available from Git.') ?>"/>
  228. </button>
  229. </div>
  230. </div> <!-- toolbar -->
  231. </div> <!-- toolbar pane -->
  232. <div id="headlines-wrap-inner" dojoType="dijit.layout.BorderContainer" region="center">
  233. <div id="floatingTitle" style="visibility : hidden"></div>
  234. <div id="headlines-frame" dojoType="dijit.layout.ContentPane" tabindex="0"
  235. onscroll="headlines_scroll_handler(this)" region="center">
  236. <div id="headlinesInnerContainer">
  237. <div class="whiteBox"><?php echo __('Loading, please wait...') ?></div>
  238. </div>
  239. </div>
  240. <div id="content-insert" dojoType="dijit.layout.ContentPane" region="bottom"
  241. style="height : 50%" splitter="true"></div>
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246. </body>
  247. </html>