PHPCMS模块分析之广告模块详解----北冥神功破解法(一)

逍遥派的顶级武功之一,与天山六阳掌、天山折梅手和小无相功齐名,可以吸取他人的内力以供己用,是迅速提升功力的捷径,内力既厚,天下武功无不为我所用,犹如北冥,大舟小舟无不载,大鱼小鱼无不容。“北冥有鱼,其名为鲲,鲲之大,不知其几千里也……”,能够容纳几千里的大鱼必定是非常广阔的海洋,因而北冥神功正是寓含了广大恢宏之意,也体现了神功的威力。

<?php //====================================ad.php========================================



//定义使用js显示

define('SHOWJS', 1);

//引入需要用的的文件

require './include/common.inc.php';

require MOD_ROOT.'/include/global.func.php';



//将id转为Int形式

$placeid = intval($id);



//定义查询语句

$query ="SELECT * FROM ".TABLE_ADS." AS a LEFT JOIN ".TABLE_ADS_PLACE." AS p ON (a.placeid=p.placeid) WHERE a.placeid=".$placeid." AND a.fromdate<=UNIX_TIMESTAMP() AND a.todate>=UNIX_TIMESTAMP() AND p.passed=1 AND a.passed=1 AND a.checked=1 ORDER BY a.addtime";

//进行数据库查询,使用缓存,大小为10240

$ads = $db->get_one($query, "CAHCE", 10240);

//如果没有相应的广告,则退出,添加内容为空

if(!$ads) exit('document.write("")');



//如果存在该广告,则对其进行更新

$db->query("UPDATE ".TABLE_ADS." SET views=views+1 WHERE adsid=".$ads['adsid']);



//模块的全局定义函数,将广告内容转换为html格式的代码,该函数位置为:../global.func.php

$content = ads_content($ads);

//确定模板文件的名字

$templateid = $ads['templateid'] ? $ads['templateid'] : 'ads';

//加载模板文件,并将其显示

include template('ads', $templateid);

//将文件内容从缓存中输出

phpcache();

?>





<?php  //==========================================add.php========================================



/**

 * 增加广告的php代码文件

 */

//引入所需文件

require './include/common.inc.php';



//检查用户是否已经登录,如果没有登录则将其重定向到相应的页面

//showmessage()函数所在位置:/include/global.func.php

if(!$_userid) showmessage($LANG['please_login_or_register'], $MODULE['member']['linkurl'].'login.php?forward='.urlencode($PHP_URL));



//取得用户名

$ads['username'] = $_username;

//取得广告id

$ads['placeid'] = intval($ads['placeid']);

//如果id为空,显示非法参数,并将其返回到上一页

if(!$ads['placeid']) showmessage($LANG['invalid_parameters']);



//从数据库中选择第一条匹配的广告

$sql = "select * from ".TABLE_ADS_PLACE." where placeid={$ads['placeid']} limit 1";

$result = $db->get_one($sql);

//如果没有要选择的广告,显示:操作失败!意外错误,请确认存在此广告位。

if(empty($result))

{

	showmessage($LANG['opration_failure_or_advertisement _not_exists']);

}

//如果存在此广告,则将其重新赋给变量$place

$place = $result;



//如果现金不足,显示:您的资金不足!请补充预留款!

if($_money<($place['price']*$ads['longtime'])) showmessage($LANG['not_enough_balance_please_charge'],PHPCMS_PATH."pay/");



//添加广告,如果已经提交

if($submit)

