"Fossies" - the Fresh Open Source Software Archive

Member "OCSNG_UNIX_SERVER_2.6/ocsreports/require/function_dico.php" (17 Apr 2019, 4544 Bytes) of package /linux/privat/OCSNG_UNIX_SERVER_2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 /*
    3  * Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
    4  * See the Contributors file for more details about them.
    5  *
    6  * This file is part of OCSInventory-NG/OCSInventory-ocsreports.
    7  *
    8  * OCSInventory-NG/OCSInventory-ocsreports is free software: you can redistribute
    9  * it and/or modify it under the terms of the GNU General Public License as
   10  * published by the Free Software Foundation, either version 2 of the License,
   11  * or (at your option) any later version.
   12  *
   13  * OCSInventory-NG/OCSInventory-ocsreports is distributed in the hope that it
   14  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16  * GNU General Public License for more details.
   17  *
   18  * You should have received a copy of the GNU General Public License
   19  * along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
   20  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   21  * MA 02110-1301, USA.
   22  */
   23 
   24 function search_all_item() {
   25     $result_search_soft = mysqli_query($_SESSION['OCS']["readServer"], $_SESSION['OCS']['query_dico']);
   26     while ($item_search_soft = mysqli_fetch_object($result_search_soft)) {
   27         $list[] = $item_search_soft->ID;
   28     }
   29     return $list;
   30 }
   31 
   32 function del_soft($onglet, $list_soft) {
   33     if ($_SESSION['OCS']['usecache']) {
   34         $table = "softwares_name_cache";
   35     } else {
   36         $table = "softwares";
   37     }
   38 
   39     $sql_soft_name = "select distinct NAME from " . $table . " where ID in (" . implode(",", $list_soft) . ")";
   40     $result_soft_name = mysqli_query($_SESSION['OCS']["readServer"], $sql_soft_name);
   41     while ($item_soft_name = mysqli_fetch_object($result_soft_name)) {
   42         $list_soft_name[] = str_replace('"', '\"', $item_soft_name->NAME);
   43     }
   44     if ($onglet == "CAT" || $onglet == "UNCHANGED") {
   45         $sql_delete = "delete from dico_soft where extracted in (\"" . implode("\",\"", $list_soft_name) . "\")";
   46     }
   47     if ($onglet == "IGNORED") {
   48         $sql_delete = "delete from dico_ignored where extracted in (\"" . implode("\",\"", $list_soft_name) . "\")";
   49     }
   50     mysqli_query($_SESSION['OCS']["writeServer"], $sql_delete);
   51 }
   52 
   53 function trans($onglet, $list_soft, $affect_type, $new_cat, $exist_cat) {
   54     global $l;
   55     
   56     // If new cat and exist cat are empty return
   57     if($new_cat == '' and $exist_cat == ''){
   58         return ;
   59     }
   60     
   61     if ($_SESSION['OCS']['usecache']) {
   62         $table = "softwares_name_cache";
   63     } else {
   64         $table = "softwares";
   65     }
   66     
   67     //verif is this cat exist
   68     if ($new_cat != '') {
   69         $sql_verif = "select extracted from dico_soft where formatted ='" . mysqli_real_escape_string($_SESSION['OCS']["readServer"], $new_cat) . "'";
   70         $result_search_soft = mysqli_query($_SESSION['OCS']["readServer"], $sql_verif);
   71         $item_search_soft = mysqli_fetch_object($result_search_soft);
   72         if (isset($item_search_soft->extracted) || $new_cat == "IGNORED" || $new_cat == "UNCHANGED") {
   73             $already_exist = true;
   74         }
   75     }
   76 
   77     if ($onglet == "NEW") {
   78         $table = "softwares";
   79         $ok = true;
   80     } else {
   81         if (!isset($already_exist)) {
   82             del_soft($onglet, $list_soft);
   83         }
   84         $ok = true;
   85     }
   86 
   87     if ($ok == true) {
   88         if ($affect_type == "EXIST_CAT") {
   89             if ($exist_cat == "IGNORED") {
   90                 $sql = "insert dico_ignored (extracted) select distinct NAME from " . $table . " where ID in (" . implode(",", $list_soft) . ")";
   91             } elseif ($exist_cat == "UNCHANGED") {
   92                 $sql = "insert dico_soft (extracted,formatted) select distinct NAME,NAME from " . $table . " where ID in (" . implode(",", $list_soft) . ")";
   93             } else {
   94                 $sql = "insert dico_soft (extracted,formatted) select distinct NAME,'" . mysqli_real_escape_string($_SESSION['OCS']["readServer"], $exist_cat) . "' from " . $table . " where ID in (" . implode(",", $list_soft) . ")";
   95             }
   96         } else {
   97             if (!isset($already_exist)) {
   98                 $sql = "insert dico_soft (extracted,formatted) select distinct NAME,'" . mysqli_real_escape_string($_SESSION['OCS']["readServer"], $new_cat) . "' from " . $table . " where ID in (" . implode(",", $list_soft) . ")";
   99             } else {
  100                 echo "<script>alert('" . $l->g(771) . "')</script>";
  101             }
  102         }
  103         if ($sql != '') {
  104             mysqli_query($_SESSION['OCS']["writeServer"], $sql);
  105         }
  106     }
  107 }
  108 
  109 ?>