Projet

Général

Profil

Révision 7074cc57

Voir les différences:

plugins/anet_migration/front/plugin_anet_migration.config.form.php
1
<?php
2

  
3
//Création automatique des 2000 packs dans la base de données
4

  
5
if(!defined('GLPI_ROOT')){
6
  define('GLPI_ROOT', '../../..'); 
7
}
8
include_once (GLPI_ROOT . "/inc/includes.php");
9

  
10
checkRight("config","w");
11

  
12
commonHeader("anet_migration",$_SERVER['PHP_SELF'],"config","plugins");
13

  
14
/*
15
// Pour le jour où on aura un réel développement GLPI ... en attendant je fais un appel
16
// brutal au fichier ...
17

  
18
echo "<div align='center'>";
19
echo "<form method='post' action=\"./plugin_aner-migration.config.php\">";
20
echo "<table class='tab_cadre' cellpadding='5'>";
21
echo "<tr><th colspan=\"2\">Configuration anet-migration</th></tr>";
22
if (haveRight("config","w")){
23
	echo "<tr><td>Nombre de packs</td><td><input type=\"text\" name=\"nombre\" value=\"2000\"></td></tr>";
24
	echo "<tr><td>Racine</td><td><input type=\"text\" name=\"nombre\" value=\"ENR\"></td></tr>";
25
	echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\"></td></tr>";
26
}
27
echo "</table></div>";
28
*/
29

  
30
print "<p>Editez le fichier plugin_anet_migration.config.form.php et retournez sur cette page pour créer automatiquement 2000 packs</p>";
31
print "<p>Voyez ça avec Éric !</p>";
32
//On fait ça a la main pour l'instant
33
/*
34
global $DB;
35
$nb_packs = 2000;
36
$prefix = "ENR09-01-";
37
for($i = 0; $i < $nb_packs; $i++) {
38
  srand();
39
  $code=$prefix . rand(1000,9999) . "-" . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . "-" . rand(1000,9999);
40
  $password=rand(1000,9999) . "-" . rand(1000,9999);
41
  $query="INSERT into glpi_plugin_anet_migration values('','','','2011-12-31','$code','$password',0,0,0,0);";
42
  //print "<p>" . $query . "</p>";
43
  //exit;
44
  $DB->query($query);// or die($DB->error());
45
}
46
*/
47

  
48
commonFooter();
49
?>
50

  
plugins/anet_migration/front/plugin_anet_migration.etapes.php
1
<?php
2
/*******
3
*
4
* migration: collecte des données et envoi par email en attendant
5
* de générer un rapport PDF/OOO
6
*
7
*******/
8
//recup les stats aussi
9

  
10
if(!defined('GLPI_ROOT')){
11
  define('GLPI_ROOT', '../../..');
12
}
13
include_once (GLPI_ROOT . "/inc/includes.php");
14

  
15
$cmd = "bzip2 -dc " . $_FILES['file']['tmp_name'] . " | head -n50";
16
$ANET                      = $_POST['ANET'];
17
$EPACK                     = $_POST['EPACK'];
18
$MESSAGE                   = $_POST['MESSAGE'];
19
$ECOLE                     = $_POST['ECOLE'];
20
$ETAPE                     = $_POST['ETAPE'];
21
$INSTALLATION_NAME         = $_POST['INSTALLATION_NAME'];
22
if($ETAPE == "end") {
23
  $LOG                       = `$cmd`;
24
}
25
$IPADDR                    = $_SERVER['REMOTE_ADDR'];
26

  
27
if($INSTALLATION_NAME != "") {
28
  if($ETAPE == "prerestaure") {
29
    $subject = "[migration] AbulEdu Début de migration : " . $INSTALLATION_NAME;
30
    $mail_body = "
31

  
32
Site:        " . $INSTALLATION_NAME . "
33
Ecole:       " . $ECOLE . "
34
Compte ANET: " . $ANET . "
35

  
36
Etape: Lancement de la migration ...
37

  
38
--
39
Script de collecte de migration ...
40
https://anet.ryxeo.com/migration.php
41
";
42
    
43
  }
44
  else if($ETAPE == "end") {
45
    $subject = "[migration] AbulEdu Rapport : " . $INSTALLATION_NAME;
46
    $mail_body = "
47

  
48
Site:        " . $INSTALLATION_NAME . "
49
Ecole:       " . $ECOLE . "
50
Compte ANET: " . $ANET . "
51
Log de la migration:\n\n" . $LOG . "
52

  
53
--
54
Script de collecte de migration ...
55
https://secure.ryxeo.com/glpi/plugins/anet_migration/front/plugin_anet_migration.etapes.php
56
";
57
 }
58

  
59

  
60
  //insersion dans la base GLPI / plugin_migration
61
  global $DB;
62
  $query = "SELECT id FROM glpi_plugin_anet_epacks WHERE code='" . $EPACK . "'";
63
  $result = $DB->query($query);
64
  if($result) {
65
    $data=$DB->fetch_array($result);
66
    $epackid=$data['id'];
67

  
68
    $query2 = "INSERT INTO glpi_plugin_anet_migration(etape,FK_epack,message) VALUES('" . $ETAPE . "','" . $epackid . "','" . $MESSAGE . "')";
69
    $result2 = $DB->query($query2);
70
  }
71
  //@mail("abuledu.installation@ryxeo.com", "[migration] AbulEdu ... (" . $INSTALLATION_NAME . ")", $mail_body);
72

  
73
  if($subject != "") {
74

  
75
    include('Mail.php');
76
    include('Mail/mime.php');
77
    //$text = $mail_body;
78
    $html = "<html>
79
<head>
80
  <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"> 
81
</head>
82
<body>
83
  <pre>" . $mail_body . "</pre>
84
</body>
85
</html>\n";
86
    $file = $_FILES['file']['tmp_name'];
87
    $filename = $_FILES['file']['name'];
88
    $crlf = "\n";
89
    $hdrs = array( 'From' => 'supportteam@ryxeo.com',
90
		   'Subject' => $subject ,
91
		   'Content-Type' => 'text/html; charset="UTF-8"'
92
		   );
93
    
94
    $mime = new Mail_mime($crlf);
95
    //$mime->setTXTBody($text);
96
    $mime->setHTMLBody($html);
97
    $mime->addAttachment($file, 'application/octet-stream', $filename);
98
    $body = $mime->get(array('text_charset' => 'utf-8', 'html_charset' => 'utf-8'));
99
    $hdrs = $mime->headers($hdrs);
100
    $mail =& Mail::factory('mail');
101
    $mail->send('supportteam@ryxeo.com', $hdrs, $body);
102
    
103
    
104
    //SMS de confirmation
105
    $sms_message = urlencode("Fin de la migration de $ECOLE ($INSTALLATION_NAME).");
106
    $dest = urlencode($ANET);
107
    $url = "https://secure.ryxeo.com/glpi/plugins/anet_epacks/front/plugin_sms_send.php?dest=$dest&message=$sms_message";
108
    readfile($url);
109
  }
110
}
111

  
112
?>
plugins/anet_migration/front/plugin_anet_migration.index.php
1
<?php
2

  
3
if(!defined('GLPI_ROOT')){
4
  define('GLPI_ROOT', '../../..');
5
}
6
include_once (GLPI_ROOT . "/inc/includes.php");
7

  
8
commonHeader("anet_migration",$_SERVER['PHP_SELF'],"config","plugins");
9

  
10
$glpiid = $_SESSION['glpiID'];
11

  
12
print "<h1>Liste des migrations de serveurs</h1>";
13

  
14
function local_make_array_header() {
15
  return   "<table style=\"width:100%; padding: 0 10px 0 10px;\">
16
<tr class='tab_bg_2'>
17
  <th>Nom / epack</th>
18
  <th>Date</th>
19
  <th>Étape</th>
20
  <th>Message</th>
21
</tr>\n";
22

  
23
}
24

  
25
function local_make_array_footer() {
26
  $s .= "</table>";
27
  return $s;
28
}
29

  
30

  
31
commonHeader("AbulEdu.NET -- Tableau récapitulatif -- Accueil RyXéo",$_SERVER['PHP_SELF'],"config","plugins");
32

  
33
$glpiid = $_SESSION['glpiID'];
34

  
35
global $DB;
36

  
37
$query = "SELECT glpi_profiles.name AS name,glpi_users_profiles.FK_entities as FK_entities FROM glpi_profiles,glpi_users_profiles,glpi_users WHERE glpi_users_profiles.FK_users='" . $glpiid . "' AND glpi_users_profiles.FK_profiles=glpi_profiles.ID GROUP BY FK_entities";
38

  
39
//print $query;
40
//exit;
41

  
42
$tab_deja_affiche         = array();
43
$num_debut_ligne_maint    = 0;
44
$num_debut_ligne_horsmaint = 0;
45

  
46
$result = $DB->query($query);
47
if($result) {
48
  
49
  print local_make_array_header();
50

  
51
  $query2 = "SELECT m.*,e.code FROM glpi_plugin_anet_migration as m
52
LEFT JOIN glpi_plugin_anet_epacks as e ON e.id=FK_epack
53
GROUP BY FK_epack,etape
54
ORDER BY ladate,etape";
55
  $result2 = $DB->query($query2);
56
  for($i = 0; $i < $DB->numrows($result2); $i++) {
57
    $data2=$DB->fetch_array($result2);
58
    print "<tr>
59
 <td>" . $data2['code'] . "</td>
60
 <td>" . $data2['ladate'] . "</td>
61
 <td align=\"left\">" . $data2['etape'] . "</td>
62
 <td>" . $data2['message'] . "</td>
63
</tr>\n";
64
  }
65
  print local_make_array_footer();
66
  
67
  commonFooter();
68
  exit;
69
 }
