Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8: Fix major compatibility issues #216

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
* Protokollfreie URLs (welche, die mit // beginnen), werden automatisch mit dem korrekten Protokoll ergänzt.
* In diesem Fall wird auch ein SSL-Umschalt-Button im Header angezeigt
*/
if(@$_SERVER['SERVER_NAME'] == 'localhost' || @$_SERVER['SERVER_NAME'] == '0.0.0.0')
if(isset($_SERVER['SERVER_NAME']) && ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '0.0.0.0'))
{
// keine Konfiguration -> BASEURL wird automatisch erraten
}
else if(@$_SERVER['SERVER_NAME'] == 'streaming.test.c3voc.de')
else if(isset($_SERVER['SERVER_NAME']) && ($_SERVER['SERVER_NAME'] == 'streaming.test.c3voc.de'))
{
$GLOBALS['CONFIG']['BASEURL'] = '//streaming.test.c3voc.de/';
}
Expand Down Expand Up @@ -104,7 +104,7 @@
/**
* Konfiguration der Room-Defaults
*
* Falls in der Raum-Konfiguration innerhalb der Konferenz für diese Keys nichts definiert ist,
* Falls in der Raum-Konfiguration innerhalb der Konferenz für diese Keys nichts definiert ist,
* fällt das System auf diese Werte zurück.
*/

Expand Down
13 changes: 7 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
try {
if(isset($_GET['htaccess']))
{
$route = @$_GET['route'];
$route = isset($_GET['route']) ? $_GET['route'] : "";
}
elseif(isset($_SERVER["REQUEST_URI"]))
{
$route = ltrim(@$_SERVER["REQUEST_URI"], '/');
$route = ltrim($_SERVER["REQUEST_URI"], '/');

// serve static
if($route != '' && file_exists($_SERVER["DOCUMENT_ROOT"].'/'.$route))
Expand Down Expand Up @@ -87,11 +87,12 @@
'conference' => new GenericConference(),
));

if(startswith('//', @$GLOBALS['CONFIG']['BASEURL']))
if(isset($GLOBALS['CONFIG']['BASEURL']) && startswith('//', $GLOBALS['CONFIG']['BASEURL']))
{
$mandator = isset($GLOBALS['MANDATOR']) ? $GLOBALS['MANDATOR'] : "";
$tpl->set(array(
'httpsurl' => forceslash(forceslash('https:'.$GLOBALS['CONFIG']['BASEURL']).@$GLOBALS['MANDATOR']).forceslash($route).url_params(),
'httpurl' => forceslash(forceslash('http:'. $GLOBALS['CONFIG']['BASEURL']).@$GLOBALS['MANDATOR']).forceslash($route).url_params(),
'httpsurl' => forceslash(forceslash('https:'.$GLOBALS['CONFIG']['BASEURL']).$mandator).forceslash($route).url_params(),
'httpurl' => forceslash(forceslash('http:'. $GLOBALS['CONFIG']['BASEURL']).$mandator).forceslash($route).url_params(),
));
}

Expand Down Expand Up @@ -128,7 +129,7 @@
exit;
}

@list($mandator, $route) = explode('/', $route, 2);
list($mandator, $route) = array_pad(explode('/', $route, 2), 2, "");
if(!$mandator)
{
// root requested
Expand Down
2 changes: 2 additions & 0 deletions lib/PhpTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ function h($s)
class PhpTemplate
{
private $data = array();
public $file;

public function __construct($file)
{
$this->file = $file;
$this->data["naked"] = false;
}

public function set($___data = array())
Expand Down
19 changes: 17 additions & 2 deletions lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ function joinpath($parts)

function forceslash($url)
{
if ($url == NULL) {
$url = "";
}
$url = rtrim($url, '/');
if(strlen($url) > 0)
$url .= '/';
Expand Down Expand Up @@ -241,8 +244,20 @@ function query_data($operation, $query, $variables = [], $assoc = false, $cache
if (is_null($r)) {
throw new NotFoundException();
}

// TODO: add error handling?
// TODO: should we return the cached value, when we did not get an answer?
return $assoc ? @$r['data'] : @$r->data;
if ($assoc) {
if (isset($r['data'])) {
return $r['data'];
} else {
throw new NotFoundException();
}
} else {
if (isset($r->data)) {
return $r->data;
} else {
throw new NotFoundException();
}
}
}
Loading