forked from DistributedProofreaders/ppwb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppsmq-action.php
51 lines (37 loc) · 1.41 KB
/
ppsmq-action.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require_once("base.inc");
list($workdir, $workurl, $upid) = init_workdir();
$extensions = ["txt", "htm", "html"]; // allowed file extensions
// ----- process the main project file ---------------------------------
$target_name = process_file_upload("userfile", $workdir, $extensions);
// ----- no errors. proceed ----------------------------------------
log_tool_access("ppsmq", $upid);
// ----- run the ppsmq command ----------------------------------------
// build the command
$command = join(" ", [
$python_runner,
"./bin/ppsmq.py",
"-i " . escapeshellarg($target_name),
"-o " . escapeshellarg("$workdir/report.txt"),
"2>&1",
]);
log_tool_action($workdir, "command", $command);
// and finally, run ppsmq
$output = shell_exec($command);
log_tool_action($workdir, "output", $output);
// ----- display results -------------------------------------------
output_header("ppsmq Results");
$reportok = false;
echo "<p>";
if (file_exists("$workdir/report.txt")) {
echo "results available: <a href='$workurl/report.txt'>here</a>.<br>";
$reportok = true;
}
if ($reportok) {
echo "Left click to view. Right click to download.</p>";
} else {
echo "<p>Whoops! Something went wrong and no output was generated.
The error message was<br><br>
<tt>${output}</tt></p>
</p>For more assistance, ask in the <a href='$help_url'>discussion topic</a> and include this identifier: ${upid}</p>";
}