Skip to content

Commit

Permalink
Disabling error printing (#393)
Browse files Browse the repository at this point in the history
* Disable error printing based on verbosity flag
  • Loading branch information
Magiczne authored Jul 22, 2021
1 parent 4ad1427 commit 53d5634
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 0 additions & 2 deletions source/CAS.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,6 @@ public static function error($msg)
}
if (self::$_PHPCAS_VERBOSE) {
echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
} else {
echo "<br />\n<b>Error</b>: <font color=\"FF0000\"><b>". DEFAULT_ERROR ."</b><br />\n";
}
phpCAS :: trace($msg . ' in ' . $file . 'on line ' . $line );
phpCAS :: traceEnd();
Expand Down
14 changes: 9 additions & 5 deletions source/CAS/AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ public function __construct($client,$failure,$cas_url,$no_response,
phpCAS::traceBegin();
$lang = $client->getLangObj();
$client->printHTMLHeader($lang->getAuthenticationFailed());
printf(
$lang->getYouWereNotAuthenticated(),
htmlentities($client->getURL()),
isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN']:''
);

if (phpCAS::getVerbose()) {
printf(
$lang->getYouWereNotAuthenticated(),
htmlentities($client->getURL()),
$_SERVER['SERVER_ADMIN'] ?? ''
);
}

phpCAS::trace($messages[] = 'CAS URL: '.$cas_url);
phpCAS::trace($messages[] = 'Authentication failure: '.$failure);
if ( $no_response ) {
Expand Down
23 changes: 14 additions & 9 deletions source/CAS/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ private function _htmlFilterOutput($str)
*/
public function printHTMLHeader($title)
{
if (!phpCAS::getVerbose()) {
return;
}

$this->_htmlFilterOutput(
str_replace(
'__TITLE__', $title,
Expand Down Expand Up @@ -130,16 +134,17 @@ public function printHTMLHeader($title)
*/
public function printHTMLFooter()
{
if (!phpCAS::getVerbose()) {
return;
}

$lang = $this->getLangObj();
$this->_htmlFilterOutput(
empty($this->_output_footer)?
(phpCAS::getVerbose())?
'<hr><address>phpCAS __PHPCAS_VERSION__ '
.$lang->getUsingServer()
.' <a href="__SERVER_BASE_URL__">__SERVER_BASE_URL__</a> (CAS __CAS_VERSION__)</a></address></body></html>'
:'</body></html>'
:$this->_output_footer
);
$message = empty($this->_output_footer)
? '<hr><address>phpCAS __PHPCAS_VERSION__ ' . $lang->getUsingServer() .
' <a href="__SERVER_BASE_URL__">__SERVER_BASE_URL__</a> (CAS __CAS_VERSION__)</a></address></body></html>'
: $this->_output_footer;

$this->_htmlFilterOutput($message);
}

/**
Expand Down

0 comments on commit 53d5634

Please sign in to comment.