Skip to content

Commit 795c4ef

Browse files
committed
AnyEvent existence check
1 parent 0be1951 commit 795c4ef

File tree

6 files changed

+121
-112
lines changed

6 files changed

+121
-112
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ http://lemirep.wordpress.com/2013/06/01/deploying-qt-applications-on-linux-and-w
216216

217217
## Perl 5
218218
http://www.perlmonks.org/bare/?node_id=768448 "Permanently sort a hash"
219+
http://www.perlmonks.org/?node_id=27443 "Checking to see if a particular Module is installed"
219220

220221
http://stackoverflow.com/questions/1725097/how-can-i-disable-terminal-polling-for-cpan-used-from-crontab
221222
http://stackoverflow.com/questions/4510550/using-perl-how-do-i-decode-or-create-those-encodings-on-the-web

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The following compile-time variable can tighten further the security of PEB.
137137
PEB can also use any Perl on PATH.
138138

139139
## Supported Perl Script Types
140-
PEB does not impose execution timeouts and recognizes four main types of local Perl scripts:
140+
PEB recognizes four main types of local Perl scripts and does not impose execution timeouts on them:
141141
* [**non-interactive scripts**](#non-interactive-perl-scripts)
142142
* [**interactive scripts**](#interactive-perl-scripts)
143143
* [**AJAX scripts**](#ajax-perl-scripts)
Lines changed: 109 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,109 @@
1-
<!DOCTYPE html>
2-
<html>
3-
4-
<head>
5-
<title>Perl Executing Browser - Interactive Scripts Test</title>
6-
<meta name="viewport" content="width=device-width, initial-scale=1">
7-
<meta charset="utf-8">
8-
9-
<script type="text/javascript" src="jquery/jquery-1.11.1.min.js"></script>
10-
11-
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
12-
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" media="all">
13-
<link rel="stylesheet" type="text/css" href="bootstrap/css/themes/darkly-theme.css" media="all">
14-
15-
<script type="text/javascript" src="pebjs/context-menu.js"></script>
16-
<script type="text/javascript" src="pebjs/dialogs.js"></script>
17-
<script type="text/javascript" src="pebjs/forms-close-window.js"></script>
18-
19-
<style type='text/css'>
20-
.output {
21-
font-size: 20px;
22-
}
23-
</style>
24-
</head>
25-
26-
<body>
27-
<form action="http://interactive:one@local-pseudodomain/perl/interactive-script.pl" method="post">
28-
<br>
29-
<div class="col-lg-10 col-lg-offset-1">
30-
<div class="form-group">
31-
<div class="input-prepend">
32-
<input type="text" name="input" class="form-control" placeholder="Send data to the first instance of the interactive script">
33-
</div>
34-
</div>
35-
36-
<div class="form-group">
37-
<input type="reset" value="Reset" class="btn btn-default">
38-
<input type="submit" value="Submit" class="btn btn-primary">
39-
</div>
40-
41-
<div id="script-one-output" class="output">
42-
<br>
43-
<br>
44-
</div>
45-
46-
</div>
47-
</form>
48-
49-
<form action="http://interactive:two@local-pseudodomain/perl/interactive-script.pl" method="post">
50-
<br>
51-
<div class="col-lg-10 col-lg-offset-1">
52-
<div class="form-group">
53-
<div class="input-prepend">
54-
<input type="text" name="input" class="form-control" placeholder="Send data to the second instance of the interactive script">
55-
</div>
56-
</div>
57-
58-
<div class="form-group">
59-
<input type="reset" value="Reset" class="btn btn-default">
60-
<input type="submit" value="Submit" class="btn btn-primary">
61-
</div>
62-
63-
<div id="script-two-output" class="output">
64-
<br>
65-
<br>
66-
</div>
67-
68-
</div>
69-
</form>
70-
71-
<script type="text/javascript">
72-
document.addEventListener("DOMContentLoaded", function(event) {
73-
var scriptOneRequest = new XMLHttpRequest();
74-
var scriptOneParameters = {
75-
stdout: "script-one-output",
76-
close_command: "_close_",
77-
close_confirmation: "_closed_",
78-
mode: "unix-epoch"
79-
}
80-
scriptOneRequest.open('GET', 'http://interactive:one@local-pseudodomain/perl/interactive-script.pl' +
81-
formatParameters(scriptOneParameters), true);
82-
scriptOneRequest.send();
83-
84-
var scriptTwoRequest = new XMLHttpRequest();
85-
var scriptTwoParameters = {
86-
stdout: "script-two-output",
87-
close_command: "_close_",
88-
close_confirmation: "_closed_",
89-
mode: "local-time"
90-
}
91-
scriptTwoRequest.open('GET', 'http://interactive:two@local-pseudodomain/perl/interactive-script.pl' +
92-
formatParameters(scriptTwoParameters), true);
93-
scriptTwoRequest.send();
94-
});
95-
96-
function formatParameters(parameters) {
97-
return "?" + Object
98-
.keys(parameters)
99-
.map(function(key){
100-
return key + "=" + parameters[key]
101-
})
102-
.join("&")
103-
}
104-
</script>
105-
</body>
106-
107-
</html>
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Perl Executing Browser - Interactive Scripts Test</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta charset="utf-8">
8+
9+
<script type="text/javascript" src="jquery/jquery-1.11.1.min.js"></script>
10+
11+
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
12+
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" media="all">
13+
<link rel="stylesheet" type="text/css" href="bootstrap/css/themes/darkly-theme.css" media="all">
14+
15+
<script type="text/javascript" src="pebjs/context-menu.js"></script>
16+
<script type="text/javascript" src="pebjs/dialogs.js"></script>
17+
<script type="text/javascript" src="pebjs/forms-close-window.js"></script>
18+
19+
<style type='text/css'>
20+
.output {
21+
font-size: 20px;
22+
}
23+
</style>
24+
</head>
25+
26+
<body>
27+
<form action="http://interactive:one@local-pseudodomain/perl/interactive-script.pl" method="post">
28+
<br>
29+
<div class="col-lg-10 col-lg-offset-1">
30+
<div class="form-group">
31+
<div class="input-prepend">
32+
<input type="text" name="input" class="form-control"
33+
placeholder="Send data to the first instance of the interactive script">
34+
</div>
35+
</div>
36+
37+
<div class="form-group">
38+
<input type="reset" value="Reset" class="btn btn-default">
39+
<input type="submit" value="Submit" class="btn btn-primary">
40+
</div>
41+
42+
<div id="script-one-output" class="output">
43+
<br>
44+
<br>
45+
</div>
46+
47+
</div>
48+
</form>
49+
50+
<form action="http://interactive:two@local-pseudodomain/perl/interactive-script.pl" method="post">
51+
<br>
52+
<div class="col-lg-10 col-lg-offset-1">
53+
<div class="form-group">
54+
<div class="input-prepend">
55+
<input type="text" name="input" class="form-control"
56+
placeholder="Send data to the second instance of the interactive script">
57+
</div>
58+
</div>
59+
60+
<div class="form-group">
61+
<input type="reset" value="Reset" class="btn btn-default">
62+
<input type="submit" value="Submit" class="btn btn-primary">
63+
</div>
64+
65+
<div id="script-two-output" class="output">
66+
<br>
67+
<br>
68+
</div>
69+
70+
</div>
71+
</form>
72+
73+
<script type="text/javascript">
74+
document.addEventListener("DOMContentLoaded", function(event) {
75+
var scriptOneRequest = new XMLHttpRequest();
76+
var scriptOneParameters = {
77+
stdout: "script-one-output",
78+
close_command: "_close_",
79+
close_confirmation: "_closed_",
80+
mode: "unix-epoch"
81+
}
82+
scriptOneRequest.open('GET', 'http://interactive:one@local-pseudodomain/perl/interactive-script.pl' +
83+
formatParameters(scriptOneParameters), true);
84+
scriptOneRequest.send();
85+
86+
var scriptTwoRequest = new XMLHttpRequest();
87+
var scriptTwoParameters = {
88+
stdout: "script-two-output",
89+
close_command: "_close_",
90+
close_confirmation: "_closed_",
91+
mode: "local-time"
92+
}
93+
scriptTwoRequest.open('GET', 'http://interactive:two@local-pseudodomain/perl/interactive-script.pl' +
94+
formatParameters(scriptTwoParameters), true);
95+
scriptTwoRequest.send();
96+
});
97+
98+
function formatParameters(parameters) {
99+
return "?" + Object
100+
.keys(parameters)
101+
.map(function(key){
102+
return key + "=" + parameters[key]
103+
})
104+
.join("&")
105+
}
106+
</script>
107+
</body>
108+
109+
</html>

resources/app/perl/interactive-script.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
use strict;
44
use warnings;
5-
use AnyEvent;
65
use POSIX qw(strftime);
76
binmode STDOUT, ":utf8";
87

8+
if (eval("require AnyEvent;")) {
9+
AnyEvent->import();
10+
} else {
11+
print "AnyEvent Perl module is not loaded.<br><br>";
12+
exit 0;
13+
}
14+
915
# Disable built-in buffering:
1016
$| = 1;
1117

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#ifdef Q_OS_WIN
2323
#if ADMIN_PRIVILEGES_CHECK == 1
24-
#include <windows.h> // for isUserAdmin()
24+
#include <windows.h> // isUserAdmin()
2525
#endif
2626
#endif
2727

src/page.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public slots:
133133
if (scriptAccumulatedOutput.length() > 0 and
134134
scriptAccumulatedErrors.length() == 0 and
135135
scriptStdoutTarget.length() == 0) {
136-
137136
qDisplayScriptOutputSlot(scriptAccumulatedOutput, emptyString);
138137
}
139138

@@ -160,7 +159,8 @@ public slots:
160159
}
161160
} else {
162161
// If script has some output and errors,
163-
// HTML formatted errors will be displayed in a new window:
162+
// HTML formatted errors
163+
// will be displayed in a new window:
164164
qFormatScriptErrors(scriptAccumulatedErrors,
165165
scriptFullFilePath,
166166
true);

0 commit comments

Comments
 (0)