ecshop签到功能开发

前台签到后能

getRow(‘SELECT mobile_phone FROM ‘.$GLOBALS[‘ecs’]->table(‘users’).”WHERE user_id = ‘$_SESSION[user_id]'”);
if(empty($moblie))
{
show_message(‘您没有绑定手机号’,’绑定手机号’,’user.php?act=safe’);
}
//检测时间是否已到
$time = $GLOBALS[‘db’]->getRow(‘SELECT user_id,sign_days,next_time FROM ‘.$GLOBALS[‘ecs’]->table(‘points_rule’).’where user_id = ‘.$_SESSION[‘user_id’]);
//如果没有表则创建一个
if(empty($time)){
$GLOBALS[‘db’] -> query(“INSERT INTO”.$GLOBALS[‘ecs’]->table(‘points_rule’).”(user_id) VALUES (‘”.$_SESSION[‘user_id’].”‘)”);
$time = 1;
}
//有则判断时间
if(date(‘d’,$time[‘next_time’]) == date(‘d’,time())) {
show_message(‘您今天已经签到过了!’,’回首页’,’index.php’);
}else{
//添加下次签到时间
//签到天数
if($time[‘sign_days’] < $regular_cycle && date('d',time()) - date('d',$time['next_time']) ==1){ //断签判定 $sign_days = $time['sign_days'] + 1; }else{ $sign_days = 1; } $field_values = Array('next_time'=>time(),’sign_days’=>$sign_days);
$GLOBALS[‘db’] -> autoExecute($GLOBALS[‘ecs’]->table(‘points_rule’), $field_values, $mode = ‘UPDATE’, $where = ‘user_id =’.$_SESSION[‘user_id’]);
//计算应得极客币
$points_n = $sign_days * $intergral_rule + $start_point;
if($points_n > $max_point){
show_message(‘您获得的极客币超过了最大上限’,’回首页’,’index.php’);
exit();
}
$points_all =$points_n + $GLOBALS[‘db’]->getOne(“SELECT pay_points FROM ” . $GLOBALS[‘ecs’]->table(‘users’) . ” WHERE user_id = ‘$_SESSION[user_id]'”);
//极客币加入
$GLOBALS[‘db’] -> query(“UPDATE”.$GLOBALS[‘ecs’]->table(‘users’).”SET pay_points = $points_all where user_id = ‘$_SESSION[user_id]'”);
show_message(‘签到成功!您获得了’.$points_n.’极客币’,’回首页’,’index.php’);
}
// 设置后
/* 清除缓存 */
clear_all_files();

$_CFG = load_config();
/* 提示信息 */
$links = array(
array(
‘href’ => ‘points.php’, ‘text’ => “返回上一页”
)
);
}

后台设置功能

assign(‘start_point’,get_config(“./includes/inc_points.php”,”start_point”)); //开始积分
$smarty->assign(‘intergral_rule’,get_config(“./includes/inc_points.php”,”intergral_rule”)); //积分每日递增数
$smarty->assign(‘max_point’,get_config(“./includes/inc_points.php”,”max_point”)); //最大每日签到积分
$smarty->assign(‘failure_rule’,get_config(“./includes/inc_points.php”,”failure_rule”)); //失效时间
$smarty->assign(‘regular_cycle’,get_config(“./includes/inc_points.php”,”regular_cycle”)); //规则周期
$smarty->display(‘signed_points.htm’);
}
//修改规则
function action_points_edit(){
//过滤输入
addslashes_deep($_POST);
set_config(“./includes/inc_points.php”,”start_point”,$_POST[‘start_point’]);
set_config(“./includes/inc_points.php”,”intergral_rule”,$_POST[‘intergral_rule’]);
set_config(“./includes/inc_points.php”,”max_point”,$_POST[‘max_point’]);
set_config(“./includes/inc_points.php”,”failure_rule”,$_POST[‘failure_rule’]);
set_config(“./includes/inc_points.php”,”regular_cycle”,$_POST[‘regular_cycle’]);

/* 清除缓存 */
clear_all_files();

$_CFG = load_config();
/* 提示信息 */
$links = array(
array(
‘href’ => ‘points.php’, ‘text’ => “返回上一页”
)
);
sys_msg(“设置成功”, 0, $links);
}
?>

赞 (0)
分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址