' . $city['cityname'] . $GLOBALS['mymps_global']['SiteName'] . '' . ' ' . $raquo . ' ' . ' ' . $city[cityname] . '优惠券'; $page_title = $city['cityname'] . '优惠券-' . $mymps_global['SiteName']; if (!empty($cate_id)) { $page_title = htmlspecialchars($couponclass[$cate_id]['cate_name']) . '-' . $page_title; $location .= ' ' . $raquo . ' ' . htmlspecialchars($couponclass[$cate_id]['cate_name']) . ''; } $areaname = $mymps_global['SiteCity'] . ($areaid ? get_areaname($areaid) : ''); $page_title = $areaname . $page_title; if (!empty($str)) { $page_title = $str . '-' . $page_title; $location .= ' ' . $raquo . '  ' . $str; } $cur = array('page_title' => $page_title, 'location' => $location); unset($page_title); unset($cat); unset($location); unset($type); unset($couponclass); return $cur; } define('IN_SMT', true); define('CURSCRIPT', 'coupon'); define('IN_MYMPS', true); define('DIR_NAV', dirname(__FILE__)); require_once DIR_NAV . '/include/global.php'; require_once MYMPS_DATA . '/config.php'; require_once MYMPS_DATA . '/config.db.php'; require_once MYMPS_INC . '/db.class.php'; ifsiteopen(); $cate_id = isset($cate_id) ? intval($cate_id) : ''; $areaid = isset($areaid) ? intval($areaid) : ''; $id = isset($id) ? intval($id) : ''; $orderby = isset($orderby) ? mhtmlspecialchars($orderby) : ''; $data = $pluginsettings = ''; $action = isset($action) ? mhtmlspecialchars($action) : ''; if (!in_array($orderby, array('prints', 'dateline', 'hit'))) { $orderby = 'hit'; } $advertisement = get_advertisement('other'); $adveritems = $advertisement['items']; $advertisement = $advertisement['all']; !ifplugin(CURSCRIPT) && exit('管理员已禁用或未安装优惠券插件...'); require_once DIR_NAV . '/plugin/coupon/include/functions.php'; $couponclass = $coupon_class = get_coupon_class(); $coupon_class = is_array($coupon_class) ? array_merge(array( array('cate_id' => 0, 'cate_name' => '全部', 'cate_uri' => plugin_url(CURSCRIPT, array('cate_id' => 0))) ), $coupon_class) : array(); $area_class = cat_list('area', 0, 0, false, 1); $area_class = array_merge(array( array('areaid' => '', 'areaname' => '全部') ), $area_class); if (is_array($area_class)) { foreach ($area_class as $areakey => $areaval) { $area_class[$areakey]['uri'] = plugin_url(CURSCRIPT, array('cate_id' => $cate_id, 'areaid' => $areaval['areaid'])); $area_class[$areakey]['select'] = $areaval['areaid'] == $areaid ? '1' : 0; } } $advertisement = get_advertisement('other'); $adveritems = $city['advertisement']; $advertisement = $advertisement['all']; $where .= $city[cityid] ? ' AND cityid = \'' . $city['cityid'] . '\'' : ''; $counts = $db->getAll('SELECT cate_id,count(id) AS num FROM ' . $db_mymps . 'coupon AS i WHERE status = \'1\' AND grade > \'0\' ' . $where . ' GROUP BY cate_id '); $count = array(); $count['total'] = $db->getOne('SELECT count(id) FROM ' . $db_mymps . 'coupon WHERE status = \'1\' AND grade > \'0\' ' . $where); foreach ($counts as $k => $v) { $count[$v['cate_id']] = !empty($v['num']) ? $v['num'] : 0; } if ($id) { $coupon = $db->getRow('SELECT * FROM `' . $db_mymps . 'coupon` WHERE id = \'' . $id . '\' AND status = \'1\' AND grade > \'0\''); if (!$coupon['id']) { write_msg('该优惠券已失效或者尚未通过审核!', 'olmsg'); } if ($action == 'print') { $db->query('UPDATE `' . $db_mymps . 'coupon` SET prints = prints + 1 WHERE id = \'' . $id . '\''); globalassign(); include mymps_tpl('print'); } else { $db->query('UPDATE `' . $db_mymps . 'coupon` SET hit = hit + 1 WHERE id = \'' . $id . '\''); $coupon['content'] = replace_insidelink($coupon['content'], 'coupon'); $space = $db->getRow('SELECT tname,address,busway,tel FROM `' . $db_mymps . 'member` WHERE userid = \'' . $coupon['userid'] . '\''); $uid = $db->getOne('SELECT id FROM `' . $db_mymps . 'member` WHERE userid = \'' . $coupon['userid'] . '\''); $space['uri'] = Rewrite('store', array('uid' => $uid, 'action' => 'index')); $space['tname'] = $space['tname'] ? $space['tname'] : $space['userid']; $space['address'] = $space['address'] ? $space['address'] : $space['busway']; $loc = get_coupon_location($coupon['cate_id'], $coupon['title']); $page_title = $loc['page_title']; $location = $loc['location']; globalassign(); include mymps_tpl('view'); } } else { $where = 'WHERE status = \'1\' AND grade > \'0\''; if ($cate_id) { $where .= ' AND cate_id = \'' . $cate_id . '\''; } if ($areaid) { $where .= ' AND areaid = \'' . $areaid . '\''; } $rows_num = $db->getOne('SELECT count(id) FROM ' . $db_mymps . 'coupon ' . $where); $param = setParam(array('cateid', 'areaid', 'orderby')); $coupon = page1('SELECT * FROM `' . $db_mymps . 'coupon` ' . $where . ' ORDER BY ' . $orderby . ' DESC'); $list = array(); foreach ($coupon as $k => $v) { $list[$v['id']]['id'] = $v['id']; $list[$v['id']]['title'] = $v['title']; $list[$v['id']]['des'] = $v['des']; $list[$v['id']]['enddate'] = $v['enddate']; $list[$v['id']]['begindate'] = $v['begindate']; $list[$v['id']]['prints'] = $v['prints']; $list[$v['id']]['pre_picture'] = $v['pre_picture']; $list[$v['id']]['sup'] = $v['sup']; $list[$v['id']]['uri'] = plugin_url('coupon', array('id' => $v['id'])); } foreach (array('hit' => '默认', 'prints' => '打印', 'dateline' => '最新') as $k => $v) { $orderby_url[$k]['selected'] = $orderby == $k ? 1 : 0; $orderby_url[$k]['name'] = $v; $orderby_url[$k]['url'] = plugin_url(CURSCRIPT, array('cate_id' => $cate_id, 'areaid' => $areaid, 'orderby' => $k)); } $page_view = page2(); $loc = get_coupon_location($cate_id); $page_title = empty($cate_id) && empty($areaid) ? ($pluginsettings[CURSCRIPT]['seotitle'] ? $pluginsettings[CURSCRIPT]['seotitle'] : $loc['page_title']) : $loc['page_title']; $page_title = str_replace('{city}', $city['cityname'], $page_title); $location = $loc['location']; $seo = array(); $seo['keywords'] = str_replace('{city}', $city['cityname'], $pluginsettings[CURSCRIPT]['seokeywords']); $seo['description'] = str_replace('{city}', $city['cityname'], $pluginsettings[CURSCRIPT]['seodescription']); $currentlocate = $areaname . $couponclass[$cate_id]['cate_name'] . '优惠券'; globalassign(); include mymps_tpl('index'); } is_object($db) && $db->Close(); ?>