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

44 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 DedeCMS.Site
  8. * @copyright Copyright (c) 2020, 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. {
  19. $row = $dsql->GetOne("SELECT * FROM `#@__myad` WHERE aid='$aid' ");
  20. $adbody = '';
  21. if($row['timeset']==0)
  22. {
  23. $adbody = $row['normbody'];
  24. }
  25. else
  26. {
  27. $ntime = time();
  28. if($ntime > $row['endtime'] || $ntime < $row['starttime']) {
  29. $adbody = $row['expbody'];
  30. } else {
  31. $adbody = $row['normbody'];
  32. }
  33. }
  34. $adbody = str_replace('"', '\"',$adbody);
  35. $adbody = str_replace("\r", "\\r",$adbody);
  36. $adbody = str_replace("\n", "\\n",$adbody);
  37. $adbody = "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
  38. $fp = fopen($cacheFile, 'w');
  39. fwrite($fp, $adbody);
  40. fclose($fp);
  41. }
  42. include $cacheFile;