/** * WebAdModel::delWebAd() * 网站广告删除 * @param integer $id ID * @return bool */ public static function delWebAd($id) { self::initDB(); $sql = "UPDATE `" . self::$prefix . self::$table . "` SET is_delete = 1 WHERE id = {$id}"; $query = self::$dbConn->query($sql); if ($query) { $rows = self::$dbConn->affected_rows(); if ($rows) { return $res; } else { self::$errCode = 10001; self::$errMsg = "删除数据失败"; return false; } } else { self::$errCode = 10000; self::$errMsg = "执行SQL语句失败!"; return false; } }
/** * WebAdAct::act_delWebAd() * 删除网站广告 * @param int $id ID * @return bool */ public function act_delWebAd() { $id = isset($_POST["id"]) ? intval(trim($_POST["id"])) : 0; $act = isset($_REQUEST["act"]) ? post_check($_REQUEST["act"]) : ""; $mod = isset($_REQUEST["mod"]) ? post_check($_REQUEST["mod"]) : ""; if (!AuthUser::checkLogin($mod, $act)) { self::$errCode = 30001; self::$errMsg = "对不起,您无数据删除权限!"; return false; } if (empty($id) || !is_numeric($id)) { self::$errCode = 30000; self::$errMsg = "ID有误!"; return false; } $res = WebAdModel::delWebAd($id); self::$errCode = WebAdModel::$errCode; self::$errMsg = WebAdModel::$errMsg; return $res; }
/** * WebAdStatAct::actIndex() * 列出符合条件的数据并分页显示 * @param string $condition 查询条件 * @param integer $curpage 页码 * @param integer $pagenum 每页个数 * @return array */ public function actIndex() { $data = array(); $condition = ''; $ipNum = 0; $webAdStat = new WebAdStatModel(); //接收参数生成条件 $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1; $adId = isset($_GET['adId']) ? abs(intval($_GET['adId'])) : 0; $type = isset($_GET['type']) ? trim($_GET['type']) : ''; $key = isset($_GET['key']) ? post_check(trim($_GET['key'])) : ''; $timeNode = isset($_GET['timeNode']) ? post_check(trim($_GET['timeNode'])) : ''; $condition .= "1"; if (!empty($adId)) { $condition .= " AND a.adId = '{$adId}'"; } if ($type && $key) { if (!in_array($type, array('ip'))) { redirect_to("index.php?mod=webAdStat&act=index"); } if ($type == 'ip') { if (!preg_match("/^([\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3})\$/", $key)) { show_message($this->smarty, "IP地址参数有误!", ""); exit; } $ipNum = sprintf('%u', ip2long($key)); $condition .= " AND a.ipNum = '{$ipNum}'"; } else { $condition .= ' AND a.' . $type . " = '" . $key . "'"; } } if (!empty($timeNode)) { if (!in_array($timeNode, array('addTime', 'lastTime'))) { redirect_to("index.php?mod=webAdStat&act=index"); } $startTime = isset($_GET['startTime']) ? strtotime(trim($_GET['startTime']) . " 00:00:00") : strtotime(date("Y-m-d", time()) . " 00:00:00"); $endTime = isset($_GET['endTime']) ? strtotime(trim($_GET['endTime']) . " 23:59:59") : strtotime(date("Y-m-d", time()) . " 23:59:59"); if ($startTime && $endTime) { $condition .= ' AND a.' . $timeNode . " BETWEEN '" . $startTime . "' AND " . "'" . $endTime . "'"; } } //获取符合条件的数据并分页 $pagenum = 20; $total = $webAdStat->modListCount($condition); $res = $webAdStat->modList($condition, $curpage, $pagenum); $page = new Page($total, $pagenum, '', 'CN'); $pageStr = ""; if ($res) { if ($total > $pagenum) { $pageStr = $page->fpage(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $pageStr = $page->fpage(array(0, 1, 2, 3)); } } else { $pageStr = '暂无数据'; } //封装数据返回 $data['key'] = $key; $data['type'] = $type; $data['adId'] = $adId; $data['lists'] = $res; $data['pages'] = $pageStr; $data['timeNode'] = $timeNode; $data['startTime'] = $startTime ? date('Y-m-d', $startTime) : ''; $data['endTime'] = $endTime ? date('Y-m-d', $endTime) : ''; $data['adList'] = WebAdModel::adList(1, "id,topic"); self::$errCode = webAdStatModel::$errCode; self::$errMsg = webAdStatModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); exit; } return $data; }