-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatadelete.php
More file actions
61 lines (47 loc) · 1.8 KB
/
datadelete.php
File metadata and controls
61 lines (47 loc) · 1.8 KB
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
/*
Minutes represents the minutes of a given hour, 0-59 respectively.
Hours represents the hours of a given day, 0-23 respectively.
Days represents the days of a given month, 1-31 respectively.
Months represents the months of a given year, 1-12 respectively.
Day of the Week represents the day of the week, Sunday through Saturday, numerically, as 0-6 respectively.
1:
crontab -e
2:
kies editor
3:
0 0 * * * php /filepath.....php -I
*/
$datablok_length = 43;
$date_realtime = date("Y-m-d") ;
// ***maybe: for each veranderen naar sysdate -1 zodat je de vorige dag formateerd
//checkt voor alle .dat bestanden in testdata
echo $date_realtime;
$back_day = date('Y-m-d', strtotime($date_realtime . "-1 day") );
echo $back_day;
//$back_day i.p.v. * hieronder
foreach (glob("testdata/".$back_day."/*.dat") as $file) {
//echo "$file size " . filesize($file) . "\n";
echo "<br>";
$new_file = $file."_"; //nieuwe filenaam van gefilterde zooi.
$new_handle = fopen($new_file, "w"); ///////////////deze moet ander map maybe voor data maar een keer filteren ipv van vaker.
$handle = fopen($file, "rb");
while(true) {
if(!$data = fread($handle, $datablok_length)) break;
echo "data =:".$data;
echo "<br>";
$array = unpack("Ntime/Gtemp/Gdewp/Gstp/Gslp/Gvisib/Gwdsp/Gprcp/Gsndp/Cfrshtt/Gcldc/nwnddir", $data);
print_r($array);
echo "<br>";
$packed = pack("NGG", $array['time'], $array['temp'],$array['prcp']);
fwrite($new_handle, $packed);
echo "<br>";
}
fclose($handle);
fclose($new_handle);
echo "<br>";
unlink ($file);
//rename($new_file, $file);
}
// mapje van filtered files aanmaken om naar te refereren.
?>