index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.6.0', '<')) {
  13. print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\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 if ($_SESSION["uid"]) {
  53. $theme = get_pref("USER_CSS_THEME", false, false);
  54. if ($theme && theme_exists("$theme")) {
  55. echo stylesheet_tag(get_theme_path($theme), 'theme_css');
  56. } else {
  57. echo stylesheet_tag("css/default.css", 'theme_css');
  58. }
  59. }
  60. ?>
  61. <?php print_user_stylesheet() ?>
  62. <style type="text/css">
  63. <?php
  64. foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
  65. if (method_exists($p, "get_css")) {
  66. echo $p->get_css();
  67. }
  68. }
  69. ?>
  70. </style>
  71. <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
  72. <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
  73. <script>
  74. dojoConfig = {
  75. async: true,
  76. cacheBust: "<?php echo get_scripts_timestamp(); ?>",
  77. packages: [
  78. { name: "fox", location: "../../js" },
  79. ]
  80. };
  81. </script>
  82. <?php
  83. foreach (array("lib/prototype.js",
  84. "lib/scriptaculous/scriptaculous.js?load=effects,controls",
  85. "lib/dojo/dojo.js",
  86. "lib/dojo/tt-rss-layer.js",
  87. "js/tt-rss.js",
  88. "js/common.js",
  89. "errors.php?mode=js") as $jsfile) {
  90. echo javascript_tag($jsfile);
  91. } ?>
  92. <script type="text/javascript">
  93. require({cache:{}});
  94. </script>
  95. <script type="text/javascript">
  96. <?php
  97. foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
  98. if (method_exists($p, "get_js")) {
  99. $script = $p->get_js();
  100. if ($script) {
  101. echo "try {
  102. $script
  103. } catch (e) {
  104. console.warn('failed to initialize plugin JS: $n', e);
  105. }";
  106. }
  107. }
  108. }
  109. init_js_translations();
  110. ?>
  111. </script>
  112. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  113. <meta name="referrer" content="no-referrer"/>
  114. </head>
  115. <body class="flat ttrss_main ttrss_index">
  116. <div id="overlay" style="display : block">
  117. <div id="overlay_inner">
  118. <?php echo __("Loading, please wait...") ?>
  119. <div dojoType="dijit.ProgressBar" places="0" style="width : 300px" id="loading_bar"
  120. progress="0" maximum="100">
  121. </div>
  122. <noscript><br/><?php print_error('Javascript is disabled. Please enable it.') ?></noscript>
  123. </div>
  124. </div>
  125. <div id="notify" class="notify"></div>
  126. <div id="cmdline" style="display : none"></div>
  127. <div id="main" dojoType="dijit.layout.BorderContainer">
  128. <div id="feeds-holder" dojoType="dijit.layout.ContentPane" region="leading" style="width : 20%" splitter="true">
  129. <div id="feedlistLoading">
  130. <img src='images/indicator_tiny.gif'/>
  131. <?php echo __("Loading, please wait..."); ?></div>
  132. <div id="feedTree"></div>
  133. </div>
  134. <div dojoType="dijit.layout.BorderContainer" region="center" id="content-wrap">
  135. <div id="toolbar-frame" dojoType="dijit.layout.ContentPane" region="top">
  136. <div id="toolbar" dojoType="dijit.Toolbar">
  137. <i class="material-icons net-alert" style="display : none"
  138. title="<?php echo __("Communication problem with server.") ?>">error_outline</i>
  139. <i class="material-icons log-alert" style="display : none"
  140. title="<?php echo __("Recent entries found in event log.") ?>">warning</i>
  141. <i id="updates-available" class="material-icons icon-new-version" style="display : none"
  142. title="<?php echo __('Updates are available from Git.') ?>">new_releases</i>
  143. <?php
  144. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_MAIN_TOOLBAR_BUTTON) as $p) {
  145. echo $p->hook_main_toolbar_button();
  146. }
  147. ?>
  148. <form id="toolbar-headlines" action="" onsubmit='return false'>
  149. </form>
  150. <form id="toolbar-main" action="" onsubmit='return false'>
  151. <select name="view_mode" title="<?php echo __('Show articles') ?>"
  152. onchange="App.onViewModeChanged()"
  153. dojoType="dijit.form.Select">
  154. <option selected="selected" value="adaptive"><?php echo __('Adaptive') ?></option>
  155. <option value="all_articles"><?php echo __('All Articles') ?></option>
  156. <option value="marked"><?php echo __('Starred') ?></option>
  157. <option value="published"><?php echo __('Published') ?></option>
  158. <option value="unread"><?php echo __('Unread') ?></option>
  159. <option value="has_note"><?php echo __('With Note') ?></option>
  160. <!-- <option value="noscores"><?php echo __('Ignore Scoring') ?></option> -->
  161. </select>
  162. <select title="<?php echo __('Sort articles') ?>"
  163. onchange="App.onViewModeChanged()"
  164. dojoType="dijit.form.Select" name="order_by">
  165. <option selected="selected" value="default"><?php echo __('Default') ?></option>
  166. <option value="feed_dates"><?php echo __('Newest first') ?></option>
  167. <option value="date_reverse"><?php echo __('Oldest first') ?></option>
  168. <option value="title"><?php echo __('Title') ?></option>
  169. </select>
  170. <div dojoType="dijit.form.ComboButton" onclick="Feeds.catchupCurrent()">
  171. <span><?php echo __('Mark as read') ?></span>
  172. <div dojoType="dijit.DropDownMenu">
  173. <div dojoType="dijit.MenuItem" onclick="Feeds.catchupCurrent('1day')">
  174. <?php echo __('Older than one day') ?>
  175. </div>
  176. <div dojoType="dijit.MenuItem" onclick="Feeds.catchupCurrent('1week')">
  177. <?php echo __('Older than one week') ?>
  178. </div>
  179. <div dojoType="dijit.MenuItem" onclick="Feeds.catchupCurrent('2week')">
  180. <?php echo __('Older than two weeks') ?>
  181. </div>
  182. </div>
  183. </div>
  184. </form>
  185. <div class="action-chooser">
  186. <?php
  187. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
  188. echo $p->hook_toolbar_button();
  189. }
  190. ?>
  191. <div dojoType="dijit.form.DropDownButton">
  192. <span><?php echo __('Actions...') ?></span>
  193. <div dojoType="dijit.Menu" style="display: none">
  194. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcPrefs')"><?php echo __('Preferences...') ?></div>
  195. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcSearch')"><?php echo __('Search...') ?></div>
  196. <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div>
  197. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
  198. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
  199. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
  200. <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
  201. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
  202. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
  203. <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
  204. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
  205. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcToggleNightMode')"><?php echo __('Toggle night mode') ?></div>
  206. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
  207. <?php
  208. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
  209. echo $p->hook_action_item();
  210. }
  211. ?>
  212. <?php if (!$_SESSION["hide_logout"]) { ?>
  213. <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcLogout')"><?php echo __('Logout') ?></div>
  214. <?php } ?>
  215. </div>
  216. </div>
  217. </div>
  218. </div> <!-- toolbar -->
  219. </div> <!-- toolbar pane -->
  220. <div id="headlines-wrap-inner" dojoType="dijit.layout.BorderContainer" region="center">
  221. <div id="floatingTitle" style="display : none"></div>
  222. <div id="headlines-frame" dojoType="dijit.layout.ContentPane" tabindex="0"
  223. region="center">
  224. <div id="headlinesInnerContainer">
  225. <div class="whiteBox"><?php echo __('Loading, please wait...') ?></div>
  226. </div>
  227. </div>
  228. <div id="content-insert" dojoType="dijit.layout.ContentPane" region="bottom"
  229. style="height : 50%" splitter="true"></div>
  230. </div>
  231. </div>
  232. </div>
  233. </body>
  234. </html>