diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index e8b87d0a19a55a25142ebf489617d8cea6e42313..05648442c3dde0516a8a9e6dd01ec3abd0d9da7a 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -1660,7 +1660,7 @@ class Admin_UserController extends AuthenticatedController )->asDialog(); $actions->addLink( _('Konten zusammenführen'), - $this->url_for('admin/user/migrate/' . ((!empty($this->user) && is_array($this->user)) ? $this->user['user_id'] : '')), + $this->url_for('admin/user/migrate/' . (!empty($this->user['user_id']) ? $this->user['user_id'] : '')), Icon::create('community') ); diff --git a/app/controllers/course/dates.php b/app/controllers/course/dates.php index 18df893ea13398c38c5d46aefe1bd448a7e862cf..976b9e78437d2686cfa2b579510ebf3f8ee28ffc 100644 --- a/app/controllers/course/dates.php +++ b/app/controllers/course/dates.php @@ -80,7 +80,10 @@ class Course_DatesController extends AuthenticatedController )->asDialog(); } - if (Seminar::setInstance(new Seminar(Course::findCurrent()))->getSlotModule('documents') && CourseDateFolder::availableInRange(Course::findCurrent(), User::findCurrent()->id)) { + if ( + Seminar::setInstance(new Seminar(Course::findCurrent()))->getSlotModule('documents') + && CourseDateFolder::availableInRange(Course::findCurrent(), User::findCurrent() ? User::findCurrent()->id : null) + ) { $actions->addLink( _('Sitzungsordner anlegen'), $this->url_for('course/dates/create_folders'), diff --git a/app/controllers/oer/endpoints.php b/app/controllers/oer/endpoints.php index 31563f531c02dd274cf217cebbe900fb0992f280..62bf10da10065ef95b754a97c1dff284c5f93176 100644 --- a/app/controllers/oer/endpoints.php +++ b/app/controllers/oer/endpoints.php @@ -374,7 +374,7 @@ class Oer_EndpointsController extends StudipController header("Expires: Mon, 12 Dec 2001 08:00:00 GMT"); header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); - if ($_SERVER['HTTPS'] == "on") { + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { header("Pragma: public"); header("Cache-Control: private"); } else { diff --git a/app/controllers/quicksearch.php b/app/controllers/quicksearch.php index 194f317480acc02241bdd5524de966b6c18d071a..9c6a4ae67c20abaee553d082d6fa29eb79854a4e 100644 --- a/app/controllers/quicksearch.php +++ b/app/controllers/quicksearch.php @@ -94,7 +94,7 @@ class QuicksearchController extends AuthenticatedController if (!empty($result[3])) { $formatted['item_description'] = sprintf('%s (%s)', $result[2], $result[3]); } else { - $formatted['item_description'] = $result[2]; + $formatted['item_description'] = $result[2] ?? ''; } } else if ($this->search instanceof SearchType) { $formatted['item_name'] = $this->search->getAvatarImageTag($result[0], Avatar::SMALL, ['title' => '']) . $formatted['item_name']; diff --git a/app/views/activityfeed/configuration.php b/app/views/activityfeed/configuration.php index ceb87eb2180dd4251d043433bfa70ff1794c8a9d..9161db0f926b1ed23c70939f50b46a778279d984 100644 --- a/app/views/activityfeed/configuration.php +++ b/app/views/activityfeed/configuration.php @@ -15,7 +15,7 @@ <? foreach ($provider as $prv_id => $prv_name) : ?> <label> <input type="checkbox" name="provider[<?= $context ?>][]" value="<?= htmlReady($prv_id) ?>" - <?= empty($config) || (is_array($config[$context]) && in_array($prv_id, $config[$context])) ? 'checked' : ''?>> + <?= empty($config) || (isset($config[$context]) && is_array($config[$context]) && in_array($prv_id, $config[$context])) ? 'checked' : ''?>> <?= htmlReady($prv_name) ?> </label> <? endforeach ?> diff --git a/app/views/admin/autoinsert/manual.php b/app/views/admin/autoinsert/manual.php index dd0f834bddeb4812cbac2044bc92a0faff6a4e31..a4f5f5ef0199bb0aab5960d566f692553bf5edcd 100644 --- a/app/views/admin/autoinsert/manual.php +++ b/app/views/admin/autoinsert/manual.php @@ -114,14 +114,14 @@ <? foreach ($values[$type] as $key => $value): ?> <? if (is_array($value)): ?> <option value="<?= $key ?>" - class="nested-item-header" <?= in_array($key, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($value['name']) ?></option> + class="nested-item-header" <?= in_array($key, $filter[$type] ?? []) ? 'selected' : '' ?>><?= htmlReady($value['name']) ?></option> <? foreach ($value['values'] as $k => $v): ?> <option value="<?= $k ?>" - class="nested-item" <?= in_array($k, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($v) ?></option> + class="nested-item" <?= in_array($k, $filter[$type] ?? []) ? 'selected' : '' ?>><?= htmlReady($v) ?></option> <? endforeach; ?> <? else: ?> <option - value="<?= $key ?>" <?= in_array($key, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($value) ?></option> + value="<?= $key ?>" <?= in_array($key, $filter[$type] ?? []) ? 'selected' : '' ?>><?= htmlReady($value) ?></option> <? endif ?> <? endforeach; ?> </select> diff --git a/app/views/admin/cronjobs/schedules/index.php b/app/views/admin/cronjobs/schedules/index.php index 61608758899ea406f0ce69c0cc41fa4588927f4c..5413d8de81a704338b40528cc2060c65cb01e4ef 100644 --- a/app/views/admin/cronjobs/schedules/index.php +++ b/app/views/admin/cronjobs/schedules/index.php @@ -35,7 +35,7 @@ use Studip\Button, Studip\LinkButton; <select name="filter[task_id]" id="task_id" class="submit-upon-select"> <option value=""><?= _('Alle Cronjobs anzeigen') ?></option> <? foreach ($tasks as $task): ?> - <option value="<?= $task->task_id ?>" <? if ($filter['task_id'] === $task->task_id) echo 'selected'; ?>> + <option value="<?= $task->task_id ?>" <? if (isset($filter['task_id']) && $filter['task_id'] === $task->task_id) echo 'selected'; ?>> <?= htmlReady($task->name) ?> </option> <? endforeach; ?> diff --git a/app/views/admin/user/edit.php b/app/views/admin/user/edit.php index bf0c0100c7826ac4326955df9eae95c1691b91a0..98111d23a261a80bd81714a6a45157e6a049acda 100644 --- a/app/views/admin/user/edit.php +++ b/app/views/admin/user/edit.php @@ -334,7 +334,7 @@ use Studip\Button, Studip\LinkButton; <br> - <? if ($user->online->last_lifesign): ?> + <? if (!empty($user->online->last_lifesign)): ?> <abbr title="<?= strftime('%x %X', $user->online->last_lifesign) ?>"> <?= reltime($user->online->last_lifesign, true, 2) ?> </abbr> @@ -424,7 +424,7 @@ use Studip\Button, Studip\LinkButton; <?= sprintf( '%s, %s, %s. %s', htmlReady($usc->studycourse->name), - htmlReady($usc->degree->name), + htmlReady($usc->degree->name ?? _('Unbekannt')), htmlReady($usc->semester), _('Fachsemester') ) ?> diff --git a/app/views/file/choose_destination.php b/app/views/file/choose_destination.php index 49afe8769c3f1593ccf942278b8135eee5144039..bcb5582709d5ea3ff04e1661d7e5058bc0d7af1b 100644 --- a/app/views/file/choose_destination.php +++ b/app/views/file/choose_destination.php @@ -33,7 +33,7 @@ $options = array_filter([ <?= Icon::create('folder-parent', Icon::ROLE_CLICKABLE)->asInput(50, ['formaction' => $controller->action_url('choose_folder/' . $parent_folder->getId()), 'to_plugin' => $options['from_plugin'] ?? null]) ?> <button class="undecorated" - formaction="<?= $controller->action_link('choose_folder/' . $parent_folder->getId()) ?>" <? if ($options['from_plugin']): ?> name="to_plugin" value="<?= htmlReady($options['from_plugin'] ?? null) ?>"<? endif; ?> + formaction="<?= $controller->action_link('choose_folder/' . $parent_folder->getId()) ?>" <? if (!empty($options['from_plugin'])): ?> name="to_plugin" value="<?= htmlReady($options['from_plugin']) ?>"<? endif; ?> data-dialog="size=medium"> <?= _('Aktueller Ordner') ?> </button> diff --git a/lib/classes/ForumEntry.php b/lib/classes/ForumEntry.php index f98e59cd7a121dc1dd14b88c3d3c112d5de11a21..7ac5306eb62e73198569d87a3e7755b4b68a2bd1 100644 --- a/lib/classes/ForumEntry.php +++ b/lib/classes/ForumEntry.php @@ -218,7 +218,7 @@ class ForumEntry implements PrivacyObject array_pop($path); $data = array_pop($path); - return $data['id'] ?: false; + return $data['id'] ?? false; } @@ -1029,7 +1029,7 @@ class ForumEntry implements PrivacyObject $stmt = DBManager::get()->prepare("SELECT chdate FROM forum_entries WHERE lft > ? AND rgt < ? AND seminar_id = ? ORDER BY chdate DESC LIMIT 1"); - $stmt->execute([$parent['lft'], $parent['rgt'], $parent['seminar_id']]); + $stmt->execute([$parent['lft'] ?? null, $parent['rgt'] ?? null, $parent['seminar_id'] ?? null]); $chdate = $stmt->fetchColumn(); $stmt_insert = DBManager::get()->prepare("UPDATE forum_entries diff --git a/lib/classes/exportdocument/ExportPDF.class.php b/lib/classes/exportdocument/ExportPDF.class.php index 8645f5b03958fc30d155f27e0ba939ce35a41ea8..915cfdeaab8a5368fc00879f3aa295cdc8d645f8 100644 --- a/lib/classes/exportdocument/ExportPDF.class.php +++ b/lib/classes/exportdocument/ExportPDF.class.php @@ -115,12 +115,15 @@ class ExportPDF extends TCPDF implements ExportDocument // Fetch headers from url, handle possible redirects do { $headers = get_headers($url, true, get_default_http_stream_context($url)); + if (!$headers) { + break; + } list(, $status) = explode(' ', $headers[0]); $url = $headers['Location'] ?? $headers['location'] ?? $url; } while (in_array($status, [300, 301, 302, 303, 305, 307])); - $status = $status ?: 404; + $status = $status ?? 404; // Replace image with link on error (and not internal), otherwise return sainitized // url diff --git a/lib/classes/librarysearch/LibraryDocument.class.php b/lib/classes/librarysearch/LibraryDocument.class.php index 4c90e0b4595450e1dcd24cfe7af05cde5b113042..8b74a2efa2868147b715fb3032997ccebb26ff52 100644 --- a/lib/classes/librarysearch/LibraryDocument.class.php +++ b/lib/classes/librarysearch/LibraryDocument.class.php @@ -322,8 +322,8 @@ class LibraryDocument $doc->csl_data = $data['csl_data']; $doc->datafields = $data['datafields']; $doc->search_params = $data['search_params']; - $doc->catalog = $data['catalog']; - $doc->opac_link = $data['opac_link']; + $doc->catalog = $data['catalog'] ?? null; + $doc->opac_link = $data['opac_link'] ?? null; return $doc; } diff --git a/lib/phplib/Seminar_Auth.class.php b/lib/phplib/Seminar_Auth.class.php index e4f9e36495bba43deadd3748b963dd42dc709a23..78247e97f227625161e44bc88f4c0f52f9f4334d 100644 --- a/lib/phplib/Seminar_Auth.class.php +++ b/lib/phplib/Seminar_Auth.class.php @@ -308,7 +308,7 @@ class Seminar_Auth // load the default set of plugins PluginEngine::loadPlugins(); - if (Request::get('loginname') && !$_COOKIE[get_class($GLOBALS['sess'])]) { + if (Request::get('loginname') && empty($_COOKIE[get_class($GLOBALS['sess'])])) { $login_template = $GLOBALS['template_factory']->open('nocookies'); } else if (isset($this->need_email_activation)) { $this->unauth(); diff --git a/lib/visual.inc.php b/lib/visual.inc.php index f61583b8399826c9d56bd637e44f3ecc2c16ba97..68ddd7a74cbe7dd4654c9a1a43176e608222c6f4 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -695,7 +695,7 @@ function TransformInternalLinks($str){ $domain_data['domains'] = preg_replace("'\|[^/|]*'", '$0[^/]*?', $domain_data['domains']); $domain_data['domains'] = mb_substr($domain_data['domains'], 1); $domain_data['user_domain'] = preg_replace("'^({$domain_data['domains']})(.*)$'i", "\\1", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); - $domain_data['user_domain_scheme'] = 'http' . (($_SERVER['HTTPS'] || $_SERVER['SERVER_PORT'] == 443) ? 's' : '') . '://'; + $domain_data['user_domain_scheme'] = 'http' . ((!empty($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443) ? 's' : '') . '://'; $GLOBALS['TransformInternalLinks_domainData'] = $domain_data; } $domain_data = $GLOBALS['TransformInternalLinks_domainData']; diff --git a/templates/filesystem/group_folder/edit.php b/templates/filesystem/group_folder/edit.php index 1d438bf50c5362bab39f47671d7fad229da44cac..a5dc2f4de30557d362a8ee8ba7530500df5aa235 100644 --- a/templates/filesystem/group_folder/edit.php +++ b/templates/filesystem/group_folder/edit.php @@ -10,7 +10,7 @@ $groups = Statusgruppen::findBySeminar_id(Request::get('cid')); </option> <? endif; ?> <? foreach ($groups as $one_group): ?> - <option <?=(@$group->id === $one_group->id ? 'selected' : '')?> value="<?= htmlReady($one_group->id) ?>"> + <option <?= isset($group) && $group->id === $one_group->id ? 'selected' : '' ?> value="<?= htmlReady($one_group->id) ?>"> <?= htmlReady($one_group->name) ?> </option> <? endforeach; ?> diff --git a/templates/filesystem/topic_folder/edit.php b/templates/filesystem/topic_folder/edit.php index 1ac39af5923baa9b77099eaaedafcbd4ba2885cc..e4eb6b06d45129e117ca161a3df5a221181a11fb 100644 --- a/templates/filesystem/topic_folder/edit.php +++ b/templates/filesystem/topic_folder/edit.php @@ -10,7 +10,7 @@ $topics = CourseTopic::findBySeminar_id($folder->range_id); </option> <? endif; ?> <? foreach ($topics as $one_topic): ?> - <option <?=(@$topic->id === $one_topic->id ? 'selected' : '')?> value="<?= htmlReady($one_topic->id) ?>"> + <option <?= isset($topic) && $topic->id === $one_topic->id ? 'selected' : '' ?> value="<?= htmlReady($one_topic->id) ?>"> <?= htmlReady($one_topic->title) ?> </option> <? endforeach; ?>