if (!$aid) { return false; } $a or $a = $db->get_one("SELECT * FROM {$DT_PRE}ad WHERE aid={$aid}"); $p = $db->get_one("SELECT * FROM {$DT_PRE}ad_place WHERE pid={$a['pid']}"); if (!$p || !$a) { return false; } $ad_moduleid = $p['moduleid']; $pid = $p['pid']; $typeid = $p['typeid']; $width = $p['width']; $height = $p['height']; $areaid = intval($a['areaid']); $fileroot = DT_CACHE . '/htm/'; $filename = $fileroot . ad_name($a); $template = $p['template'] ? $p['template'] : 'ad_code'; if ($p['code']) { $default = $typeid > 5 ? 'ad_' . $ad_moduleid . '_d' . $typeid . '.htm' : 'ad_' . $pid . '_d0.htm'; file_put($fileroot . $default, '<!--' . ($DT_TIME + 86400 * 365 * 10) . '-->' . $p['code']); } if ($typeid == 7) { $totime = 0; $code = ''; $ad = $db->query("SELECT * FROM {$DT_PRE}ad WHERE pid={$p['pid']} AND status=3 AND key_moduleid={$a['key_moduleid']} AND key_catid={$a['key_catid']} AND key_word='{$a['key_word']}' AND fromtime<{$DT_TIME} AND totime>{$DT_TIME} AND areaid={$areaid} ORDER BY listorder ASC,addtime ASC"); while ($t = $db->fetch_array($ad)) { if ($t['totime'] > $totime) { $totime = $t['totime']; } $code .= $t['code']; }
} else { if ($html == 'spread') { $r = $db->get_one("SELECT * FROM {$DT_PRE}spread ORDER BY rand()"); $r or exit; $itemid = $r['itemid']; $filename = DT_CACHE . '/htm/m' . $r['mid'] . '_k' . urlencode($r['word']) . '.htm'; if ($DT_TIME - @filemtime($filename) > $task_item) { $MOD = cache_read('module-' . $r['mid'] . '.php'); tohtml('spread', $module); } } else { if ($html == 'ad') { $a = $db->get_one("SELECT * FROM {$DT_PRE}ad ORDER BY rand()"); $a or exit; $aid = $a['aid']; if ($DT_TIME - @filemtime(DT_CACHE . '/htm/' . ad_name($a)) > $task_item) { if ($a['typeid'] == 6) { $MOD['linkurl'] = $MODULE[$a['key_moduleid']]['linkurl']; } tohtml('ad', $module); } } else { if ($html == 'xml') { $MOD = $EXT; if ($MOD['sitemaps'] && $DT_TIME - @filemtime(DT_ROOT . '/sitemaps.xml') > $MOD['sitemaps_update'] * 60) { tohtml('sitemaps', $module); } if ($MOD['baidunews'] && $DT_TIME - @filemtime(DT_ROOT . '/baidunews.xml') > $MOD['baidunews_update'] * 60) { tohtml('baidunews', $module); } if (!$_userid) {
function delete($aid) { if (is_array($aid)) { foreach ($aid as $v) { $this->delete($v); } } else { $this->aid = $aid; $a = $this->get_one(); $filename = ad_name($a); file_del(DT_CACHE . '/htm/' . $filename); $userid = get_user($a['username']); if ($a['image_src']) { delete_upload($a['image_src'], $userid); } if ($a['flash_src']) { delete_upload($a['flash_src'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE aid={$aid}"); $this->db->query("UPDATE {$this->table_place} SET ads=ads-1 WHERE pid={$a['pid']}"); } }