Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <?
  2. /*****************************************************************
  3. Tools switch center
  4. This page acts as a switch for the tools pages.
  5. *****************************************************************/
  6. if (isset($argv[1])) {
  7. $_REQUEST['action'] = $argv[1];
  8. } else {
  9. if (empty($_REQUEST['action']) || ($_REQUEST['action'] != 'public_sandbox' && $_REQUEST['action'] != 'ocelot')) {
  10. enforce_login();
  11. }
  12. }
  13. if (!isset($_REQUEST['action'])) {
  14. include(SERVER_ROOT.'/sections/tools/tools.php');
  15. die();
  16. }
  17. if (substr($_REQUEST['action'], 0, 7) == 'sandbox' && !isset($argv[1])) {
  18. if (!check_perms('site_debug')) {
  19. error(403);
  20. }
  21. }
  22. if (substr($_REQUEST['action'], 0, 12) == 'update_geoip' && !isset($argv[1])) {
  23. if (!check_perms('site_debug')) {
  24. error(403);
  25. }
  26. }
  27. if (substr($_REQUEST['action'],0,16) == 'rerender_gallery' && !isset($argv[1])) {
  28. if (!check_perms('site_debug')) {
  29. error(403);
  30. }
  31. }
  32. include(SERVER_ROOT.'/classes/validate.class.php');
  33. $Val = new VALIDATE;
  34. include(SERVER_ROOT.'/classes/feed.class.php');
  35. $Feed = new FEED;
  36. switch ($_REQUEST['action']) {
  37. case 'phpinfo':
  38. if (!check_perms('site_debug')) {
  39. error(403);
  40. }
  41. phpinfo();
  42. break;
  43. //Services
  44. case 'get_host':
  45. include(SERVER_ROOT.'/sections/tools/services/get_host.php');
  46. break;
  47. case 'get_cc':
  48. include(SERVER_ROOT.'/sections/tools/services/get_cc.php');
  49. break;
  50. //Managers
  51. case 'forum':
  52. include(SERVER_ROOT.'/sections/tools/managers/forum_list.php');
  53. break;
  54. case 'forum_alter':
  55. include(SERVER_ROOT.'/sections/tools/managers/forum_alter.php');
  56. break;
  57. case 'whitelist':
  58. include(SERVER_ROOT.'/sections/tools/managers/whitelist_list.php');
  59. break;
  60. case 'whitelist_alter':
  61. include(SERVER_ROOT.'/sections/tools/managers/whitelist_alter.php');
  62. break;
  63. case 'enable_requests':
  64. include(SERVER_ROOT.'/sections/tools/managers/enable_requests.php');
  65. break;
  66. case 'delete_email':
  67. include(SERVER_ROOT.'/sections/tools/managers/email_delete_requests.php');
  68. break;
  69. case 'ajax_take_enable_request':
  70. if (FEATURE_EMAIL_REENABLE) {
  71. include(SERVER_ROOT.'/sections/tools/managers/ajax_take_enable_request.php');
  72. } else {
  73. // Prevent post requests to the ajax page
  74. header("Location: tools.php");
  75. die();
  76. }
  77. break;
  78. case 'login_watch':
  79. include(SERVER_ROOT.'/sections/tools/managers/login_watch.php');
  80. break;
  81. case 'email_blacklist':
  82. include(SERVER_ROOT.'/sections/tools/managers/email_blacklist.php');
  83. break;
  84. case 'email_blacklist_alter':
  85. include(SERVER_ROOT.'/sections/tools/managers/email_blacklist_alter.php');
  86. break;
  87. case 'email_blacklist_search':
  88. include(SERVER_ROOT.'/sections/tools/managers/email_blacklist_search.php');
  89. break;
  90. case 'dnu':
  91. include(SERVER_ROOT.'/sections/tools/managers/dnu_list.php');
  92. break;
  93. case 'dnu_alter':
  94. include(SERVER_ROOT.'/sections/tools/managers/dnu_alter.php');
  95. break;
  96. case 'editnews':
  97. case 'news':
  98. include(SERVER_ROOT.'/sections/tools/managers/news.php');
  99. break;
  100. case 'edit_tags':
  101. include(SERVER_ROOT.'/sections/tools/misc/tags.php');
  102. break;
  103. case 'takeeditnews':
  104. if (!check_perms('admin_manage_news')) {
  105. error(403);
  106. }
  107. if (is_number($_POST['newsid'])) {
  108. $DB->query("
  109. UPDATE news
  110. SET Title = '".db_string($_POST['title'])."',
  111. Body = '".db_string($_POST['body'])."'
  112. WHERE ID = '".db_string($_POST['newsid'])."'");
  113. $Cache->delete_value('news');
  114. $Cache->delete_value('feed_news');
  115. }
  116. header('Location: index.php');
  117. break;
  118. case 'deletenews':
  119. if (!check_perms('admin_manage_news')) {
  120. error(403);
  121. }
  122. if (is_number($_GET['id'])) {
  123. authorize();
  124. $DB->query("
  125. DELETE FROM news
  126. WHERE ID = '".db_string($_GET['id'])."'");
  127. $Cache->delete_value('news');
  128. $Cache->delete_value('feed_news');
  129. // Deleting latest news
  130. $LatestNews = $Cache->get_value('news_latest_id');
  131. if ($LatestNews !== false && $LatestNews == $_GET['id']) {
  132. $Cache->delete_value('news_latest_id');
  133. $Cache->delete_value('news_latest_title');
  134. }
  135. }
  136. header('Location: index.php');
  137. break;
  138. case 'takenewnews':
  139. if (!check_perms('admin_manage_news')) {
  140. error(403);
  141. }
  142. $DB->query("
  143. INSERT INTO news (UserID, Title, Body, Time)
  144. VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')");
  145. $Cache->delete_value('news_latest_id');
  146. $Cache->delete_value('news_latest_title');
  147. $Cache->delete_value('news');
  148. NotificationsManager::send_push(NotificationsManager::get_push_enabled_users(), $_POST['title'], $_POST['body'], site_url() . 'index.php', NotificationsManager::NEWS);
  149. header('Location: index.php');
  150. break;
  151. case 'tokens':
  152. include(SERVER_ROOT.'/sections/tools/managers/tokens.php');
  153. break;
  154. case 'multiple_freeleech':
  155. include(SERVER_ROOT.'/sections/tools/managers/multiple_freeleech.php');
  156. break;
  157. case 'ocelot':
  158. include(SERVER_ROOT.'/sections/tools/managers/ocelot.php');
  159. break;
  160. case 'ocelot_info':
  161. include(SERVER_ROOT.'/sections/tools/data/ocelot_info.php');
  162. break;
  163. case 'official_tags':
  164. include(SERVER_ROOT.'/sections/tools/managers/official_tags.php');
  165. break;
  166. case 'freeleech':
  167. include(SERVER_ROOT.'/sections/tools/managers/sitewide_freeleech.php');
  168. break;
  169. case 'tag_aliases':
  170. include(SERVER_ROOT.'/sections/tools/managers/tag_aliases.php');
  171. break;
  172. case 'label_aliases':
  173. include(SERVER_ROOT.'/sections/tools/managers/label_aliases.php');
  174. break;
  175. case 'change_log':
  176. include(SERVER_ROOT.'/sections/tools/managers/change_log.php');
  177. break;
  178. case 'global_notification':
  179. include(SERVER_ROOT.'/sections/tools/managers/global_notification.php');
  180. break;
  181. case 'take_global_notification':
  182. include(SERVER_ROOT.'/sections/tools/managers/take_global_notification.php');
  183. break;
  184. case 'permissions':
  185. if (!check_perms('admin_manage_permissions')) {
  186. error(403);
  187. }
  188. if (!empty($_REQUEST['id'])) {
  189. $Val->SetFields('name', true, 'string', 'You did not enter a valid name for this permission set.');
  190. $Val->SetFields('level', true, 'number', 'You did not enter a valid level for this permission set.');
  191. $Val->SetFields('maxcollages', true, 'number', 'You did not enter a valid number of personal collages.');
  192. //$Val->SetFields('test', true, 'number', 'You did not enter a valid level for this permission set.');
  193. if (is_numeric($_REQUEST['id'])) {
  194. $DB->query("
  195. SELECT p.ID, p.Name, p.Abbreviation, p.Level, p.Secondary, p.PermittedForums, p.Values, p.DisplayStaff, COUNT(u.ID)
  196. FROM permissions AS p
  197. LEFT JOIN users_main AS u ON u.PermissionID = p.ID
  198. WHERE p.ID = '".db_string($_REQUEST['id'])."'
  199. GROUP BY p.ID");
  200. list($ID, $Name, $Abbreviation, $Level, $Secondary, $Forums, $Values, $DisplayStaff, $UserCount) = $DB->next_record(MYSQLI_NUM, array(6));
  201. if ($Level > $LoggedUser['EffectiveClass'] || (isset($_REQUEST['level']) && $_REQUEST['level'] > $LoggedUser['EffectiveClass'])) {
  202. error(403);
  203. }
  204. $Values = unserialize($Values);
  205. }
  206. if (!empty($_POST['submit'])) {
  207. $Err = $Val->ValidateForm($_POST);
  208. if (!is_numeric($_REQUEST['id'])) {
  209. $DB->query("
  210. SELECT ID
  211. FROM permissions
  212. WHERE Level = '".db_string($_REQUEST['level'])."'");
  213. list($DupeCheck)=$DB->next_record();
  214. if ($DupeCheck) {
  215. $Err = 'There is already a permission class with that level.';
  216. }
  217. }
  218. $Values = array();
  219. foreach ($_REQUEST as $Key => $Perms) {
  220. if (substr($Key, 0, 5) == 'perm_') {
  221. $Values[substr($Key, 5)] = (int)$Perms;
  222. }
  223. }
  224. $Name = $_REQUEST['name'];
  225. $Level = $_REQUEST['level'];
  226. $Abbreviation = $_REQUEST['abbreviation'];
  227. $Secondary = empty($_REQUEST['secondary']) ? 0 : 1;
  228. $Forums = $_REQUEST['forums'];
  229. $DisplayStaff = isset($_REQUEST['displaystaff']) ? $_REQUEST['displaystaff']: 0;
  230. $Values['MaxCollages'] = $_REQUEST['maxcollages'];
  231. if (!$Err) {
  232. if (!is_numeric($_REQUEST['id'])) {
  233. $DB->query("
  234. INSERT INTO permissions (Level, Name, Abbreviation, Secondary, PermittedForums, `Values`, DisplayStaff)
  235. VALUES ('".db_string($Level)."',
  236. '".db_string($Name)."',
  237. '".db_string($Abbreviation)."',
  238. $Secondary,
  239. '".db_string($Forums)."',
  240. '".db_string(serialize($Values))."',
  241. '".db_string($DisplayStaff)."')");
  242. } else {
  243. $DB->query("
  244. UPDATE permissions
  245. SET Level = '".db_string($Level)."',
  246. Name = '".db_string($Name)."',
  247. Abbreviation = '".db_string($Abbreviation)."',
  248. Secondary = $Secondary,
  249. PermittedForums = '".db_string($Forums)."',
  250. `Values` = '".db_string(serialize($Values))."',
  251. DisplayStaff = '".db_string($DisplayStaff)."'
  252. WHERE ID = '".db_string($_REQUEST['id'])."'");
  253. $Cache->delete_value('perm_'.$_REQUEST['id']);
  254. if ($Secondary) {
  255. $DB->query("
  256. SELECT DISTINCT UserID
  257. FROM users_levels
  258. WHERE PermissionID = ".db_string($_REQUEST['id']));
  259. while (list($UserID) = $DB->next_record()) {
  260. $Cache->delete_value("user_info_heavy_$UserID");
  261. }
  262. }
  263. }
  264. $Cache->delete_value('classes');
  265. } else {
  266. error($Err);
  267. }
  268. }
  269. include(SERVER_ROOT.'/sections/tools/managers/permissions_alter.php');
  270. } else {
  271. if (!empty($_REQUEST['removeid'])) {
  272. $DB->query("
  273. DELETE FROM permissions
  274. WHERE ID = '".db_string($_REQUEST['removeid'])."'");
  275. $DB->query("
  276. SELECT UserID
  277. FROM users_levels
  278. WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
  279. while (list($UserID) = $DB->next_record()) {
  280. $Cache->delete_value("user_info_$UserID");
  281. $Cache->delete_value("user_info_heavy_$UserID");
  282. }
  283. $DB->query("
  284. DELETE FROM users_levels
  285. WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
  286. $DB->query("
  287. SELECT ID
  288. FROM users_main
  289. WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
  290. while (list($UserID) = $DB->next_record()) {
  291. $Cache->delete_value("user_info_$UserID");
  292. $Cache->delete_value("user_info_heavy_$UserID");
  293. }
  294. $DB->query("
  295. UPDATE users_main
  296. SET PermissionID = '".USER."'
  297. WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
  298. $Cache->delete_value('classes');
  299. }
  300. include(SERVER_ROOT.'/sections/tools/managers/permissions_list.php');
  301. }
  302. break;
  303. case 'ip_ban':
  304. //TODO: Clean up DB table ip_bans.
  305. include(SERVER_ROOT.'/sections/tools/managers/bans.php');
  306. break;
  307. case 'quick_ban':
  308. include(SERVER_ROOT.'/sections/tools/misc/quick_ban.php');
  309. break;
  310. //Data
  311. case 'registration_log':
  312. include(SERVER_ROOT.'/sections/tools/data/registration_log.php');
  313. break;
  314. case 'donation_log':
  315. include(SERVER_ROOT.'/sections/tools/finances/donation_log.php');
  316. break;
  317. case 'bitcoin_unproc':
  318. include(SERVER_ROOT.'/sections/tools/finances/bitcoin_unproc.php');
  319. break;
  320. case 'bitcoin_balance':
  321. include(SERVER_ROOT.'/sections/tools/finances/bitcoin_balance.php');
  322. break;
  323. case 'donor_rewards':
  324. include(SERVER_ROOT.'/sections/tools/finances/donor_rewards.php');
  325. break;
  326. case 'upscale_pool':
  327. include(SERVER_ROOT.'/sections/tools/data/upscale_pool.php');
  328. break;
  329. case 'invite_pool':
  330. include(SERVER_ROOT.'/sections/tools/data/invite_pool.php');
  331. break;
  332. case 'torrent_stats':
  333. include(SERVER_ROOT.'/sections/tools/data/torrent_stats.php');
  334. break;
  335. case 'user_flow':
  336. include(SERVER_ROOT.'/sections/tools/data/user_flow.php');
  337. break;
  338. case 'economic_stats':
  339. include(SERVER_ROOT.'/sections/tools/data/economic_stats.php');
  340. break;
  341. case 'service_stats':
  342. include(SERVER_ROOT.'/sections/tools/development/service_stats.php');
  343. break;
  344. case 'database_specifics':
  345. include(SERVER_ROOT.'/sections/tools/data/database_specifics.php');
  346. break;
  347. case 'special_users':
  348. include(SERVER_ROOT.'/sections/tools/data/special_users.php');
  349. break;
  350. case 'browser_support':
  351. include(SERVER_ROOT.'/sections/tools/data/browser_support.php');
  352. break;
  353. //END Data
  354. //Misc
  355. case 'update_geoip':
  356. include(SERVER_ROOT.'/sections/tools/development/update_geoip.php');
  357. break;
  358. case 'dupe_ips':
  359. include(SERVER_ROOT.'/sections/tools/misc/dupe_ip.php');
  360. break;
  361. case 'clear_cache':
  362. include(SERVER_ROOT.'/sections/tools/development/clear_cache.php');
  363. break;
  364. case 'create_user':
  365. include(SERVER_ROOT.'/sections/tools/misc/create_user.php');
  366. break;
  367. case 'manipulate_tree':
  368. include(SERVER_ROOT.'/sections/tools/misc/manipulate_tree.php');
  369. break;
  370. case 'misc_values':
  371. include(SERVER_ROOT.'/sections/tools/development/misc_values.php');
  372. break;
  373. case 'recommendations':
  374. include(SERVER_ROOT.'/sections/tools/misc/recommendations.php');
  375. break;
  376. case 'analysis':
  377. include(SERVER_ROOT.'/sections/tools/misc/analysis.php');
  378. break;
  379. case 'database_key':
  380. include(SERVER_ROOT.'/sections/tools/misc/database_key.php');
  381. break;
  382. case 'process_info':
  383. include(SERVER_ROOT.'/sections/tools/development/process_info.php');
  384. break;
  385. case 'rerender_gallery':
  386. include(SERVER_ROOT.'/sections/tools/development/rerender_gallery.php');
  387. break;
  388. case 'sandbox1':
  389. include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox1.php');
  390. break;
  391. case 'sandbox2':
  392. include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox2.php');
  393. break;
  394. case 'sandbox3':
  395. include(SERVER_ROOT.'/sections/tools/sandboxes/sandbox3.php');
  396. break;
  397. case 'public_sandbox':
  398. include(SERVER_ROOT.'/sections/tools/sandboxes/public_sandbox.php');
  399. break;
  400. case 'mod_sandbox':
  401. if (check_perms('users_mod')) {
  402. include(SERVER_ROOT.'/sections/tools/sandboxes/mod_sandbox.php');
  403. } else {
  404. error(403);
  405. }
  406. break;
  407. case 'bbcode_sandbox':
  408. include(SERVER_ROOT.'/sections/tools/sandboxes/bbcode_sandbox.php');
  409. break;
  410. case 'calendar':
  411. include(SERVER_ROOT.'/sections/tools/managers/calendar.php');
  412. break;
  413. case 'get_calendar_event':
  414. include(SERVER_ROOT.'/sections/tools/managers/ajax_get_calendar_event.php');
  415. break;
  416. case 'take_calendar_event':
  417. include(SERVER_ROOT.'/sections/tools/managers/ajax_take_calendar_event.php');
  418. break;
  419. case 'mass_pm':
  420. include(SERVER_ROOT.'/sections/tools/managers/mass_pm.php');
  421. break;
  422. case 'take_mass_pm':
  423. include(SERVER_ROOT.'/sections/tools/managers/take_mass_pm.php');
  424. break;
  425. default:
  426. include(SERVER_ROOT.'/sections/tools/tools.php');
  427. }
  428. ?>