File tree Expand file tree Collapse file tree 9 files changed +23
-15
lines changed
Expand file tree Collapse file tree 9 files changed +23
-15
lines changed Original file line number Diff line number Diff line change 77
88class UnitySite
99{
10- public static function die ($ x )
10+ public static function die ($ x = null )
1111 {
1212 if (@$ GLOBALS ["PHPUNIT_NO_DIE_PLEASE " ] == true ) {
13- throw new PhpUnitNoDieException (strval ($ x ));
13+ if (is_null ($ x )) {
14+ throw new PhpUnitNoDieException ();
15+ } else {
16+ throw new PhpUnitNoDieException ($ x );
17+ }
1418 } else {
15- die ($ x );
19+ if (is_null ($ x )) {
20+ die ();
21+ } else {
22+ die ($ x );
23+ }
1624 }
1725 }
1826
@@ -28,7 +36,7 @@ public static function headerResponseCode(int $code)
2836 {
2937 $ responseCodeMessage = @http_response_code ($ code ) ?? "" ;
3038 $ msg = $ _SERVER ["SERVER_PROTOCOL " ] . " " . strval ($ code ) . " " . $ responseCodeMessage ;
31- header ($ msg , true , $ ncode );
39+ header ($ msg , true , $ code );
3240 }
3341
3442 public static function errorLog (string $ title , string $ message )
@@ -53,10 +61,10 @@ public static function badRequest($message)
5361 self ::die ();
5462 }
5563
56- public static function unauthorized ($ message )
64+ public static function forbidden ($ message )
5765 {
58- self ::headerResponseCode (401 );
59- self ::errorLog ("unauthorized " , $ message );
66+ self ::headerResponseCode (403 );
67+ self ::errorLog ("forbidden " , $ message );
6068 self ::die ();
6169 }
6270
Original file line number Diff line number Diff line change 66use UnityWebPortal \lib \UnitySite ;
77
88if (!$ USER ->isAdmin ()) {
9- UnitySite::unauthorized ("not an admin " );
9+ UnitySite::forbidden ("not an admin " );
1010}
1111
1212if (!isset ($ _GET ["pi_uid " ])) {
Original file line number Diff line number Diff line change 55use UnityWebPortal \lib \UnitySite ;
66
77if (!$ USER ->isAdmin ()) {
8- UnitySite::unauthorized ("not an admin " );
8+ UnitySite::forbidden ("not an admin " );
99}
1010
1111if (!isset ($ _GET ["pageid " ])) {
Original file line number Diff line number Diff line change 55use UnityWebPortal \lib \UnitySite ;
66
77if (!$ USER ->isAdmin ()) {
8- UnitySite::unauthorized ("not an admin " );
8+ UnitySite::forbidden ("not an admin " );
99}
1010
1111if ($ _SERVER ["REQUEST_METHOD " ] == "POST " ) {
Original file line number Diff line number Diff line change 55use UnityWebPortal \lib \UnitySite ;
66
77if (!$ USER ->isAdmin ()) {
8- UnitySite::unauthorized ("not an admin " );
8+ UnitySite::forbidden ("not an admin " );
99}
1010
1111if ($ _SERVER ["REQUEST_METHOD " ] == "POST " ) {
Original file line number Diff line number Diff line change 77use UnityWebPortal \lib \UnitySite ;
88
99if (!$ USER ->isAdmin ()) {
10- UnitySite::unauthorized ("not an admin " );
10+ UnitySite::forbidden ("not an admin " );
1111}
1212
1313if ($ _SERVER ["REQUEST_METHOD " ] == "POST " ) {
Original file line number Diff line number Diff line change 55use UnityWebPortal \lib \UnitySite ;
66
77if (!$ USER ->isAdmin ()) {
8- UnitySite::unauthorized ("not an admin " );
8+ UnitySite::forbidden ("not an admin " );
99}
1010
1111if ($ _SERVER ["REQUEST_METHOD " ] == "POST " ) {
Original file line number Diff line number Diff line change 2121}
2222
2323if ($ found ) {
24- UnitySite::unauthorized ("not a group member " );
24+ UnitySite::forbidden ("not a group member " );
2525}
2626
2727$ count = count ($ members );
Original file line number Diff line number Diff line change 88$ group = $ USER ->getPIGroup ();
99
1010if (!$ USER ->isPI ()) {
11- UnitySite::unauthorized ("not a PI " );
11+ UnitySite::forbidden ("not a PI " );
1212}
1313
1414if ($ _SERVER ["REQUEST_METHOD " ] == "POST " ) {
You can’t perform that action at this time.
0 commit comments