-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoi_report_ss.php
More file actions
37 lines (34 loc) · 892 Bytes
/
aoi_report_ss.php
File metadata and controls
37 lines (34 loc) · 892 Bytes
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
<?php
/**
* file parses report using string and array functions to tab-delimited file
*
* @package ncgap
*/
$report_name = "ncgap".rand(100000, 999999).".xls";
require('nc_config.php');
$fp = fopen("{$mspath}{$report_name}", "w");
$content = $_POST['content'];
$content_lns = explode("\n", $content);
//parse out text report to spreadsheet
foreach ($content_lns as $v1){
$v2 = explode("|", $v1);
if (preg_match("/#|^ *[0-9]+|TOTAL/", $v2[1])) {
if ($pos1 = strpos($v2[2], ".")) {
$v2[2] = substr($v2[2], 0, $pos1);
}
$v2[2] = html_entity_decode($v2[2]);
foreach ($v2 as &$v3){
while ($pos2 = strpos($v3, ",")) {
$v3 = substr($v3, 0, $pos2).substr($v3, $pos2 + 1);
}
}
if (!preg_match("/TOTAL/", $v2[1])) {
array_shift($v2);
}
$out = implode("\t", $v2);
fwrite($fp, $out."\n");
}
}
fclose($fp);
echo json_encode(array("ssreport"=>$report_name));
?>