{

	//验证广告的名字是否合法

	if(strlen($ads['adsname'])<2 || strlen($ads['adsname'])>30)

	{

		showmessage($LANG['invalid_name']);

	}

	//读取广告信息,并将其转义

	$ads['adsname'] = str_safe($ads['adsname']);

	$ads['introduce'] = str_safe($ads['introduce']);

	$ads['alt'] = str_safe($ads['alt']);

	$ads['linkurl'] = linkurl($ads['linkurl']);

	$ads['text'] = str_safe($ads['text']);

	$ads['code'] = str_safe($ads['code']);



	//验证是否有广告发布日期

	if(!$ads['fromdate'])

	{

		showmessage($LANG['please_input_the_advertising_day']);

	}



	//验证广告期限是否合法

	if(!is_numeric($ads['longtime']) && !($ads['longtime'])>0)

	{

		showmessage($LANG['invalid_advertising_time']);

	}

	else

	{

		include_once(PHPCMS_ROOT."/include/date.class.php");

		$date = new phpcms_date();

		$date->set_date($ads['fromdate']);

		$date->monthadd($ads['longtime']);

		$ads['todate'] =  $date->get_date();

	}



	/*

	根据广告的类型不同,将其添加到数据库

	*/



	if($ads['type']=="image") {

		if(!strlen($imageurl)) showmessage($LANG['input_advertising_images_url']);

		$type_sql = ",type='{$ads['type']}',alt='{$ads['alt']}',linkurl='{$ads['linkurl']}',imageurl='{$imageurl}'";

	}



	if($ads['type']=="flash")

	{

		if(!$flashurl) showmessage($LANG['please_input_the_flash_url']);

		$type_sql = ",type='{$ads['type']}',flashurl='{$flashurl}',wmode='".($ads['wmode']=="transparent"?"transparent":"")."'";

	}



	if($ads['type']=="text")

	{

		if(!$ads['text']) showmessage($LANG['please_input_the_advertising_content']);

		$type_sql = ",type='{$ads['type']}',text='{$ads['text']}'";

	}



	if($ads['type']=="code")

	{

		if(!$ads['code']) showmessage($LANG['please_input_the_advertising_code']);

		$type_sql = ",type='{$ads['type']}',code='{$ads['code']}'";

	}



	$sql = "INSERT INTO ".TABLE_ADS." SET adsname='{$ads['adsname']}',introduce='{$ads['introduce']}',addtime='".time()."',placeid='{$ads['placeid']}',username='{$ads['username']}',checked=0,fromdate=".strtotime($ads['fromdate']).",todate=".strtotime($ads['todate']).$type_sql;



	$result=$db->query($sql);

	//判断数据是否已经被添加

	if($db->affected_rows()>0)

	{

		showmessage($LANG['opration_success_waiting_for_check'], $MOD['linkurl']);

	}

	else

	{

		showmessage($LANG['opration_failure_make_sure_enter_the_correct_content']);

	}

}

showmessage($LANG['please_input_content'], $referer);

?>





<?php  //=======================================admin.inc.php=============================================



//检查用户权限

//定义常量,指向模块根目录

//引入模块全局函数文件

defined('IN_PHPCMS') or exit('Access Denied');

define('MOD_ROOT', PHPCMS_ROOT.'/'.$mod);



require MOD_ROOT.'/include/global.func.php';



//变量$mod在include中定义为"ads"

$module  = $mod;

//定义菜单数组

$submenu = array(

				array('<font color="red">'.$LANG['add_advertisement'].'</font>','?mod='.$mod.'&file=adsplace&action=add&catid='.$catid),

				array($LANG['manage_advertisement'],'?mod='.$mod.'&file=adsplace&action=manage'),

				array($LANG['manage_the_order_of_advertisement'],'?mod='.$mod.'&file=ads&action=manage'),

				array($LANG['update_html_and_js'],'?mod='.$mod.'&file=createhtml'),

	       );

//将子菜单添加到主菜单中

$menu = adminmenu($LANG['advertising_management'],$submenu);

if(!@include_once(MOD_ROOT.'/admin/'.$file.'.inc.php')) showmessage($LANG['illegal_operation']);

?>







<?php //===============================================ads.php====================================



//很有趣的引入,引入ad.php文件

require './ad.php';

?>





<?php  //==============================================clickads.php==================================



//引入文件

require './include/common.inc.php';

//将id转换为十进制数字

$id = intval($id);

//按id查找广告

$ads = $db->get_one("SELECT adsid,linkurl FROM ".TABLE_ADS." WHERE adsid=$id","CACHE",10240);



//如果广告存在,取出他的链接地址

if($ads)

{

	$db->query("UPDATE ".TABLE_ADS." SET hits=hits+1 WHERE adsid=".$ads['adsid']);

	$url = $ads['linkurl'];

}

?>



//将文件重定向到广告的地址

<SCRIPT LANGUAGE="JavaScript">

<!--

location.href = "<?=$url?>";

//-->

</SCRIPT>





<?php //==============================================./index.php===========================================



//引入所需文件

require './include/common.inc.php';



//确定分页标签

$page = isset($page) ? intval($page) : 1;

$offset = ($page-1)*$PHPCMS['pagesize'];

$r = $db->get_one("SELECT count(*) as num FROM ".TABLE_ADS_PLACE);

$pages = phppages($r['num'], $page, $PHPCMS['pagesize']);



//初始化

$places = array();

//分页查询数据从数据表中

$query ="SELECT *  ".

"FROM ".TABLE_ADS_PLACE." as p ".

"order by placeid ".

"limit $offset,$PHPCMS[pagesize] ";

$result = $db->query($query);

//将查询结果保存到$places数组中

while($r = $db->fetch_array($result))

{

	$places[] = $r;

}



//查询广告的详细信息

foreach ($places as $key=>$place)