70

  
71

  
72
?>
plugins/anet_migration/index.php
1
<?php
2

  
3
define('GLPI_ROOT', '../..');
4
include (GLPI_ROOT."/inc/includes.php");
5

  
6
glpi_header("front/plugin_anet_migration.index.php");
7

  
8
commonFooter();
9
?>
plugins/anet_migration/ryxeo.php
1
<?php
2

  
3
// ---------------------------------------------
4
// On vire les espaces ponctuations etc.
5
// agressif = 0 on est gentil - on ne fait rien
6
//          = 1 on vire les accents + tout en minuscules
7
//          = 2 on vire aussi les tirets et espaces (login / pass)
8
function anti_speciaux($t) {
9
  if(trim($t) == "")
10
  return ;
11
  $texte = strtolower($t);
12
  $texte = str_replace(" ","",$texte);
13
  $texte = str_replace("?","",$texte);
14
  $texte = str_replace("\\","",$texte);
15
  $texte = str_replace("/","",$texte);
16
  $texte = str_replace("-","",$texte);
17
  $texte = str_replace("_","",$texte);
18
  $texte = str_replace("'","",$texte);
19
  $texte = str_replace('"',"",$texte);
20
  $texte = remove_accents($texte);
21
  return $texte;
22
}
23

  
24

  
25
/**
26
 * Code from wordpress - wordpress.org
27
 * Converts all accent characters to ASCII characters.
28
 *
29
 * If there are no accent characters, then the string given is just returned.
30
 *
31
 * @since 1.2.1
32
 *
33
 * @param string $string Text that might have accent characters
34
 * @return string Filtered string with replaced "nice" characters.
35
 */
