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");
308 $variable =
"OidcM2MAppId";
309 $oidcPrompt = _(
'OIDC M2M Client Id');
310 $oidcDesc = _(
'e.g. "e0ec21b9f4b21adc76f185962b52bdfc13af134a"<br>Client ID generated while registering the M2M application.');
311 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
312 strval(
CONFIG_TYPE_TEXT),
"'OauthM2M'",
"1",
"'$oidcDesc'",
"null",
"null");
314 $variable =
"OidcM2MSecret";
315 $oidcPrompt = _(
'OIDC M2M Secret');
316 $oidcDesc = _(
'e.g. "cf13476f185b9f4b2e0ec962b52211adbdfc13aa"<br>Secret generated while registering the M2M application.');
317 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
320 $variable =
"OidcM2MScope";
321 $oidcPrompt = _(
'OIDC M2M Scope');
322 $oidcDesc = _(
'Scope used for the client_credentials grant with LicenseDB.');
323 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$oidcPrompt'",
324 strval(
CONFIG_TYPE_TEXT),
"'OauthM2M'",
"3",
"'$oidcDesc'",
"null",
"null");
326 $variable =
"OidcM2MAuthorizeURL";
327 $oidcPrompt = _(
'OIDC M2M Authorize URL');
328 $oidcDesc = _(
'URL for the M2M OAuth2 authorization endpoint.');
329 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
330 strval(
CONFIG_TYPE_TEXT),
"'OauthM2M'",
"4",
"'$oidcDesc'",
"null",
"null");
332 $variable =
"OidcM2MAccessTokenURL";
333 $oidcPrompt = _(
'OIDC M2M Access Token URL');
334 $oidcDesc = _(
'URL for the M2M OAuth2 access token endpoint.');
335 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
336 strval(
CONFIG_TYPE_TEXT),
"'OauthM2M'",
"5",
"'$oidcDesc'",
"null",
"null");
338 $variable =
"OidcM2MResourceOwnerURL";
339 $oidcPrompt = _(
'OIDC M2M User Info URL(required for provider initialisation)');
340 $oidcDesc = _(
'e.g. "http://oauth.com/userinfo.oauth2"<br>URL for M2M OAuth2 user info endpoint.');
341 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
342 strval(
CONFIG_TYPE_TEXT),
"'OauthM2M'",
"6",
"'$oidcDesc'",
"null",
"null");
345 $variable =
"BannerMsg";
346 $bannerMsgPrompt = _(
'Banner message');
347 $bannerMsgDesc = _(
'This is message will be displayed on every page with a banner. HTML is ok.');
348 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$bannerMsgPrompt'",
352 $variable =
"LogoImage";
353 $logoImagePrompt = _(
'Logo Image URL');
354 $logoImageValid =
"check_logo_image_url";
355 $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.');
356 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoImagePrompt'",
357 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"1",
"'$logoImageDesc'",
"'$logoImageValid'",
"null");
359 $variable =
"LogoLink";
360 $logoLinkPrompt = _(
'Logo URL');
361 $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.');
362 $logoLinkValid =
"check_logo_url";
363 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoLinkPrompt'",
364 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"2",
"'$logoLinkDesc'",
"'$logoLinkValid'",
"null");
366 $variable =
"FOSSologyURL";
367 $urlPrompt = _(
"FOSSology URL");
368 $hostname = exec(
"hostname -f");
369 if (empty($hostname)) {
370 $hostname =
"localhost";
372 $fossologyURL = $hostname.
"/repo/";
373 $urlDesc = _(
"URL of this FOSSology server, e.g. $fossologyURL");
374 $urlValid =
"check_fossology_url";
375 $valueArray[$variable] = array(
"'$variable'",
"'$fossologyURL'",
"'$urlPrompt'",
376 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"1",
"'$urlDesc'",
"'$urlValid'",
"null");
378 $variable =
"ClearlyDefinedURL";
379 $urlPrompt = _(
"ClearlyDefined URL");
380 $cdURL =
"https://api.clearlydefined.io/";
381 $urlDesc = _(
"URL of ClearlyDefined server, e.g. $cdURL");
382 $urlValid =
"check_url";
383 $valueArray[$variable] = array(
"'$variable'",
"'$cdURL'",
"'$urlPrompt'",
384 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"2",
"'$urlDesc'",
"'$urlValid'",
"null");
386 $variable =
"NomostListNum";
387 $nomosNumPrompt = _(
"Maximum licenses to List");
388 $nomostListNum =
"2200";
389 $NomosNumDesc = _(
"For License List and License List Download, you can set the maximum number of lines to list/download. Default 2200.");
390 $valueArray[$variable] = array(
"'$variable'",
"'$nomostListNum'",
"'$nomosNumPrompt'",
391 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"1",
"'$NomosNumDesc'",
"null",
"null");
393 $variable =
"BlockSizeHex";
394 $hexPrompt = _(
"Chars per page in hex view");
395 $hexDesc = _(
"Number of characters per page in hex view");
396 $valueArray[$variable] = array(
"'$variable'",
"'8192'",
"'$hexPrompt'",
399 $variable =
"BlockSizeText";
400 $textPrompt = _(
"Chars per page in text view");
401 $textDesc = _(
"Number of characters per page in text view");
402 $valueArray[$variable] = array(
"'$variable'",
"'81920'",
"'$textPrompt'",
405 $variable =
"ShowJobsAutoRefresh";
406 $contextNamePrompt = _(
"ShowJobs Auto Refresh Time");
407 $contextValue =
"10";
408 $contextDesc = _(
"No of seconds to refresh ShowJobs");
409 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
410 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"4",
"'$contextDesc'",
"null",
"null");
413 $variable =
"ReportHeaderText";
414 $contextNamePrompt = _(
"Report Header Text");
415 $contextValue =
"FOSSology";
416 $contextDesc = _(
"Report Header Text at right side corner");
417 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
418 strval(
CONFIG_TYPE_TEXT),
"'ReportText'",
"1",
"'$contextDesc'",
"null",
"null");
420 $variable =
"CommonObligation";
421 $contextNamePrompt = _(
"Common Obligation");
423 $commonExObligations = _(
'you can add HTML line break, Also use json format for table rows');
424 $contextDesc = _(
"Common Obligation Text,".
"$commonExObligations");
425 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
428 $variable =
"AdditionalObligation";
429 $contextNamePrompt = _(
"Additional Obligation");
431 $contextDesc = _(
"Additional Obligation Text,".
"$commonExObligations");
432 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
435 $variable =
"ObligationAndRisk";
436 $contextNamePrompt = _(
"Obligation And Risk Assessment");
438 $contextDesc = _(
"Obligations and risk assessment,".
"$commonExObligations");
439 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
442 $variable =
"EnableOsselotReuse";
443 $prompt = (
"Enable OSSelot Reuse");
444 $desc = (
"When enabled, shows the OSSelot-based reuse option in the Reuser plugin");
445 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
446 strval(
CONFIG_TYPE_BOOL),
"'ReportText'",
"5",
"'$desc'",
"'check_boolean'",
"null");
448 $variable =
"OsselotCuratedUrl";
449 $osselotCuratedPrompt = _(
'OSSelot Curated API URL');
450 $osselotCuratedValid =
"check_url";
451 $osselotCuratedDesc = _(
'URL for OSSelot curated package information API.');
452 $valueArray[$variable] = array(
"'$variable'",
"'https://www.osselot.org/curated.php'",
"'$osselotCuratedPrompt'",
453 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"1",
"'$osselotCuratedDesc'",
"'$osselotCuratedValid'",
"null");
455 $variable =
"OsselotPackageAnalysisUrl";
456 $osselotPackagePrompt = _(
'OSSelot Package Analysis Base URL');
457 $osselotPackageValid =
"check_url";
458 $osselotPackageDesc = _(
'Base URL for OSSelot package analysis repository.');
459 $valueArray[$variable] = array(
"'$variable'",
"'https://raw.githubusercontent.com/Open-Source-Compliance/package-analysis/main/analysed-packages'",
"'$osselotPackagePrompt'",
460 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"2",
"'$osselotPackageDesc'",
"'$osselotPackageValid'",
"null");
462 $variable =
"OsselotPrimaryDomain";
463 $osselotPrimaryPrompt = _(
'OSSelot Primary Domain');
464 $osselotPrimaryValid =
"check_domain";
465 $osselotPrimaryDesc = _(
'Primary domain used in OSSelot package analysis URLs (e.g., raw.githubusercontent.com).');
466 $valueArray[$variable] = array(
"'$variable'",
"'raw.githubusercontent.com'",
"'$osselotPrimaryPrompt'",
467 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"3",
"'$osselotPrimaryDesc'",
"'$osselotPrimaryValid'",
"null");
469 $variable =
"OsselotFallbackDomain";
470 $osselotFallbackPrompt = _(
'OSSelot Fallback Domain');
471 $osselotFallbackValid =
"check_domain";
472 $osselotFallbackDesc = _(
'Fallback domain used when primary domain fails (e.g., osselot.org).');
473 $valueArray[$variable] = array(
"'$variable'",
"'osselot.org'",
"'$osselotFallbackPrompt'",
474 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"4",
"'$osselotFallbackDesc'",
"'$osselotFallbackValid'",
"null");
477 $variable =
"UploadFromServerWhitelist";
478 $contextNamePrompt = _(
"Whitelist for serverupload");
479 $contextValue =
"/tmp";
480 $contextDesc = _(
"List of allowed prefixes for upload, separated by \":\" (colon)");
481 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
482 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"1",
"'$contextDesc'",
"null",
"null");
484 $variable =
"UploadFromServerAllowedHosts";
485 $contextNamePrompt = _(
"List of allowed hosts for serverupload");
486 $contextValue =
"localhost";
487 $contextDesc = _(
"List of allowed hosts for upload, separated by \":\" (colon)");
488 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
489 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"2",
"'$contextDesc'",
"null",
"null");
492 $variable =
"SMTPHostName";
493 $smtpHostPrompt = _(
'SMTP Host Name');
494 $smtpHostDesc = _(
'e.g.: "smtp.domain.com"<br>The domain to be used to send emails.');
495 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpHostPrompt'",
496 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"1",
"'$smtpHostDesc'",
"null",
"null");
498 $variable =
"SMTPPort";
499 $smtpPortPrompt = _(
'SMTP Port');
500 $smtpPortDesc = _(
'e.g.: "25"<br>SMTP port to be used.');
501 $valueArray[$variable] = array(
"'$variable'",
"25",
"'$smtpPortPrompt'",
502 strval(
CONFIG_TYPE_INT),
"'SMTP'",
"2",
"'$smtpPortDesc'",
"null",
"null");
504 $variable =
"SMTPAuth";
505 $smtpAuthPrompt = _(
'SMTP Auth Type');
506 $smtpAuthDesc = _(
'Algorithm to use for login.<br>Login => Encrypted<br>None => No authentication<br>Plain => Send as plain text');
507 $valueArray[$variable] = array(
"'$variable'",
"'L'",
"'$smtpAuthPrompt'",
508 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"3",
"'$smtpAuthDesc'",
"null",
"'Login{L}|None{N}|Plain{P}'");
510 $variable =
"SMTPFrom";
511 $smtpFrom = _(
'SMTP Email');
512 $smtpFromDesc = _(
'e.g.: "user@domain.com"<br>Sender email.');
513 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpFrom'",
514 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"4",
"'$smtpFromDesc'",
"'check_email_address'",
"null");
516 $variable =
"SMTPAuthUser";
517 $smtpAuthUserPrompt = _(
'SMTP User');
518 $smtpAuthUserDesc = _(
'e.g.: "user"<br>Login to be used for login on SMTP Server.');
519 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthUserPrompt'",
520 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"5",
"'$smtpAuthUserDesc'",
"null",
"null");
522 $variable =
"SMTPAuthPasswd";
523 $smtpAuthPasswdPrompt = _(
'SMTP Login Password');
524 $smtpAuthPasswdDesc = _(
'Password used for SMTP login.');
525 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthPasswdPrompt'",
528 $variable =
"SMTPSslVerify";
529 $smtpSslPrompt = _(
'SMTP SSL Verify');
530 $smtpSslDesc = _(
'The SSL verification for connection is required?');
531 $valueArray[$variable] = array(
"'$variable'",
"'S'",
"'$smtpSslPrompt'",
532 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"7",
"'$smtpSslDesc'",
"null",
"'Ignore{I}|Strict{S}|Warn{W}'");
534 $variable =
"SMTPStartTls";
535 $smtpTlsPrompt = _(
'Start TLS');
536 $smtpTlsDesc = _(
'Use TLS connection for SMTP?');
537 $valueArray[$variable] = array(
"'$variable'",
"'1'",
"'$smtpTlsPrompt'",
538 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"8",
"'$smtpTlsDesc'",
"null",
"'Yes{1}|No{2}'");
540 $variable =
"UploadVisibility";
541 $prompt = _(
'Default Upload Visibility');
542 $desc = _(
'Default Visibility for uploads by the user');
543 $valueArray[$variable] = array(
"'$variable'",
"'protected'",
"'$prompt'",
544 strval(
CONFIG_TYPE_DROP),
"'UploadFlag'",
"1",
"'$desc'",
"null",
"'Visible only for active group{private}|Visible for all groups{protected}|Make Public{public}'");
547 $variable =
"PasswdPolicy";
548 $prompt = _(
'Enable password policy');
549 $desc = _(
'Enable password policy check');
550 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
552 "'check_boolean'",
"null");
554 $variable =
"PasswdPolicyMinChar";
555 $prompt = _(
'Minimum characters');
556 $desc = _(
'Blank for no limit');
557 $valueArray[$variable] = array(
"'$variable'",
"8",
"'$prompt'",
560 $variable =
"PasswdPolicyMaxChar";
561 $prompt = _(
'Maximum characters');
562 $desc = _(
'Blank for no limit');
563 $valueArray[$variable] = array(
"'$variable'",
"16",
"'$prompt'",
566 $variable =
"PasswdPolicyLower";
567 $prompt = _(
'Lowercase');
568 $desc = _(
'Minimum one lowercase character.');
569 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
571 "'check_boolean'",
"null");
573 $variable =
"PasswdPolicyUpper";
574 $prompt = _(
'Uppercase');
575 $desc = _(
'Minimum one uppercase character.');
576 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
578 "'check_boolean'",
"null");
580 $variable =
"PasswdPolicyDigit";
581 $prompt = _(
'Digit');
582 $desc = _(
'Minimum one digit.');
583 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
585 "'check_boolean'",
"null");
587 $variable =
"PasswdPolicySpecial";
588 $prompt = _(
'Allowed special characters');
589 $desc = _(
'Empty for do not care');
590 $valueArray[$variable] = array(
"'$variable'",
"'@$!%*?&'",
"'$prompt'",
593 $variable =
"PATMaxExipre";
594 $patTokenValidityPrompt = _(
'Max token validity');
595 $patTokenValidityDesc = _(
'Maximum validity of tokens (in days)');
596 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenValidityPrompt'",
597 strval(
CONFIG_TYPE_INT),
"'PAT'",
"1",
"'$patTokenValidityDesc'",
"null",
"null");
599 $variable =
"PATMaxPostExpiryRetention";
600 $patTokenRetentionPrompt = _(
'Max expired token retention period');
601 $patTokenRetentionDesc = _(
'Maximum retention period of expired tokens (in days) for Maintagent');
602 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenRetentionPrompt'",
603 strval(
CONFIG_TYPE_INT),
"'PAT'",
"2",
"'$patTokenRetentionDesc'",
"null",
"null");
605 $variable =
"SkipFiles";
606 $mimeTypeToSkip = _(
"Skip MimeTypes from scanning");
607 $mimeTypeDesc = _(
"add comma (,) separated mimetype to exclude files from scanning");
608 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
609 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
613 $variable =
"SourceCodeDownloadRights";
614 $SourceDownloadRightsPrompt = _(
'Access rights required to download source code');
615 $SourceDownloadRightsDesc = _(
'Choose which access level will be required for user to be able to download source code.');
616 $valueArray[$variable] = array(
"'$variable'",
"'$perm_write'",
"'$SourceDownloadRightsPrompt'",
617 strval(
CONFIG_TYPE_DROP),
"'DOWNLOAD'",
"1",
"'$SourceDownloadRightsDesc'",
"null",
"'Administrator{{$perm_admin}}|Read_Write{{$perm_write}}'");
619 $variable =
"UserDescReadOnly";
620 $prompt = _(
'Make account details read-only');
621 $desc = _(
'Make account details (username, email, description) read-only');
622 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
624 "'check_boolean'",
"null");
626 $variable =
"LicenseTypes";
627 $licenseTypeTitle = _(
"License Types");
628 $licenseTypeDesc = _(
"add comma (,) separated different license types");
629 $valueArray[$variable] = array(
"'$variable'",
630 "'Permissive, Strong Copyleft, Weak Copyleft, Network Copyleft, Public Domain, Non-commercial, Source Available, Font, Data, Exception, Unknown'",
631 "'$licenseTypeTitle'",
632 strval(
CONFIG_TYPE_TEXT),
"'LICENSE'",
"1",
"'$licenseTypeDesc'",
"null",
"null");
635 $variable =
"SwhURL";
636 $prompt = _(
'SoftwareHeritage URL');
637 $desc = _(
'URL to Software Heritage servers');
638 $valueArray[$variable] = array(
"'$variable'",
639 "'https://archive.softwareheritage.org'",
"'$prompt'",
642 $variable =
"SwhBaseURL";
643 $prompt = _(
'SoftwareHeritage API base URI');
644 $desc = _(
'Base URI for API calls');
645 $valueArray[$variable] = array(
"'$variable'",
"'/api/1/content/sha256:'",
649 $variable =
"SwhContent";
650 $prompt = _(
'Content endpoint');
651 $desc = _(
'Endpoint to get content about file');
652 $valueArray[$variable] = array(
"'$variable'",
"'/license'",
"'$prompt'",
655 $variable =
"SwhSleep";
656 $prompt = _(
'Max sleep time');
657 $desc = _(
'Max time to sleep for rate-limit. Note: This concerns with scheduler heartbeat.');
658 $valueArray[$variable] = array(
"'$variable'",
"100",
"'$prompt'",
661 $variable =
"SwhToken";
662 $prompt = _(
'Auth token');
664 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
667 $variable =
"ScAPIURL";
668 $prompt = _(
'Scanoss API url');
669 $desc = _(
'Set URL to SCANOSS API (blank for default osskb.org)');
670 $valueArray[$variable] = array(
"'$variable'",
674 $variable =
"ScToken";
675 $prompt = _(
'Access token');
676 $desc = _(
'Set token to access full service (blank for basic scan)');
677 $valueArray[$variable] = array(
"'$variable'",
682 $variable =
"LicenseDBBaseURL";
683 $prompt = _(
'LicenseDB API base URI');
684 $desc = _(
'Base URI for API calls e.g. /api/v1');
685 $valueArray[$variable] = array(
"'$variable'",
"'http://localhost:8080/api/v1'",
686 "'$prompt'", strval(
CONFIG_TYPE_TEXT),
"'LicenseDB'",
"1",
"'$desc'",
"null",
689 $variable =
"LicenseDBHealth";
690 $prompt = _(
'Health check');
691 $desc = _(
'Endpoint to check health of LicenseDB service');
692 $valueArray[$variable] = array(
"'$variable'",
"'/health'",
"'$prompt'",
695 $variable =
"LicenseDBContent";
696 $prompt = _(
'Export endpoint Licenses');
697 $desc = _(
'Endpoint to Export licenses in JSON e.g. /licenses/export');
698 $valueArray[$variable] = array(
"'$variable'",
"'/licenses/export'",
"'$prompt'",
701 $variable =
"LicenseDBContentObligations";
702 $prompt = _(
'Export endpoint Obligations');
703 $desc = _(
'Endpoint to Export Obligations in JSON e.g. /obligations/export');
704 $valueArray[$variable] = array(
"'$variable'",
"'/obligations/export'",
"'$prompt'",
707 $variable =
"LicenseDBToken";
708 $prompt = _(
'Auth token For LicenseDB');
709 $desc = _(
"Token from LicenseDB. Do not set if using OIDC for LicenseDB and FOSSology communication.");
710 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
713 $variable =
"ExcludeFolders";
714 $mimeTypeToSkip = _(
"Exclude Folders from scanning");
715 $mimeTypeDesc = _(
"Add comma (,) separated folder patterns to exclude from unpacking");
716 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
717 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
720 $variable =
"KotobaDelimiters";
721 $prompt = _(
'Kotoba Agent Delimiters');
722 $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');
723 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$prompt'",
729 foreach ($valueArray as $variable => $values) {
735 $VarRec =
GetSingleRec(
"sysconfig",
"WHERE variablename='$variable'");
736 if (empty($VarRec)) {
737 $sql =
"INSERT INTO sysconfig (" . implode(
",", $columns) .
") VALUES (" .
738 implode(
",", $values) .
");";
741 foreach ($columns as $index => $column) {
742 if ($index != 0 && $index != 1) {
743 $updateString[] = $column .
"=" . $values[$index];
746 $sql =
"UPDATE sysconfig SET " . implode(
",", $updateString) .
747 " WHERE variablename='$variable';";
751 pg_free_result($result);
768 if (! strcmp($value,
'true') || ! strcmp($value,
'false')) {
786 $url_array = explode(
"/", $url, 2);
787 $name = $url_array[0];
788 if (! empty($name)) {
789 $hostname = exec(
"hostname -f");
790 if (empty($hostname)) {
791 $hostname =
"localhost";
794 $hostname1 = gethostbyaddr($name);
795 if (strcmp($hostname, $hostname1) == 0) {
799 $server_name = $_SERVER[
'SERVER_NAME'];
802 if (strcmp($name, $hostname) && strcmp($name, $server_name)) {
850 $logoLink = @$SysConf[
"LogoLink"];
851 $new_url = $logoLink . $url;
889 if (array_key_exists(
'http_proxy', $SysConf[
'FOSSOLOGY']) &&
890 $SysConf[
'FOSSOLOGY'][
'http_proxy']) {
891 $proxyStmts .=
"export http_proxy=" . escapeshellarg($SysConf[
'FOSSOLOGY'][
'http_proxy']) .
";";
893 if (array_key_exists(
'https_proxy', $SysConf[
'FOSSOLOGY']) &&
894 $SysConf[
'FOSSOLOGY'][
'https_proxy']) {
895 $proxyStmts .=
"export https_proxy=" . escapeshellarg($SysConf[
'FOSSOLOGY'][
'https_proxy']) .
";";
897 if (array_key_exists(
'ftp_proxy', $SysConf[
'FOSSOLOGY']) &&
898 $SysConf[
'FOSSOLOGY'][
'ftp_proxy']) {
899 $proxyStmts .=
"export ftp_proxy=" . escapeshellarg($SysConf[
'FOSSOLOGY'][
'ftp_proxy']) .
";";
902 $commands = $proxyStmts .
"wget --spider " . escapeshellarg($url) .
903 " --tries=" . (int) $tries .
" --timeout=" . (
int) $timeout;
904 system($commands, $return_var);
905 if (0 == $return_var) {
920 preg_match(
"@^((http)|(https)|(ftp))://([[:alnum:]]+)@i", $url) != 1 ||
921 preg_match(
"@[[:space:]]@", $url) != 0) {
935 $e =
"([0-9]|1[0-9]{2}|[1-9][0-9]|2[0-4][0-9]|25[0-5])";
936 return preg_match(
"/^$e\.$e\.$e\.$e$/", $ip);
946 $path =
"/home/" . $SysConf[
'DIRECTORIES'][
'PROJECTUSER'] .
"/pythondeps";
947 putenv(
"PYTHONPATH=$path");
948 return [
"PYTHONPATH" => $path];
961 $cores =
trim(shell_exec(
"nproc"));
964 $load = sys_getloadavg()[1];
966 $percentageOfLoad = ($load / $cores);
968 if ($percentageOfLoad < 0.30) {
969 $class =
'btn-success';
970 }
else if ($percentageOfLoad < 0.60) {
971 $class =
'btn-warning';
973 $class =
'btn-danger';
976 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