Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / plugins / anet_migration / front / plugin_anet_migration.etapes.php @ 7074cc57

Historique | Voir | Annoter | Télécharger (3,2 ko)

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
?>
Redmine Appliance - Powered by TurnKey Linux