36
function remove_accents($string) {
37
	if ( !preg_match('/[\x80-\xff]/', $string) )
38
		return $string;
39

  
40
	if (seems_utf8($string)) {
41
		$chars = array(
42
		// Decompositions for Latin-1 Supplement
43
		chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
44
		chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
45
		chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
46
		chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
47
		chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
48
		chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
49
		chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
50
		chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
51
		chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
52
		chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
53
		chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
54
		chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
55
		chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
56
		chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
57
		chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
58
		chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
59
		chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
60
		chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
61
		chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
62
		chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
63
		chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
64
		chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
65
		chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
66
		chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
67
		chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
68
		chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
69
		chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
70
		chr(195).chr(191) => 'y',
71
		// Decompositions for Latin Extended-A
72
		chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
73
		chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
74
		chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
75
		chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
76
		chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
77
		chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
78
		chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
79
		chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
80
		chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
81
		chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
82
		chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
83
		chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
84
		chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
85
		chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
86
		chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
87
		chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
88
		chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
89
		chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
90
		chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
91
		chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
92
		chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
93
		chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
94
		chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
95
		chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
96
		chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
97
		chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
98
		chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
99
		chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
100
		chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
101
		chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
102
		chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
103
		chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
104
		chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
105
		chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
106
		chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
107
		chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
108
		chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
109
		chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
110
		chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
111
		chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
112
		chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
113
		chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
114
		chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
115
		chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
116
		chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
117
		chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
118
		chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
119
		chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
120
		chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
121
		chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
122
		chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
123
		chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
124
		chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
125
		chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
126
		chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
127
		chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
128
		chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
129
		chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
130
		chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
131
		chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
132
		chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
133
		chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
134
		chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
135
		chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
136
		// Euro Sign
137
		chr(226).chr(130).chr(172) => 'E',
138
		// GBP (Pound) Sign
139
		chr(194).chr(163) => '');
140

  
141
		$string = strtr($string, $chars);
142
	} else {
143
		// Assume ISO-8859-1 if not UTF-8
144
		$chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
145
			.chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
146
			.chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
147
			.chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
148
			.chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
149
			.chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
150
			.chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
151
			.chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
152
			.chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
153
			.chr(252).chr(253).chr(255);
154

  
155
		$chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
156

  
157
		$string = strtr($string, $chars['in'], $chars['out']);
158
		$double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
159
		$double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
160
		$string = str_replace($double_chars['in'], $double_chars['out'], $string);
161
	}
162

  
163
	return $string;
164
}
165

  
166
?>
plugins/anet_migration/setup.php
1
<?php
2
//anet_migration plugin
3
function plugin_init_anet_migration() {
4
  global $PLUGIN_HOOKS,$CFG_GLPI;
5

  
6

  
7
  $PLUGIN_HOOKS['menu_entry']['anet_migration'] = true;
8
  $PLUGIN_HOOKS['submenu_entry']['anet_migration']['search'] = 'front/plugin_anet_migration.view.php';
9
  $PLUGIN_HOOKS['submenu_entry']['anet_migration']['showall'] = 'front/plugin_anet_migration.view.php';
10
  $PLUGIN_HOOKS['submenu_entry']['anet_migration']['summary'] = 'front/plugin_anet_migration.view.php';
11
  $PLUGIN_HOOKS['submenu_entry']['anet_migration']['config'] = 'front/plugin_anet_migration.config.form.php';
12

  
13
  $PLUGIN_HOOKS['config_page']['anet_migration'] = 'front/plugin_anet_migration.config.form.php';
14

  
15
}
16

  
17
function plugin_version_anet_migration() {
18
  return array ('name' => "anet_migration", 
19
		'minGlpiVersion' => '0.71', 
20
		'maxGlpiVersion' => '0.71.9', 
21
		'version' => '11.07');
22
}
23

  
24
?>

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux