hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
 
namespace Note;
 
//д¼Ç¼
function WriteNote($data)
{
    unset($data['sign']);
    $dir = dirname(__FILE__)."\\note\\";
    $filename= $dir.date("Y-m-d",time()).".txt";
    $nowTime = date("Y-m-d H:i:s",time());
    
    //´´½¨Ä¿Â¼
    if (!is_dir($dir))
    {
        mkdir($dir);
    }
    
    $wstring = $nowTime."=>[";
    
    foreach ($data as $key => $value)
    {
        $wstring.= $key.":".$value.",";
    }
    
    $wstring .= "]\n";
    
    $f_open = fopen($filename, "a+") or die("file is not exist");
    fwrite($f_open, $wstring);
    fclose($f_open);
}
 
 
//¶Á¼Ç¼
function ReadNote($date1, $date2, $time1, $time2)
{
    $dir = dirname(__FILE__)."\\note\\";
    
    //´«½øµÄʱ¼ä
    $starTime = $date1." ".$time1;
    $endTime = $date2." ".$time2;
    
    
    if (!is_dir($dir))
    {
        return "can find nothing";
    }
    
    $showInfo = "";
    
    $curDate = strtotime($date1);
    
    while ($curDate <= strtotime($date2))
    {
        //Òª²éÕÒµÄÎļþÃû
        $filename= $dir.date("Y-m-d", $curDate).".txt";
        
        //²»´æÔÚ¸Äʱ¼äµÄÎļþ
        if (!file_exists($filename))
        {
            $curDate = strtotime('+1 day', $curDate);
            continue;
            #return date("Y-m-d", $curDate).":can find nothing";
        }
        
        //´ò¿ªÎļþ
        $fopen = fopen($filename, "rb") or die("file is not exist");
        
        while(!feof($fopen))
        {
            $lineInfo = fgets($fopen);
            $timeList = explode('=>[', $lineInfo);
            $noteTime = $timeList[0];
        
            if (strtotime($noteTime) >= strtotime($starTime) && strtotime($noteTime) <= strtotime($endTime))
            {
                $showInfo .= $lineInfo."<br/><hr><br/>";
            }
        }
        
        //¹Ø±ÕÎļþ
        fclose($fopen);
        
        //ʱ¼ä+1Ìì
        $curDate = strtotime('+1 day', $curDate);
    }
    
    if ($showInfo == "")
    {
        return "can find nothing";
    }
    
    return $showInfo;
    
}
 
//½âÎö×Ö·û´®×ª»»Êý×é
function parse($strinfo)
{
    //echo $strinfo;
    //½âÎö×Ö·û´®
    $POSTDATA = str_replace("=>","=",$strinfo);
    $POSTDATA = str_replace("\"","","$POSTDATA");
    $POSTDATA = str_replace("'","","$POSTDATA");
    $POSTDATA = str_replace("\n","","$POSTDATA");
    $POSTDATA = str_replace("\t","","$POSTDATA");
    $POSTDATA = str_replace("\r","","$POSTDATA");
    $POSTDATA = str_replace(",","&","$POSTDATA");
 
    //½«½âÎöºóµÄÄÚÈÝת»»³ÉÊý×é
    parse_str($POSTDATA,$arr);
 
    return $arr;
}
 
 
//¶ÁÊý×éÊý¾Ý
function ReadFile($File)
{
    $dir = dirname(__FILE__)."\\cfg\\";
 
    if(!is_dir($dir))
    {
        echo $dir." can find nothing";
    }
    
    $showInfo = "";
 
    //Òª²éÕÒµÄÎļþÃû
    $filename= $dir.$File.".txt";
 
    //²»´æÔÚÎļþ
    if(!file_exists($filename))
    {
        echo filename.":can find nothing";
    }
    
    //´ò¿ªÎļþ
    $fopen = fopen($filename, "rb") or die("file is not exist");
 
    while(!feof($fopen))
    {
        $lineInfo = fgets($fopen);
        $showInfo .= $lineInfo;
        
    }
 
    //¹Ø±ÕÎļþ
    fclose($fopen);
 
    eval('$Resarr = ' .$showInfo .';' );
 
    if ($showInfo == "")
    {
        return "can find nothing";
    }
 
    return $Resarr;
    
}
 
 
?>