portalcp_related.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: portalcp_related.php 30723 2012-06-14 03:49:17Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $op = in_array($_GET['op'], array('manual','search','add','get')) ? $_GET['op'] : '';
  12. $aid = intval($_GET['aid']);
  13. $catid = intval($_GET['catid']);
  14. if($aid) {
  15. check_articleperm($catid, $aid);
  16. } else {
  17. check_articleperm($catid);
  18. }
  19. $wherearr = $articlelist = $relatedarr = array();
  20. if($op == 'manual') {
  21. $manualid = intval($_GET['manualid']);
  22. $ra = array();
  23. if($manualid) {
  24. $ra = C::t('portal_article_title')->fetch($manualid);
  25. }
  26. } elseif($op == 'get') {
  27. $id = trim($_GET['id']);
  28. $getidarr = explode(',', $id);
  29. $getidarr = array_map('intval', $getidarr);
  30. $getidarr = array_unique($getidarr);
  31. $getidarr = array_filter($getidarr);
  32. if($getidarr) {
  33. $list = array();
  34. $query = C::t('portal_article_title')->fetch_all($getidarr);
  35. foreach($query as $value) {
  36. $list[$value['aid']] = $value;
  37. }
  38. foreach($getidarr as $getid) {
  39. if($list[$getid]) {
  40. $articlelist[] = $list[$getid];
  41. }
  42. }
  43. }
  44. } elseif($op == 'search') {
  45. $catids = array();
  46. $searchkey = addslashes(stripsearchkey($_GET['searchkey']));
  47. $searchcate = intval($_GET['searchcate']);
  48. $catids = category_get_childids('portal', $searchcate);
  49. $catids[] = $searchcate;
  50. if($searchkey) {
  51. $wherearr[] = "title LIKE '%$searchkey%'";
  52. }
  53. $searchkey = dhtmlspecialchars($searchkey);
  54. if($searchcate) {
  55. $wherearr[] = "catid IN (".dimplode($catids).")";
  56. }
  57. $wheresql = implode(' AND ', $wherearr);
  58. $count = C::t('portal_article_title')->fetch_all_by_sql($wheresql, '', 0, 0, 1);
  59. if($count) {
  60. $query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, 'ORDER BY dateline DESC', 0, 50);
  61. foreach($query as $value) {
  62. $articlelist[] = $value;
  63. }
  64. }
  65. } elseif($op == 'add') {
  66. $relatedid = trim($_GET['relatedid']);
  67. $relatedarr = explode(',', $relatedid);
  68. $relatedarr = array_map('intval', $relatedarr);
  69. $relatedarr = array_unique($relatedarr);
  70. $relatedarr = array_filter($relatedarr);
  71. if($relatedarr) {
  72. $query = C::t('portal_article_title')->fetch_all($relatedarr);
  73. $list = array();
  74. foreach($query as $value) {
  75. $list[$value['aid']] = $value;
  76. }
  77. foreach($relatedarr as $relateid) {
  78. if($list[$relateid]) {
  79. $articlelist[] = $list[$relateid];
  80. }
  81. }
  82. }
  83. if($_GET['update'] && $aid) {
  84. addrelatedarticle($aid, $relatedarr);
  85. }
  86. } else {
  87. $count = 0;
  88. $query = C::t('portal_article_title')->range(0, 50);
  89. foreach($query as $value) {
  90. $articlelist[] = $value;
  91. $count++;
  92. }
  93. }
  94. $category = category_showselect('portal', 'searchcate', false, $_GET[searchcate]);
  95. include_once template("portal/portalcp_related_article");
  96. ?>