国内流行的内容管理系统(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.

52 lines
1.9KB

  1. <?php
  2. /**
  3. *
  4. * 自定义标签js调用方式
  5. *
  6. * @version $Id: mytag_js.php$
  7. * @package DedeBIZ.Site
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__).'/../include/common.inc.php');
  13. require_once(DEDEINC.'/arc.partview.class.php');
  14. if (isset($arcID)) $aid = $arcID;
  15. $arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
  16. if ($aid == 0) die(" document.write('Request Error!'); ");
  17. $cacheFile = DEDEDATA.'/cache/mytag-'.$aid.'.htm';
  18. if (isset($nocache) || !file_exists($cacheFile) || time() - filemtime($cacheFile) > $cfg_puccache_time) {
  19. $pv = new PartView();
  20. $row = $pv->dsql->GetOne(" SELECT * FROM `#@__mytag` WHERE aid='$aid' ");
  21. if (!is_array($row)) {
  22. $myvalues = "<!--\r\ndocument.write('Not found input!');\r\n-->";
  23. } else {
  24. $tagbody = '';
  25. if ($row['timeset'] == 0) {
  26. $tagbody = $row['normbody'];
  27. } else {
  28. $ntime = time();
  29. if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
  30. $tagbody = $row['expbody'];
  31. } else {
  32. $tagbody = $row['normbody'];
  33. }
  34. }
  35. $pv->SetTemplet($tagbody, 'string');
  36. $myvalues = $pv->GetResult();
  37. $myvalues = str_replace('"', '\"', $myvalues);
  38. $myvalues = str_replace("\r", "\\r", $myvalues);
  39. $myvalues = str_replace("\n", "\\n", $myvalues);
  40. $myvalues = "<!--\r\ndocument.write(\"{$myvalues}\");\r\n-->\r\n";
  41. file_put_contents($cacheFile, $myvalues);
  42. /* 使用 file_put_contents替换下列代码提高执行效率
  43. $fp = fopen($cacheFile, 'w');
  44. fwrite($fp, $myvalues);
  45. fclose($fp);
  46. */
  47. }
  48. }
  49. include $cacheFile;