<commit_before><?php

/*
   ------------------------------------------------------------------------
   FusionInventory
   Copyright (C) 2010-2012 by the FusionInventory Development Team.

   http://www.fusioninventory.org/   http://forge.fusioninventory.org/
   ------------------------------------------------------------------------

   LICENSE

   This file is part of FusionInventory project.

   FusionInventory is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   FusionInventory is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with Behaviors. If not, see <http://www.gnu.org/licenses/>.

   ------------------------------------------------------------------------

   @package   FusionInventory
   @author    <NAME>
   @co-author 
   @copyright Copyright (c) 2010-2012 FusionInventory team
   @license   AGPL License 3.0 or (at your option) any later version
              http://www.gnu.org/licenses/agpl-3.0-standalone.html
   @link      http://www.fusioninventory.org/
   @link      http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
   @since     2010
 
   ------------------------------------------------------------------------
 */

if (!defined('GLPI_ROOT')) {
   define('GLPI_ROOT', '../../..');
}

require_once GLPI_ROOT."/inc/includes.php";

Session::checkLoginUser();
// ** Used for rules in the wizard

if (!isset($_GET['wizz'])) {
   if (isset($_POST)) {
      if (isset($_POST['endtask'])) {
         $action = current($_POST['endtask']);
         switch ($action) {
            
            case 'finishdelete':
               if (isset($_SESSION['plugin_fusioninventory_wizard']['ipranges_id'])) {
                  $nb = countElementsInTable("glpi_plugin_fusioninventory_taskjobs", 
                          "`definition` LIKE '%\"PluginFusioninventoryIPRange\":\"".$_SESSION['plugin_fusioninventory_wizard']['ipranges_id']."\"%'");
                  if ($nb == 1) {
                     // Delete iprange
                     $pfIPRange = new PluginFusioninventoryIPRange();
                     $pfIPRange->delete(array('id' => $_SESSION['plugin_fusioninventory_wizard']['ipranges_id']));
                  }
                  $pfTask = new PluginFusioninventoryTask();
                  $pfTask->delete(array('id'=>$_SESSION['plugin_fusioninventory_wizard']['tasks_id']));
              }
              if (isset($_SESSION['plugin_fusioninventory_wizard']['credentialips_id'])) {
                  $nb = countElementsInTable("glpi_plugin_fusioninventory_taskjobs", 
                          "`definition` LIKE '%\"PluginFusioninventoryCredentialIp\":\"".$_SESSION['plugin_fusioninventory_wizard']['credentialips_id']."\"%'");
                  if ($nb == 1) {
                     // Delete iprange
                     $pfCredentialIp = new PluginFusioninventoryCredentialIp();
                     $pfCredentialIp->delete(array('id' => $_SESSION['plugin_fusioninventory_wizard']['credentialips_id']));
                  }
                  $pfTask = new PluginFusioninventoryTask();
                  $pfTask->delete(array('id'=>$_SESSION['plugin_fusioninventory_wizard']['tasks_id']));
              }
              $url = $_SERVER['PHP_SELF']."?wizz=w_start";
              $url = str_replace("wizard.form.php", "wizard.php", $url);
              Html::redirect($url);
              break;
           
           case 'finish':
              $url = $_SERVER['PHP_SELF']."?wizz=w_start";
              $url = str_replace("wizard.form.php", "wizard.php", $url);
              Html::redirect($url);
              break;
           
           case 'runagain':

              break;
            
         }         
      }      
      if (isset($_POST['iprange'])
              AND count($_POST['iprange'] > 0)) {
         $ipranges_id = current($_POST['iprange']);
         if ($ipranges_id == '-1') {
            $pfIPRange = new PluginFusioninventoryIPRange();
            if ($pfIPRange->checkip($_POST)) {
               $_POST['ip_start']  = $_POST['ip_start0'].".".$_POST['ip_start1'].".";
               $_POST['ip_start'] .= $_POST['ip_start2'].".".$_POST['ip_start3'];
               $_POST['ip_end']    = $_POST['ip_end0'].".".$_POST['ip_end1'].".";
               $_POST['ip_end']   .= $_POST['ip_end2'].".".$_POST['ip_end3'];
               $ipranges_id = $pfIPRange->add($_POST);
            } else {
               $ipranges_id = 0;
            }
         }
         if (!(isset($_SESSION['plugin_fusioninventory_wizard'])
                 AND isset($_SESSION['plugin_fusioninventory_wizard']['ipranges_id'])
                 AND $_SESSION['plugin_fusioninventory_wizard']['ipranges_id'] == $ipranges_id)) {
            if (isset($_SESSION['plugin_fusioninventory_wizard']['tasks_id'])) {
               unset($_SESSION['plugin_fusioninventory_wizard']['tasks_id']);
            }
         }
         if (isset($_SESSION["plugin_fusioninventory_forcerun"])) {
            unset($_SESSION["plugin_fusioninventory_forcerun"]);
         }
         $_SESSION['plugin_fusioninventory_wizard']['ipranges_id'] = $ipranges_id;
      }
      
      if (isset($_POST['credentialip'])
              AND count($_POST['credentialip'] > 0)) {
         $credentialips_id = current($_POST['credentialip']);
         $pfCredential = new PluginFusioninventoryCredential();
         $pfCredentialIp = new PluginFusioninventoryCredentialIp();
         if ($credentialips_id == '-1') {
            if (!isset($_POST['credential'])
                    OR (isset($_POST['credential'])
                            AND count($_POST['credential']) == '0')) {
               
               Html::redirect($_SERVER['HTTP_REFERER']);
            }
            $credentials_id = current($_POST['credential']);
            if ($credentials_id == '-1') {
               $input = array();
               $input['name'] = $_POST['name'];
               $input['username'] = $_POST['username'];
               $input['password'] = $_<PASSWORD>['password'];
               $input['itemtype'] = 'PluginFusinvinventoryVmwareESX';
               $credentials_id = $pfCredential->add($input);
            }
            $input = array();
            $input['name'] = $_POST['cipname'];
            $input['plugin_fusioninventory_credentials_id'] = $credentials_id;
            $input['ip']  = $_POST['ip0'].".".$_POST['ip1'].".";
            $input['ip'] .= $_POST['ip2'].".".$_POST['ip3'];
            $credentialips_id = $pfCredentialIp->add($input);
         }
         if (!(isset($_SESSION['plugin_fusioninventory_wizard'])
                 AND isset($_SESSION['plugin_fusioninventory_wizard']['credentialips_id'])
                 AND $_SESSION['plugin_fusioninventory_wizard']['credentialips_id'] == $credentialips_id)) {
            if (isset($_SESSION['plugin_fusioninventory_wizard']['tasks_id'])) {
               unset($_SESSION['plugin_fusioninventory_wizard']['tasks_id']);
            }
         }
         if (isset($_SESSION["plugin_fusioninventory_forcerun"])) {
            unset($_SESSION["plugin_fusioninventory_forcerun"]);
         }
         $_SESSION['plugin_fusioninventory_wizard']['credentialips_id'] = $credentialips_id;
      }
      $url = $_SERVER['PHP_SELF']."?wizz=".$_POST['nexturl'];
      $url = str_replace("wizard.form.php", "wizard.php", $url);
      Html::redirect($url);
   } else {
      $a_split = explode("?", $_SERVER['HTTP_REFERER']);
      $a_vars = explode("&", $a_split[1]);
      foreach($a_vars as $vars) {
         $endsplit = explode("=", $vars);
         $_GET[$endsplit[0]] = $endsplit[1];<commit_msg>Fix problem on the wizzard (Undefined index: nexturl). Thanks to wbunaarf for report the problem<commit_after><?php

/*
   ------------------------------------------------------------------------
   FusionInventory
   Copyright (C) 2010-2012 by the FusionInventory Development Team.

   http://www.fusioninventory.org/   http://forge.fusioninventory.org/
   ------------------------------------------------------------------------

   LICENSE

   This file is part of FusionInventory project.

   FusionInventory is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   FusionInventory is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with Behaviors. If not, see <http://www.gnu.org/licenses/>.

   ------------------------------------------------------------------------

   @package   FusionInventory
   @author    <NAME>
   @co-author 
   @copyright Copyright (c) 2010-2012 FusionInventory team
   @license   AGPL License 3.0 or (at your option) any later version
              http://www.gnu.org/licenses/agpl-3.0-standalone.html
   @link      http://www.fusioninventory.org/
   @link      http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
   @since     2010
 
   ------------------------------------------------------------------------
 */

if (!defined('GLPI_ROOT')) {
   define('GLPI_ROOT', '../../..');
}

require_once GLPI_ROOT."/inc/includes.php";

Session::checkLoginUser();
// ** Used for rules in the wizard

if (!isset($_GET['wizz'])) {
   if (isset($_POST)) {
      if (isset($_POST['endtask'])) {
         $action = current($_POST['endtask']);
         switch ($action) {
            
            case 'finishdelete':
               if (isset($_SESSION['plugin_fusioninventory_wizard']['ipranges_id'])) {
                  $nb = countElementsInTable("glpi_plugin_fusioninventory_taskjobs", 
                          "`definition` LIKE '%\"PluginFusioninventoryIPRange\":\"".$_SESSION['plugin_fusioninventory_wizard']['ipranges_id']."\"%'");
                  if ($nb == 1) {
                     // Delete iprange
                     $pfIPRange = new PluginFusioninventoryIPRange();
                     $pfIPRange->delete(array('id' => $_SESSION['plugin_fusioninventory_wizard']['ipranges_id']));
                  }
                  $pfTask = new PluginFusioninventoryTask();
                  $pfTask->delete(array('id'=>$_SESSION['plugin_fusioninventory_wizard']['tasks_id']));
              }
              if (isset($_SESSION['plugin_fusioninventory_wizard']['credentialips_id'])) {
                  $nb = countElementsInTable("glpi_plugin_fusioninventory_taskjobs", 
                          "`definition` LIKE '%\"PluginFusioninventoryCredentialIp\":\"".$_SESSION['plugin_fusioninventory_wizard']['credentialips_id']."\"%'");
                  if ($nb == 1) {
                     // Delete iprange
                     $pfCredentialIp = new PluginFusioninventoryCredentialIp();
                     $pfCredentialIp->delete(array('id' => $_SESSION['plugin_fusioninventory_wizard']['credentialips_id']));
                  }
                  $pfTask = new PluginFusioninventoryTask();
                  $pfTask->delete(array('id'=>$_SESSION['plugin_fusioninventory_wizard']['tasks_id']));
              }
              $url = $_SERVER['PHP_SELF']."?wizz=w_start";
              $url = str_replace("wizard.form.php", "wizard.php", $url);
              Html::redirect($url);
              break;
           
           case 'finish':
              $url = $_SERVER['PHP_SELF']."?wizz=w_start";
              $url = str_replace("wizard.form.php", "wizard.php", $url);
              Html::redirect($url);
              break;
           
           case 'runagain':

              break;
            
         }         
      }      
      if (isset($_POST['iprange'])
              AND count($_POST['iprange'] > 0)) {
         $ipranges_id = current($_POST['iprange']);
         if ($ipranges_id == '-1') {
            $pfIPRange = new PluginFusioninventoryIPRange();
            if ($pfIPRange->checkip($_POST)) {
               $_POST['ip_start']  = $_POST['ip_start0'].".".$_POST['ip_start1'].".";
               $_POST['ip_start'] .= $_POST['ip_start2'].".".$_POST['ip_start3'];
               $_POST['ip_end']    = $_POST['ip_end0'].".".$_POST['ip_end1'].".";
               $_POST['ip_end']   .= $_POST['ip_end2'].".".$_POST['ip_end3'];
               $ipranges_id = $pfIPRange->add($_POST);
            } else {
               $ipranges_id = 0;
            }
         }
         if (!(isset($_SESSION['plugin_fusioninventory_wizard'])
                 AND isset($_SESSION['plugin_fusioninventory_wizard']['ipranges_id'])
                 AND $_SESSION['plugin_fusioninventory_wizard']['ipranges_id'] == $ipranges_id)) {
            if (isset($_SESSION['plugin_fusioninventory_wizard']['tasks_id'])) {
               unset($_SESSION['plugin_fusioninventory_wizard']['tasks_id']);
            }
         }
         if (isset($_SESSION["plugin_fusioninventory_forcerun"])) {
            unset($_SESSION["plugin_fusioninventory_forcerun"]);
         }
         $_SESSION['plugin_fusioninventory_wizard']['ipranges_id'] = $ipranges_id;
      }
      
      if (isset($_POST['credentialip'])
              AND count($_POST['credentialip'] > 0)) {
         $credentialips_id = current($_POST['credentialip']);
         $pfCredential = new PluginFusioninventoryCredential();
         $pfCredentialIp = new PluginFusioninventoryCredentialIp();
         if ($credentialips_id == '-1') {
            if (!isset($_POST['credential'])
                    OR (isset($_POST['credential'])
                            AND count($_POST['credential']) == '0')) {
               
               Html::redirect($_SERVER['HTTP_REFERER']);
            }
            $credentials_id = current($_POST['credential']);
            if ($credentials_id == '-1') {
               $input = array();
               $input['name'] = $_POST['name'];
               $input['username'] = $_POST['username'];
               $input['password'] = $_POST['password'];
               $input['itemtype'] = 'PluginFusinvinventoryVmwareESX';
               $credentials_id = $pfCredential->add($input);
            }
            $input = array();
            $input['name'] = $_POST['cipname'];
            $input['plugin_fusioninventory_credentials_id'] = $credentials_id;
            $input['ip']  = $_POST['ip0'].".".$_POST['ip1'].".";
            $input['ip'] .= $_POST['ip2'].".".$_POST['ip3'];
            $credentialips_id = $pfCredentialIp->add($input);
         }
         if (!(isset($_SESSION['plugin_fusioninventory_wizard'])
                 AND isset($_SESSION['plugin_fusioninventory_wizard']['credentialips_id'])
                 AND $_SESSION['plugin_fusioninventory_wizard']['credentialips_id'] == $credentialips_id)) {
            if (isset($_SESSION['plugin_fusioninventory_wizard']['tasks_id'])) {
               unset($_SESSION['plugin_fusioninventory_wizard']['tasks_id']);
            }
         }
         if (isset($_SESSION["plugin_fusioninventory_forcerun"])) {
            unset($_SESSION["plugin_fusioninventory_forcerun"]);
         }
         $_SESSION['plugin_fusioninventory_wizard']['credentialips_id'] = $credentialips_id;
      }
      if (isset($_POST['nexturl'])) {
         $url = $_SERVER['PHP_SELF']."?wizz=".$_POST['nexturl'];
         $url = str_replace("wizard.form.php", "wizard.php", $url);
      } else {
         $url = $_SERVER['PHP_SELF'];
      }
      Html::redirect($url);
   } else {
      $a_split = explode("?", $_SERVER['HTTP_REFERER']);
      $a_vars = explode("&", $a_split[1]);
      foreach($a_vars as $vars) {
         $endsplit = explode("=", $vars);
         $_GET[$endsplit[0]] = $endsplit[1];
{'fraction_non_alphanumeric': 0.183007740508662, 'fraction_numerical': 0.00602039562599828, 'mean_word_length': 2.072089073410077, 'pattern_counts': {'":': 4, '<': 10, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6871895', 'n_tokens_mistral': 4674, 'n_tokens_neox': 4457, 'n_words': 754}