Skip to content

Commit 625076c

Browse files
committed
let header handle redirect
1 parent 4c8160f commit 625076c

File tree

11 files changed

+19
-19
lines changed

11 files changed

+19
-19
lines changed

resources/templates/header.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
use UnityWebPortal\lib\UnitySite;
44

5-
if ((@$_SESSION["is_admin"] ?? false) == true
6-
&& $_SERVER["REQUEST_METHOD"] == "POST"
7-
&& (@$_POST["form_name"] ?? null) == "clearView"
8-
) {
9-
unset($_SESSION["viewUser"]);
10-
UnitySite::redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
5+
if (isset($_POST)) {
6+
if ((@$_SESSION["is_admin"] ?? false) == true
7+
&& (@$_POST["form_name"] ?? null) == "clearView"
8+
) {
9+
unset($_SESSION["viewUser"]);
10+
UnitySite::redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
11+
}
12+
// Webroot files need to handle their own POSTs before loading the header
13+
// so that they can do UnitySite::badRequest before anything else has been printed.
14+
// They also must not redirect like standard PRG practice because this
15+
// header also needs to handle POST data. So this header does the PRG redirect
16+
// for all pages.
17+
UnitySite::redirect($_SERVER['PHP_SELF']);
18+
unset($_POST); // unset ensures that header must not come before POST handling
1119
}
1220

1321
if (isset($SSO)) {

webroot/admin/content.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
if (!empty($_POST["pageSel"])) {
1313
$SQL->editPage($_POST["pageSel"], $_POST["content"], $USER);
1414
}
15-
UnitySite::redirect($_SERVER['PHP_SELF']);
1615
}
1716

1817
include $LOC_HEADER;

webroot/admin/notices.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
break;
2525
}
26-
UnitySite::redirect($_SERVER['PHP_SELF']);
2726
}
2827

2928
include $LOC_HEADER;

webroot/admin/pi-mgmt.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
break;
5252
}
53-
UnitySite::redirect($_SERVER['PHP_SELF']);
5453
}
5554

5655
include $LOC_HEADER;

webroot/admin/user-mgmt.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/account.php");
1616
break;
1717
}
18-
UnitySite::redirect($_SERVER['PHP_SELF']);
1918
}
2019

2120
include $LOC_HEADER;

webroot/index.php

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

33
require_once __DIR__ . "/../resources/autoload.php";
44

5-
require_once $LOC_HEADER;
5+
include $LOC_HEADER;
66
?>
77

88

webroot/panel/account.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use UnityWebPortal\lib\UnitySite;
66

7-
require_once $LOC_HEADER;
8-
97
if ($_SERVER['REQUEST_METHOD'] == "POST") {
108
switch (UnitySite::arrayGetOrBadRequest($_POST, "form_type")) {
119
case "addKey":
@@ -72,8 +70,9 @@
7270
}
7371
break;
7472
}
75-
UnitySite::redirect($_SERVER['PHP_SELF']);
7673
}
74+
75+
include $LOC_HEADER;
7776
?>
7877

7978
<h1>Account Settings</h1>

webroot/panel/groups.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
break;
4242
}
4343
}
44-
UnitySite::redirect($_SERVER['PHP_SELF']);
4544
}
4645

4746
include $LOC_HEADER;

webroot/panel/new_account.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
} else {
4343
UnitySite::badRequest("neither 'new_user_sel' or 'cancel' are set!");
4444
}
45-
UnitySite::redirect($_SERVER['PHP_SELF']);
4645
}
47-
require_once $LOC_HEADER;
46+
include $LOC_HEADER;
4847
?>
4948

5049
<h1>Request Account</h1>

webroot/panel/pi.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
break;
3333
}
34-
UnitySite::redirect($_SERVER['PHP_SELF']);
3534
}
3635

3736
include $LOC_HEADER;

webroot/panel/support.php

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

33
require "../../resources/autoload.php";
44

5-
require_once $LOC_HEADER;
5+
include $LOC_HEADER;
66
?>
77

88
<h1>Support</h1>

0 commit comments

Comments
 (0)