File: ms_server_redistrib.php

package info (click to toggle)
ocsinventory-server 2.5%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,088 kB
  • sloc: php: 27,462; perl: 8,241; sh: 1,680; sql: 1,355; xml: 1,041; makefile: 34
file content (139 lines) | stat: -rw-r--r-- 4,971 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/*
 * Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
 * See the Contributors file for more details about them.
 *
 * This file is part of OCSInventory-NG/OCSInventory-ocsreports.
 *
 * OCSInventory-NG/OCSInventory-ocsreports is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 2 of the License,
 * or (at your option) any later version.
 *
 * OCSInventory-NG/OCSInventory-ocsreports 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

/*
 * For redistribution's server
 */

//require_once('require/function_server.php');
//view of all group's machin

require_once('require/function_groups.php');
require_once('require/function_machine.php');
require_once('require/function_server.php');

// TELEDEPLOY
print_item_header($l->g(481));
show_redistrib_groups_packages($systemid);
        
show_redis_infos($systemid);

function show_redis_infos($systemid){
    
    global $protectedPost, $l;
    
    if(isset($protectedPost['SUP_PROF']) && $protectedPost['SUP_PROF'] != ""){
        remove_list_serv($systemid, $protectedPost['SUP_PROF']);
    }
    
    if($protectedPost['Valid_modif'] != ""){
        $sql_update = "update download_servers set URL='" . $protectedPost['URL'] . "' ,ADD_REP='" . $protectedPost['REP_STORE'] . "' where hardware_id=" . $protectedPost['MODIF'];
        mysqli_query($_SESSION['OCS']["writeServer"], $sql_update);
        $sql_update = "update download_enable set pack_loc='" . $protectedPost['URL'] . "' where SERVER_ID=" . $protectedPost['MODIF'];
        mysqli_query($_SESSION['OCS']["writeServer"], $sql_update);
        
        unset($protectedPost['URL']);
        unset($protectedPost['REP_STORE']);
        unset($protectedPost['MODIF']);
    }

    if (isset($systemid)) {
    
        $form_name = "srv_redis";
        $table_name = "srv_redis_table";
        $tab_options = array();
        $tab_options = $protectedPost;
        $tab_options['form_name'] = $form_name;
        $tab_options['table_name'] = $table_name;

        echo open_form($form_name, '', '', 'form-horizontal');
        
        $sql = "select d.HARDWARE_ID,
                              h.NAME,
                              h.IPADDR,
                              h.DESCRIPTION,
                              d.URL,
                              d.ADD_REP
                    from hardware h right join download_servers d on h.id=d.hardware_id
                    where d.GROUP_ID=".$systemid ;

        $list_fields=array( 
            $l->g(296) => 'HARDWARE_ID',
            $l->g(49) => 'NAME',
            $l->g(34) => 'IPADDR',
            $l->g(53) => 'DESCRIPTION',
            $l->g(646) => 'URL',
            'ADD_REP' => 'ADD_REP',
            'MODIF' => 'HARDWARE_ID',
            'SUP' => 'HARDWARE_ID'
        );
        
        $list_col_cant_del=array( 
            $l->g(49) => 'NAME',
            $l->g(34) => 'IPADDR',
            'MODIF' => 'MODIF',
            'SUP' => 'SUP'
        );
        
        $default_fields= array( 
            $l->g(49) => 'NAME',
            $l->g(34) => 'IPADDR',
            $l->g(646) => 'URL',
            'ADD_REP' => 'ADD_REP',
        );

        ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
        
        if ($protectedPost['MODIF'] != "" && !isset($protectedPost['Valid_modif']) && !isset($protectedPost['Reset_modif'])) {
        
            $sql = "select URL, ADD_REP from download_servers where HARDWARE_ID = ".$protectedPost['MODIF'] ;
            $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]);
            $redis_values = mysqli_fetch_array($result);

            echo "<div class='col col-md-8 col-md-offset-2'>";

            echo $l->g(691);
            formGroup('text', 'URL', $l->g(646), '', '', $redis_values['URL'], '', '', '', '');
            formGroup('text', 'REP_STORE', $l->g(648), '', '', $redis_values['ADD_REP'], '', '', '', '');

            echo "<input type='submit' class='btn btn-success' value=".$l->g(13).">";
            formGroup('hidden', 'Valid_modif', '', '', '', 'OK', '', '', '' ,'');
            formGroup('hidden', 'MODIF', '', '', '', $protectedPost['MODIF'], '', '', '' ,'');

            echo "</div>";
        }

        echo close_form();
        
    }

    if (AJAX){
        ob_end_clean();
        tab_req($list_fields,$default_fields,$list_col_cant_del,$sql,$tab_options);
    }
    
}



?>