FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
common-sysconfig.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2011-2015 Hewlett-Packard Development Company, L.P.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License version 2.1 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this library; if not, write to the Free Software Foundation, Inc.0
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 ***********************************************************/
18 
20 
27 define("CONFIG_TYPE_INT", 1);
29 define("CONFIG_TYPE_TEXT", 2);
31 define("CONFIG_TYPE_TEXTAREA", 3);
33 define("CONFIG_TYPE_PASSWORD", 4);
35 define("CONFIG_TYPE_DROP", 5);
36 
37 
75 function ConfigInit($sysconfdir, &$SysConf)
76 {
77  global $PG_CONN;
78 
79  /************* Parse VERSION *******************/
80  $versionFile = "{$sysconfdir}/VERSION";
81  $versionConf = parse_ini_file($versionFile, true);
82 
83  /* Add this file contents to $SysConf, then destroy $VersionConf
84  * This file can define its own groups and is eval'd.
85  */
86  foreach ($versionConf as $groupName => $groupArray) {
87  foreach ($groupArray as $var => $assign) {
88  $toeval = "\$$var = \"$assign\";";
89  eval($toeval);
90  $SysConf[$groupName][$var] = ${$var};
91  $GLOBALS[$var] = ${$var};
92  }
93  }
94  unset($versionConf);
95 
96  /************* Parse Db.conf *******************/
97  $dbPath = "{$sysconfdir}/Db.conf";
98  $dbConf = parse_ini_file($dbPath, true);
99 
100  /* Add this file contents to $SysConf, then destroy $dbConf
101  * This file can define its own groups and is eval'd.
102  */
103  foreach ($dbConf as $var => $val) {
104  $SysConf['DBCONF'][$var] = $val;
105  }
106  unset($dbConf);
107 
108  /*
109  * Connect to the database. If the connection fails,
110  * DBconnect() will print a failure message and exit.
111  */
112  $PG_CONN = DBconnect($sysconfdir);
113 
114  global $container;
115  $postgresDriver = new \Fossology\Lib\Db\Driver\Postgres($PG_CONN);
116  $container->get('db.manager')->setDriver($postgresDriver);
117 
118  /**************** read/create/populate the sysconfig table *********/
119  /* create if sysconfig table if it doesn't exist */
120  $newTable = Create_sysconfig();
121  $newColumn = Create_option_value();
122 
123  /* populate it with core variables */
125 
126  /* populate the global $SysConf array with variable/value pairs */
127  $sql = "SELECT variablename, conf_value FROM sysconfig;";
128  $result = pg_query($PG_CONN, $sql);
129  DBCheckResult($result, $sql, __FILE__, __LINE__);
130 
131  while ($row = pg_fetch_assoc($result)) {
132  $SysConf['SYSCONFIG'][$row['variablename']] = $row['conf_value'];
133  }
134  pg_free_result($result);
135 
136  return;
137 } // ConfigInit()
138 
139 
147 {
148  global $PG_CONN;
149 
150  /* If sysconfig exists, then we are done */
151  $sql = "SELECT typlen FROM pg_type WHERE typname='sysconfig' limit 1;";
152  $result = pg_query($PG_CONN, $sql);
153  DBCheckResult($result, $sql, __FILE__, __LINE__);
154  $numrows = pg_num_rows($result);
155  pg_free_result($result);
156  if ($numrows > 0) {
157  return 0;
158  }
159 
160  /* Create the sysconfig table */
161  $sql = "
162 CREATE TABLE sysconfig (
163  sysconfig_pk serial NOT NULL PRIMARY KEY,
164  variablename character varying(30) NOT NULL UNIQUE,
165  conf_value text,
166  ui_label character varying(60) NOT NULL,
167  vartype int NOT NULL,
168  group_name character varying(20) NOT NULL,
169  group_order int,
170  description text NOT NULL,
171  validation_function character varying(40) DEFAULT NULL,
172  option_value character varying(40) DEFAULT NULL
173 );
174 ";
175 
176  $result = pg_query($PG_CONN, $sql);
177  DBCheckResult($result, $sql, __FILE__, __LINE__);
178  pg_free_result($result);
179 
180  /* Document columns */
181  $sql = "
182 COMMENT ON TABLE sysconfig IS 'System configuration values';
183 COMMENT ON COLUMN sysconfig.variablename IS 'Name of configuration variable';
184 COMMENT ON COLUMN sysconfig.conf_value IS 'value of config variable';
185 COMMENT ON COLUMN sysconfig.ui_label IS 'Label that appears on user interface to prompt for variable';
186 COMMENT ON COLUMN sysconfig.group_name IS 'Name of this variables group in the user interface';
187 COMMENT ON COLUMN sysconfig.group_order IS 'The order this variable appears in the user interface group';
188 COMMENT ON COLUMN sysconfig.description IS 'Description of variable to document how/where the variable value is used.';
189 COMMENT ON COLUMN sysconfig.validation_function IS 'Name of function to validate input. Not currently implemented.';
190 COMMENT ON COLUMN sysconfig.vartype IS 'variable type. 1=int, 2=text, 3=textarea, 4=password, 5=dropdown';
191 COMMENT ON COLUMN sysconfig.option_value IS 'If vartype is 5, provide options in format op1{val1}|op2{val2}|...';
192  ";
193  /* this is a non critical update */
194  $result = pg_query($PG_CONN, $sql);
195  DBCheckResult($result, $sql, __FILE__, __LINE__);
196  pg_free_result($result);
197  return 1;
198 }
199 
200 
205 {
206  global $PG_CONN;
207 
208  $columns = array("variablename", "conf_value", "ui_label", "vartype", "group_name",
209  "group_order", "description", "validation_function", "option_value");
210  $valueArray = array();
211 
212  /* Email */
213  $variable = "SupportEmailLabel";
214  $supportEmailLabelPrompt = _('Support Email Label');
215  $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.');
216  $valueArray[$variable] = array("'$variable'", "'Support'", "'$supportEmailLabelPrompt'",
217  strval(CONFIG_TYPE_TEXT), "'Support'", "1", "'$supportEmailLabelDesc'", "null", "null");
218 
219  $variable = "SupportEmailAddr";
220  $supportEmailAddrPrompt = _('Support Email Address');
221  $supportEmailAddrValid = "check_email_address";
222  $supportEmailAddrDesc = _('e.g. "support@mycompany.com"<br>Individual or group email address to those providing FOSSology support.');
223  $valueArray[$variable] = array("'$variable'", "null", "'$supportEmailAddrPrompt'",
224  strval(CONFIG_TYPE_TEXT), "'Support'", "2", "'$supportEmailAddrDesc'", "'$supportEmailAddrValid'", "null");
225 
226  $variable = "SupportEmailSubject";
227  $supportEmailSubjectPrompt = _('Support Email Subject line');
228  $supportEmailSubjectDesc = _('e.g. "fossology support"<br>Subject line to use on support email.');
229  $valueArray[$variable] = array("'$variable'", "'FOSSology Support'", "'$supportEmailSubjectPrompt'",
230  strval(CONFIG_TYPE_TEXT), "'Support'", "3", "'$supportEmailSubjectDesc'", "null", "null");
231 
232  /* Banner Message */
233  $variable = "BannerMsg";
234  $bannerMsgPrompt = _('Banner message');
235  $bannerMsgDesc = _('This is message will be displayed on every page with a banner. HTML is ok.');
236  $valueArray[$variable] = array("'$variable'", "null", "'$bannerMsgPrompt'",
237  strval(CONFIG_TYPE_TEXTAREA), "'Banner'", "1", "'$bannerMsgDesc'", "null", "null");
238 
239  /* Logo */
240  $variable = "LogoImage";
241  $logoImagePrompt = _('Logo Image URL');
242  $logoImageValid = "check_logo_image_url";
243  $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.');
244  $valueArray[$variable] = array("'$variable'", "null", "'$logoImagePrompt'",
245  strval(CONFIG_TYPE_TEXT), "'Logo'", "1", "'$logoImageDesc'", "'$logoImageValid'", "null");
246 
247  $variable = "LogoLink";
248  $logoLinkPrompt = _('Logo URL');
249  $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.');
250  $logoLinkValid = "check_logo_url";
251  $valueArray[$variable] = array("'$variable'", "null", "'$logoLinkPrompt'",
252  strval(CONFIG_TYPE_TEXT), "'Logo'", "2", "'$logoLinkDesc'", "'$logoLinkValid'", "null");
253 
254  $variable = "FOSSologyURL";
255  $urlPrompt = _("FOSSology URL");
256  $hostname = exec("hostname -f");
257  if (empty($hostname)) {
258  $hostname = "localhost";
259  }
260  $fossologyURL = $hostname."/repo/";
261  $urlDesc = _("URL of this FOSSology server, e.g. $fossologyURL");
262  $urlValid = "check_fossology_url";
263  $valueArray[$variable] = array("'$variable'", "'$fossologyURL'", "'$urlPrompt'",
264  strval(CONFIG_TYPE_TEXT), "'URL'", "1", "'$urlDesc'", "'$urlValid'", "null");
265 
266  $variable = "NomostListNum";
267  $nomosNumPrompt = _("Maximum licenses to List");
268  $nomostListNum = "2200";
269  $NomosNumDesc = _("For License List and License List Download, you can set the maximum number of lines to list/download. Default 2200.");
270  $valueArray[$variable] = array("'$variable'", "'$nomostListNum'", "'$nomosNumPrompt'",
271  strval(CONFIG_TYPE_TEXT), "'Number'", "1", "'$NomosNumDesc'", "null", "null");
272 
273  $variable = "BlockSizeHex";
274  $hexPrompt = _("Chars per page in hex view");
275  $hexDesc = _("Number of characters per page in hex view");
276  $valueArray[$variable] = array("'$variable'", "'8192'", "'$hexPrompt'",
277  strval(CONFIG_TYPE_TEXT), "'Number'", "2", "'$hexDesc'", "null", "null");
278 
279  $variable = "BlockSizeText";
280  $textPrompt = _("Chars per page in text view");
281  $textDesc = _("Number of characters per page in text view");
282  $valueArray[$variable] = array("'$variable'", "'81920'", "'$textPrompt'",
283  strval(CONFIG_TYPE_TEXT), "'Number'", "3", "'$textDesc'", "null", "null");
284 
285  $variable = "ShowJobsAutoRefresh";
286  $contextNamePrompt = _("ShowJobs Auto Refresh Time");
287  $contextValue = "10";
288  $contextDesc = _("No of seconds to refresh ShowJobs");
289  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
290  strval(CONFIG_TYPE_TEXT), "'Number'", "4", "'$contextDesc'", "null", "null");
291 
292  /* Report Header Text */
293  $variable = "ReportHeaderText";
294  $contextNamePrompt = _("Report Header Text");
295  $contextValue = "FOSSology";
296  $contextDesc = _("Report Header Text at right side corner");
297  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
298  strval(CONFIG_TYPE_TEXT), "'ReportText'", "1", "'$contextDesc'", "null", "null");
299 
300  $variable = "CommonObligation";
301  $contextNamePrompt = _("Common Obligation");
302  $contextValue = "";
303  $contextDesc = _("Common Obligation Text, add line break at the end of the line");
304  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
305  strval(CONFIG_TYPE_TEXTAREA), "'ReportText'", "2", "'$contextDesc'", "null", "null");
306 
307  $variable = "AdditionalObligation";
308  $contextNamePrompt = _("Additional Obligation");
309  $contextValue = "";
310  $contextDesc = _("Additional Obligation Text, add line break at the end of the line");
311  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
312  strval(CONFIG_TYPE_TEXTAREA), "'ReportText'", "3", "'$contextDesc'", "null", "null");
313 
314  $variable = "ObligationAndRisk";
315  $contextNamePrompt = _("Obligation And Risk Assessment");
316  $contextValue = "";
317  $contextDesc = _("Obligations and risk assessment, add line break at the end of the line");
318  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
319  strval(CONFIG_TYPE_TEXTAREA), "'ReportText'", "4", "'$contextDesc'", "null", "null");
320 
321  /* "Upload from server"-configuration */
322  $variable = "UploadFromServerWhitelist";
323  $contextNamePrompt = _("Whitelist for serverupload");
324  $contextValue = "/tmp";
325  $contextDesc = _("List of allowed prefixes for upload, separated by \":\" (colon)");
326  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
327  strval(CONFIG_TYPE_TEXT), "'UploadFromServer'", "1", "'$contextDesc'", "null", "null");
328 
329  $variable = "UploadFromServerAllowedHosts";
330  $contextNamePrompt = _("List of allowed hosts for serverupload");
331  $contextValue = "localhost";
332  $contextDesc = _("List of allowed hosts for upload, separated by \":\" (colon)");
333  $valueArray[$variable] = array("'$variable'", "'$contextValue'", "'$contextNamePrompt'",
334  strval(CONFIG_TYPE_TEXT), "'UploadFromServer'", "2", "'$contextDesc'", "null", "null");
335 
336  /* SMTP config */
337  $variable = "SMTPHostName";
338  $smtpHostPrompt = _('SMTP Host Name');
339  $smtpHostDesc = _('e.g.: "smtp.domain.com"<br>The domain to be used to send emails.');
340  $valueArray[$variable] = array("'$variable'", "null", "'$smtpHostPrompt'",
341  strval(CONFIG_TYPE_TEXT), "'SMTP'", "1", "'$smtpHostDesc'", "null", "null");
342 
343  $variable = "SMTPPort";
344  $smtpPortPrompt = _('SMTP Port');
345  $smtpPortDesc = _('e.g.: "25"<br>SMTP port to be used.');
346  $valueArray[$variable] = array("'$variable'", "25", "'$smtpPortPrompt'",
347  strval(CONFIG_TYPE_INT), "'SMTP'", "2", "'$smtpPortDesc'", "null", "null");
348 
349  $variable = "SMTPAuth";
350  $smtpAuthPrompt = _('SMTP Auth Type');
351  $smtpAuthDesc = _('Algorithm to use for login.<br>Login => Encrypted<br>None => No authentication<br>Plain => Send as plain text');
352  $valueArray[$variable] = array("'$variable'", "'L'", "'$smtpAuthPrompt'",
353  strval(CONFIG_TYPE_DROP), "'SMTP'", "3", "'$smtpAuthDesc'", "null", "'Login{L}|None{N}|Plain{P}'");
354 
355  $variable = "SMTPFrom";
356  $smtpFrom = _('SMTP Email');
357  $smtpFromDesc = _('e.g.: "user@domain.com"<br>Sender email.');
358  $valueArray[$variable] = array("'$variable'", "null", "'$smtpFrom'",
359  strval(CONFIG_TYPE_TEXT), "'SMTP'", "4", "'$smtpFromDesc'", "'check_email_address'", "null");
360 
361  $variable = "SMTPAuthUser";
362  $smtpAuthUserPrompt = _('SMTP User');
363  $smtpAuthUserDesc = _('e.g.: "user"<br>Login to be used for login on SMTP Server.');
364  $valueArray[$variable] = array("'$variable'", "null", "'$smtpAuthUserPrompt'",
365  strval(CONFIG_TYPE_TEXT), "'SMTP'", "5", "'$smtpAuthUserDesc'", "null", "null");
366 
367  $variable = "SMTPAuthPasswd";
368  $smtpAuthPasswdPrompt = _('SMTP Login Password');
369  $smtpAuthPasswdDesc = _('Password used for SMTP login.');
370  $valueArray[$variable] = array("'$variable'", "null", "'$smtpAuthPasswdPrompt'",
371  strval(CONFIG_TYPE_PASSWORD), "'SMTP'", "5", "'$smtpAuthPasswdDesc'", "null", "null");
372 
373  $variable = "SMTPSslVerify";
374  $smtpSslPrompt = _('SMTP SSL Verify');
375  $smtpSslDesc = _('The SSL verification for connection is required?');
376  $valueArray[$variable] = array("'$variable'", "'S'", "'$smtpSslPrompt'",
377  strval(CONFIG_TYPE_DROP), "'SMTP'", "6", "'$smtpSslDesc'", "null", "'Ignore{I}|Strict{S}|Warn{W}'");
378 
379  $variable = "SMTPStartTls";
380  $smtpTlsPrompt = _('Start TLS');
381  $smtpTlsDesc = _('Use TLS connection for SMTP?');
382  $valueArray[$variable] = array("'$variable'", "'1'", "'$smtpTlsPrompt'",
383  strval(CONFIG_TYPE_DROP), "'SMTP'", "7", "'$smtpTlsDesc'", "null", "'Yes{1}|No{2}'");
384 
385  $variable = "PATMaxExipre";
386  $patTokenValidityPrompt = _('Max token validity');
387  $patTokenValidityDesc = _('Maximum validity of tokens (in days)');
388  $valueArray[$variable] = array("'$variable'", "30", "'$patTokenValidityPrompt'",
389  strval(CONFIG_TYPE_INT), "'PAT'", "1", "'$patTokenValidityDesc'", "null", "null");
390 
391  $variable = "SkipFiles";
392  $mimeTypeToSkip = _("Skip MimeTypes from scanning");
393  $mimeTypeDesc = _("add comma (,) separated mimetype to exclude files from scanning");
394  $valueArray[$variable] = array("'$variable'", "null", "'$mimeTypeToSkip'",
395  strval(CONFIG_TYPE_TEXT), "'Skip'", "1", "'$mimeTypeDesc'", "null", "null");
396 
397  $perm_admin=Auth::PERM_ADMIN;
398  $perm_write=Auth::PERM_WRITE;
399  $variable = "SourceCodeDownloadRights";
400  $SourceDownloadRightsPrompt = _('Acces rights required to download source code');
401  $SourceDownloadRightsDesc = _('Choose which acces level will be required for user to be able to download source code.');
402  $valueArray[$variable] = array("'$variable'", "'$perm_write'", "'$SourceDownloadRightsPrompt'",
403  strval(CONFIG_TYPE_DROP), "'DOWNLOAD'", "1", "'$SourceDownloadRightsDesc'", "null", "'Administrator{{$perm_admin}}|Read_Write{{$perm_write}}'");
404 
405  /* Doing all the rows as a single insert will fail if any row is a dupe.
406  So insert each one individually so that new variables get added.
407  */
408  foreach ($valueArray as $variable => $values) {
409  /*
410  * Check if the variable already exists. Insert it if it does not.
411  * This is better than an insert ignoring duplicates, because that
412  * generates a postresql log message.
413  */
414  $VarRec = GetSingleRec("sysconfig", "WHERE variablename='$variable'");
415  if (empty($VarRec)) {
416  $sql = "INSERT INTO sysconfig (" . implode(",", $columns) . ") VALUES (" .
417  implode(",", $values) . ");";
418  $result = pg_query($PG_CONN, $sql);
419  DBCheckResult($result, $sql, __FILE__, __LINE__);
420  pg_free_result($result);
421  } else { // Values exist, update them
422  $updateString = [];
423  foreach ($columns as $index => $column) {
424  if ($index != 0 && $index != 1) { // Skip variablename and conf_value
425  $updateString[] = $column . "=" . $values[$index];
426  }
427  }
428  $sql = "UPDATE sysconfig SET " . implode(",", $updateString) .
429  " WHERE variablename='$variable';";
430  $result = pg_query($PG_CONN, $sql);
431  DBCheckResult($result, $sql, __FILE__, __LINE__);
432  pg_free_result($result);
433  }
434  unset($VarRec);
435  }
436 }
437 
445 {
446  global $PG_CONN;
447 
448  /* If sysconfig exists, then we are done */
449  $sql = "SELECT column_name FROM information_schema.columns WHERE "
450  . "table_name='sysconfig' and column_name='option_value' limit 1;";
451  $result = pg_query($PG_CONN, $sql);
452  DBCheckResult($result, $sql, __FILE__, __LINE__);
453  $numrows = pg_num_rows($result);
454  pg_free_result($result);
455  if ($numrows > 0) {
456  return 0;
457  }
458 
459  /* Create the option_value column */
460  $sql = "ALTER TABLE sysconfig ADD COLUMN option_value character varying(40) DEFAULT NULL;";
461 
462  $result = pg_query($PG_CONN, $sql);
463  DBCheckResult($result, $sql, __FILE__, __LINE__);
464  pg_free_result($result);
465 
466  /* Document columns */
467  $sql = "COMMENT ON COLUMN sysconfig.option_value IS 'If vartype is 5, "
468  . "provide options in format op1{val1}|op2{val2}|...';";
469  /* this is a non critical update */
470  $result = pg_query($PG_CONN, $sql);
471  DBCheckResult($result, $sql, __FILE__, __LINE__);
472  pg_free_result($result);
473  return 1;
474 }
475 
486 function check_boolean($value)
487 {
488  if (! strcmp($value, 'true') || ! strcmp($value, 'false')) {
489  return 1;
490  } else {
491  return 0;
492  }
493 }
494 
504 function check_fossology_url($url)
505 {
506  $url_array = explode("/", $url, 2);
507  $name = $url_array[0];
508  if (! empty($name)) {
509  $hostname = exec("hostname -f");
510  if (empty($hostname)) {
511  $hostname = "localhost";
512  }
513  if (check_IP($name)) {
514  $hostname1 = gethostbyaddr($name);
515  if (strcmp($hostname, $hostname1) == 0) {
516  return 0; // host is not reachable
517  }
518  }
519  $server_name = $_SERVER['SERVER_NAME'];
520 
521  /* intput $name must match either the hostname or the server name */
522  if (strcmp($name, $hostname) && strcmp($name, $server_name)) {
523  return 0;
524  }
525  } else {
526  return 0;
527  }
528  return 1;
529 }
530 
540 function check_logo_url($url)
541 {
542  if (empty($url)) {
543  return 1; /* logo url can be null, with the default */
544  }
545  // $res = check_url($url);
546  $res = is_available($url);
547  if (1 == $res) {
548  return 1;
549  } else {
550  return 0;
551  }
552 }
553 
563 function check_logo_image_url($url)
564 {
565  global $SysConf;
566 
567  if (empty($url)) {
568  return 1; /* logo url can be null, with the default */
569  }
570  $logoLink = @$SysConf["LogoLink"];
571  $new_url = $logoLink . $url;
572  if (is_available($url) || is_available($new_url)) {
573  return 1;
574  } else {
575  return 0;
576  }
577 
578 }
579 
590 function check_email_address($email_address)
591 {
592  return 1;
593 }
594 
604 function is_available($url, $timeout = 2, $tries = 2)
605 {
606  global $SysConf;
607 
608  $proxyStmts = "";
609  if (array_key_exists('http_proxy', $SysConf['FOSSOLOGY']) &&
610  $SysConf['FOSSOLOGY']['http_proxy']) {
611  $proxyStmts .= "export http_proxy={$SysConf['FOSSOLOGY']['http_proxy']};";
612  }
613  if (array_key_exists('https_proxy', $SysConf['FOSSOLOGY']) &&
614  $SysConf['FOSSOLOGY']['https_proxy']) {
615  $proxyStmts .= "export https_proxy={$SysConf['FOSSOLOGY']['https_proxy']};";
616  }
617  if (array_key_exists('ftp_proxy', $SysConf['FOSSOLOGY']) &&
618  $SysConf['FOSSOLOGY']['ftp_proxy']) {
619  $proxyStmts .= "export ftp_proxy={$SysConf['FOSSOLOGY']['ftp_proxy']};";
620  }
621 
622  $commands = "$proxyStmts wget --spider '$url' --tries=$tries --timeout=$timeout";
623  system($commands, $return_var);
624  if (0 == $return_var) {
625  return 1;
626  } else {
627  return 0;
628  }
629 }
630 
636 function check_url($url)
637 {
638  if (empty($url) ||
639  preg_match("@^((http)|(https)|(ftp))://([[:alnum:]]+)@i", $url) != 1 ||
640  preg_match("@[[:space:]]@", $url) != 0) {
641  return 0;
642  } else {
643  return 1;
644  }
645 }
646 
652 function check_IP($ip)
653 {
654  $e = "([0-9]|1[0-9]{2}|[1-9][0-9]|2[0-4][0-9]|25[0-5])";
655  return preg_match("/^$e\.$e\.$e\.$e$/", $ip);
656 }
const CONFIG_TYPE_TEXTAREA
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
Definition: common-db.php:44
check_url($url)
Check if the url is valid.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Definition: common-db.php:102
Populate_sysconfig()
Populate the sysconfig table with core variables.
const CONFIG_TYPE_PASSWORD
const CONFIG_TYPE_DROP
check_fossology_url($url)
Validation function check_fossology_url().
check_email_address($email_address)
Validation function check_email_address().
Create_option_value()
Create the option_value column in sysconfig table.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
check_logo_image_url($url)
Validation function check_logo_image_url().
const CONFIG_TYPE_TEXT
Create_sysconfig()
Create the sysconfig table.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Definition: common-db.php:198
check_logo_url($url)
Validation function check_logo_url().
check_boolean($value)
Validation function check_boolean().
const CONFIG_TYPE_INT
ConfigInit($sysconfdir, &$SysConf)
Initialize the fossology system after bootstrap().
check_IP($ip)
Check if the ip address is valid.
is_available($url, $timeout=2, $tries=2)
Check if the URL is available.
#define PERM_ADMIN
Administrator.
Definition: libfossology.h:46
#define PERM_WRITE
Read-Write permission.
Definition: libfossology.h:45