<?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)
|
{
|
//var_dump($File);
|
//var_dump($ResultType);
|
|
$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);
|
//$str = "array('key1'=>'value1','key2'=>'value2')";
|
//echo iconv("GB2312","UTF-8",$showInfo);
|
eval('$Resarr = ' .$showInfo .';' );
|
//var_dump($Resarr);
|
//echo "==========";
|
//print_r($Resarr);
|
//echo iconv("GB2312","UTF-8",$Resarr);
|
//return;
|
|
//$Resarr = parse($showInfo);
|
//echo "===========================";
|
//print_r($Resarr);
|
//echo "===========================";
|
//echo $Resarr["AccID"];
|
|
//if(!array_key_exists($ResultType,$Resarr))
|
//{
|
|
// echo 'ERROR : ['.$ResultType."] Key does not exists!";
|
// //echo iconv("GB2312","UTF-8","½á¹û£º".$ErrorType[(int)$arr['ErrorNo']]);
|
// echo "<br/><br/><br/>".$_POST['data'];
|
// return;
|
|
//}
|
|
|
//echo iconv("GB2312","UTF-8","Result£º".$Resarr[$ResultType]);
|
|
|
if ($showInfo == "")
|
{
|
return "can find nothing";
|
}
|
|
return $Resarr;
|
|
}
|
|
|
?>
|