chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
function smarty_function_sign($paramer,$template){ 
    global $db,$db_config,$config;
    $date=date("Ymd"); 
    $reg=$db->DB_select_once("member_reg","`uid`='".$_COOKIE['uid']."' and `usertype`='".$_COOKIE['usertype']."' and `date`='".$date."'"); 
    
    $arr=array();
    $allreg=$db->select_all("member_reg","`uid`='".$_COOKIE['uid']."' and `usertype`='".$_COOKIE['usertype']."' order by `id` desc limit 32");    
    
    if($allreg&&is_array($allreg)){
        $alldate=array();
        foreach($allreg as $val){
            $alldate[]=$val['date'];
        }
    }
    $date=date("Ymd"); 
    $year=date('Y');
    $month=date('m');
    if($month>12){
        $month=1;
        $year+=1;
    }
    $currentDate=$year."年".$month."月";//当前得到的日期信息
    $days = date("t",mktime(0,0,0,$month,1,$year));//得到给定的月份应有的天数
    $dayofweek = date("w",mktime(0,0,0,$month,1,$year));//得到给定的月份的 1号 是星期几 
    if($reg['id']){
        $ahtml='<a href="javascript:void(0)"  class="left_box_zp_qd  yqd" >已签到</a>';
    }else{
        $ahtml='<a href="javascript:void(0)"  class="left_box_zp_qd">签到</a>';
    }
    $html='<div class="signdiv">'.$ahtml.'<div class="sign_main" id="sign_layer">
        <div class="sign_succ_calendar_title">
        <div class="calendar_month_span">'.$currentDate.'</div>
        </div>
        <div class="sign" id="sign_cal"><table><tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>';
    
    $html.="<tr>";        
    $nums=$dayofweek+1;
    for ($i=1;$i<=$dayofweek;$i++){//输出1号之前的空白日期
        $html.="<td>&nbsp;</td>";
    }  
    for ($i=1;$i<=$days;$i++){//输出天数信息 
        if($i<10){
            $ndays=$year.$month.str_pad($i,2,'0',STR_PAD_LEFT);
        }else{
            $ndays=$year.$month.$i;
        }
        if(in_array($ndays,$alldate)){
            $class='on';
        }else{$class='';}
        if ($nums%7==0){//换行处理:7个一行
            $html.='<td class="day'.$i.' '.$class.'">'.$i.'</td></tr><tr>';
        }else{
            $html.='<td class="day'.$i.' '.$class.'">'.$i.'</td>';
        }
        $nums++;
    }
    $html.="</tr></table></div></div></div>"; 
    return $html;
}
?>