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

37 lines
1.3KB

  1. <?php
  2. /**
  3. * 广告js调用方式
  4. *
  5. * @version $Id: ad_js.php 1 20:30 2010年7月8日Z tianya $
  6. * @package DedeBIZ.Site
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/../system/common.inc.php");
  12. if (isset($arcID)) $aid = $arcID;
  13. $arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
  14. if ($aid == 0) die('dedebiz');
  15. $cacheFile = DEDEDATA.'/cache/myad-'.$aid.'.htm';
  16. if (isset($nocache) || !file_exists($cacheFile) || time() - filemtime($cacheFile) > $cfg_puccache_time) {
  17. $row = $dsql->GetOne("SELECT * FROM `#@__myad` WHERE aid='$aid' ");
  18. $adbody = '';
  19. if ($row['timeset'] == 0) {
  20. $adbody = $row['normbody'];
  21. } else {
  22. $ntime = time();
  23. if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
  24. $adbody = $row['expbody'];
  25. } else {
  26. $adbody = $row['normbody'];
  27. }
  28. }
  29. $adbody = str_replace('"', '\"', $adbody);
  30. $adbody = str_replace("\r", "\\r", $adbody);
  31. $adbody = str_replace("\n", "\\n", $adbody);
  32. $adbody = "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
  33. $fp = fopen($cacheFile, 'w');
  34. fwrite($fp, $adbody);
  35. fclose($fp);
  36. }
  37. include $cacheFile;