The version of vichan running on lainchan.org
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 13 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 11 años
hace 12 años
hace 12 años
hace 10 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 11 años
hace 12 años
hace 11 años
hace 12 años
hace 12 años
hace 12 años
hace 12 años
hace 13 años
hace 12 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. /*
  3. * Copyright (c) 2010-2014 Tinyboard Development Group
  4. */
  5. require_once 'inc/functions.php';
  6. if ($config['debug'])
  7. $parse_start_time = microtime(true);
  8. require_once 'inc/bans.php';
  9. require_once 'inc/mod/pages.php';
  10. check_login(true);
  11. $query = isset($_SERVER['QUERY_STRING']) ? rawurldecode($_SERVER['QUERY_STRING']) : '';
  12. // If there's a thread parameter (eg, for returning to after enacting a ban)
  13. // drop it from the $query.
  14. if(isset($_GET['thread'])) {
  15. $query = explode("&thread=", $query)[0];
  16. }
  17. $pages = array(
  18. '' => ':?/', // redirect to dashboard
  19. '/' => 'dashboard', // dashboard
  20. '/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
  21. '/logout' => 'secure logout', // logout
  22. '/users' => 'users', // manage users
  23. '/users/(\d+)/(promote|demote)' => 'secure user_promote', // prmote/demote user
  24. '/users/(\d+)' => 'secure_POST user', // edit user
  25. '/users/new' => 'secure_POST user_new', // create a new user
  26. '/new_PM/([^/]+)' => 'secure_POST new_pm', // create a new pm
  27. '/PM/(\d+)(/reply)?' => 'pm', // read a pm
  28. '/inbox' => 'inbox', // pm inbox
  29. '/log' => 'log', // modlog
  30. '/log/(\d+)' => 'log', // modlog
  31. '/log:([^/:]+)' => 'user_log', // modlog
  32. '/log:([^/:]+)/(\d+)' => 'user_log', // modlog
  33. '/log:b:([^/]+)' => 'board_log', // modlog
  34. '/log:b:([^/]+)/(\d+)' => 'board_log', // modlog
  35. '/edit_news' => 'secure_POST news', // view news
  36. '/edit_news/(\d+)' => 'secure_POST news', // view news
  37. '/edit_news/delete/(\d+)' => 'secure news_delete', // delete from news
  38. '/edit_pages(?:/?(\%b)?)' => 'secure_POST pages',
  39. '/edit_page/(\d+)' => 'secure_POST edit_page',
  40. '/edit_pages/delete/([a-z0-9]+)' => 'secure delete_page',
  41. '/edit_pages/delete/([a-z0-9]+)/(\%b)' => 'secure delete_page_board',
  42. '/noticeboard' => 'secure_POST noticeboard', // view noticeboard
  43. '/noticeboard/(\d+)' => 'secure_POST noticeboard', // view noticeboard
  44. '/noticeboard/delete/(\d+)' => 'secure noticeboard_delete', // delete from noticeboard
  45. '/edit/(\%b)' => 'secure_POST edit_board', // edit board details
  46. '/new-board' => 'secure_POST new_board', // create a new board
  47. '/rebuild' => 'secure_POST rebuild', // rebuild static files
  48. '/reports' => 'reports', // report queue
  49. '/reports/(\d+)/dismiss(all)?' => 'secure report_dismiss', // dismiss a report
  50. '/IP/([\w.:]+)' => 'secure_POST ip', // view ip address
  51. '/IP/([\w.:]+)/remove_note/(\d+)' => 'secure ip_remove_note', // remove note from ip address
  52. '/ban' => 'secure_POST ban', // new ban
  53. '/bans' => 'secure_POST bans', // ban list
  54. '/bans.json' => 'secure bans_json', // ban list JSON
  55. '/ban-appeals' => 'secure_POST ban_appeals', // view ban appeals
  56. '/recent/(\d+)' => 'recent_posts', // view recent posts
  57. '/recent/(\d+)/([\w,]+?)' => 'recent_posts', // view recent posts
  58. '/recent/(\d+)/([\w,]+?)/(json)?' => 'recent_posts', // view recent posts JSON
  59. '/search' => 'search_redirect', // search
  60. '/search/(posts|IP_notes|bans|log)/(.+)/(\d+)' => 'search', // search
  61. '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search
  62. '/(\%b)/warning/(\d+)' => 'secure_POST warning_post', // warn poster
  63. '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster
  64. '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
  65. '/(\%b)/move_reply/(\d+)' => 'secure_POST move_reply', // move reply
  66. '/(\%b)/merge/(\d+)' => 'secure_POST merge', // merge thread
  67. '/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post
  68. '/(\%b)/delete/(\d+)' => 'secure delete', // delete post
  69. '/(\%b)/deletefile/(\d+)/(\d+)' => 'secure deletefile', // delete file from post
  70. '/(\%b+)/spoiler/(\d+)/(\d+)' => 'secure spoiler_image', // spoiler file
  71. '/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address
  72. '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
  73. '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
  74. '/(\%b)/(un)?cycle/(\d+)' => 'secure cycle', // cycle thread
  75. '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread
  76. '/themes' => 'themes_list', // manage themes
  77. '/themes/(\w+)' => 'secure_POST theme_configure', // configure/reconfigure theme
  78. '/themes/(\w+)/rebuild' => 'secure theme_rebuild', // rebuild theme
  79. '/themes/(\w+)/uninstall' => 'secure theme_uninstall', // uninstall theme
  80. '/config' => 'secure_POST config', // config editor
  81. '/config/(\%b)' => 'secure_POST config', // config editor
  82. // these pages aren't listed in the dashboard without $config['debug']
  83. '/debug/antispam' => 'debug_antispam',
  84. '/debug/recent' => 'debug_recent_posts',
  85. '/debug/apc' => 'debug_apc',
  86. '/debug/sql' => 'secure_POST debug_sql',
  87. // This should always be at the end:
  88. '/(\%b)/' => 'view_board',
  89. '/(\%b)/' . preg_quote($config['file_index'], '!') => 'view_board',
  90. '/(\%b)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_board',
  91. '/(\%b)/' . preg_quote($config['dir']['res'], '!') .
  92. str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '!')) => 'view_thread50',
  93. '/(\%b)/' . preg_quote($config['dir']['res'], '!') .
  94. str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_thread',
  95. '/(\%b)/' . preg_quote($config['dir']['res'], '!') .
  96. str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '!')) => 'view_thread50',
  97. '/(\%b)/' . preg_quote($config['dir']['res'], '!') .
  98. str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '!')) => 'view_thread',
  99. );
  100. if (!$mod) {
  101. $pages = array('!^(.+)?$!' => 'login');
  102. } elseif (isset($_GET['status'], $_GET['r'])) {
  103. header('Location: ' . $_GET['r'], true, (int)$_GET['status']);
  104. exit;
  105. }
  106. if (isset($config['mod']['custom_pages'])) {
  107. $pages = array_merge($pages, $config['mod']['custom_pages']);
  108. }
  109. $new_pages = array();
  110. foreach ($pages as $key => $callback) {
  111. if (is_string($callback) && preg_match('/^secure /', $callback))
  112. $key .= '(/(?P<token>[a-f0-9]{8}))?';
  113. $key = str_replace('\%b', '?P<board>' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key);
  114. $new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback;
  115. }
  116. $pages = $new_pages;
  117. foreach ($pages as $uri => $handler) {
  118. if (preg_match($uri, $query, $matches)) {
  119. $matches = array_slice($matches, 1);
  120. if (isset($matches['board'])) {
  121. $board_match = $matches['board'];
  122. unset($matches['board']);
  123. $key = array_search($board_match, $matches);
  124. if (preg_match('/^' . sprintf(substr($config['board_path'], 0, -1), '(' . $config['board_regex'] . ')') . '$/u', $matches[$key], $board_match)) {
  125. $matches[$key] = $board_match[1];
  126. }
  127. }
  128. if (is_string($handler) && preg_match('/^secure(_POST)? /', $handler, $m)) {
  129. $secure_post_only = isset($m[1]);
  130. if (!$secure_post_only || $_SERVER['REQUEST_METHOD'] == 'POST') {
  131. $token = isset($matches['token']) ? $matches['token'] : (isset($_POST['token']) ? $_POST['token'] : false);
  132. if ($token === false) {
  133. if ($secure_post_only)
  134. error($config['error']['csrf']);
  135. else {
  136. mod_confirm(substr($query, 1));
  137. exit;
  138. }
  139. }
  140. // CSRF-protected page; validate security token
  141. $actual_query = preg_replace('!/([a-f0-9]{8})$!', '', $query);
  142. if ($token != make_secure_link_token(substr($actual_query, 1))) {
  143. error($config['error']['csrf']);
  144. }
  145. }
  146. $handler = preg_replace('/^secure(_POST)? /', '', $handler);
  147. }
  148. if ($config['debug']) {
  149. $debug['mod_page'] = array(
  150. 'req' => $query,
  151. 'match' => $uri,
  152. 'handler' => $handler,
  153. );
  154. $debug['time']['parse_mod_req'] = '~' . round((microtime(true) - $parse_start_time) * 1000, 2) . 'ms';
  155. }
  156. if (is_string($handler)) {
  157. if ($handler[0] == ':') {
  158. header('Location: ' . substr($handler, 1), true, $config['redirect_http']);
  159. } elseif (is_callable("mod_page_$handler")) {
  160. call_user_func_array("mod_page_$handler", $matches);
  161. } elseif (is_callable("mod_$handler")) {
  162. call_user_func_array("mod_$handler", $matches);
  163. } else {
  164. error("Mod page '$handler' not found!");
  165. }
  166. } elseif (is_callable($handler)) {
  167. call_user_func_array($handler, $matches);
  168. } else {
  169. error("Mod page '$handler' not a string, and not callable!");
  170. }
  171. exit;
  172. }
  173. }
  174. error($config['error']['404']);