-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiredrill.php
More file actions
87 lines (75 loc) · 1.56 KB
/
Copy pathfiredrill.php
File metadata and controls
87 lines (75 loc) · 1.56 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
#create global shareable sessions
function generate_id() {
$sessionid = 'A111A135818';
return $sessionid;
}
$nchanels = 2;
session_id(generate_id());
session_start();
#create sessions variables
for ($x = 0; $x < $nchanels; $x++) {
#ifpost was about channelvariable then set one
if (isset($_POST['chnl'.$x]) && !empty($_POST['chnl'.$x])) {
$_SESSION['chnl'.$x] = $_POST['chnl'.$x];
}
}
#query /?action=post
#query /?action=recv&channel=chnl1
#query /?action=check&channel=chnl1
#query /?action=terminate
if (isset($_GET["action"])) {
#set session variables by posting
if ($_GET["action"] == "post") {
for ($i=0; $i < $nchanels; $i++) {
$add .= '<input name = "chnl'. $i .'" type="hidden" /> ';
}
echo '
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "POST">'. $add .
'
<input type = "submit" />
</form>
</body>
</html>';
}
#recv data from channel
elseif ($_GET["action"] == "recv") {
if (isset($_GET["channel"])) {
echo $_SESSION[$_GET["channel"]];
#reset channel
$unset = $_GET["channel"];
unset($_SESSION[$unset]);
}
else
{
echo "Specify channel";
}
}
#check if a channel has data
elseif ($_GET["action"] == "check") {
if (isset($_GET["channel"])) {
if (empty($_SESSION[$_GET["channel"]])) {
#no data
echo 0;
}else
{
#has data
echo 1;
}
}
}
#destroy all session variables
elseif ($_GET["action"] == "terminate") {
session_destroy();
echo "Session destroyed";
}
else {
echo "Specify a valid action";
}
}
else {
echo "Specify a valid parameter";
}
?>