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);
65 function ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=
true)
85 function get_pg_conn($sysconfdir, &$SysConf, $exitOnDbFail=
true)
88 $versionFile =
"{$sysconfdir}/VERSION";
89 $versionConf = parse_ini_file($versionFile,
true);
94 foreach ($versionConf as $groupName => $groupArray) {
95 foreach ($groupArray as $var => $assign) {
96 $toeval =
"\$$var = \"$assign\";";
98 $SysConf[$groupName][$var] = ${$var};
99 $GLOBALS[$var] = ${$var};
105 $dbPath =
"{$sysconfdir}/Db.conf";
106 $dbConf = parse_ini_file($dbPath,
true);
111 foreach ($dbConf as $var => $val) {
112 $SysConf[
'DBCONF'][$var] = $val;
120 $pg_conn =
DBconnect($sysconfdir,
"", $exitOnDbFail);
122 if (! $exitOnDbFail && ($pg_conn ===
null || $pg_conn ===
false)) {
127 $postgresDriver = new \Fossology\Lib\Db\Driver\Postgres($pg_conn);
128 $container->get(
'db.manager')->setDriver($postgresDriver);
142 $sql =
"SELECT variablename, conf_value FROM sysconfig;";
143 $result = pg_query($conn, $sql);
146 while ($row = pg_fetch_assoc($result)) {
147 $SysConf[
'SYSCONFIG'][$row[
'variablename']] = $row[
'conf_value'];
149 pg_free_result($result);
159 $columns = array(
"variablename",
"conf_value",
"ui_label",
"vartype",
"group_name",
160 "group_order",
"description",
"validation_function",
"option_value");
161 $valueArray = array();
164 $variable =
"CorsOrigins";
165 $prompt = _(
'Allowed origins for REST API');
166 $desc = _(
'[scheme]://[hostname]:[port], "*" for anywhere');
167 $valueArray[$variable] = array(
"'$variable'",
"'*'",
"'$prompt'",
171 $variable =
"SupportEmailLabel";
172 $supportEmailLabelPrompt = _(
'Support Email Label');
173 $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.');
174 $valueArray[$variable] = array(
"'$variable'",
"'Support'",
"'$supportEmailLabelPrompt'",
175 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"1",
"'$supportEmailLabelDesc'",
"null",
"null");
177 $variable =
"SupportEmailAddr";
178 $supportEmailAddrPrompt = _(
'Support Email Address');
179 $supportEmailAddrValid =
"check_email_address";
180 $supportEmailAddrDesc = _(
'e.g. "support@mycompany.com"<br>Individual or group email address to those providing FOSSology support.');
181 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$supportEmailAddrPrompt'",
182 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"2",
"'$supportEmailAddrDesc'",
"'$supportEmailAddrValid'",
"null");
184 $variable =
"SupportEmailSubject";
185 $supportEmailSubjectPrompt = _(
'Support Email Subject line');
186 $supportEmailSubjectDesc = _(
'e.g. "fossology support"<br>Subject line to use on support email.');
187 $valueArray[$variable] = array(
"'$variable'",
"'FOSSology Support'",
"'$supportEmailSubjectPrompt'",
188 strval(
CONFIG_TYPE_TEXT),
"'Support'",
"3",
"'$supportEmailSubjectDesc'",
"null",
"null");
191 $variable =
"OidcAppName";
192 $oidcPrompt = _(
'OIDC App Name');
193 $oidcDesc = _(
'e.g. "my oAuth"<br>App name to display on login page.');
194 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
195 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"1",
"'$oidcDesc'",
"null",
"null");
197 $variable =
"OidcClientIdClaim";
198 $oidcPrompt = _(
'OIDC Client Id Claim');
199 $oidcDesc = _(
'e.g. "azp"<br>Client ID claim in the decoded payload.');
200 $valueArray[$variable] = array(
"'$variable'",
"'client-id'",
"'$oidcPrompt'",
201 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"2",
"'$oidcDesc'",
"null",
"null");
203 $variable =
"OidcResourceOwnerId";
204 $oidcPrompt = _(
'Resource owner id field');
205 $oidcDesc = _(
'e.g. "email", "upn"<br>Field in token which provides user id. The field <b>should not be empty</b>.');
206 $valueArray[$variable] = array(
"'$variable'",
"'email'",
"'$oidcPrompt'",
207 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"3",
"'$oidcDesc'",
"null",
"null");
209 $variable =
"OidcTokenType";
210 $oidcPrompt = _(
'Token to use from provider');
211 $oidcDesc = _(
'OpenID Connect providers 2 types of tokens, access and id. Which to use for authentication?<br>AzureAD prefers ID token.');
212 $valueArray[$variable] = array(
"'$variable'",
"'A'",
"'$oidcPrompt'",
213 strval(
CONFIG_TYPE_DROP),
"'OauthSupport'",
"4",
"'$oidcDesc'",
"null",
"'Access Token{A}|ID Token{I}'");
215 $variable =
"OidcAppId";
216 $oidcPrompt = _(
'OIDC Client Id');
217 $oidcDesc = _(
'e.g. "e0ec21b9f4b21adc76f185962b52bdfc13af134a"<br>Client ID generated while registering your application.');
218 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
219 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"5",
"'$oidcDesc'",
"null",
"null");
221 $variable =
"OidcSecret";
222 $oidcPrompt = _(
'OIDC Secret');
223 $oidcDesc = _(
'e.g. "cf13476f185b9f4b2e0ec962b52211adbdfc13aa"<br>Secret generated while registering your application.');
224 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
227 $variable =
"OidcRedirectURL";
228 $oidcPrompt = _(
'Redirect URL');
229 $oidcDesc = _(
'e.g. "http://fossology.application.url.com/repo"<br>URL of your fossology application.');
230 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
231 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"7",
"'$oidcDesc'",
"null",
"null");
233 $variable =
"OidcDiscoveryURL";
234 $oidcPrompt = _(
'OIDC Discovery URL');
235 $oidcDesc = _(
'e.g. "http://oauth.com/.well-known/openid-configuration"<br>URL for OIDC Discovery document JSON to fill following fields upon save.');
236 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
237 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"8",
"'$oidcDesc'",
"null",
"null");
239 $variable =
"OidcIssuer";
240 $oidcPrompt = _(
'OIDC Token Issuer');
241 $oidcDesc = _(
'e.g. "http://oauth.com"<br>Issuer for OIDC tokens.');
242 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
243 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"9",
"'$oidcDesc'",
"null",
"null");
245 $variable =
"OidcAuthorizeURL";
246 $oidcPrompt = _(
'OIDC Authorize URL');
247 $oidcDesc = _(
'e.g. "http://oauth.com/authorization.oauth2"<br>URL for OAuth2 authorization endpoint.');
248 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
249 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"10",
"'$oidcDesc'",
"null",
"null");
251 $variable =
"OidcAccessTokenURL";
252 $oidcPrompt = _(
'OIDC Access Token URL');
253 $oidcDesc = _(
'e.g. "http://oauth.com/token.oauth2"<br>URL for OAuth2 access token endpoint.');
254 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
255 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"11",
"'$oidcDesc'",
"null",
"null");
257 $variable =
"OidcResourceURL";
258 $oidcPrompt = _(
'OIDC User Info URL');
259 $oidcDesc = _(
'e.g. "http://oauth.com/userinfo.oauth2"<br>URL for OAuth2 user info endpoint.');
260 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
261 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"12",
"'$oidcDesc'",
"null",
"null");
263 $variable =
"OidcJwksURL";
264 $oidcPrompt = _(
'OIDC JWKS URL');
265 $oidcDesc = _(
'e.g. "http://oauth.com/jwks.oauth2"<br>URL for OIDC JWKS keys.');
266 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
267 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"13",
"'$oidcDesc'",
"null",
"null");
269 $variable =
"OidcJwkAlgInject";
270 $oidcPrompt = _(
'OIDC JWKS Algorithm inject');
271 $oidcDesc = _(
'Algorithm value to inject for JWKS. Leave empty to not modifiy.' .
272 '<br><a href="https://datatracker.ietf.org/doc/html/rfc7517#section-4.4">Check info</a>.');
273 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
274 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"14",
"'$oidcDesc'",
"null",
"null");
276 $variable =
"OidcLogoutURL";
277 $oidcPrompt = _(
'Logout URL');
278 $oidcDesc = _(
'e.g. "http://oauth.com/logout.oauth2"<br>URL to redirect user to for logout.');
279 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$oidcPrompt'",
280 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"15",
"'$oidcDesc'",
"null",
"null");
282 $variable =
"OidcScope";
283 $prompt = _(
'OIDC Scope');
284 $desc = _(
'Scope of OIDC for client_credential grant. Used with LicenseDB.');
285 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
286 strval(
CONFIG_TYPE_TEXT),
"'OauthSupport'",
"16",
"'$oidcDesc'",
"null",
"null");
289 $variable =
"BannerMsg";
290 $bannerMsgPrompt = _(
'Banner message');
291 $bannerMsgDesc = _(
'This is message will be displayed on every page with a banner. HTML is ok.');
292 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$bannerMsgPrompt'",
296 $variable =
"LogoImage";
297 $logoImagePrompt = _(
'Logo Image URL');
298 $logoImageValid =
"check_logo_image_url";
299 $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.');
300 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoImagePrompt'",
301 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"1",
"'$logoImageDesc'",
"'$logoImageValid'",
"null");
303 $variable =
"LogoLink";
304 $logoLinkPrompt = _(
'Logo URL');
305 $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.');
306 $logoLinkValid =
"check_logo_url";
307 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$logoLinkPrompt'",
308 strval(
CONFIG_TYPE_TEXT),
"'Logo'",
"2",
"'$logoLinkDesc'",
"'$logoLinkValid'",
"null");
310 $variable =
"FOSSologyURL";
311 $urlPrompt = _(
"FOSSology URL");
312 $hostname = exec(
"hostname -f");
313 if (empty($hostname)) {
314 $hostname =
"localhost";
316 $fossologyURL = $hostname.
"/repo/";
317 $urlDesc = _(
"URL of this FOSSology server, e.g. $fossologyURL");
318 $urlValid =
"check_fossology_url";
319 $valueArray[$variable] = array(
"'$variable'",
"'$fossologyURL'",
"'$urlPrompt'",
320 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"1",
"'$urlDesc'",
"'$urlValid'",
"null");
322 $variable =
"ClearlyDefinedURL";
323 $urlPrompt = _(
"ClearlyDefined URL");
324 $cdURL =
"https://api.clearlydefined.io/";
325 $urlDesc = _(
"URL of ClearlyDefined server, e.g. $cdURL");
326 $urlValid =
"check_url";
327 $valueArray[$variable] = array(
"'$variable'",
"'$cdURL'",
"'$urlPrompt'",
328 strval(
CONFIG_TYPE_TEXT),
"'URL'",
"2",
"'$urlDesc'",
"'$urlValid'",
"null");
330 $variable =
"NomostListNum";
331 $nomosNumPrompt = _(
"Maximum licenses to List");
332 $nomostListNum =
"2200";
333 $NomosNumDesc = _(
"For License List and License List Download, you can set the maximum number of lines to list/download. Default 2200.");
334 $valueArray[$variable] = array(
"'$variable'",
"'$nomostListNum'",
"'$nomosNumPrompt'",
335 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"1",
"'$NomosNumDesc'",
"null",
"null");
337 $variable =
"BlockSizeHex";
338 $hexPrompt = _(
"Chars per page in hex view");
339 $hexDesc = _(
"Number of characters per page in hex view");
340 $valueArray[$variable] = array(
"'$variable'",
"'8192'",
"'$hexPrompt'",
343 $variable =
"BlockSizeText";
344 $textPrompt = _(
"Chars per page in text view");
345 $textDesc = _(
"Number of characters per page in text view");
346 $valueArray[$variable] = array(
"'$variable'",
"'81920'",
"'$textPrompt'",
349 $variable =
"ShowJobsAutoRefresh";
350 $contextNamePrompt = _(
"ShowJobs Auto Refresh Time");
351 $contextValue =
"10";
352 $contextDesc = _(
"No of seconds to refresh ShowJobs");
353 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
354 strval(
CONFIG_TYPE_TEXT),
"'Number'",
"4",
"'$contextDesc'",
"null",
"null");
357 $variable =
"ReportHeaderText";
358 $contextNamePrompt = _(
"Report Header Text");
359 $contextValue =
"FOSSology";
360 $contextDesc = _(
"Report Header Text at right side corner");
361 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
362 strval(
CONFIG_TYPE_TEXT),
"'ReportText'",
"1",
"'$contextDesc'",
"null",
"null");
364 $variable =
"CommonObligation";
365 $contextNamePrompt = _(
"Common Obligation");
367 $commonExObligations = _(
'you can add HTML line break, Also use json format for table rows');
368 $contextDesc = _(
"Common Obligation Text,".
"$commonExObligations");
369 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
372 $variable =
"AdditionalObligation";
373 $contextNamePrompt = _(
"Additional Obligation");
375 $contextDesc = _(
"Additional Obligation Text,".
"$commonExObligations");
376 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
379 $variable =
"ObligationAndRisk";
380 $contextNamePrompt = _(
"Obligation And Risk Assessment");
382 $contextDesc = _(
"Obligations and risk assessment,".
"$commonExObligations");
383 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
386 $variable =
"EnableOsselotReuse";
387 $prompt = (
"Enable OSSelot Reuse");
388 $desc = (
"When enabled, shows the OSSelot-based reuse option in the Reuser plugin");
389 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
390 strval(
CONFIG_TYPE_BOOL),
"'ReportText'",
"5",
"'$desc'",
"'check_boolean'",
"null");
392 $variable =
"OsselotCuratedUrl";
393 $osselotCuratedPrompt = _(
'OSSelot Curated API URL');
394 $osselotCuratedValid =
"check_url";
395 $osselotCuratedDesc = _(
'URL for OSSelot curated package information API.');
396 $valueArray[$variable] = array(
"'$variable'",
"'https://www.osselot.org/curated.php'",
"'$osselotCuratedPrompt'",
397 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"1",
"'$osselotCuratedDesc'",
"'$osselotCuratedValid'",
"null");
399 $variable =
"OsselotPackageAnalysisUrl";
400 $osselotPackagePrompt = _(
'OSSelot Package Analysis Base URL');
401 $osselotPackageValid =
"check_url";
402 $osselotPackageDesc = _(
'Base URL for OSSelot package analysis repository.');
403 $valueArray[$variable] = array(
"'$variable'",
"'https://raw.githubusercontent.com/Open-Source-Compliance/package-analysis/main/analysed-packages'",
"'$osselotPackagePrompt'",
404 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"2",
"'$osselotPackageDesc'",
"'$osselotPackageValid'",
"null");
406 $variable =
"OsselotPrimaryDomain";
407 $osselotPrimaryPrompt = _(
'OSSelot Primary Domain');
408 $osselotPrimaryValid =
"check_domain";
409 $osselotPrimaryDesc = _(
'Primary domain used in OSSelot package analysis URLs (e.g., raw.githubusercontent.com).');
410 $valueArray[$variable] = array(
"'$variable'",
"'raw.githubusercontent.com'",
"'$osselotPrimaryPrompt'",
411 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"3",
"'$osselotPrimaryDesc'",
"'$osselotPrimaryValid'",
"null");
413 $variable =
"OsselotFallbackDomain";
414 $osselotFallbackPrompt = _(
'OSSelot Fallback Domain');
415 $osselotFallbackValid =
"check_domain";
416 $osselotFallbackDesc = _(
'Fallback domain used when primary domain fails (e.g., osselot.org).');
417 $valueArray[$variable] = array(
"'$variable'",
"'osselot.org'",
"'$osselotFallbackPrompt'",
418 strval(
CONFIG_TYPE_TEXT),
"'OSSelot'",
"4",
"'$osselotFallbackDesc'",
"'$osselotFallbackValid'",
"null");
421 $variable =
"UploadFromServerWhitelist";
422 $contextNamePrompt = _(
"Whitelist for serverupload");
423 $contextValue =
"/tmp";
424 $contextDesc = _(
"List of allowed prefixes for upload, separated by \":\" (colon)");
425 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
426 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"1",
"'$contextDesc'",
"null",
"null");
428 $variable =
"UploadFromServerAllowedHosts";
429 $contextNamePrompt = _(
"List of allowed hosts for serverupload");
430 $contextValue =
"localhost";
431 $contextDesc = _(
"List of allowed hosts for upload, separated by \":\" (colon)");
432 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$contextNamePrompt'",
433 strval(
CONFIG_TYPE_TEXT),
"'UploadFromServer'",
"2",
"'$contextDesc'",
"null",
"null");
436 $variable =
"SMTPHostName";
437 $smtpHostPrompt = _(
'SMTP Host Name');
438 $smtpHostDesc = _(
'e.g.: "smtp.domain.com"<br>The domain to be used to send emails.');
439 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpHostPrompt'",
440 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"1",
"'$smtpHostDesc'",
"null",
"null");
442 $variable =
"SMTPPort";
443 $smtpPortPrompt = _(
'SMTP Port');
444 $smtpPortDesc = _(
'e.g.: "25"<br>SMTP port to be used.');
445 $valueArray[$variable] = array(
"'$variable'",
"25",
"'$smtpPortPrompt'",
446 strval(
CONFIG_TYPE_INT),
"'SMTP'",
"2",
"'$smtpPortDesc'",
"null",
"null");
448 $variable =
"SMTPAuth";
449 $smtpAuthPrompt = _(
'SMTP Auth Type');
450 $smtpAuthDesc = _(
'Algorithm to use for login.<br>Login => Encrypted<br>None => No authentication<br>Plain => Send as plain text');
451 $valueArray[$variable] = array(
"'$variable'",
"'L'",
"'$smtpAuthPrompt'",
452 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"3",
"'$smtpAuthDesc'",
"null",
"'Login{L}|None{N}|Plain{P}'");
454 $variable =
"SMTPFrom";
455 $smtpFrom = _(
'SMTP Email');
456 $smtpFromDesc = _(
'e.g.: "user@domain.com"<br>Sender email.');
457 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpFrom'",
458 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"4",
"'$smtpFromDesc'",
"'check_email_address'",
"null");
460 $variable =
"SMTPAuthUser";
461 $smtpAuthUserPrompt = _(
'SMTP User');
462 $smtpAuthUserDesc = _(
'e.g.: "user"<br>Login to be used for login on SMTP Server.');
463 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthUserPrompt'",
464 strval(
CONFIG_TYPE_TEXT),
"'SMTP'",
"5",
"'$smtpAuthUserDesc'",
"null",
"null");
466 $variable =
"SMTPAuthPasswd";
467 $smtpAuthPasswdPrompt = _(
'SMTP Login Password');
468 $smtpAuthPasswdDesc = _(
'Password used for SMTP login.');
469 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$smtpAuthPasswdPrompt'",
472 $variable =
"SMTPSslVerify";
473 $smtpSslPrompt = _(
'SMTP SSL Verify');
474 $smtpSslDesc = _(
'The SSL verification for connection is required?');
475 $valueArray[$variable] = array(
"'$variable'",
"'S'",
"'$smtpSslPrompt'",
476 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"7",
"'$smtpSslDesc'",
"null",
"'Ignore{I}|Strict{S}|Warn{W}'");
478 $variable =
"SMTPStartTls";
479 $smtpTlsPrompt = _(
'Start TLS');
480 $smtpTlsDesc = _(
'Use TLS connection for SMTP?');
481 $valueArray[$variable] = array(
"'$variable'",
"'1'",
"'$smtpTlsPrompt'",
482 strval(
CONFIG_TYPE_DROP),
"'SMTP'",
"8",
"'$smtpTlsDesc'",
"null",
"'Yes{1}|No{2}'");
484 $variable =
"UploadVisibility";
485 $prompt = _(
'Default Upload Visibility');
486 $desc = _(
'Default Visibility for uploads by the user');
487 $valueArray[$variable] = array(
"'$variable'",
"'protected'",
"'$prompt'",
488 strval(
CONFIG_TYPE_DROP),
"'UploadFlag'",
"1",
"'$desc'",
"null",
"'Visible only for active group{private}|Visible for all groups{protected}|Make Public{public}'");
491 $variable =
"PasswdPolicy";
492 $prompt = _(
'Enable password policy');
493 $desc = _(
'Enable password policy check');
494 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
496 "'check_boolean'",
"null");
498 $variable =
"PasswdPolicyMinChar";
499 $prompt = _(
'Minimum characters');
500 $desc = _(
'Blank for no limit');
501 $valueArray[$variable] = array(
"'$variable'",
"8",
"'$prompt'",
504 $variable =
"PasswdPolicyMaxChar";
505 $prompt = _(
'Maximum characters');
506 $desc = _(
'Blank for no limit');
507 $valueArray[$variable] = array(
"'$variable'",
"16",
"'$prompt'",
510 $variable =
"PasswdPolicyLower";
511 $prompt = _(
'Lowercase');
512 $desc = _(
'Minimum one lowercase character.');
513 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
515 "'check_boolean'",
"null");
517 $variable =
"PasswdPolicyUpper";
518 $prompt = _(
'Uppercase');
519 $desc = _(
'Minimum one uppercase character.');
520 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
522 "'check_boolean'",
"null");
524 $variable =
"PasswdPolicyDigit";
525 $prompt = _(
'Digit');
526 $desc = _(
'Minimum one digit.');
527 $valueArray[$variable] = array(
"'$variable'",
"true",
"'$prompt'",
529 "'check_boolean'",
"null");
531 $variable =
"PasswdPolicySpecial";
532 $prompt = _(
'Allowed special characters');
533 $desc = _(
'Empty for do not care');
534 $valueArray[$variable] = array(
"'$variable'",
"'@$!%*?&'",
"'$prompt'",
537 $variable =
"PATMaxExipre";
538 $patTokenValidityPrompt = _(
'Max token validity');
539 $patTokenValidityDesc = _(
'Maximum validity of tokens (in days)');
540 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenValidityPrompt'",
541 strval(
CONFIG_TYPE_INT),
"'PAT'",
"1",
"'$patTokenValidityDesc'",
"null",
"null");
543 $variable =
"PATMaxPostExpiryRetention";
544 $patTokenRetentionPrompt = _(
'Max expired token retention period');
545 $patTokenRetentionDesc = _(
'Maximum retention period of expired tokens (in days) for Maintagent');
546 $valueArray[$variable] = array(
"'$variable'",
"30",
"'$patTokenRetentionPrompt'",
547 strval(
CONFIG_TYPE_INT),
"'PAT'",
"2",
"'$patTokenRetentionDesc'",
"null",
"null");
549 $variable =
"SkipFiles";
550 $mimeTypeToSkip = _(
"Skip MimeTypes from scanning");
551 $mimeTypeDesc = _(
"add comma (,) separated mimetype to exclude files from scanning");
552 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
553 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
557 $variable =
"SourceCodeDownloadRights";
558 $SourceDownloadRightsPrompt = _(
'Access rights required to download source code');
559 $SourceDownloadRightsDesc = _(
'Choose which access level will be required for user to be able to download source code.');
560 $valueArray[$variable] = array(
"'$variable'",
"'$perm_write'",
"'$SourceDownloadRightsPrompt'",
561 strval(
CONFIG_TYPE_DROP),
"'DOWNLOAD'",
"1",
"'$SourceDownloadRightsDesc'",
"null",
"'Administrator{{$perm_admin}}|Read_Write{{$perm_write}}'");
563 $variable =
"UserDescReadOnly";
564 $prompt = _(
'Make account details read-only');
565 $desc = _(
'Make account details (username, email, description) read-only');
566 $valueArray[$variable] = array(
"'$variable'",
"false",
"'$prompt'",
568 "'check_boolean'",
"null");
570 $variable =
"LicenseTypes";
571 $licenseTypeTitle = _(
"License Types");
572 $contextValue =
"Permissive, Strong Copyleft, Weak Copyleft";
573 $licenseTypeDesc = _(
"add comma (,) separated different license types");
574 $valueArray[$variable] = array(
"'$variable'",
"'$contextValue'",
"'$licenseTypeTitle'",
575 strval(
CONFIG_TYPE_TEXT),
"'LICENSE'",
"1",
"'$licenseTypeDesc'",
"null",
"null");
578 $variable =
"SwhURL";
579 $prompt = _(
'SoftwareHeritage URL');
580 $desc = _(
'URL to Software Heritage servers');
581 $valueArray[$variable] = array(
"'$variable'",
582 "'https://archive.softwareheritage.org'",
"'$prompt'",
585 $variable =
"SwhBaseURL";
586 $prompt = _(
'SoftwareHeritage API base URI');
587 $desc = _(
'Base URI for API calls');
588 $valueArray[$variable] = array(
"'$variable'",
"'/api/1/content/sha256:'",
592 $variable =
"SwhContent";
593 $prompt = _(
'Content endpoint');
594 $desc = _(
'Endpoint to get content about file');
595 $valueArray[$variable] = array(
"'$variable'",
"'/license'",
"'$prompt'",
598 $variable =
"SwhSleep";
599 $prompt = _(
'Max sleep time');
600 $desc = _(
'Max time to sleep for rate-limit. Note: This concerns with scheduler heartbeat.');
601 $valueArray[$variable] = array(
"'$variable'",
"100",
"'$prompt'",
604 $variable =
"SwhToken";
605 $prompt = _(
'Auth token');
607 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
610 $variable =
"ScAPIURL";
611 $prompt = _(
'Scanoss API url');
612 $desc = _(
'Set URL to SCANOSS API (blank for default osskb.org)');
613 $valueArray[$variable] = array(
"'$variable'",
617 $variable =
"ScToken";
618 $prompt = _(
'Access token');
619 $desc = _(
'Set token to access full service (blank for basic scan)');
620 $valueArray[$variable] = array(
"'$variable'",
625 $variable =
"LicenseDBBaseURL";
626 $prompt = _(
'LicenseDB API base URI');
627 $desc = _(
'Base URI for API calls e.g. /api/v1');
628 $valueArray[$variable] = array(
"'$variable'",
"'http://localhost:8080/api/v1'",
629 "'$prompt'", strval(
CONFIG_TYPE_TEXT),
"'LicenseDB'",
"1",
"'$desc'",
"null",
632 $variable =
"LicenseDBHealth";
633 $prompt = _(
'Health check');
634 $desc = _(
'Endpoint to check health of LicenseDB service');
635 $valueArray[$variable] = array(
"'$variable'",
"'/health'",
"'$prompt'",
638 $variable =
"LicenseDBContent";
639 $prompt = _(
'Export endpoint Licenses');
640 $desc = _(
'Endpoint to Export licenses in JSON e.g. /licenses/export');
641 $valueArray[$variable] = array(
"'$variable'",
"'/licenses/export'",
"'$prompt'",
644 $variable =
"LicenseDBContentObligations";
645 $prompt = _(
'Export endpoint Obligations');
646 $desc = _(
'Endpoint to Export Obligations in JSON e.g. /obligations/export');
647 $valueArray[$variable] = array(
"'$variable'",
"'/obligations/export'",
"'$prompt'",
650 $variable =
"LicenseDBToken";
651 $prompt = _(
'Auth token For LicenseDB');
652 $desc = _(
"Token from LicenseDB. Do not set if using OIDC for LicenseDB and FOSSology communication.");
653 $valueArray[$variable] = array(
"'$variable'",
"''",
"'$prompt'",
656 $variable =
"ExcludeFolders";
657 $mimeTypeToSkip = _(
"Exclude Folders from scanning");
658 $mimeTypeDesc = _(
"Add comma (,) separated folder patterns to exclude from unpacking");
659 $valueArray[$variable] = array(
"'$variable'",
"null",
"'$mimeTypeToSkip'",
660 strval(
CONFIG_TYPE_TEXT),
"'Skip'",
"1",
"'$mimeTypeDesc'",
"null",
"null");
665 foreach ($valueArray as $variable => $values) {
671 $VarRec =
GetSingleRec(
"sysconfig",
"WHERE variablename='$variable'");
672 if (empty($VarRec)) {
673 $sql =
"INSERT INTO sysconfig (" . implode(
",", $columns) .
") VALUES (" .
674 implode(
",", $values) .
");";
677 foreach ($columns as $index => $column) {
678 if ($index != 0 && $index != 1) {
679 $updateString[] = $column .
"=" . $values[$index];
682 $sql =
"UPDATE sysconfig SET " . implode(
",", $updateString) .
683 " WHERE variablename='$variable';";
687 pg_free_result($result);
704 if (! strcmp($value,
'true') || ! strcmp($value,
'false')) {
722 $url_array = explode(
"/", $url, 2);
723 $name = $url_array[0];
724 if (! empty($name)) {
725 $hostname = exec(
"hostname -f");
726 if (empty($hostname)) {
727 $hostname =
"localhost";
730 $hostname1 = gethostbyaddr($name);
731 if (strcmp($hostname, $hostname1) == 0) {
735 $server_name = $_SERVER[
'SERVER_NAME'];
738 if (strcmp($name, $hostname) && strcmp($name, $server_name)) {
786 $logoLink = @$SysConf[
"LogoLink"];
787 $new_url = $logoLink . $url;
825 if (array_key_exists(
'http_proxy', $SysConf[
'FOSSOLOGY']) &&
826 $SysConf[
'FOSSOLOGY'][
'http_proxy']) {
827 $proxyStmts .=
"export http_proxy={$SysConf['FOSSOLOGY']['http_proxy']};";
829 if (array_key_exists(
'https_proxy', $SysConf[
'FOSSOLOGY']) &&
830 $SysConf[
'FOSSOLOGY'][
'https_proxy']) {
831 $proxyStmts .=
"export https_proxy={$SysConf['FOSSOLOGY']['https_proxy']};";
833 if (array_key_exists(
'ftp_proxy', $SysConf[
'FOSSOLOGY']) &&
834 $SysConf[
'FOSSOLOGY'][
'ftp_proxy']) {
835 $proxyStmts .=
"export ftp_proxy={$SysConf['FOSSOLOGY']['ftp_proxy']};";
838 $commands =
"$proxyStmts wget --spider '$url' --tries=$tries --timeout=$timeout";
839 system($commands, $return_var);
840 if (0 == $return_var) {
855 preg_match(
"@^((http)|(https)|(ftp))://([[:alnum:]]+)@i", $url) != 1 ||
856 preg_match(
"@[[:space:]]@", $url) != 0) {
870 $e =
"([0-9]|1[0-9]{2}|[1-9][0-9]|2[0-4][0-9]|25[0-5])";
871 return preg_match(
"/^$e\.$e\.$e\.$e$/", $ip);
881 $path =
"/home/" . $SysConf[
'DIRECTORIES'][
'PROJECTUSER'] .
"/pythondeps";
882 putenv(
"PYTHONPATH=$path");
883 return [
"PYTHONPATH" => $path];
896 $cores =
trim(shell_exec(
"nproc"));
899 $load = sys_getloadavg()[1];
901 $percentageOfLoad = ($load / $cores);
903 if ($percentageOfLoad < 0.30) {
904 $class =
'btn-success';
905 }
else if ($percentageOfLoad < 0.60) {
906 $class =
'btn-warning';
908 $class =
'btn-danger';
911 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().
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.
ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=true)
Initialize the fossology system after bootstrap().
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