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

41 lines
1.3KB

  1. <?php
  2. /**
  3. *
  4. * 广告JS调用方式
  5. *
  6. * @version $Id: ad_js.php 1 20:30 2010年7月8日Z tianya $
  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. if (isset($arcID)) $aid = $arcID;
  14. $arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
  15. if ($aid == 0) die(' Request Error! ');
  16. $cacheFile = DEDEDATA.'/cache/myad-'.$aid.'.htm';
  17. if (isset($nocache) || !file_exists($cacheFile) || time() - filemtime($cacheFile) > $cfg_puccache_time) {
  18. $row = $dsql->GetOne("SELECT * FROM `#@__myad` WHERE aid='$aid' ");
  19. $adbody = '';
  20. if ($row['timeset'] == 0) {
  21. $adbody = $row['normbody'];
  22. } else {
  23. $ntime = time();
  24. if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
  25. $adbody = $row['expbody'];
  26. } else {
  27. $adbody = $row['normbody'];
  28. }
  29. }
  30. $adbody = str_replace('"', '\"', $adbody);
  31. $adbody = str_replace("\r", "\\r", $adbody);
  32. $adbody = str_replace("\n", "\\n", $adbody);
  33. $adbody = "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
  34. $fp = fopen($cacheFile, 'w');
  35. fwrite($fp, $adbody);
  36. fclose($fp);
  37. }
  38. include $cacheFile;