-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhackish.php
36 lines (36 loc) · 1.1 KB
/
hackish.php
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
<?php
$filenames = array( "1", "2", "3" );
foreach($filenames as $filename) {
$handle = fopen($filename, "rb");
$raw = fread($handle, filesize($filename));
fclose($handle);
$cleaned = trim(str_ireplace( array("\x0D", "^M", "\xD2", "\xF5\xF5", "\xF5"), array("\n","", '"', '"',"'"), $raw));
$cleaned = 'Date:' . explode('Date:', $cleaned)[1];
$cleaned = substr($cleaned, 0, strpos($cleaned, "\x03"));
var_dump($cleaned);
if (false === strpos($cleaned,"###")) {
$ps = array_filter(explode("\n", $pieces[1]), function($a){return !empty($a);});
foreach($ps as $p) {
if (false !== strpos($p, ":")) {
echo "HAS MARKER $p";
}
}
} else {
$pieces = explode("###",$cleaned);
}
$metas = explode("\n", $pieces[0]);
$d = array();
foreach($metas as $meta) {
if (false !== strpos($meta, ":")) {
$ks = explode(":",$meta);
$d[trim($ks[0])] = trim($ks[1]);
}
}
$ps = array_filter(explode("\n", $pieces[1]), function($a){return !empty($a);});
$results = array(
'meta' => $d,
'content' => $ps
);
var_dump($results);
file_put_contents('hackish/' . $filename . '.txt', json_encode($results));
}