Skip to content

Commit ace27c4

Browse files
committed
Revert "UnitySite not static"
This reverts commit 01e7581.
1 parent c2ceb00 commit ace27c4

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

resources/init.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use UnityWebPortal\lib\UnityRedis;
1414
use UnityWebPortal\lib\UnityWebhook;
1515
use UnityWebPortal\lib\UnityGithub;
16-
use UnityWebPortal\lib\UnitySite;
1716

1817
//
1918
// Initialize Session
@@ -126,8 +125,6 @@
126125
}
127126
}
128127

129-
$SITE = new UnitySite();
130-
131128
//
132129
// Define vars
133130
//

resources/lib/UnitySite.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
class UnitySite
88
{
9-
public function redirect($destination)
9+
public static function redirect($destination)
1010
{
1111
if ($_SERVER["PHP_SELF"] != $destination) {
1212
header("Location: $destination");
1313
die("Redirect failed, click <a href='$destination'>here</a> to continue.");
1414
}
1515
}
1616

17-
public function removeTrailingWhitespace($arr)
17+
public static function removeTrailingWhitespace($arr)
1818
{
1919
$out = array();
2020
foreach ($arr as $str) {
@@ -25,7 +25,7 @@ public function removeTrailingWhitespace($arr)
2525
return $out;
2626
}
2727

28-
public function testValidSSHKey($key_str)
28+
public static function testValidSSHKey($key_str)
2929
{
3030
// key loader still throws, these just mute warnings for phpunit
3131
// https://github.com/phpseclib/phpseclib/issues/2079

resources/templates/header.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
2+
3+
use UnityWebPortal\lib\UnitySite;
4+
25
if (isset($SSO)) {
36
if (!$_SESSION["user_exists"]) {
4-
$SITE->redirect($CONFIG["site"]["prefix"] . "/panel/new_account.php");
7+
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/new_account.php");
58
}
69
}
710

@@ -116,7 +119,7 @@
116119
if (isset($_SESSION["is_admin"]) && $_SESSION["is_admin"]) {
117120
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["form_name"]) && $_POST["form_name"] == "clearView") {
118121
unset($_SESSION["viewUser"]);
119-
$SITE->redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
122+
UnitySite::redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
120123
}
121124

122125
if (isset($_SESSION["viewUser"])) {
@@ -132,4 +135,4 @@
132135
echo "</div>";
133136
}
134137
}
135-
?>
138+
?>

webroot/admin/user-mgmt.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
use UnityWebPortal\lib\UnitySite;
6+
57
if (!$USER->isAdmin()) {
68
throw new Exception("access denied");
79
}
@@ -10,7 +12,7 @@
1012
switch ($_POST["form_name"]) {
1113
case "viewAsUser":
1214
$_SESSION["viewUser"] = $_POST["uid"];
13-
$SITE->redirect($CONFIG["site"]["prefix"] . "/panel/account.php");
15+
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/account.php");
1416
break;
1517
}
1618
}

webroot/js/ajax/ssh_validate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

33
require_once __DIR__ . "/../../../resources/lib/UnitySite.php";
4+
require_once __DIR__ . "/../../../vendor/autoload.php";
45

5-
echo (new UnityWebPortal\lib\UnitySite())->testValidSSHKey($_POST["key"]) ? "true" : "false";
6+
echo UnityWebPortal\lib\UnitySite::testValidSSHKey($_POST["key"]) ? "true" : "false";

webroot/panel/account.php

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

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

5+
use UnityWebPortal\lib\UnitySite;
6+
57
require_once $LOC_HEADER;
68

79
$invalid_ssh_dialogue = "<script type='text/javascript'>
@@ -16,7 +18,7 @@
1618
switch ($_POST["add_type"]) {
1719
case "paste":
1820
$key = $_POST["key"];
19-
if ($SITE->testValidSSHKey($key)) {
21+
if (UnitySite::testValidSSHKey($key)) {
2022
array_push($added_keys, $key);
2123
} else {
2224
echo $invalid_ssh_dialogue;
@@ -25,7 +27,7 @@
2527
case "import":
2628
$keyfile = $_FILES["keyfile"]["tmp_name"];
2729
$key = file_get_contents($keyfile);
28-
if ($SITE->testValidSSHKey($key)) {
30+
if (UnitySite::testValidSSHKey($key)) {
2931
array_push($added_keys, $key);
3032
} else {
3133
echo $invalid_ssh_dialogue;
@@ -38,15 +40,15 @@
3840
$gh_user = $_POST["gh_user"];
3941
$keys = $GITHUB->getSshPublicKeys($gh_user);
4042
foreach ($keys as $key) {
41-
if ($SITE->testValidSSHKey($key)) {
43+
if (UnitySite::testValidSSHKey($key)) {
4244
array_push($added_keys, $key);
4345
}
4446
}
4547
break;
4648
}
4749

4850
if (!empty($added_keys)) {
49-
$added_keys = $SITE->removeTrailingWhitespace($added_keys);
51+
$added_keys = UnitySite::removeTrailingWhitespace($added_keys);
5052
$totalKeys = array_merge($USER->getSSHKeys(), $added_keys);
5153
$USER->setSSHKeys($totalKeys, $OPERATOR);
5254
}

webroot/panel/new_account.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

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

5+
use UnityWebPortal\lib\UnitySite;
56
use UnityWebPortal\lib\UnityGroup;
67

78
require_once $LOC_HEADER;
89

910
if ($USER->exists()) {
10-
$SITE->redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); // Redirect if account already exists
11+
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); // Redirect if account already exists
1112
}
1213

1314
if ($_SERVER["REQUEST_METHOD"] == "POST") {

webroot/panel/pi.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_once __DIR__ . "/../../resources/autoload.php";
44

55
use UnityWebPortal\lib\UnityUser;
6+
use UnityWebPortal\lib\UnitySite;
67

78
$group = $USER->getPIGroup();
89

0 commit comments

Comments
 (0)