FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
common-cli.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2008-2012 Hewlett-Packard Development Company, L.P.
4  Copyright (C) 2015 Siemens AG
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License version 2.1 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this library; if not, write to the Free Software Foundation, Inc.0
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 ***********************************************************/
19 
36 function cli_Init()
37 {
38  // every cli must perform these steps
39  global $Plugins;
40 
41  /* Load the plugins */
42  plugin_load(0); /* load but do not initialize */
43 
44  /* Turn off authentication */
45  /* The auth module hijacks and disables plugins, so turn it off. */
46  if (array_key_exists("auth", $Plugins)) {
47  $P = &$Plugins["auth"];
48  if (!empty($P)) {
49  $P->State = PLUGIN_STATE_FAIL;
50  }
51  }
52  $_SESSION['User'] = 'fossy';
53 
54  /* Initialize plugins */
55  /* This registers plugins with the menu structure and start the DB
56  connection. */
57  plugin_preinstall();
58 
59  return(true);
60 } // cli_Init()
61 
74 function cli_logger($handle, $message, $mode='a')
75 {
76  $message .= "\n";
77  $FR = fopen($handle, $mode) or
78  die("Can't open $handle, $php_errormsg\n");
79  $wrote = fwrite ($FR, $message);
80  fflush($FR);
81  if ($wrote == -1) {
82  fclose($FR);
83  $text = _("ERROR: could not write message to");
84  return("$text $handle\n");
85  }
86  fclose($FR);
87  return(null);
88 }
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
Definition: common-cli.php:36
plugin_load()
Load every module ui found in mods-enabled.
cli_logger($handle, $message, $mode='a')
Write/append a message to the log handle passed in.
Definition: common-cli.php:74