Пример #1
0
/**
 * \brief Initalize the fossology environment for cli use.  This routine loads
 * the plugins so they can be use by cli programs.  In the process of doing
 * that it disables the core-auth plugin.
 *
 * \return true
 */
function cli_Init()
{
    // every cli must perform these steps
    global $Plugins;
    /* Load the plugins */
    plugin_load(0);
    /* load but do not initialize */
    /* Turn off authentication */
    /** The auth module hijacks and disables plugins, so turn it off. **/
    $P =& $Plugins[plugin_find_any_id("auth")];
    if (!empty($P)) {
        $P->State = PLUGIN_STATE_FAIL;
    }
    $_SESSION['User'] = '******';
    /* Initialize plugins */
    /** This registers plugins with the menu structure and start the DB
       connection. **/
    plugin_init();
    /* this registers plugins with menus */
    return true;
}
Пример #2
0
 /**
  * \brief This is only called when the user logs out.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     global $Plugins;
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /* If you are not logged in, then force a login. */
             if (empty($_SESSION['User'])) {
                 $P =& $Plugins[plugin_find_id("auth")];
                 $P->OutputSet($this->OutputType, 0);
                 $V .= $P->Output();
                 $P->OutputUnSet();
             } else {
                 $FailFlag = 0;
                 $Filename = getcwd() . "/init.ui";
                 $Schema =& $Plugins[plugin_find_any_id("schema")];
                 if (empty($Schema)) {
                     $V .= _("Failed to find schema plugin.\n");
                     $FailFlag = 1;
                 } else {
                     print "<pre>";
                     $FailFlag = $Schema->ApplySchema($Schema->Filename, 0, 0);
                     print "</pre>";
                 }
                 if (!$FailFlag) {
                     $V .= _("Initialization complete.  Click 'Home' in the top menu to proceed.<br />");
                     if (is_writable(getcwd())) {
                         $State = unlink($Filename);
                     } else {
                         $State = 0;
                     }
                     if (!$State) {
                         $V .= "<font color='red'>";
                         $V .= _("Failed to remove {$Filename}\n");
                         $text = _("Remove this file to complete the initialization.\n");
                         $V .= "<br />{$text}";
                         $V .= "</font>\n";
                         $FailedFlag = 1;
                     }
                 } else {
                     $V .= "<font color='red'>";
                     $V .= _("Initialization complete with errors.");
                     $V .= "</font>\n";
                 }
             }
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }