request->param('nocache', 0); $cacheTag = 'advn-' . md5($tags); $htmlbody = $nocache ? '' : $this->cacheGet($cacheTag); if (empty($htmlbody)) { $list = Loader::model('ad')->getList(['stat' => ['eq', 0], 'tags' => $tags, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num); if (empty($list)) { $this->cacheTag('adTagVn')->set($cacheTag, "\");\r\n-->\r\n"); exit; } $htmlbody = ''; $expire = 3600; foreach ($list as $row) { $adbody = ''; if ($row['timeset'] == 0) { $adbody = $row['normbody']; $exp = 0; } else { $ntime = time(); if ($ntime > $row['endtime'] || $ntime < $row['starttime']) { $adbody = $row['expbody']; $exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0; } else { $adbody = $row['normbody']; $exp = $row['endtime'] - $ntime; } } $expire = $exp > 0 && $exp < $expire ? $exp : $expire; $adbody = str_replace('"', '\"', $adbody); $adbody = str_replace("\r", "\\r", $adbody); $adbody = str_replace("\n", "\\n", $adbody); $htmlbody .= "\r\n"; //print_r($htmlbody);exit; } $this->cacheTag('adTagVn')->set($cacheTag, $htmlbody, $expire); } echo $htmlbody; exit; } exit(' Error! '); } public function tagsli($tags = '', $num = 1) { if ($tags) { $nocache = $this->request->param('nocache', 0); $cacheTag = 'advn-' . md5($tags); $htmlbody = $nocache ? '' : $this->cacheGet($cacheTag); if (empty($htmlbody)) { $list = Loader::model('ad')->getList(['stat' => ['eq', 0], 'tags' => $tags, 'typeid' => 32, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num); if (empty($list)) { $this->cacheTag('adTagVn')->set($cacheTag, "\");\r\n-->\r\n"); exit; } $htmlbody = ''; $expire = 3600; foreach ($list as $k => $row) { $adbody = ''; if ($row['timeset'] == 0) { $adbody = $row['normbody']; $exp = 0; } else { $ntime = time(); if ($ntime > $row['endtime'] || $ntime < $row['starttime']) { $adbody = $row['expbody']; $exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0; } else { $adbody = $row['normbody']; $exp = $row['endtime'] - $ntime; } } $expire = $exp > 0 && $exp < $expire ? $exp : $expire; $adbody = str_replace('"', '\"', $adbody); $adbody = str_replace("\r", "\\r", $adbody); $adbody = str_replace("\n", "\\n", $adbody); $htmlbody .= "\r\n"; //print_r($htmlbody);exit; } $this->cacheTag('adTagVn')->set($cacheTag, $htmlbody, $expire); } echo $htmlbody; exit; } exit(' Error! '); } public function index($id = 0) { if ($id > 0) { $nocache = $this->request->param('nocache', 0); $cacheTag = 'advn-' . $id; $adbody = $nocache ? '' : $this->cacheGet($cacheTag); if (empty($adbody)) { $row = Loader::model('ad')->where(['stat' => ['eq', 0], 'id' => $id, 'country_code' => $this->country_code])->find(); if (empty($row)) { $this->cacheTag('adTagVn')->set($cacheTag, "\");\r\n-->\r\n"); exit; } $adbody = ''; if ($row['timeset'] == 0) { $adbody = $row['normbody']; $expire = 0; } else { $ntime = time(); if ($ntime > $row['endtime'] || $ntime < $row['starttime']) { $adbody = $row['expbody']; $expire = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0; } else { $adbody = $row['normbody']; $expire = $row['endtime'] - $ntime; } } $adbody = str_replace('"', '\"', $adbody); $adbody = str_replace("\r", "\\r", $adbody); $adbody = str_replace("\n", "\\n", $adbody); $adbody = "\r\n"; $this->cacheTag('adTagVn')->set($cacheTag, $adbody, $expire); } echo $adbody; exit; } exit(' Error! '); } public function cat($id = '', $num = 1) { if ($id) { $nocache = $this->request->param('nocache', 0); $cacheTag = 'advn-' . $id; $htmlbody = $nocache ? '' : $this->cacheGet($cacheTag); if (empty($htmlbody)) { $list = Loader::model('ad')->getList(['stat' => ['eq', 0], 'typeid' => $id, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num); if (empty($list)) { $this->cacheTag('adTagVn')->set($cacheTag, "\");\r\n-->\r\n"); exit; } $htmlbody = ''; $expire = 3600; foreach ($list as $row) { $adbody = ''; if ($row['timeset'] == 0) { $adbody = $row['normbody']; $exp = 0; } else { $ntime = time(); if ($ntime > $row['endtime'] || $ntime < $row['starttime']) { $adbody = $row['expbody']; $exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0; } else { $adbody = $row['normbody']; $exp = $row['endtime'] - $ntime; } } $expire = $exp > 0 && $exp < $expire ? $exp : $expire; $adbody = str_replace('"', '\"', $adbody); $adbody = str_replace("\r", "\\r", $adbody); $adbody = str_replace("\n", "\\n", $adbody); $htmlbody .= "\r\n"; } $this->cacheTag('adTagVn')->set($cacheTag, $htmlbody, $expire); } echo $htmlbody; exit; } exit(' Error! '); } public function previewjs($id) { $id = intval($id); if ($id > 0) { echo ''; } exit(); } }