FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
common-sysconfig.php File Reference

System configuration functions. More...

Go to the source code of this file.

Functions

 ConfigInit ($sysconfdir, &$SysConf)
 Initialize the fossology system after bootstrap(). More...
 
 Create_sysconfig ()
 Create the sysconfig table. More...
 
 Populate_sysconfig ()
 Populate the sysconfig table with core variables.
 
 Create_option_value ()
 Create the option_value column in sysconfig table. More...
 
 check_boolean ($value)
 Validation function check_boolean(). More...
 
 check_fossology_url ($url)
 Validation function check_fossology_url(). More...
 
 check_logo_url ($url)
 Validation function check_logo_url(). More...
 
 check_logo_image_url ($url)
 Validation function check_logo_image_url(). More...
 
 check_email_address ($email_address)
 Validation function check_email_address(). More...
 
 is_available ($url, $timeout=2, $tries=2)
 Check if the URL is available. More...
 
 check_url ($url)
 Check if the url is valid. More...
 
 check_IP ($ip)
 Check if the ip address is valid. More...
 

Variables

const CONFIG_TYPE_INT 1
 
const CONFIG_TYPE_TEXT 2
 
const CONFIG_TYPE_TEXTAREA 3
 
const CONFIG_TYPE_PASSWORD 4
 
const CONFIG_TYPE_DROP 5
 

Detailed Description

System configuration functions.

Definition in file common-sysconfig.php.

Function Documentation

check_boolean (   $value)

Validation function check_boolean().

Check if the value format is valid, only true/false is valid

Parameters
string$valueThe value which will be checked
Returns
1, if the value is valid, or 0

Definition at line 486 of file common-sysconfig.php.

check_email_address (   $email_address)

Validation function check_email_address().

Check if the email address is valid.

Todo:
Implement this function if needed in the future.
Parameters
string$email_addressThe email address which will be checked
Returns
1: valid, 0: invalid

Definition at line 590 of file common-sysconfig.php.

check_fossology_url (   $url)

Validation function check_fossology_url().

Check if the URL is valid.

Parameters
string$urlThe URL which will be checked
Returns
1: valid, 0: invalid

Definition at line 504 of file common-sysconfig.php.

check_IP (   $ip)

Check if the ip address is valid.

Parameters
string$ipIP address
Returns
1: yes

Definition at line 652 of file common-sysconfig.php.

check_logo_image_url (   $url)

Validation function check_logo_image_url().

Check if the URL is available.

Parameters
string$urlThe url which will be checked
Returns
1: the url is available, 0: unavailable

Definition at line 563 of file common-sysconfig.php.

check_logo_url (   $url)

Validation function check_logo_url().

Check if the URL is available.

Parameters
string$urlThe URL which will be checked
Returns
1: available, 0: unavailable

Definition at line 540 of file common-sysconfig.php.

check_url (   $url)

Check if the url is valid.

Parameters
string$urlThe url which will be checked
Returns
1: the url is valid, 0: invalid

Definition at line 636 of file common-sysconfig.php.

ConfigInit (   $sysconfdir,
$SysConf 
)

Initialize the fossology system after bootstrap().

This function also opens a database connection (global PG_CONN).

System configuration variables are in four places:

  • SYSCONFDIR/fossology.conf (parsed by bootstrap())
  • SYSCONFDIR/VERSION
  • SYSCONFDIR/Db.conf
  • Database sysconfig table

VERSION and fossology.conf variables are organized by group. For example,

1 [DIRECTORIES]
2  REPODIR=/srv/mydir

But the sysconfig table and Db.conf are not. So all the table values will be put in a made up "SYSCONFIG" group. And all the Db.conf values will be put in a "DBCONF" group.

Parameters
string$sysconfdirPath to SYSCONFDIR
[out]array&$SysConfConfiguration variable array (updated by this function)

If the sysconfig table doesn't exist then create it. Write records for the core variables into sysconfig table.

The first array dimension of $SysConf is the group, the second is the variable name. For example:

  • $SysConf[SYSCONFIG][LogoLink] => "http://my/logo.gif"
  • $SysConf[DIRECTORIES][MODDIR] => "/mymoduledir/ - $SysConf[VERSION][COMMIT_HASH] => "4467M"
Note
Since so many files expect directory paths that used to be in pathinclude.php to be global, this function will define the same globals (everything in the DIRECTORIES section of fossology.conf).

Definition at line 75 of file common-sysconfig.php.

Create_option_value ( )

Create the option_value column in sysconfig table.

Returns
0 if column already exists. 1 if it was created

Definition at line 444 of file common-sysconfig.php.

Create_sysconfig ( )

Create the sysconfig table.

Returns
0 if table already exists. 1 if it was created

Definition at line 146 of file common-sysconfig.php.

is_available (   $url,
  $timeout = 2,
  $tries = 2 
)

Check if the URL is available.

Parameters
string$urlURL
int$timeoutTimeout interval, default 2 seconds
int$triesIf unavailable, will try several times, default 2 times
Returns
1: available, 0: unavailable

Definition at line 604 of file common-sysconfig.php.

Variable Documentation

const CONFIG_TYPE_DROP 5

Dropdown type config

Definition at line 35 of file common-sysconfig.php.

const CONFIG_TYPE_INT 1

Integer type config

Definition at line 27 of file common-sysconfig.php.

const CONFIG_TYPE_PASSWORD 4

Password type config

Definition at line 33 of file common-sysconfig.php.

const CONFIG_TYPE_TEXT 2

Text type config

Definition at line 29 of file common-sysconfig.php.

const CONFIG_TYPE_TEXTAREA 3

Textarea type config

Definition at line 31 of file common-sysconfig.php.