FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-cli.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2012 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015 Siemens AG
5 
6  SPDX-License-Identifier: LGPL-2.1-only
7 */
8 
25 function cli_Init()
26 {
27  // every cli must perform these steps
28  global $Plugins;
29 
30  /* Load the plugins */
31  plugin_load(0); /* load but do not initialize */
32 
33  /* Turn off authentication */
34  /* The auth module hijacks and disables plugins, so turn it off. */
35  if (array_key_exists("auth", $Plugins)) {
36  $P = &$Plugins["auth"];
37  if (!empty($P)) {
38  $P->State = PLUGIN_STATE_FAIL;
39  }
40  }
41  $_SESSION['User'] = 'fossy';
42 
43  /* Initialize plugins */
44  /* This registers plugins with the menu structure and start the DB
45  connection. */
46  plugin_preinstall();
47 
48  return(true);
49 } // cli_Init()
50 
63 function cli_logger($handle, $message, $mode='a')
64 {
65  $message .= "\n";
66  $FR = fopen($handle, $mode) or
67  die("Can't open $handle, $php_errormsg\n");
68  $wrote = fwrite ($FR, $message);
69  fflush($FR);
70  fclose($FR);
71  if ($wrote == -1) {
72  $text = _("ERROR: could not write message to");
73  return "$text $handle\n";
74  }
75  return null;
76 }
cli_logger($handle, $message, $mode='a')
Write/append a message to the log handle passed in.
Definition: common-cli.php:63
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
Definition: common-cli.php:25
plugin_load()
Load every module ui found in mods-enabled.