ryxeo-glpi-git / scripts / migration_gnudip_anet_to_glpi.php @ 4ce9f9ca
Historique | Voir | Annoter | Télécharger (2,75 ko)
1 | 4ce9f9ca | Eric Seigne | #!/usr/bin/php -q |
---|---|---|---|
2 | <?php
|
||
3 | /** **************************************************************************
|
||
4 | * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or modify
|
||
7 | * it under the terms of the GNU General Public License as published by
|
||
8 | * the Free Software Foundation; either version 2 of the License.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
18 | * ***************************************************************************
|
||
19 | * File : net2dip.sendtohurlevent
|
||
20 | * Author : Eric SEIGNE
|
||
21 | * mailto:eric.seigne@ryxeo.com
|
||
22 | * http://www.ryxeo.com/
|
||
23 | * Date : 12/06/2004
|
||
24 | * Licence : GNU/GPL Version 2
|
||
25 | *
|
||
26 | * Description:
|
||
27 | * ------------
|
||
28 | *
|
||
29 | * @version $Id: net2dip.sendtohurlevent,v 1.5 2004/12/09 11:31:49 erics Exp $
|
||
30 | * @author Eric Seigne
|
||
31 | * @project
|
||
32 | * @copyright Eric Seigne 12/06/2004
|
||
33 | *
|
||
34 | * Passe de .NET GnuDIP les infos ncessaires pour que le serveur GnuDIP
|
||
35 | * puisse faire son travail
|
||
36 | *
|
||
37 | * ************************************************************************* */
|
||
38 | |||
39 | $base_dir = dirname(__FILE__); |
||
40 | $text = ""; |
||
41 | |||
42 | require_once "$base_dir/config/config.php"; |
||
43 | require_once "$base_dir/libraries/fonctions.php"; |
||
44 | |||
45 | $req = "SELECT dns_alias0, gnudip_pass, dns_alias1 " . |
||
46 | "FROM gnudip " .
|
||
47 | "WHERE 1;";
|
||
48 | $res = sql_exec($req); |
||
49 | |||
50 | //Migration anet -> glpi pour gnudip2
|
||
51 | $nb = $res->NumRows(); |
||
52 | for ( $i = 0; $i < $nb; $i++) { |
||
53 | $row = $res->fetchrow( DB_FETCHMODE_ASSOC, $i ); |
||
54 | //Il nous faut le FK_serveur et le FK_enduser
|
||
55 | $query = "SELECT ID,FK_entities FROM glpi_computers WHERE os_license_number='" . $row['dns_alias0'] . ".dip.abuledu.net';"; |
||
56 | if ( DB::isError($result = $dbglpi->query($query)) ) { |
||
57 | die ("***\n$query\n" . DB::errorMessage($result) . "\n***\n\n"); |
||
58 | } |
||
59 | $data = $result->fetchRow(DB_FETCHMODE_ASSOC); |
||
60 | |||
61 | if($data['ID']) { |
||
62 | |||
63 | $query2 = "INSERT INTO glpi_plugin_anet_epacks(creation_date,activation_date,expiration_date,code,password,FK_serveur,FK_enduser) |
||
64 | VALUES(
|
||
65 | '2009-07-01',
|
||
66 | '2009-07-01',
|
||
67 | '2009-07-01',
|
||
68 | 'ABE08-01-$i',
|
||
69 | '" . $row['gnudip_pass'] . "', |
||
70 | '" . $data['ID'] . "', |
||
71 | '" . $data['FK_entities'] . "' |
||
72 | );";
|
||
73 | //$res = $dbglpi->query($query2);
|
||
74 | if ( DB::isError($result2 = $dbglpi->query($query2)) ) { |
||
75 | print ("***\n$query2\n" . DB::errorMessage($result2) . "\n***\n\n"); |
||
76 | } |
||
77 | } |
||
78 | else
|
||
79 | print "impossible pour " . $row['dns_alias0'] . "\n"; |
||
80 | |||
81 | } |
||
82 | ?> |