17 define(
"CONFIG_TYPE_INT", 1);
19 define(
"CONFIG_TYPE_TEXT", 2);
21 define(
"CONFIG_TYPE_TEXTAREA", 3);
23 define(
"CONFIG_TYPE_PASSWORD", 4);
25 define(
"CONFIG_TYPE_DROP", 5);
27 define(
"CONFIG_TYPE_BOOL", 6);
37 if (!function_exists(
'resolve_sysconfig_value')) {
38 function resolve_sysconfig_value($value, array $scope)
40 return preg_replace_callback(
'/\$(?:([A-Za-z_][A-Za-z0-9_]*)|\{([A-Za-z_][A-Za-z0-9_]*)\})/',
static function ($matches) use ($scope) {
41 $name = !empty($matches[1]) ? $matches[1] : $matches[2];
42 return array_key_exists($name, $scope) ? $scope[$name] : $matches[0];
83 function ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=
true)
106 $versionFile =
"{$sysconfdir}/VERSION";
107 $versionConf = parse_ini_file($versionFile,
true);
108 $resolvedValues = array();
113 foreach ($versionConf as $groupName => $groupArray) {
114 foreach ($groupArray as $var => $assign) {
115 $resolvedValue = resolve_sysconfig_value($assign, $resolvedValues);
116 $resolvedValues[$var] = $resolvedValue;
117 $SysConf[$groupName][$var] = $resolvedValue;
118 ${$var} = $resolvedValue;
119 $GLOBALS[$var] = $resolvedValue;
125 $dbPath =
"{$sysconfdir}/Db.conf";
126 $dbConf = parse_ini_file($dbPath,
true);
131 foreach ($dbConf as $var => $val) {
132 $SysConf[
'DBCONF'][$var] = $val;
140 $pg_conn =
DBconnect($sysconfdir,
"", $exitOnDbFail);
142 if (! $exitOnDbFail && ($pg_conn ===
null || $pg_conn ===
false)) {
147 $postgresDriver = new \Fossology\Lib\Db\Driver\Postgres($pg_conn);
148 $container->get(
'db.manager')->setDriver($postgresDriver);
162 $sql =
"SELECT variablename, conf_value FROM sysconfig;";
163 $result = pg_query($conn, $sql);
166 while ($row = pg_fetch_assoc($result)) {
167 $SysConf[
'SYSCONFIG'][$row[
'variablename']] = $row[
'conf_value'];
169 pg_free_result($result);
179 $columns = array(
"variablename",
"conf_value",
"ui_label",
"vartype",
"group_name",
180 "group_order",
"description",
"validation_function",
"option_value");
181 $valueArray = array();
184 $variable =
"CorsOrigins";
185 $prompt = _(
'Allowed origins for REST API');
186 $desc = _(
'[scheme]://[hostname]:[port], "*" for anywhere');
187 $valueArray[$variable] = array(
"'$variable'",
"'*'",
"'$prompt'",
191 $variable =
"SupportEmailLabel";
192 $supportEmailLabelPrompt = _(
'Support Email Label');
193 $supportEmailLabelDesc = _(
'e.g. "Support"<br>Text that the user clicks on to create a new support email. This new email will be preaddressed to this support email address and subject. HTML is ok.');
194 $valueArray[$variable] = array(
"'$variable'",
"'Support'",
"'$supportEmailLabelPrompt'",
195 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"1",
"'$supportEmailLabelDesc'",
"null",
"null");
197 $variable =
"SupportEmailAddr";
198 $supportEmailAddrPrompt = _(
'Support Email Address');
199 $supportEmailAddrValid =
"check_email_address";
200 $supportEmailAddrDesc = _(
'e.g. "support@mycompany.com"<br>Individual or group email address to those providing FOSSology support.');
201 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$supportEmailAddrPrompt'",
202 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"2",
"'$supportEmailAddrDesc'",
"'$supportEmailAddrValid'",
"null");
204 $variable =
"SupportEmailSubject";
205 $supportEmailSubjectPrompt = _(
'Support Email Subject line');
206 $supportEmailSubjectDesc = _(
'e.g. "fossology support"<br>Subject line to use on support email.');
207 $valueArray[$variable] = array(
"'$variable'",
"'FOSSology Support'",
"'$supportEmailSubjectPrompt'",
208 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"3",
"'$supportEmailSubjectDesc'",
"null",
"null");
211 $variable =
"OidcAppName";
212 $oidcPrompt = _(
'OIDC App Name');
213 $oidcDesc = _(
'e.g. "my oAuth"<br>App name to display on login page.');
214 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
215 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"1",
"'$oidcDesc'",
"null",
"null");
217 $variable =
"OidcClientIdClaim";
218 $oidcPrompt = _(
'OIDC Client Id Claim');
219 $oidcDesc = _(
'e.g. "azp"<br>Client ID claim in the decoded payload.');
220 $valueArray[$variable] = array(
"'$variable'",
"'client-id'",
"'$oidcPrompt'",
221 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"2",
"'$oidcDesc'",
"null",
"null");
223 $variable =
"OidcResourceOwnerId";
224 $oidcPrompt = _(
'Resource owner id field');
225 $oidcDesc = _(
'e.g. "email", "upn"<br>Field in token which provides user id. The field <b>should not be empty</b>.');
226 $valueArray[$variable] = array(
"'$variable'",
"'email'",
"'$oidcPrompt'",
227 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"3",
"'$oidcDesc'",
"null",
"null");
229 $variable =
"OidcTokenType";
230 $oidcPrompt = _(
'Token to use from provider');
231 $oidcDesc = _(
'OpenID Connect providers 2 types of tokens, access and id. Which to use for authentication?<br>AzureAD prefers ID token.');
232 $valueArray[$variable] = array(
"'$variable'",
"'A'",
"'$oidcPrompt'",
233 strval(
CONFIG_TYPE_DROP),
"'OauthSupport'",
"4",
"'$oidcDesc'",
"null",
"'Access Token{A}|ID Token{I}'");
235 $variable =
"OidcAppId";
236 $oidcPrompt = _(
'OIDC Client Id');
237 $oidcDesc = _(
'e.g. "e0ec21b9f4b21adc76f185962b52bdfc13af134a"<br>Client ID generated while registering your application.');
238 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
239 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"5",
"'$oidcDesc'",
"null",
"null");
241 $variable =
"OidcSecret";
242 $oidcPrompt = _(
'OIDC Secret');
243 $oidcDesc = _(
'e.g. "cf13476f185b9f4b2e0ec962b52211adbdfc13aa"<br>Secret generated while registering your application.');
244 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
247 $variable =
"OidcRedirectURL";
248 $oidcPrompt = _(
'Redirect URL');
249 $oidcDesc = _(
'e.g. "http://fossology.application.url.com/repo"<br>URL of your fossology application.');
250 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
251 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"7",
"'$oidcDesc'",
"null",
"null");
253 $variable =
"OidcDiscoveryURL";
254 $oidcPrompt = _(
'OIDC Discovery URL');
255 $oidcDesc = _(
'e.g. "http://oauth.com/.well-known/openid-configuration"<br>URL for OIDC Discovery document JSON to fill following fields upon save.');
256 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
257 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"8",
"'$oidcDesc'",
"null",
"null");
259 $variable =
"OidcIssuer";
260 $oidcPrompt = _(
'OIDC Token Issuer');
261 $oidcDesc = _(
'e.g. "http://oauth.com"<br>Issuer for OIDC tokens.');
262 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
263 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"9",
"'$oidcDesc'",
"null",
"null");
265 $variable =
"OidcAuthorizeURL";
266 $oidcPrompt = _(
'OIDC Authorize URL');
267 $oidcDesc = _(
'e.g. "http://oauth.com/authorization.oauth2"<br>URL for OAuth2 authorization endpoint.');
268 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
269 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"10",
"'$oidcDesc'",
"null",
"null");
271 $variable =
"OidcAccessTokenURL";
272 $oidcPrompt = _(
'OIDC Access Token URL');
273 $oidcDesc = _(
'e.g. "http://oauth.com/token.oauth2"<br>URL for OAuth2 access token endpoint.');
274 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
275 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"11",
"'$oidcDesc'",
"null",
"null");
277 $variable =
"OidcResourceURL";
278 $oidcPrompt = _(
'OIDC User Info URL');
279 $oidcDesc = _(
'e.g. "http://oauth.com/userinfo.oauth2"<br>URL for OAuth2 user info endpoint.');
280 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
281 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"12",
"'$oidcDesc'",
"null",
"null");
283 $variable =
"OidcJwksURL";
284 $oidcPrompt = _(
'OIDC JWKS URL');
285 $oidcDesc = _(
'e.g. "http://oauth.com/jwks.oauth2"<br>URL for OIDC JWKS keys.');
286 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
287 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"13",
"'$oidcDesc'",
"null",
"null");
289 $variable =
"OidcJwkAlgInject";
290 $oidcPrompt = _(
'OIDC JWKS Algorithm inject');
291 $oidcDesc = _(
'Algorithm value to inject for JWKS. Leave empty to not modify.' .
292 '<br><a href="https://datatracker.ietf.org/doc/html/rfc7517#section-4.4">Check info</a>.');
293 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
294 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"14",
"'$oidcDesc'",
"null",
"null");
296 $variable =
"OidcLogoutURL";
297 $oidcPrompt = _(
'Logout URL');
298 $oidcDesc = _(
'e.g. "http://oauth.com/logout.oauth2"<br>URL to redirect user to for logout.');
299 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
300 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"15",
"'$oidcDesc'",
"null",
"null");
302 $variable =
"OidcScope";
303 $prompt = _(
'OIDC Scope');
304 $desc = _(
'Scope of OIDC for client_credential grant. Used with LicenseDB.');
305 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
306 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"16",
"'$oidcDesc'",
"null",
"null");
309 $variable =
"BannerMsg";
310 $bannerMsgPrompt = _(
'Banner message');
311 $bannerMsgDesc = _(
'This is message will be displayed on every page with a banner. HTML is ok.');
312 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$bannerMsgPrompt'",
316 $variable =
"LogoImage";
317 $logoImagePrompt = _(
'Logo Image URL');
318 $logoImageValid =
"check_logo_image_url";
319 $logoImageDesc = _(
'e.g. "http://mycompany.com/images/companylogo.png" or "images/mylogo.png"<br>This image replaces the fossology project logo. Image is constrained to 150px wide. 80-100px high is a good target. If you change this URL, you MUST also enter a logo URL.');
320 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoImagePrompt'",
321 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"1",
"'$logoImageDesc'",
"'$logoImageValid'",
"null");
323 $variable =
"LogoLink";
324 $logoLinkPrompt = _(
'Logo URL');
325 $logoLinkDesc = _(
'e.g. "http://mycompany.com/fossology"<br>URL a person goes to when they click on the logo. If you change the Logo URL, you MUST also enter a Logo Image.');
326 $logoLinkValid =
"check_logo_url";
327 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoLinkPrompt'",
328 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"2",
"'$logoLinkDesc'",
"'$logoLinkValid'",
"null");
330 $variable =
"FOSSologyURL";
331 $urlPrompt = _(
"FOSSology URL");
332 $hostname = exec(
"hostname -f");
333 if (empty($hostname)) {
334 $hostname =
"localhost";
336 $fossologyURL = $hostname.
"/repo/";
337 $urlDesc = _(
"URL of this FOSSology server, e.g. $fossologyURL");
338 $urlValid =
"check_fossology_url";
339 $valueArray[$variable] = array(
"'$variable'",
"'$fossologyURL'",
"'$urlPrompt'",
340 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"1",
"'$urlDesc'",
"'$urlValid'",
"null");
342 $variable =
"ClearlyDefinedURL";
343 $urlPrompt = _(
"ClearlyDefined URL");
344 $cdURL =
"https://api.clearlydefined.io/";
345 $urlDesc = _(
"URL of ClearlyDefined server, e.g. $cdURL");
346 $urlValid =
"check_url";
347 $valueArray[$variable] = array(
"'$variable'",
"'$cdURL'",
"'$urlPrompt'",
348 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"2",
"'$urlDesc'",
"'$urlValid'",
"null");
350 $variable =
"NomostListNum";
351 $nomosNumPrompt = _(
"Maximum licenses to List");
352 $nomostListNum =
"2200";
353 $NomosNumDesc = _(
"For License List and License List Download, you can set the maximum number of lines to list/download. Default 2200.");
354 $valueArray[$variable] = array(
"'$variable'",
"'$nomostListNum'",
"'$nomosNumPrompt'",
355 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"1",
"'$NomosNumDesc'",
"null",
"null");
357 $variable =
"BlockSizeHex";
358 $hexPrompt = _(
"Chars per page in hex view");
359 $hexDesc = _(
"Number of characters per page in hex view");
360 $valueArray[$variable] = array(
"'$variable'",
"'8192'",
"'$hexPrompt'",
363 $variable =
"BlockSizeText";
364 $textPrompt = _(
"Chars per page in text view");
365 $textDesc = _(
"Number of characters per page in text view");
366 $valueArray[$variable] = array(
"'$variable'",
"'81920'",
"'$textPrompt'",
369 $variable =
"ShowJobsAutoRefresh";
370 $contextNamePrompt = _(
"ShowJobs Auto Refresh Time");
371 $contextValue =
"10";
372 $contextDesc = _(
"No of seconds to refresh ShowJobs");
373 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
374 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"4",
"'$contextDesc'",
"null",
"null");
377 $variable =
"ReportHeaderText";
378 $contextNamePrompt = _(
"Report Header Text");
379 $contextValue =
"FOSSology";
380 $contextDesc = _(
"Report Header Text at right side corner");
381 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
382 strval(
CONFIG_TYPE_TEXT),
"'ReportText'",
"1",
"'$contextDesc'",
"null",
"null");
384 $variable =
"CommonObligation";
385 $contextNamePrompt = _(
"Common Obligation");
387 $commonExObligations = _(
'you can add HTML line break, Also use json format for table rows');
388 $contextDesc = _(
"Common Obligation Text,".
"$commonExObligations");
389 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
392 $variable =
"AdditionalObligation";
393 $contextNamePrompt = _(
"Additional Obligation");
395 $contextDesc = _(
"Additional Obligation Text,".
"$commonExObligations");
396 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
399 $variable =
"ObligationAndRisk";
400 $contextNamePrompt = _(
"Obligation And Risk Assessment");
402 $contextDesc = _(
"Obligations and risk assessment,".
"$commonExObligations");
403 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
406 $variable =
"EnableOsselotReuse";
407 $prompt = (
"Enable OSSelot Reuse");
408 $desc = (
"When enabled, shows the OSSelot-based reuse option in the Reuser plugin");
409 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
410 strval(
CONFIG_TYPE_BOOL),
"'ReportText'",
"5",
"'$desc'",
"'check_boolean'",
"null");
412 $variable =
"OsselotCuratedUrl";
413 $osselotCuratedPrompt = _(
'OSSelot Curated API URL');
414 $osselotCuratedValid =
"check_url";
415 $osselotCuratedDesc = _(
'URL for OSSelot curated package information API.');
416 $valueArray[$variable] = array(
"'$variable'",
"'https://www.osselot.org/curated.php'",
"'$osselotCuratedPrompt'",
417 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"1",
"'$osselotCuratedDesc'",
"'$osselotCuratedValid'",
"null");
419 $variable =
"OsselotPackageAnalysisUrl";
420 $osselotPackagePrompt = _(
'OSSelot Package Analysis Base URL');
421 $osselotPackageValid =
"check_url";
422 $osselotPackageDesc = _(
'Base URL for OSSelot package analysis repository.');
423 $valueArray[$variable] = array(
"'$variable'",
"'https://raw.githubusercontent.com/Open-Source-Compliance/package-analysis/main/analysed-packages'",
"'$osselotPackagePrompt'",
424 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"2",
"'$osselotPackageDesc'",
"'$osselotPackageValid'",
"null");
426 $variable =
"OsselotPrimaryDomain";
427 $osselotPrimaryPrompt = _(
'OSSelot Primary Domain');
428 $osselotPrimaryValid =
"check_domain";
429 $osselotPrimaryDesc = _(
'Primary domain used in OSSelot package analysis URLs (e.g., raw.githubusercontent.com).');
430 $valueArray[$variable] = array(
"'$variable'",
"'raw.githubusercontent.com'",
"'$osselotPrimaryPrompt'",
431 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"3",
"'$osselotPrimaryDesc'",
"'$osselotPrimaryValid'",
"null");
433 $variable =
"OsselotFallbackDomain";
434 $osselotFallbackPrompt = _(
'OSSelot Fallback Domain');
435 $osselotFallbackValid =
"check_domain";
436 $osselotFallbackDesc = _(
'Fallback domain used when primary domain fails (e.g., osselot.org).');
437 $valueArray[$variable] = array(
"'$variable'",
"'osselot.org'",
"'$osselotFallbackPrompt'",
438 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"4",
"'$osselotFallbackDesc'",
"'$osselotFallbackValid'",
"null");
441 $variable =
"UploadFromServerWhitelist";
442 $contextNamePrompt = _(
"Whitelist for serverupload");
443 $contextValue =
"/tmp";
444 $contextDesc = _(
"List of allowed prefixes for upload, separated by \":\" (colon)");
445 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
446 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"1",
"'$contextDesc'",
"null",
"null");
448 $variable =
"UploadFromServerAllowedHosts";
449 $contextNamePrompt = _(
"List of allowed hosts for serverupload");
450 $contextValue =
"localhost";
451 $contextDesc = _(
"List of allowed hosts for upload, separated by \":\" (colon)");
452 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
453 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"2",
"'$contextDesc'",
"null",
"null");
456 $variable =
"SMTPHostName";
457 $smtpHostPrompt = _(
'SMTP Host Name');
458 $smtpHostDesc = _(
'e.g.: "smtp.domain.com"<br>The domain to be used to send emails.');
459 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpHostPrompt'",
460 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"1",
"'$smtpHostDesc'",
"null",
"null");
462 $variable =
"SMTPPort";
463 $smtpPortPrompt = _(
'SMTP Port');
464 $smtpPortDesc = _(
'e.g.: "25"<br>SMTP port to be used.');
465 $valueArray[$variable] = array(
"'$variable'",
"25",
"'$smtpPortPrompt'",
466 strval(
CONFIG_TYPE_INT),
"'SMTP'",
"2",
"'$smtpPortDesc'",
"null",
"null");
468 $variable =
"SMTPAuth";
469 $smtpAuthPrompt = _(
'SMTP Auth Type');
470 $smtpAuthDesc = _(
'Algorithm to use for login.<br>Login => Encrypted<br>None => No authentication<br>Plain => Send as plain text');
471 $valueArray[$variable] = array(
"'$variable'",
"'L'",
"'$smtpAuthPrompt'",
472 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"3",
"'$smtpAuthDesc'",
"null",
"'Login{L}|None{N}|Plain{P}'");
474 $variable =
"SMTPFrom";
475 $smtpFrom = _(
'SMTP Email');
476 $smtpFromDesc = _(
'e.g.: "user@domain.com"<br>Sender email.');
477 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpFrom'",
478 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"4",
"'$smtpFromDesc'",
"'check_email_address'",
"null");
480 $variable =
"SMTPAuthUser";
481 $smtpAuthUserPrompt = _(
'SMTP User');
482 $smtpAuthUserDesc = _(
'e.g.: "user"<br>Login to be used for login on SMTP Server.');
483 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthUserPrompt'",
484 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"5",
"'$smtpAuthUserDesc'",
"null",
"null");
486 $variable =
"SMTPAuthPasswd";
487 $smtpAuthPasswdPrompt = _(
'SMTP Login Password');
488 $smtpAuthPasswdDesc = _(
'Password used for SMTP login.');
489 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthPasswdPrompt'",
492 $variable =
"SMTPSslVerify";
493 $smtpSslPrompt = _(
'SMTP SSL Verify');
494 $smtpSslDesc = _(
'The SSL verification for connection is required?');
495 $valueArray[$variable] = array(
"'$variable'",
"'S'",
"'$smtpSslPrompt'",
496 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"7",
"'$smtpSslDesc'",
"null",
"'Ignore{I}|Strict{S}|Warn{W}'");
498 $variable =
"SMTPStartTls";
499 $smtpTlsPrompt = _(
'Start TLS');
500 $smtpTlsDesc = _(
'Use TLS connection for SMTP?');
501 $valueArray[$variable] = array(
"'$variable'",
"'1'",
"'$smtpTlsPrompt'",
502 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"8",
"'$smtpTlsDesc'",
"null",
"'Yes{1}|No{2}'");
504 $variable =
"UploadVisibility";
505 $prompt = _(
'Default Upload Visibility');
506 $desc = _(
'Default Visibility for uploads by the user');
507 $valueArray[$variable] = array(
"'$variable'",
"'protected'",
"'$prompt'",
508 strval(
CONFIG_TYPE_DROP),
"'UploadFlag'",
"1",
"'$desc'",
"null",
"'Visible only for active group{private}|Visible for all groups{protected}|Make Public{public}'");
511 $variable =
"PasswdPolicy";
512 $prompt = _(
'Enable password policy');
513 $desc = _(
'Enable password policy check');
514 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
516 "'check_boolean'",
"null");
518 $variable =
"PasswdPolicyMinChar";
519 $prompt = _(
'Minimum characters');
520 $desc = _(
'Blank for no limit');
521 $valueArray[$variable] = array(
"'$variable'",
"8",
"'$prompt'",
524 $variable =
"PasswdPolicyMaxChar";
525 $prompt = _(
'Maximum characters');
526 $desc = _(
'Blank for no limit');
527 $valueArray[$variable] = array(
"'$variable'",
"16",
"'$prompt'",
530 $variable =
"PasswdPolicyLower";
531 $prompt = _(
'Lowercase');
532 $desc = _(
'Minimum one lowercase character.');
533 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
535 "'check_boolean'",
"null");
537 $variable =
"PasswdPolicyUpper";
538 $prompt = _(
'Uppercase');
539 $desc = _(
'Minimum one uppercase character.');
540 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
542 "'check_boolean'",
"null");
544 $variable =
"PasswdPolicyDigit";
545 $prompt = _(
'Digit');
546 $desc = _(
'Minimum one digit.');
547 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
549 "'check_boolean'",
"null");
551 $variable =
"PasswdPolicySpecial";
552 $prompt = _(
'Allowed special characters');
553 $desc = _(
'Empty for do not care');
554 $valueArray[$variable] = array(
"'$variable'",
"'@$!%*?&'",
"'$prompt'",
557 $variable =
"PATMaxExipre";
558 $patTokenValidityPrompt = _(
'Max token validity');
559 $patTokenValidityDesc = _(
'Maximum validity of tokens (in days)');
560 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenValidityPrompt'",
561 strval(
CONFIG_TYPE_INT),
"'PAT'",
"1",
"'$patTokenValidityDesc'",
"null",
"null");
563 $variable =
"PATMaxPostExpiryRetention";
564 $patTokenRetentionPrompt = _(
'Max expired token retention period');
565 $patTokenRetentionDesc = _(
'Maximum retention period of expired tokens (in days) for Maintagent');
566 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenRetentionPrompt'",
567 strval(
CONFIG_TYPE_INT),
"'PAT'",
"2",
"'$patTokenRetentionDesc'",
"null",
"null");
569 $variable =
"SkipFiles";
570 $mimeTypeToSkip = _(
"Skip MimeTypes from scanning");
571 $mimeTypeDesc = _(
"add comma (,) separated mimetype to exclude files from scanning");
572 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
573 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
577 $variable =
"SourceCodeDownloadRights";
578 $SourceDownloadRightsPrompt = _(
'Access rights required to download source code');
579 $SourceDownloadRightsDesc = _(
'Choose which access level will be required for user to be able to download source code.');
580 $valueArray[$variable] = array(
"'$variable'",
"'$perm_write'",
"'$SourceDownloadRightsPrompt'",
581 strval(
CONFIG_TYPE_DROP),
"'DOWNLOAD'",
"1",
"'$SourceDownloadRightsDesc'",
"null",
"'Administrator{{$perm_admin}}|Read_Write{{$perm_write}}'");
583 $variable =
"UserDescReadOnly";
584 $prompt = _(
'Make account details read-only');
585 $desc = _(
'Make account details (username, email, description) read-only');
586 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
588 "'check_boolean'",
"null");
590 $variable =
"LicenseTypes";
591 $licenseTypeTitle = _(
"License Types");
592 $licenseTypeDesc = _(
"add comma (,) separated different license types");
593 $valueArray[$variable] = array(
"'$variable'",
594 "'Permissive, Strong Copyleft, Weak Copyleft, Network Copyleft, Public Domain, Non-commercial, Source Available, Font, Data, Exception, Unknown'",
595 "'$licenseTypeTitle'",
596 strval(
CONFIG_TYPE_TEXT),
"'LICENSE'",
"1",
"'$licenseTypeDesc'",
"null",
"null");
599 $variable =
"SwhURL";
600 $prompt = _(
'SoftwareHeritage URL');
601 $desc = _(
'URL to Software Heritage servers');
602 $valueArray[$variable] = array(
"'$variable'",
603 "'https://archive.softwareheritage.org'",
"'$prompt'",
606 $variable =
"SwhBaseURL";
607 $prompt = _(
'SoftwareHeritage API base URI');
608 $desc = _(
'Base URI for API calls');
609 $valueArray[$variable] = array(
"'$variable'",
"'/api/1/content/sha256:'",
613 $variable =
"SwhContent";
614 $prompt = _(
'Content endpoint');
615 $desc = _(
'Endpoint to get content about file');
616 $valueArray[$variable] = array(
"'$variable'",
"'/license'",
"'$prompt'",
619 $variable =
"SwhSleep";
620 $prompt = _(
'Max sleep time');
621 $desc = _(
'Max time to sleep for rate-limit. Note: This concerns with scheduler heartbeat.');
622 $valueArray[$variable] = array(
"'$variable'",
"100",
"'$prompt'",
625 $variable =
"SwhToken";
626 $prompt = _(
'Auth token');
628 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
631 $variable =
"ScAPIURL";
632 $prompt = _(
'Scanoss API url');
633 $desc = _(
'Set URL to SCANOSS API (blank for default osskb.org)');
634 $valueArray[$variable] = array(
"'$variable'",
638 $variable =
"ScToken";
639 $prompt = _(
'Access token');
640 $desc = _(
'Set token to access full service (blank for basic scan)');
641 $valueArray[$variable] = array(
"'$variable'",
646 $variable =
"LicenseDBBaseURL";
647 $prompt = _(
'LicenseDB API base URI');
648 $desc = _(
'Base URI for API calls e.g. /api/v1');
649 $valueArray[$variable] = array(
"'$variable'",
"'http://localhost:8080/api/v1'",
650 "'$prompt'", strval(
CONFIG_TYPE_TEXT),
"'LicenseDB'",
"1",
"'$desc'",
"null",
653 $variable =
"LicenseDBHealth";
654 $prompt = _(
'Health check');
655 $desc = _(
'Endpoint to check health of LicenseDB service');
656 $valueArray[$variable] = array(
"'$variable'",
"'/health'",
"'$prompt'",
659 $variable =
"LicenseDBContent";
660 $prompt = _(
'Export endpoint Licenses');
661 $desc = _(
'Endpoint to Export licenses in JSON e.g. /licenses/export');
662 $valueArray[$variable] = array(
"'$variable'",
"'/licenses/export'",
"'$prompt'",
665 $variable =
"LicenseDBContentObligations";
666 $prompt = _(
'Export endpoint Obligations');
667 $desc = _(
'Endpoint to Export Obligations in JSON e.g. /obligations/export');
668 $valueArray[$variable] = array(
"'$variable'",
"'/obligations/export'",
"'$prompt'",
671 $variable =
"LicenseDBToken";
672 $prompt = _(
'Auth token For LicenseDB');
673 $desc = _(
"Token from LicenseDB. Do not set if using OIDC for LicenseDB and FOSSology communication.");
674 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
677 $variable =
"ExcludeFolders";
678 $mimeTypeToSkip = _(
"Exclude Folders from scanning");
679 $mimeTypeDesc = _(
"Add comma (,) separated folder patterns to exclude from unpacking");
680 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
681 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
684 $variable =
"KotobaDelimiters";
685 $prompt = _(
'Kotoba Agent Delimiters');
686 $desc = _(
'Comma-separated list of additional delimiter characters for kotoba agent. Space, comma, tab, newline, carriage return, and form feed are always included as delimiters. Leave empty to use only the default delimiters. Example: "#,^,%,*" to add special characters');
687 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$prompt'",
693 foreach ($valueArray as $variable => $values) {
699 $VarRec =
GetSingleRec(
"sysconfig",
"WHERE variablename='$variable'");
700 if (empty($VarRec)) {
701 $sql =
"INSERT INTO sysconfig (" . implode(
",", $columns) .
") VALUES (" .
702 implode(
",", $values) .
");";
705 foreach ($columns as $index => $column) {
706 if ($index != 0 && $index != 1) {
707 $updateString[] = $column .
"=" . $values[$index];
710 $sql =
"UPDATE sysconfig SET " . implode(
",", $updateString) .
711 " WHERE variablename='$variable';";
715 pg_free_result($result);
732 if (! strcmp($value,
'true') || ! strcmp($value,
'false')) {
750 $url_array = explode(
"/", $url, 2);
751 $name = $url_array[0];
752 if (! empty($name)) {
753 $hostname = exec(
"hostname -f");
754 if (empty($hostname)) {
755 $hostname =
"localhost";
758 $hostname1 = gethostbyaddr($name);
759 if (strcmp($hostname, $hostname1) == 0) {
763 $server_name = $_SERVER[
'SERVER_NAME'];
766 if (strcmp($name, $hostname) && strcmp($name, $server_name)) {
814 $logoLink = @$SysConf[
"LogoLink"];
815 $new_url = $logoLink . $url;
853 if (array_key_exists(
'http_proxy', $SysConf[
'FOSSOLOGY']) &&
854 $SysConf[
'FOSSOLOGY'][
'http_proxy']) {
855 $proxyStmts .=
"export http_proxy={$SysConf['FOSSOLOGY']['http_proxy']};";
857 if (array_key_exists(
'https_proxy', $SysConf[
'FOSSOLOGY']) &&
858 $SysConf[
'FOSSOLOGY'][
'https_proxy']) {
859 $proxyStmts .=
"export https_proxy={$SysConf['FOSSOLOGY']['https_proxy']};";
861 if (array_key_exists(
'ftp_proxy', $SysConf[
'FOSSOLOGY']) &&
862 $SysConf[
'FOSSOLOGY'][
'ftp_proxy']) {
863 $proxyStmts .=
"export ftp_proxy={$SysConf['FOSSOLOGY']['ftp_proxy']};";
866 $commands =
"$proxyStmts wget --spider '$url' --tries=$tries --timeout=$timeout";
867 system($commands, $return_var);
868 if (0 == $return_var) {
883 preg_match(
"@^((http)|(https)|(ftp))://([[:alnum:]]+)@i", $url) != 1 ||
884 preg_match(
"@[[:space:]]@", $url) != 0) {
898 $e =
"([0-9]|1[0-9]{2}|[1-9][0-9]|2[0-4][0-9]|25[0-5])";
899 return preg_match(
"/^$e\.$e\.$e\.$e$/", $ip);
909 $path =
"/home/" . $SysConf[
'DIRECTORIES'][
'PROJECTUSER'] .
"/pythondeps";
910 putenv(
"PYTHONPATH=$path");
911 return [
"PYTHONPATH" => $path];
924 $cores =
trim(shell_exec(
"nproc"));
927 $load = sys_getloadavg()[1];
929 $percentageOfLoad = ($load / $cores);
931 if ($percentageOfLoad < 0.30) {
932 $class =
'btn-success';
933 }
else if ($percentageOfLoad < 0.60) {
934 $class =
'btn-warning';
936 $class =
'btn-danger';
939 return '<button type="button" aria-disabled="true" disabled class="btn '.$class.
'">System Load</button>';
Contains the constants and helpers for authentication of user.
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Populate_sysconfig()
Populate the sysconfig table with core variables.
check_fossology_url($url)
Validation function check_fossology_url().
if(!function_exists('resolve_sysconfig_value')) ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=true)
Initialize the fossology system after bootstrap().
is_available($url, $timeout=2, $tries=2)
Check if the URL is available.
check_IP($ip)
Check if the ip address is valid.
const CONFIG_TYPE_TEXTAREA
check_logo_image_url($url)
Validation function check_logo_image_url().
check_logo_url($url)
Validation function check_logo_url().
get_pg_conn($sysconfdir, &$SysConf, $exitOnDbFail=true)
get_system_load_average()
Get system load average.
check_email_address($email_address)
Validation function check_email_address().
check_boolean($value)
Validation function check_boolean().
populate_from_sysconfig($conn, &$SysConf)
check_url($url)
Check if the url is valid.
const CONFIG_TYPE_PASSWORD
char * trim(char *ptext)
Trimming whitespace.
#define PERM_WRITE
Read-Write permission.
#define PERM_ADMIN
Administrator.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN