/trunk/TODO |
---|
1,11 → 1,25 |
April 2023 planned: |
- Don't send information object OIDs to oid-info.com anymore |
- Don't send "information object (i.e. Non-OIDs)" OIDs to oid-info.com anymore |
- In re Internet access: |
* Check if all instances of https://github.com/danielmarschall/oidplus/issues/5 ("Offline mode") have been addressed |
* Everywhere where url_post_contents() is used, we need to check url_post_contents_available() too. |
* Everywhere where url_get_contents() is used, we need to check url_get_contents_available() too. |
Exception Refactoring: |
- [DONE] Instead of catching OIDplusException, catch Exception |
- [DONE] Check every "new OIDplusException" and "new \OIDplusException" if it contains HTML and needs to be "new OIDplusHtmlException" |
- [DONE] Check every instance of "->getMessage()" it it needs to be HTML or Text |
HTML would be $htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
- Check every instance of "catch (\Exception" |
Question: In the whole code we write "catch (\Exception" . Is that correct or should we write "catch (\Throwable" ? |
- Why are there 66 matches of "$out['icon'] = 'img/error.png';" ? Shouldn't gui() just throw OIDplusException or OIDplusHtmlException and let the caller do the rest? |
Problem is this: If gui() uses $out[...], then the title can be chosen |
But we still should prefer throwing Exceptions! |
- Idea: Implement "friendly Exceptions" |
* A "friendly" Exception is an Exception where the user has done something wrong (i.e. they are not logged in). |
* The error is therefore clearly known and therefore a technical stacktrace is NOT shown. |
Type safety: |
- PhpStorm warnings |
- Re-Check "mixed" |
/trunk/ajax.php |
---|
89,7 → 89,8 |
$json_out = array(); |
$json_out['title'] = _L('Error'); |
$json_out['icon'] = 'img/error.png'; |
$json_out['text'] = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$json_out['text'] = '<p>'.$htmlmsg.'</p>'; |
} |
$json_out['status'] = 0; |
} else if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'tree_search')) { |
139,8 → 140,6 |
} |
$errmsg = $e->getMessage(); |
$errmsg = strip_tags($errmsg); |
$errmsg = html_entity_decode($errmsg, ENT_QUOTES, 'UTF-8'); |
$json_out = array(); |
$json_out['status'] = -2; |
/trunk/cron.php |
---|
25,6 → 25,7 |
// a WebCron service (e.g. https://www.easycron.com/ ) instead, using cron.php |
use ViaThinkSoft\OIDplus\OIDplus; |
use ViaThinkSoft\OIDplus\OIDplusException; |
try { |
require_once __DIR__ . '/includes/oidplus.inc.php'; |
35,5 → 36,6 |
ob_end_clean(); |
} catch (\Exception $e) { |
http_response_code(500); // Internal Server Error |
echo $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
echo $htmlmsg; |
} |
/trunk/includes/classes/OIDplus.class.php |
---|
734,7 → 734,7 |
try { |
$authInfo = $plugin->generate($password); |
} catch (OIDplusException $e) { |
} catch (\Exception $e) { |
// This can happen when the AuthKey is too long for the database field |
// Note: The constructor and setters of OIDplusRAAuthInfo() already check for length and null/false values. |
throw new OIDplusException(_L('Auth plugin "%1" is erroneous: %2',basename($plugin->getPluginDirectory()),$e->getMessage())); |
/trunk/includes/classes/OIDplusException.class.php |
---|
23,6 → 23,16 |
\defined('INSIDE_OIDPLUS') or die; |
// phpcs:enable PSR1.Files.SideEffects |
/** |
* Every Exception that is thrown in OIDplus should be an OIDplusException. |
*/ |
class OIDplusException extends \Exception { |
/** |
* @return string |
*/ |
public function getHtmlMessage(): string { |
return htmlentities($this->getMessage()); |
} |
} |
/trunk/includes/classes/OIDplusGui.class.php |
---|
43,7 → 43,8 |
} catch (\Exception $e) { |
$out['title'] = _L('Error'); |
$out['icon'] = 'img/error.png'; |
$out['text'] = '<p>'.$e->getMessage().'</p>'; |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] = '<p>'.$htmlmsg.'</p>'; |
if (OIDplus::baseConfig()->getValue('DEBUG')) { |
$out['text'] .= self::getExceptionTechInfo($e); |
} |
126,6 → 127,9 |
*/ |
public static function html_exception_handler(\Throwable $exception) { |
// Note: This method must be static |
// OXOXO: Implement HTMLEXCEPTIONS |
if ($exception instanceof OIDplusConfigInitializationException) { |
echo '<!DOCTYPE HTML>'; |
echo '<html><head><title>'.htmlentities(_L('OIDplus initialization error')).'</title></head><body>'; |
159,7 → 163,14 |
$out .= get_class($exception)."\n"; |
$out .= _L('at file %1 (line %2)',$exception->getFile(),"".$exception->getLine())."\n\n"; |
$out .= _L('Stacktrace').":\n"; |
$out .= htmlentities($exception->getTraceAsString()); |
$stacktrace = $exception->getTraceAsString(); |
try { |
$syspath = OIDplus::localpath(NULL); |
$stacktrace = str_replace($syspath, '...'.DIRECTORY_SEPARATOR, $stacktrace); // for security |
} catch (\Throwable $e) { |
// Catch Exception and Error, because this step (censoring) is purely optional and shoult not prevent the stacktrace of being shown |
} |
$out .= htmlentities($stacktrace); |
$out .= '</pre>'; |
return $out; |
} |
/trunk/includes/classes/OIDplusHtmlException.class.php |
---|
0,0 → 1,56 |
<?php |
/* |
* OIDplus 2.0 |
* Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
namespace ViaThinkSoft\OIDplus; |
// phpcs:disable PSR1.Files.SideEffects |
\defined('INSIDE_OIDPLUS') or die; |
// phpcs:enable PSR1.Files.SideEffects |
/** |
* This kind of Exception can contain HTML code |
*/ |
class OIDplusHtmlException extends OIDplusException { |
/** |
* @var string |
*/ |
private $htmlMessage; |
/** |
* @param string $message In HTML format |
* @param int $code |
* @param \Throwable|null $previous |
*/ |
public function __construct(string $message = "", int $code = 0, \Throwable $previous = null) { |
$this->htmlMessage = $message; |
$message = strip_tags($message); |
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); |
parent::__construct($message, $code, $previous); |
} |
/** |
* @return string |
*/ |
public function getHtmlMessage(): string { |
return $this->htmlMessage; |
} |
} |
/trunk/plugins/viathinksoft/adminPages/010_notifications/OIDplusNotification.class.php |
---|
33,7 → 33,7 |
/** |
* @var string |
*/ |
private $message; |
private $message; // TODO: Rename this to $htmlMessage everywhere |
/** |
* @param string $severity One of OK, INFO, WARN, ERR, or CRIT |
99,6 → 99,7 |
* @return string |
*/ |
public function getMessage(): string { |
// TODO: Rename this method to getHtmlMessage() everywhere |
return $this->message; |
} |
/trunk/plugins/viathinksoft/adminPages/050_oobe/oobe.php |
---|
55,7 → 55,8 |
try { |
OIDplus::getActiveCaptchaPlugin()->captchaVerify($_POST); |
} catch (\Exception $e) { |
echo '<p><font color="red"><b>'.htmlentities($e->getMessage()).'</b></font></p>'; |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
echo '<p><font color="red"><b>'.$htmlmsg.'</b></font></p>'; |
$errors_happened = true; |
$edits_possible = false; |
} |
103,7 → 104,7 |
echo '<h2>'._L('Step %1: Please enter the email address of the system administrator',$step).'</h2>'; |
echo '<input type="text" name="admin_email" value="'; |
$msg = ''; |
$htmlmsg = ''; |
if (isset($_POST['sent'])) { |
echo htmlentities($_POST['admin_email'] ?? ''); |
if ($do_edits) { |
110,7 → 111,7 |
try { |
OIDplus::config()->setValue('admin_email', $_POST['admin_email'] ?? ''); |
} catch (\Exception $e) { |
$msg = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$errors_happened = true; |
} |
} |
118,7 → 119,7 |
echo htmlentities(OIDplus::config()->getValue('admin_email')); |
} |
echo '" size="25"> <font color="red"><b>'.$msg.'</b></font>'; |
echo '" size="25"> <font color="red"><b>'.$htmlmsg.'</b></font>'; |
} |
step_admin_email($step++, $do_edits, $errors_happened); |
136,7 → 137,7 |
echo '<h2>'._L('Step %1: What title should your Registration Authority / OIDplus instance have?',$step).'</h2>'; |
echo '<input type="text" name="system_title" value="'; |
$msg = ''; |
$htmlmsg = ''; |
if (isset($_POST['sent'])) { |
echo htmlentities($_POST['system_title'] ?? ''); |
if ($do_edits) { |
143,7 → 144,7 |
try { |
OIDplus::config()->setValue('system_title', $_POST['system_title'] ?? ''); |
} catch (\Exception $e) { |
$msg = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$errors_happened = true; |
} |
} |
151,7 → 152,7 |
echo htmlentities(OIDplus::config()->getValue('system_title')); |
} |
echo '" size="50"> <font color="red"><b>'.$msg.'</b></font>'; |
echo '" size="50"> <font color="red"><b>'.$htmlmsg.'</b></font>'; |
} |
step_system_title($step++, $do_edits, $errors_happened); |
/trunk/plugins/viathinksoft/adminPages/110_system_config/OIDplusPageAdminSystemConfig.class.php |
---|
34,7 → 34,7 |
public function action(string $actionID, array $params): array { |
if ($actionID == 'config_update') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
_CheckParamExists($params, 'name'); |
/trunk/plugins/viathinksoft/adminPages/120_registration/OIDplusPageAdminRegistration.class.php |
---|
663,17 → 663,17 |
echo '</select>'; |
$msg = ''; |
$htmlmsg = ''; |
if ($do_edits) { |
try { |
OIDplus::config()->setValue('reg_privacy', $_POST['reg_privacy'] ?? 1); |
OIDplus::config()->setValue('oobe_registration_done', '1'); |
} catch (\Exception $e) { |
$msg = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$errors_happened = true; |
} |
} |
if (!empty($msg)) echo ' <font color="red"><b>'.$msg.'</b></font>'; |
if (!empty($htmlmsg)) echo ' <font color="red"><b>'.$htmlmsg.'</b></font>'; |
echo '<p>'._L('<i>Privacy information:</i> This setting can always be changed in the administrator login / control panel.').'<br>'; |
echo _L('<a %1>Click here</a> for more information about privacy related topics.','href="../../../../res/OIDplus/privacy_documentation.html" target="_blank"'); |
/trunk/plugins/viathinksoft/adminPages/130_create_ra/OIDplusPageAdminCreateRa.class.php |
---|
34,7 → 34,7 |
public function action(string $actionID, array $params): array { |
if ($actionID == 'create_ra') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
_CheckParamExists($params, 'email'); |
/trunk/plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php |
---|
47,7 → 47,7 |
if ($actionID == 'import_xml_file') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
if (!isset($_FILES['userfile'])) { |
80,7 → 80,7 |
} |
} else if ($actionID == 'import_oidinfo_oid') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
_CheckParamExists($params, 'oid'); |
/trunk/plugins/viathinksoft/adminPages/700_colors/OIDplusPageAdminColors.class.php |
---|
73,7 → 73,7 |
public function action(string $actionID, array $params): array { |
if ($actionID == 'color_update') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
_CheckParamExists($params, 'hue_shift'); |
271,18 → 271,18 |
} |
echo '> <label for="color_invert">'._L('Dark Theme (inverted colors)').'</label><br>'; |
$msg = ''; |
$htmlmsg = ''; |
if ($do_edits) { |
try { |
OIDplus::config()->setValue('color_invert', $set_value ? 1 : 0); |
OIDplus::config()->setValue('oobe_colors_done', '1'); |
} catch (\Exception $e) { |
$msg = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$errors_happened = true; |
} |
} |
echo ' <font color="red"><b>'.$msg.'</b></font>'; |
echo ' <font color="red"><b>'.$htmlmsg.'</b></font>'; |
} |
} |
/trunk/plugins/viathinksoft/adminPages/900_software_update/OIDplusPageAdminSoftwareUpdate.class.php |
---|
59,7 → 59,7 |
@set_time_limit(0); |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
if (OIDplus::getInstallType() === 'git-wc') { |
423,7 → 423,8 |
try { |
$cont = $this->showChangelog($local_installation); |
} catch (\Exception $e) { |
$cont = _L('Error: %1',$e->getMessage()); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$cont = _L('Error: %1',$htmlmsg); |
} |
ob_end_clean(); |
/trunk/plugins/viathinksoft/adminPages/902_systemfile_check/OIDplusPageAdminSystemFileCheck.class.php |
---|
148,7 → 148,8 |
$out['text'] .= _L('Everything OK!'); |
} |
} catch (\Exception $e) { |
$out['text'] .= mb_strtoupper(_L('Error')).': '.htmlentities($e->getMessage()); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] .= mb_strtoupper(_L('Error')).': '.$htmlmsg; |
} |
$out['text'] .= '</pre>'; |
/trunk/plugins/viathinksoft/adminPages/910_automated_ajax_calls/OIDplusPageAdminAutomatedAJAXCalls.class.php |
---|
37,7 → 37,7 |
public function action(string $actionID, array $params): array { |
if ($actionID == 'blacklistJWT') { |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
if (!OIDplus::baseConfig()->getValue('JWT_ALLOW_AJAX_ADMIN', true)) { |
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/export_dos.php |
---|
20,6 → 20,7 |
use ViaThinkSoft\OIDplus\OIDplus; |
use ViaThinkSoft\OIDplus\OIDplusGui; |
use ViaThinkSoft\OIDplus\OIDplusException; |
use ViaThinkSoft\OIDplus\OIDplusHtmlException; |
header('Content-Type:text/html; charset=UTF-8'); |
36,7 → 37,7 |
} |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
if (!class_exists('ZipArchive')) { |
99,7 → 100,7 |
$zip = new ZipArchive(); |
if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
throw new OIDplusException("cannot open <$tmp_file>"); |
throw new OIDplusException(_L("Cannot open file %1", $tmp_file)); |
} |
/** |
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/export_win.php |
---|
20,6 → 20,7 |
use ViaThinkSoft\OIDplus\OIDplus; |
use ViaThinkSoft\OIDplus\OIDplusGui; |
use ViaThinkSoft\OIDplus\OIDplusException; |
use ViaThinkSoft\OIDplus\OIDplusHtmlException; |
header('Content-Type:text/html; charset=UTF-8'); |
36,7 → 37,7 |
} |
if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin'))); |
} |
if (!class_exists('ZipArchive')) { |
107,7 → 108,7 |
$zip = new ZipArchive(); |
if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
throw new OIDplusException("cannot open <$tmp_file>"); |
throw new OIDplusException(_L("Cannot open file %1", $tmp_file)); |
} |
$cont = ''; |
/trunk/plugins/viathinksoft/language/dede/messages.xml |
---|
1078,6 → 1078,14 |
</message> |
<message> |
<source><![CDATA[ |
Cannot open file %1 |
]]></source> |
<target><![CDATA[ |
Kann Datei %1 nicht öffnen |
]]></target> |
</message> |
<message> |
<source><![CDATA[ |
Cannot prepare statement |
]]></source> |
<target><![CDATA[ |
7273,7 → 7281,7 |
This email address already has a FreeOID registered (%1) |
]]></source> |
<target><![CDATA[ |
Diese E-Mail-Adresse hat bereits eine kostenlose OID (%1) |
Diese E-Mail-Adresse hat bereits eine kostenlose OID erhalten (%1) |
]]></target> |
</message> |
<message> |
/trunk/plugins/viathinksoft/publicPages/000_objects/OIDplusPagePublicObjects.class.php |
---|
1323,18 → 1323,18 |
echo '> <label for="enable_ot_'.$ot::ns().'">'.htmlentities($ot::objectTypeTitle()).'</label><br>'; |
} |
$msg = ''; |
$htmlmsg = ''; |
if ($do_edits) { |
try { |
OIDplus::config()->setValue('objecttypes_enabled', implode(';', $enabled_ary)); |
OIDplus::config()->setValue('oobe_objects_done', '1'); |
} catch (\Exception $e) { |
$msg = $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$errors_happened = true; |
} |
} |
echo ' <font color="red"><b>'.$msg.'</b></font>'; |
echo ' <font color="red"><b>'.$htmlmsg.'</b></font>'; |
} |
/** |
/trunk/plugins/viathinksoft/publicPages/091_forgot_password/OIDplusPagePublicForgotPassword.class.php |
---|
136,7 → 136,8 |
} catch (\Exception $e) { |
$out['icon'] = 'img/error.png'; |
$out['text'] = '<p>'._L('Error: %1',htmlentities($e->getMessage())).'</p>'; |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] = '<p>'._L('Error: %1',$htmlmsg).'</p>'; |
} |
} else if (explode('$',$id)[0] == 'oidplus:reset_password') { |
/trunk/plugins/viathinksoft/publicPages/095_attachments/OIDplusPagePublicAttachments.class.php |
---|
133,11 → 133,12 |
} catch (\Exception $e) { |
$error = _L('This functionality is not available due to a misconfiguration'); |
if (OIDplus::authUtils()->isAdminLoggedIn()) { |
$error .= ': '.$e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$error .= ': '.$htmlmsg; |
} else { |
$error .= '. '._L('Please notify the system administrator. After they log-in, they can see the reason at this place.'); |
} |
throw new OIDplusException($error); |
throw new OIDplusHtmlException($error); |
} |
// Get object-specific path |
477,7 → 478,8 |
} |
} catch (\Exception $e) { |
$doshow = true; |
$output = '<p>'.$e->getMessage().'</p>'; |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$output = '<p>'.$htmlmsg.'</p>'; |
} |
$output = '<h2>'._L('File attachments').'</h2>' . |
633,7 → 635,8 |
} |
} catch (\Exception $e) { |
$error = _L('The file attachments feature is not available due to a misconfiguration'); |
$error .= ': ' . $e->getMessage(); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$error .= ': ' . $htmlmsg; |
} |
if ($error) { |
$notifications[] = new OIDplusNotification('WARN', $error); |
/trunk/plugins/viathinksoft/publicPages/095_attachments/download.php |
---|
63,5 → 63,6 |
VtsBrowserDownload::output_file($local_file); |
} catch (\Exception $e) { |
echo '<h1>'._L('Error').'</h1><p>'.htmlentities($e->getMessage()).'<p>'; |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
echo '<h1>'._L('Error').'</h1><p>'.$htmlmsg.'<p>'; |
} |
/trunk/plugins/viathinksoft/publicPages/200_viathinksoft_freeoid/OIDplusPagePublicFreeOID.class.php |
---|
42,10 → 42,10 |
/** |
* @param string $email |
* @param bool $getId |
* @return bool|null |
* @return string|null|bool If $getId=true, then returns ID or NULL. If $getId=False, then returns TRUE or FALSE. |
* @throws OIDplusException |
*/ |
public static function alreadyHasFreeOid(string $email, bool $getId = false)/*: ?bool*/ { |
public static function alreadyHasFreeOid(string $email, bool $getId = false) { |
$res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ?", array($email, self::getFreeRootOid(true).'.%')); |
$res->naturalSortByField('id'); |
if ($row = $res->fetch_array()) { |
69,7 → 69,7 |
$email = $params['email']; |
if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) { |
throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid)); |
throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>')); |
} |
if (!OIDplus::mailUtils()->validMailAddress($email)) { |
279,7 → 279,8 |
$out['text'] .= ' - <a '.OIDplus::gui()->link('aid:D276000186F1').'>'._L('More information').'</a></p>'; |
} |
} catch (\Exception $e) { |
$out['text'] = _L('Error: %1',$e->getMessage()); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] = _L('Error: %1',$htmlmsg); |
} |
} else if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid.activate_freeoid') { |
$handled = true; |
292,7 → 293,7 |
$out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : ''; |
if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) { |
throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid)); |
throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>')); |
} else { |
if (!OIDplus::authUtils()->validateAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp, $auth)) { |
$out['icon'] = 'img/error.png'; |
/trunk/plugins/viathinksoft/publicPages/300_search/OIDplusPagePublicSearch.class.php |
---|
245,7 → 245,8 |
} |
$out['text'] .= '</div>'; |
} catch (\Exception $e) { |
$out['text'] = _L('Error: %1',$e->getMessage()); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] = _L('Error: %1',$htmlmsg); |
} |
} |
} |
/trunk/plugins/viathinksoft/raPages/092_invite/OIDplusPageRaInvite.class.php |
---|
156,7 → 156,8 |
} catch (\Exception $e) { |
$out['icon'] = 'img/error.png'; |
$out['text'] = _L('Error: %1',$e->getMessage()); |
$htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage()); |
$out['text'] = _L('Error: %1',$htmlmsg); |
} |
} else if (explode('$',$id)[0] == 'oidplus:activate_ra') { |
238,7 → 239,7 |
} |
} |
if (!$ok) { |
throw new OIDplusException(_L('You may not invite this RA. Maybe you need to <a %1>log in</a> again.',OIDplus::gui()->link('oidplus:login'))); |
throw new OIDplusHtmlException(_L('You may not invite this RA. Maybe you need to <a %1>log in</a> again.',OIDplus::gui()->link('oidplus:login'))); |
} |
} |
} |
/trunk/plugins/viathinksoft/raPages/910_automated_ajax_calls/OIDplusPageRaAutomatedAJAXCalls.class.php |
---|
44,7 → 44,7 |
$ra_email = $params['user']; |
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) { |
throw new OIDplusException(_L('You need to <a %1>log in</a> as the requested RA %2 or as admin.',OIDplus::gui()->link('oidplus:login$ra$'.$ra_email),'<b>'.htmlentities($ra_email).'</b>')); |
throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as the requested RA %2 or as admin.',OIDplus::gui()->link('oidplus:login$ra$'.$ra_email),'<b>'.htmlentities($ra_email).'</b>')); |
} |
$gen = OIDplusAuthContentStoreJWT::JWT_GENERATOR_AJAX; |
/trunk/systeminfo.php |
---|
61,7 → 61,7 |
$sys_title = OIDplus::config()->getValue('system_title'); |
$out['SystemTitle'] = $sys_title; |
// commented out because of privacy |
// commented out because of security |
/* |
$sys_ver = OIDplus::getVersion(); |
if (!$sys_ver) $sys_ver = 'unknown'; // do not translate |
68,7 → 68,7 |
$out['SystemVersion'] = $sys_ver; |
*/ |
// commented out because of privacy |
// commented out because of security |
/* |
$sys_install_type = OIDplus::getInstallType(); |
$out['SystemInstallType'] = $sys_install_type; |