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

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