24 $AllPossibleOpts =
"abc:defghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
28 $DatabaseName =
"fossology";
29 $UpdateLiceneseRef =
false;
40 if (!function_exists(
'resolve_config_value')) {
41 function resolve_config_value($value, array $scope)
43 return preg_replace_callback(
'/\$(?:([A-Za-z_][A-Za-z0-9_]*)|\{([A-Za-z_][A-Za-z0-9_]*)\})/',
static function ($matches) use ($scope) {
44 $name = !empty($matches[1]) ? $matches[1] : $matches[2];
45 return array_key_exists($name, $scope) ? $scope[$name] : $matches[0];
52 foreach(
$Options as $Option => $OptVal)
57 $sysconfdir = $OptVal;
60 echo
"Invalid Option \"$Option\".\n";
73 if ($rv ===
false) exit(1);
85 $usage =
"Usage: " . basename($argv[0]) .
" [options]
86 Update FOSSology database. Options are:
87 -c fossology system configuration directory
126 $rcfile =
"fossology.rc";
128 if (empty($sysconfdir))
130 $sysconfdir = getenv(
'SYSCONFDIR');
131 if ($sysconfdir ===
false)
133 if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
134 if ($sysconfdir ===
false)
137 $text = _(
"FATAL! System Configuration Error, no SYSCONFDIR.");
144 $sysconfdir =
trim($sysconfdir);
145 $GLOBALS[
'SYSCONFDIR'] = $sysconfdir;
148 $ConfFile =
"{$sysconfdir}/fossology.conf";
149 if (!file_exists($ConfFile))
151 $text = _(
"FATAL! Missing configuration file: $ConfFile");
155 $SysConf = parse_ini_file($ConfFile,
true);
156 if ($SysConf ===
false)
158 $text = _(
"FATAL! Invalid configuration file: $ConfFile");
167 $resolvedValues = array();
168 foreach($SysConf[
'DIRECTORIES'] as $var=>$assign)
170 $resolvedValue = resolve_config_value($assign, $resolvedValues);
171 $resolvedValues[$var] = $resolvedValue;
174 $SysConf[
'DIRECTORIES'][$var] = $resolvedValue;
175 ${$var} = $resolvedValue;
176 $GLOBALS[$var] = $resolvedValue;
181 $text = _(
"FATAL! System initialization failure: MODDIR not defined in $SysConf");
188 require_once(
"$MODDIR/lib/php/common.php");
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
if(!function_exists('resolve_sysconfig_value')) ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=true)
Initialize the fossology system after bootstrap().
bootstrap($sysconfdir="")
Bootstrap the fossology php library.
Usage()
Print Usage statement.
if(!function_exists('resolve_config_value')) $Options
char * trim(char *ptext)
Trimming whitespace.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN