test_same.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. function DelInfo($id = '')
  4. {
  5. global $db;
  6. global $db_mymps;
  7. if (!$id) {
  8. exit;
  9. }
  10. $get_row = $db->getRow('SELECT * FROM `' . $db_mymps . 'information` WHERE id = \'' . $id . '\'');
  11. @unlink(MYMPS_ROOT . $get_row['html_path']);
  12. if (!empty($get_row['img_path'])) {
  13. $del = $db->getAll('SELECT path,prepath FROM `' . $db_mymps . 'info_img` WHERE infoid=\'' . $id . '\'');
  14. foreach ($del as $k => $v) {
  15. @unlink(MYMPS_ROOT . $v[path]);
  16. @unlink(MYMPS_ROOT . $v[prepath]);
  17. }
  18. mymps_delete('info_img', 'WHERE infoid = \'' . $id . '\'');
  19. }
  20. mymps_delete('comment', 'WHERE type = \'information\' AND typeid = \'' . $id . '\'');
  21. 1 < $get_row[modid] && mymps_delete('information_' . $get_row[modid], 'WHERE id = \'' . $id . '\'');
  22. mymps_delete('information', 'WHERE id = \'' . $id . '\'');
  23. }
  24. define('CURSCRIPT', 'test_same');
  25. require_once dirname(__FILE__) . '/global.php';
  26. require_once MYMPS_INC . '/db.class.php';
  27. (!defined('IN_ADMIN') || !defined('IN_MYMPS')) && exit('Access Denied');
  28. $part = isset($part) ? $part : 'default';
  29. if ($part == 'default') {
  30. $here = '重复分类信息主题检测';
  31. chk_admin_purview('purview_删除重复');
  32. include mymps_tpl('test_same');
  33. } else {
  34. if ($part == 'do_list') {
  35. $query = $db->query('SELECT COUNT(title) AS dd,title FROM `' . $db_mymps . 'information` GROUP BY title ORDER BY dd DESC LIMIT 0,' . $pagesize);
  36. $allarc = 0;
  37. include mymps_tpl('test_same_list');
  38. exit;
  39. } else {
  40. if ($part == 'do_action') {
  41. if (empty($infoTitles)) {
  42. header('Content-Type: text/html; charset=' . $charset . '');
  43. echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8' . $charset . '">' . "\r\n";
  44. write_msg('没有指定删除的文档!');
  45. exit;
  46. }
  47. $totalarc = 0;
  48. $orderby = $deltype == 'delnew' ? ' ORDER BY id DESC ' : ' ORDER BY id ASC ';
  49. foreach ($infoTitles as $titles => $title) {
  50. $title = trim($title);
  51. $title = addslashes($title == '' ? '' : urldecode($title));
  52. $sql = 'SELECT id,title FROM `' . $db_mymps . 'information` WHERE title=\'' . $title . '\' ' . $orderby;
  53. $query = $db->query($sql);
  54. $rownum = $db->num_rows($query);
  55. if ($rownum < 2) {
  56. continue;
  57. }
  58. $i = 1;
  59. while ($row = $db->fetchRow($query)) {
  60. $i++;
  61. $nid = $row['id'];
  62. $ntitle = $row['title'];
  63. if ($rownum < $i) {
  64. continue;
  65. }
  66. $totalarc++;
  67. DelInfo($nid);
  68. }
  69. }
  70. $db->query(' OPTIMIZE TABLE `' . $db_mymps . 'information`; ');
  71. write_msg('一共删除了 [<font color=red>' . $totalarc . '</font>] 篇重复的信息主题!', 'olmsg');
  72. exit;
  73. }
  74. }
  75. }