{

	$placeid = $place['placeid'];

	$query ="SELECT count(*) as users,max(todate),a.* ".

	"FROM ".TABLE_ADS." as a left join ".TABLE_ADS_PLACE." as p on (a.placeid=p.placeid) ".

	"where a.placeid=".$placeid." and a.todate>UNIX_TIMESTAMP() and p.passed=1 and a.passed=1 GROUP BY p.placeid";

	$ads = $db->get_one($query);

	//如果广告不存在

	if(empty($ads))

	{

		$ads['todate'] = "-";

		$ads['users'] = "-";

		$places[$key]['status'] = "<font color='red'>".$LANG['no_sign']."</font>";

		$places[$key]['bgcolor'] = "#FFCC00";

	}

	else

	{

		$ads['todate'] = date("Y-m-d", $ads['todate']);

		$places[$key]['status'] = $LANG['yes_sign'];

		$places[$key]['bgcolor'] = "#efefef";

	}

	//将广告的信息存入$places数组

	$places[$key]['ads'] = $ads;

}

//加载模板,显示广告列表

include template($mod, 'placelists');

?>







<?php  //=====================================================sign.php======================================



//引入所需文件

require './include/common.inc.php';



//检查用户是否已经登录系统,否则显示错误信息,并将其转向到注册页面

if(!$_userid) showmessage($LANG['please_login_or_register'] , $MODULE['member']['linkurl'].'login.php?forward='.urlencode($PHP_URL));

//广告id

$placeid = intval($placeid);



//查询广告信息

$query ="SELECT max(todate) as todate,p.* ".

"FROM ".TABLE_ADS." as a right join ".TABLE_ADS_PLACE." as p on (a.placeid=p.placeid) ".

"where p.placeid=".$placeid." and p.passed=1 GROUP BY p.placeid";



$result = $db->get_one($query);

//如果不存在查询的广告

if (empty($result))

{

	showmessage($LANG['opration_failure_or_advertisement _not_exists']);

}

//将广告的查询结果返回赋值给$place变量

$place = $result;

//显示广告时间

$fromdate = ($place['todate'] && $PHP_TIME < $place['todate']) ? date('Y-m-d', $place['todate']) : date('Y-m-d');

$_month = "<SELECT NAME='ads[longtime]'>";

//列出时间列表

for ($i=1;$i<=12;$i++)

{

	$_month .= "<option value='$i'>$i {$LANG['month']}</option>";

}

$_month .= "</SELECT>";

//加载模板,显示标签页面

include template($mod, 'sign');

?>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PHPCMS V9采用OOP(面向对象)方式进行基础运行框架搭建。模块化开发方式做为功能开发形式。框架易于功能扩展,代码维护,优秀的二次开发能力,可满足所有网站的应用需求。 PHPCMS V9企业黄页主要特色 1、模型自定义,支持模型添加、修改、删除、导出、导入功能; 2、模型字段自定义,支持模型字段添加、修改、删除、禁用操作; 3、分类无限添加,支持批量多级添加; 4、新增附件字段功能,实现相同模型,不同分类之间内容字段差异化; 5、分类可以选择附加字段,并继承至子分类; 6、点评模块支持自定义不同的点评类型,每个类型自定义设置; 7、安装点评模块后,分类可以绑定点评类型,实现不同分类产品不同的点评内容; 8、信息管理分类列表支持异步加载,减轻分类太多一次加载js对浏览器的压力; 9、管理员可以对商家用户的信息二次编辑,支持推送至推荐位及推送到其他内容模型功能; 10、管理员可看会员组设置商家信息直接发布、模型使用的权限; 11、模块配置可设置注册企业是否需要审核、是否支持在线交易、是否开启伪静态、是否开启页面缓存及SEO等设置; 12、支持收费推荐位设置; 13、支持zip压缩包格式,上传新商家模板,且支持权限设置; 14、支持推荐商家功能; 15、启用/关闭伪静态时,支持批量更新商家主页导航菜单、分类、商家信息的URL地址; 16、商家按模型发布信息,支持无权模型提示并跳转到升级会员组页面; 17、支持商家完善商家资料、地图标注、资质证书添加、前台菜单设置、模板选择; 18、开启在线交易功能,支持商家信用等级功能:商家卖出商品后增加商家信息等级; 19、支持在线处理留言。开启在线交易功能,支持商家在线处理订单; 20、列表页支持一级或者多级筛选功能; 21、筛选内容过多是支持展开、收缩显示筛选内容; 22、商家详情页支持图片显示数字; 23、支持在线询价(留言); 24、产品终极分类页支持产品对比功能; 25、产品详情页支持多图展示产品; 以下功能需开启在线交易 26、支持购物车功能; 27、支持购物车中商品修改,备注; 28、支持收货地址设置; 29、自动判断账户余额,余额不足,提示充值; 30、商家配送商品后,支持短消息、邮件提示购物者;   PHPCMS V9企业黄页模块正式版更新内容: 新建的模型添加数据时出错 删除冗余文件 后台管理员推送推荐位的bug 后台企业库管理无搜索的问题 企业黄页卸载出现的bug 修正liunx服务器下,模板解析不兼容问题 增加浏览权限设置 修复留言不能回复的问题 安装sql文件前缀错误问题 订单支付页,判断未填写配送地址依然跳转的问题 增加IIS Rewrite规则 修正若干其他问题

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值