国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

114 line
7.4KB

  1. <?php
  2. /**
  3. * 添加联动多筛选
  4. *
  5. * @param string $str 字符
  6. * @param string $stype 类型
  7. * @param string $fieldset 字段列表
  8. * @param string $loadtype 载入类型
  9. */
  10. function litimgurls($imgid=0)
  11. {
  12. global $lit_imglist,$dsql;
  13. $row = $dsql->GetOne("SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c ON a.channel=c.id where a.id='$imgid'");
  14. $addtable = trim($row['addtable']);
  15. $row = $dsql->GetOne("Select imgurls From `$addtable` where aid='$imgid'");
  16. $ChannelUnit = new ChannelUnit(2,$imgid);
  17. $lit_imglist = $ChannelUnit->GetlitImgLinks($row['imgurls']);
  18. return $lit_imglist;
  19. }
  20. //字符过滤函数,用于安全
  21. function string_filter($str,$stype="inject") {
  22. if ($stype=="inject") {
  23. $str = str_replace (
  24. array ("select", "insert", "update", "delete", "alter", "cas", "union", "into", "load_file", "outfile", "create", "join", "where", "like", "drop", "modify", "rename", "'", "/*", "*", "../", "./"),
  25. array ("","","","","","","","","","","","","","","","","","","","","",""),
  26. $str);
  27. } else if ($stype=="xss") {
  28. $farr = array ("/\s+/" , "/<(\/?)(script|META|STYLE|HTML|HEAD|BODY|STYLE |i?frame|b|strong|style|html|img|P|o:p|iframe|u|em|strike|BR|div|a|TABLE|TBODY|object|tr|td|st1:chsdate|FONT|span|MARQUEE|body|title|\r\n|link|meta|\?|\%)([^>]*?)>/isU", "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",);
  29. $tarr = array (" ","","\\1\\2",);
  30. $str = preg_replace ($farr, $tarr, $str);
  31. $str = str_replace (
  32. array( "<", ">", "'", "\"", ";", "/*", "*", "../", "./"),
  33. array("&lt;","&gt;","","","","","","",""),
  34. $str);
  35. }
  36. return $str;
  37. }
  38. //载入自定义表单,用于发布
  39. function AddFilter($channelid, $type=1, $fieldsnamef=array(), $defaulttid=0, $loadtype='autofield')
  40. {
  41. global $tid,$dsql,$id;
  42. $tid = $defaulttid ? $defaulttid : $tid;
  43. if ($id!="")
  44. {
  45. $tidsq = $dsql->GetOne(" Select typeid From `#@__archives` where id='$id' ");
  46. $tid = $tidsq["typeid"];
  47. }
  48. $nofilter = (isset($_REQUEST['TotalResult']) ? "&TotalResult=".$_REQUEST['TotalResult'] : '').(isset($_REQUEST['PageNo']) ? "&PageNo=".$_REQUEST['PageNo'] : '');
  49. $filterarr = string_filter(stripos($_SERVER['REQUEST_URI'], "list.php?tid=") ? str_replace($nofilter, '', $_SERVER['REQUEST_URI']) : $GLOBALS['cfg_cmsurl']."/plus/list.php?tid=".$tid);
  50. $cInfos = $dsql->GetOne(" Select * From `#@__channeltype` where id='$channelid' ");
  51. $fieldset=$cInfos['fieldset'];
  52. $dtp = new DedeTagParse();
  53. $dtp->SetNameSpace('field','<','>');
  54. $dtp->LoadSource($fieldset);
  55. $dede_addonfields = '';
  56. if(is_array($dtp->CTags))
  57. {
  58. foreach($dtp->CTags as $tida=>$ctag)
  59. {
  60. $fieldsname = $fieldsnamef ? explode(",", $fieldsnamef) : explode(",", $ctag->GetName());
  61. if(($loadtype!='autofield' || ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1)) && in_array($ctag->GetName(), $fieldsname) )
  62. {
  63. $href1 = explode($ctag->GetName().'=', $filterarr);
  64. $href2 = explode('&', $href1[1]);
  65. $fields_value = $href2[0];
  66. $fields_value1 = explode('|', $fields_value);
  67. $dede_addonfields .= '<b>'.$ctag->GetAtt('itemname').':</b>';
  68. switch ($type) {
  69. case 1:
  70. $dede_addonfields .= (preg_match("/&".$ctag->GetName()."=/is",$filterarr,$regm) ? '<a href="'.str_replace("&".$ctag->GetName()."=".$fields_value,"",$filterarr).'" style="display:inline-block;padding:.25rem .5rem;line-height:1.5;color:#fff;background:#008e38;border-color:#008e38;border-radius:.2rem">全部</a>' : '<span style="display:inline-block;padding:.25rem .5rem;line-height:1.5;color:#fff;background:#dc3545;border-color:#dc3545;border-radius:.2rem">全部</span>').'&nbsp;';
  71. $addonfields_items = explode(",",$ctag->GetAtt('default'));
  72. for ($i=0; $i<count($addonfields_items); $i++)
  73. {
  74. $href = stripos($filterarr,$ctag->GetName().'=') ? str_replace("=".$fields_value,"=".$fields_value."|".urlencode($addonfields_items[$i]),$filterarr) : $filterarr.'&'.$ctag->GetName().'='.urlencode($addonfields_items[$i]);
  75. $is_select = in_array(urlencode($addonfields_items[$i]), $fields_value1) ? 1 : 0;
  76. $fields_value2 = "";
  77. for ($j=0; $j<count($fields_value1); $j++)
  78. {
  79. $fields_value2 .= $fields_value1[$j] != urlencode($addonfields_items[$i]) ? $fields_value1[$j].($j<count($fields_value1)-1 ? "|" : "") : "";
  80. }
  81. $fields_value2 = rtrim($fields_value2, "|");
  82. $href3 = str_replace(array("&".$ctag->GetName()."=".$fields_value,$ctag->GetName()."=".$fields_value, "&".$ctag->GetName()."=&"), array("&".$ctag->GetName()."=".$fields_value2,$ctag->GetName()."=".$fields_value2, "&"), $filterarr);
  83. $href3 = !end(explode("=", $href3)) ? str_replace("&".end(explode("&", $href3)), "", $href3) : $href3;
  84. $dede_addonfields .= ($fields_value!=urlencode($addonfields_items[$i]) && $is_select!=1 ? '<a title="'.$addonfields_items[$i].'" href="'.$href.'" style="display:inline-block;padding:.25rem .5rem;line-height:1.5;color:#fff;background:#008e38;border-color:#008e38;border-radius:.2rem">'.$addonfields_items[$i].'</a>' : '<a title="'.$addonfields_items[$i].'" href="'.$href3.'" style="display:inline-block;padding:.25rem .5rem;line-height:1.5;color:#fff;background:#dc3545;border-color:#dc3545;border-radius:.2rem">'.$addonfields_items[$i].'<span style="margin-left:6px;color:#fff">×</span></a>')."&nbsp;";
  85. }
  86. $dede_addonfields .= '<br><br>';
  87. break;
  88. case 2:
  89. $dede_addonfields .= (preg_match("/&".$ctag->GetName()."=/is",$filterarr,$regm) ? '<a href="'.str_replace("&".$ctag->GetName()."=".$fields_value,"",$filterarr).'">全部</a>' : '<span>全部</span>').'&nbsp;';
  90. $addonfields_items = explode(",",$ctag->GetAtt('default'));
  91. for ($i=0; $i<count($addonfields_items); $i++)
  92. {
  93. $href = stripos($filterarr,$ctag->GetName().'=') ? str_replace("=".$fields_value,"=".$fields_value."|".urlencode($addonfields_items[$i]),$filterarr) : $filterarr.'&'.$ctag->GetName().'='.urlencode($addonfields_items[$i]);
  94. $is_select = in_array(urlencode($addonfields_items[$i]), $fields_value1) ? 1 : 0;
  95. $fields_value2 = "";
  96. for ($j=0; $j<count($fields_value1); $j++)
  97. {
  98. $fields_value2 .= $fields_value1[$j] != urlencode($addonfields_items[$i]) ? $fields_value1[$j].($j<count($fields_value1)-1 ? "|" : "") : "";
  99. }
  100. $fields_value2 = rtrim($fields_value2, "|");
  101. $href3 = str_replace(array("&".$ctag->GetName()."=".$fields_value,$ctag->GetName()."=".$fields_value, "&".$ctag->GetName()."=&"), array("&".$ctag->GetName()."=".$fields_value2,$ctag->GetName()."=".$fields_value2, "&"), $filterarr);
  102. $href3 = !end(explode("=", $href3)) ? str_replace("&".end(explode("&", $href3)), "", $href3) : $href3;
  103. $dede_addonfields .= ($fields_value!=urlencode($addonfields_items[$i]) && $is_select!=1 ? '<input type="checkbox" title="'.$addonfields_items[$i].'" value="'.$href.'" onclick="window.location=this.value">&nbsp;<a title="'.$addonfields_items[$i].'" href="'.$href.'">'.$addonfields_items[$i].'</a>' : '<input type="checkbox" checked="checked" title="'.$addonfields_items[$i].'" value="'.$href3.'" onclick="window.location=this.value">&nbsp;<a title="'.$addonfields_items[$i].'" href="'.$href3.'" class="cur">'.$addonfields_items[$i].'</a>')."&nbsp;";
  104. }
  105. $dede_addonfields .= '<br><br>';
  106. break;
  107. }
  108. }
  109. }
  110. }
  111. echo $dede_addonfields;
  112. }