ryxeo-glpi-git / htdocs / epack / register.php @ 7c12ea40
Historique | Voir | Annoter | Télécharger (29,8 ko)
1 | 1c14bcc4 | Eric Seigne | <?php
|
---|---|---|---|
2 | 7c12ea40 | root | ini_set("display_errors", 0); |
3 | ini_set("error_log","/tmp/php.log"); |
||
4 | error_reporting(E_NONE); |
||
5 | |||
6 | $log_debug = 1; //flag pour savoir s'il faut ecrire les debug logs dans le fichier de logs |
||
7 | $log_file = "/tmp/debug_anet.log"; |
||
8 | 1c14bcc4 | Eric Seigne | |
9 | 7c12ea40 | root | //AJAX CODE
|
10 | 1c14bcc4 | Eric Seigne | $commande = ""; |
11 | $message = ""; |
||
12 | e213dd82 | root | $debug = ""; |
13 | 1c14bcc4 | Eric Seigne | $send_mail = 0; //flag pour savoir s'il faut envoyer un mail (en bref a toute insertion ou update de base) |
14 | |||
15 | 7c12ea40 | root | |
16 | abd6eaaa | Eric Seigne | function make_pdf($pass,$code,$datapost) { |
17 | 7c12ea40 | root | global $message, $debug; |
18 | af8e09aa | Eric Seigne | global $login_email; |
19 | abd6eaaa | Eric Seigne | require_once('lib/odf.php'); |
20 | $odf = new odf("abuledu-base_genere_automatiquement_enregistrement_epack.odp"); |
||
21 | 7c12ea40 | root | |
22 | abd6eaaa | Eric Seigne | //1ere page
|
23 | setlocale(LC_TIME, "fr_FR.UTF-8"); |
||
24 | // $odf->setVars('date', strftime("%A %e %B %Y"));
|
||
25 | $odf->setVars('date_installation', $datapost['IDATE']); |
||
26 | $odf->setVars('date', date("d/m/Y")); |
||
27 | |||
28 | //Le epack
|
||
29 | $odf->setVars('epack_pass', $pass); |
||
30 | $odf->setVars('epack_code', $code); |
||
31 | |||
32 | //Les mots de passes
|
||
33 | $odf->setVars('pass_root', $datapost['IROOT']); |
||
34 | $odf->setVars('pass_abuladmin', $datapost['IABE']); |
||
35 | |||
36 | //L'école
|
||
37 | $odf->setVars('ecole_nom', $datapost['INAME'], true, 'UTF-8'); |
||
38 | $odf->setVars('ecole_adresse', $datapost['IADDRESS0'], true, 'UTF-8'); |
||
39 | $odf->setVars('ecole_cp', $datapost['IPOSTALCODE'], true, 'UTF-8'); |
||
40 | $odf->setVars('ecole_ville', $datapost['ICITY'], true, 'UTF-8'); |
||
41 | $odf->setVars('ecole_pays', $datapost['ICOUNTRY'], true, 'UTF-8'); |
||
42 | $odf->setVars('ecole_tel', $datapost['ITEL'], true, 'UTF-8'); |
||
43 | $odf->setVars('ecole_email', $datapost['IEMAIL'], true, 'UTF-8'); |
||
44 | |||
45 | //Le serveur
|
||
46 | $odf->setVars('srv_srv', $datapost['ISRV'], true, 'UTF-8'); |
||
47 | $odf->setVars('srv_serial', $datapost['ISERIAL'], true, 'UTF-8'); |
||
48 | $odf->setVars('srv_cpu', $datapost['CPU'], true, 'UTF-8'); |
||
49 | $odf->setVars('srv_ram', $datapost['RAM'], true, 'UTF-8'); |
||
50 | $odf->setVars('srv_hdd0', $datapost['HDD0'], true, 'UTF-8'); |
||
51 | $odf->setVars('srv_hdd1', $datapost['HDD1'], true, 'UTF-8'); |
||
52 | $odf->setVars('srv_eth0', $datapost['MAC0'], true, 'UTF-8'); |
||
53 | $odf->setVars('srv_eth1', $datapost['MAC1'], true, 'UTF-8'); |
||
54 | |||
55 | //L'admin local
|
||
56 | $odf->setVars('adm_prenom', $datapost['ADM_FIRSTNAME'], true, 'UTF-8'); |
||
57 | $odf->setVars('adm_nom', $datapost['ADM_LASTNAME'], true, 'UTF-8'); |
||
58 | $odf->setVars('adm_email', $datapost['ADM_EMAIL'], true, 'UTF-8'); |
||
59 | |||
60 | //La personne ressource
|
||
61 | $odf->setVars('pr_prenom', $datapost['PR_FIRSTNAME'], true, 'UTF-8'); |
||
62 | $odf->setVars('pr_nom', $datapost['PR_LASTNAME'], true, 'UTF-8'); |
||
63 | $odf->setVars('pr_email', $datapost['PR_EMAIL'], true, 'UTF-8'); |
||
64 | |||
65 | //L'anim TICE
|
||
66 | $odf->setVars('atice_prenom', $datapost['ATICE_FIRSTNAME'], true, 'UTF-8'); |
||
67 | $odf->setVars('atice_nom', $datapost['ATICE_LASTNAME'], true, 'UTF-8'); |
||
68 | $odf->setVars('atice_email', $datapost['ATICE_EMAIL'], true, 'UTF-8'); |
||
69 | |||
70 | //Le revendeur
|
||
71 | $odf->setVars('rvd_code', $datapost['RCODE'], true, 'UTF-8'); |
||
72 | $odf->setVars('rvd_nom', $datapost['RNAME'], true, 'UTF-8'); |
||
73 | $odf->setVars('rvd_tel', $datapost['RTEL'], true, 'UTF-8'); |
||
74 | $odf->setVars('rvd_email', $datapost['REMAIL'], true, 'UTF-8'); |
||
75 | $odf->setVars('rvd_adresse', $datapost['RADDRESS'], true, 'UTF-8'); |
||
76 | $odf->setVars('rvd_cp', $datapost['RCP'], true, 'UTF-8'); |
||
77 | $odf->setVars('rvd_ville', $datapost['RVILLE'], true, 'UTF-8'); |
||
78 | |||
79 | //On créé un fichier local pour archive ...
|
||
80 | $fichier="archives/" . date("Y-m-d") . "-epack-register-" . $code . ".odp"; |
||
81 | $fichier_pdf="archives/" . date("Y-m-d") . "-epack-register-" . $code . ".pdf"; |
||
82 | |||
83 | $odf->saveToDisk($fichier); |
||
84 | 7c12ea40 | root | $debug .= " ==> Export PDF : $fichier\n"; |
85 | abd6eaaa | Eric Seigne | $t = exec("unoconv --server localhost --port 2002 -f pdf " . $fichier); |
86 | |||
87 | //Ensuite il faut l'envoyer par email ...
|
||
88 | $txtmail = "Bonjour, |
||
89 | vous venez d'enregistrer un ePack d'installation AbulÉdu et nous vous en remercions.
|
||
90 |
|
||
91 | Vous trouverez ci-joint le document récapitulatif de votre enregistrement.
|
||
92 |
|
||
93 | --
|
||
94 | RyXéo SARL
|
||
95 | contact@ryxeo.com
|
||
96 | Tel: 05 35 54 01 18";
|
||
97 | $crlf = "\n"; |
||
98 | $hdrs = array( |
||
99 | 'From' => 'contact@ryxeo.com', |
||
100 | 'Subject' => mb_encode_mimeheader("[AbulEdu] Fiche d'installation " . $datapost['INAME']), |
||
101 | af8e09aa | Eric Seigne | 'BCC' => 'contact@ryxeo.com, supportteam@ryxeo.com' |
102 | abd6eaaa | Eric Seigne | ); |
103 | $mime = new Mail_mime($crlf); |
||
104 | $mime->setTXTBody($txtmail); |
||
105 | $mime->addAttachment($fichier_pdf, mime_content_type($fichier_pdf)); |
||
106 | b069f62c | root | $mime->addAttachment($fichier, mime_content_type($fichier)); |
107 | abd6eaaa | Eric Seigne | $body = $mime->get(array('text_charset' => 'utf-8')); |
108 | $hdrs = $mime->headers($hdrs); |
||
109 | $mail =& Mail::factory('mail'); |
||
110 | af8e09aa | Eric Seigne | |
111 | if(trim($datapost['REMAIL']) == "") { |
||
112 | if(trim($login_email) != "") { |
||
113 | $mail->send($login_email, $hdrs, $body); |
||
114 | } |
||
115 | else {
|
||
116 | //On cherche le mail associe a ce pack ?
|
||
117 | $mail->send("contact@ryxeo.com", $hdrs, $body); |
||
118 | } |
||
119 | } |
||
120 | else {
|
||
121 | $mail->send($datapost['REMAIL'], $hdrs, $body); |
||
122 | } |
||
123 | abd6eaaa | Eric Seigne | } |
124 | 6fd1e9d9 | Eric Seigne | |
125 | function send_mail_installation($pass,$code,$datapost) { |
||
126 | $mail_content = " |
||
127 |
|
||
128 | Bonjour,
|
||
129 |
|
||
130 | un nouveau serveur vient d'être inséré dans AbulÉdu.NET:
|
||
131 |
|
||
132 | Référence du ePack AbulÉdu:
|
||
133 | - $pass
|
||
134 | - $code
|
||
135 |
|
||
136 | Site de l'installation:
|
||
137 | - Nom: " . addslashes($datapost['INAME']) . " |
||
138 | - Adresse: " . addslashes($datapost['IADDRESS0'] . " " . $datapost['IADDRESS1'] ) . " |
||
139 | - Code postal: " . addslashes($datapost['IPOSTALCODE']) . " |
||
140 | - Ville: " . addslashes($datapost['ICITY']) . " |
||
141 | - Pays: " . addslashes($datapost['ICOUNTRY']) . " |
||
142 | - Téléphone: " . addslashes($datapost['ITEL']) . " |
||
143 | - Adresse email: " . addslashes($datapost['IEMAIL']) . " |
||
144 |
|
||
145 | Serveur:
|
||
146 | - Marque ou modèle: " . $datapost['ISRV'] . " |
||
147 | - Numéro de série: " . $datapost['ISERIAL'] . " |
||
148 | - Processeur: " . $datapost['CPU'] . " |
||
149 | - Mémoire vive: " . $datapost['RAM'] . " |
||
150 | - Disque dur 1: " . $datapost['HDD0'] . " |
||
151 | - Disque dur 2: " . $datapost['HDD1'] . " |
||
152 | - Carte réseau 1: " . $datapost['MAC0'] . " |
||
153 | - Carte réseau 2: " . $datapost['MAC1'] . " |
||
154 | - Date d'installation: " . $datapost['IDATE'] . " |
||
155 |
|
||
156 | Mots de passe:
|
||
157 | - root: " . $datapost['IROOT'] . " |
||
158 | - abuladmin: " . $datapost['IABE'] . " |
||
159 |
|
||
160 | Installateur:
|
||
161 | - Société: " . $datapost['RCODE'] . " |
||
162 | abd6eaaa | Eric Seigne | - Adresse: " . $datapost['RADDRESS'] . " |
163 | - Ville: " . $datapost['RCP'] . " " . $datapost['RVILLE'] . " |
||
164 | 6fd1e9d9 | Eric Seigne | - Nom: " . $datapost['RNAME'] . " |
165 | - Téléphone: " . $datapost['RTEL'] . " |
||
166 | - Email: " . $datapost['REMAIL'] . " |
||
167 |
|
||
168 | Compte utilisateur:
|
||
169 | - Nom: " . $datapost['ADM_LASTNAME'] . " |
||
170 | - Prénom: " . $datapost['ADM_FIRSTNAME'] . " |
||
171 | - Email: " . $datapost['ADM_EMAIL'] . " |
||
172 |
|
||
173 | Compte personne ressource:
|
||
174 | - Nom: " . $datapost['PR_LASTNAME'] . " |
||
175 | - Prénom: " . $datapost['PR_FIRSTNAME'] . " |
||
176 | - Email: " . $datapost['PR_EMAIL'] . " |
||
177 |
|
||
178 | Compte ATICE:
|
||
179 | - Nom: " . $datapost['ATICE_LASTNAME'] . " |
||
180 | - Prénom: " . $datapost['ATICE_FIRSTNAME'] . " |
||
181 | - Email: " . $datapost['ATICE_EMAIL'] . " |
||
182 |
|
||
183 | Commentaires:
|
||
184 | " . $datapost["ICOMMENT"] . " |
||
185 |
|
||
186 | --
|
||
187 | abuledu.net est un service de RyXéo SARL, société éditrice d'AbulÉdu
|
||
188 | 7c12ea40 | root | (register.php sur abuledu.net)
|
189 | 6fd1e9d9 | Eric Seigne |
|
190 | ";
|
||
191 | abd6eaaa | Eric Seigne | |
192 | f8c1248f | Eric Seigne | if(stripos($code, "-TESTS-")) { |
193 | ryxeo_mail("anet@ryxeo.com",$mail_content,"contact@ryxeo.com","[epack de test] Nouveau serveur dans la base abuledu.net"); |
||
194 | b915f380 | Eric Seigne | make_conffiles($datapost['MAC0'],$pass,$code); |
195 | abd6eaaa | Eric Seigne | } |
196 | else {
|
||
197 | ryxeo_mail("anet@ryxeo.com",$mail_content,"contact@ryxeo.com","Nouveau serveur dans la base abuledu.net"); |
||
198 | } |
||
199 | 6fd1e9d9 | Eric Seigne | } |
200 | |||
201 | 1c14bcc4 | Eric Seigne | //Verifie si les donnees qu'on a en entree sont correctes sinon on saute ... direction webadmin/installation
|
202 | function verification_data() { |
||
203 | global $datapost; |
||
204 | global $message; |
||
205 | $error = ""; |
||
206 | b915f380 | Eric Seigne | if(trim(strtolower($datapost['MAC0'])) == "") // || trim(strtolower($datapost['MAC1'])) == "" ) |
207 | 1c14bcc4 | Eric Seigne | $error .= "<li>Il manque une carte réseau dans ce serveur !</li>"; |
208 | 7c12ea40 | root | |
209 | 1c14bcc4 | Eric Seigne | if(trim($datapost['INAME']) == "") |
210 | $error .= "<li>Erreur sur le nom de l'installation</li>"; |
||
211 | if(trim($datapost['IADDRESS0']) == "") |
||
212 | $error .= "<li>Adresse de l'installation incorrecte</li>"; |
||
213 | if(trim($datapost['IPOSTALCODE']) == "") |
||
214 | $error .= "<li>Code postal incorrect</li>"; |
||
215 | if(trim($datapost['ICITY']) == "") |
||
216 | $error .= "<li>Nom de ville incorrect</li>"; |
||
217 | if(trim($datapost['ICOUNTRY']) == "") |
||
218 | $error .= "<li>Nom du pays incorrect</li>"; |
||
219 | if(trim($datapost['ITEL']) == "") |
||
220 | $error .= "<li>Numéro de téléphone incorect</li>"; |
||
221 | if(trim($datapost['ADM_LASTNAME']) == "") |
||
222 | $error .= "<li>Nom du contact administratif incomplet</li>"; |
||
223 | if(trim($datapost['ADM_FIRSTNAME'])== "") |
||
224 | $error .= "<li>Prénom du contact administratif incomplet</li>"; |
||
225 | if(strpos($datapost['IEMAIL'],"@") == FALSE) |
||
226 | $error .= "<li>Adresse email de l'école incorrecte</li>"; |
||
227 | if(strpos($datapost['ADM_EMAIL'],"@") == FALSE) |
||
228 | $error .= "<li>Adresse email du responsable administratif incorrecte</li>"; |
||
229 | |||
230 | if($error != "") { |
||
231 | $message .= "<ul>"; |
||
232 | $message .= $error; |
||
233 | $message .= "</ul>"; |
||
234 | return false; |
||
235 | } |
||
236 | else
|
||
237 | return true; |
||
238 | |||
239 | } |
||
240 | |||
241 | b915f380 | Eric Seigne | //création des fichiers de conf sur ce nouve<au serveur
|
242 | 1c14bcc4 | Eric Seigne | //ou restauration des fichiers de conf (si réinstallation)
|
243 | function make_conffiles($login,$pass,$code) { |
||
244 | global $commande; |
||
245 | $codecrypt = md5($pass); |
||
246 | 84a3aa0e | Eric Seigne | |
247 | //Si c'est un serveur de tests on ne cree surtout pas le fichier gdipc pour eviter que apt essaye
|
||
248 | //de passer en mode authentifie, on demandera donc le login/pass rvd a chaque upgrade
|
||
249 | if(stripos($code, "-TESTS-")) { |
||
250 | $commande .= ""; |
||
251 | } |
||
252 | else {
|
||
253 | $commande .= " echo \"" . $login . ";dip.abuledu.net;http://dip.abuledu.net/gnudip/cgi-bin/gdipupdt.cgi;" . $codecrypt . ";/home/abecmd/.GnuDIP2.cache." . $login . ".dip.abuledu.net;0;2073600\" > ~abecmd/.GnuDIP2 |
||
254 | 1c14bcc4 | Eric Seigne | chmod 600 ~abecmd/.GnuDIP2
|
255 | chown abecmd:admin ~abecmd/.GnuDIP2
|
||
256 | 84a3aa0e | Eric Seigne | su - abecmd gdipc\n";
|
257 | } |
||
258 | |||
259 | $commande .= " mkdir ~abecmd/.ssh || true |
||
260 | 1c14bcc4 | Eric Seigne | echo \"ssh-dss AAAAB3NzaC1kc3MAAACBAPM3DKuDXuSsQgPeBNO/jBEAd28smHqYVAODRwshfI04/rFvwh/A+7UZ2H/QnZOn6XLS/3R4yPp/QdGKEJ0BCHDd2fLIuS6ZLDHoHdQRBFzEAXP1SE1Yyp9c1pKnWeke6oK6196yKpE2aWBRv9kma+KoPhz7mpt6KHISow+yYV/PAAAAFQDFCotxKtxherzuwzVbeXmiOGQ3EwAAAIEAq+KXzJUt13h5QvM7u0O3mbDGD6YY9avMYqFk8StJ4DoFpSfeiwvNynoDsAE2qLTje7hbs+UO4Ns1lCLhh4R4T9wdLodTRVfizvqjZhmhOGfTHUjX9qi+dTs7c0mtqZz89ZZSqJsnMb9I1Ifj0H++MOswa7qp1cFxzUYtlew128QAAACAXve21Gn+gD7GXhvLIMq7bq6/ECjcjoBQcpLF72Z3tAsd0i0Scv1eydsUiee47pr3o4fJToQAr3iFQX6zWnDaw4htg3cZAMzfuvXxuWBcDoQ2qjYAk1A/FoJM7z5pPZXnWQZ+Vq+HfsW8W7EHztVgoZ/Xj/10webHjcL8CzFGWU4= remoteabecmd@Timide
|
261 | ssh-dss AAAAB3NzaC1kc3MAAACBAIyAzv1X8Hy8r8QiJAmhlDs9INd0jCpYNk5OxBDYA1/qdmKVqVMwKACvZg8xigRBg4e5PMsgpGQf9OxHTlhIiqAjwxmi7tHAy1t1fHuqDCZmqpQG5banOPvr4R5w4q47jKAJNqRsofgZACQKo8KkSHxY5VWZNx5bOfZYdEcWcNqpAAAAFQCXElvdvY+/aILI5a1z4fKRybA7GQAAAIB+5v/foiMKyZ+JEocToPIj2fP4mH7o8xnA1T8HKUGOiutxT/TWT4OnUMmquA/XVdzOyJ/tEeznfUDvlJZzKtFoW75ftQ8Or0AJj68jGQQ3wxQW5TXKuOCoo4vdf0ZQ+ASbzY1ECdxiQEB5kWusWbpes/eyTzDzjpUjMfR2JS5+rAAAAIAksQfdasobfpGuqLIvHBpgSFyas9J6EguBQVauNyLy7IE/WmAN1zgbYvBVU7KY3WUr5pgum9GcExCfnGH/qW7zR7M5zbZdOwq2W4AphXibkf+YbB2q1BouigbUzCiA54wa6XArtHsx0PpzyToHjAplnI4O5DhJ1SQNHClLbfA9Gw== erics@hurlevent
|
||
262 | \" > ~abecmd/.ssh/authorized_keys
|
||
263 | chmod 700 ~abecmd/.ssh -R
|
||
264 | chown abecmd:admin ~abecmd/.ssh -R
|
||
265 | b915f380 | Eric Seigne | adduser abecmd admin || true
|
266 | 1c14bcc4 | Eric Seigne | cd ~abecmd
|
267 | wget apt.ryxeo.com/ryxeo/bashrc -O .bashrc
|
||
268 | chown abecmd .bashrc
|
||
269 | ";
|
||
270 | |||
271 | //Et maintenant on sauvegarde qqpart le code/pass du pack
|
||
272 | $commande .= " |
||
273 | echo \"" . $code . ":" . $pass . "\" > /etc/abuledu/epack |
||
274 | b915f380 | Eric Seigne | chown aesd:www-data /etc/abuledu/epack || true
|
275 | chmod 640 /etc/abuledu/epack || true
|
||
276 | sed -i -e \"/.*EPACK.*/D\" /etc/abuledu/rvd || true
|
||
277 | echo RVD_EPACK_CODE=\\\"$code\\\" >> /etc/abuledu/rvd
|
||
278 | 1c14bcc4 | Eric Seigne | ";
|
279 | |||
280 | //L'identification du revendeur ... a améliorer
|
||
281 | $commande .= make_rvd_conffile();
|
||
282 | |||
283 | //Il faudrait egalement faire la base pour OCS-NG et les remontees automatiques ... on utilisera le code du epack
|
||
284 | } |
||
285 | |||
286 | function make_rvd_conffile() { |
||
287 | global $DB; |
||
288 | //Securisation de l'identification du revendeur ... a améliorer
|
||
289 | $commande .= " |
||
290 | chown aesd /etc/abuledu/rvd
|
||
291 | chmod 400 /etc/abuledu/rvd
|
||
292 | ";
|
||
293 | |||
294 | } |
||
295 | |||
296 | function add_user_and_update_link($usermail,$identity,$userlastname,$userfirstname,$tag="") { |
||
297 | global $DB; |
||
298 | global $message; |
||
299 | global $send_mail; |
||
300 | |||
301 | if(trim($usermail) == "") { |
||
302 | $message .= "<li><font color=\"red\">ERROR ($tag)</font> compte utilisateur sans adresse email ! $userlastname :: $userfirstname</li>\n"; |
||
303 | 7c12ea40 | root | return -1; |
304 | 1c14bcc4 | Eric Seigne | } |
305 | |||
306 | $query = "SELECT * from glpi_users WHERE email='$usermail'"; |
||
307 | $result = $DB->query($query); |
||
308 | e213dd82 | root | $debug .= "<p>nb ; " . $DB->numrows($result) . " req : $query</p>"; |
309 | 1c14bcc4 | Eric Seigne | if($DB->numrows($result)>0) { |
310 | $data = $DB->fetch_assoc($result); |
||
311 | $iduser = $data['ID']; |
||
312 | //existe dejà on fait juste le lien s'il n'existe pas déjà
|
||
313 | $query2 = "SELECT * FROM glpi_users_profiles WHERE FK_users='$iduser' AND FK_entities='$identity'"; |
||
314 | e213dd82 | root | //$debug .= "$query2";
|
315 | 1c14bcc4 | Eric Seigne | $result2 = $DB->query($query2); |
316 | if($DB->numrows($result2)<=0) { |
||
317 | cb915e0f | Eric Seigne | //pour eviter qu'un utilisateur se retrouve dans l'entite racine ...
|
318 | if(trim($identity) != 0) { |
||
319 | $query3 = "INSERT INTO glpi_users_profiles(FK_users,FK_entities,FK_profiles,recursive,dynamic) VALUES('$iduser','$identity',1,0,1)"; |
||
320 | $result3 = $DB->query($query3); |
||
321 | $send_mail = 1; |
||
322 | if($result3) |
||
323 | $message .= "<li>Attribution des droits de l'utilisateur $usermail sur le serveur: <font color=\"green\">OK</font></li>\n"; |
||
324 | else {
|
||
325 | $message .= "<li>Attribution des droits de l'utilisateur $usermail sur le serveur: <font color=\"red\">ERROR</font></li>\n"; |
||
326 | } |
||
327 | } |
||
328 | 1c14bcc4 | Eric Seigne | else {
|
329 | b069f62c | root | $message .= "<li>Tentative de lien avec l'entité racine($identity) refusée pour $usermail: <font color=\"red\">ERROR</font></li>\n"; |
330 | d485029b | root | //$message .= "<li>$query2</li>\n";
|
331 | 1c14bcc4 | Eric Seigne | } |
332 | } |
||
333 | //Sinon c'est que tout est déjà fait !
|
||
334 | } |
||
335 | //Sinon c'est que l'utilisateur n'existe pas encore dans la base
|
||
336 | else {
|
||
337 | //Insérer l'utilisateur ... et appel sur la même fonction qui cette fois ci fera le reste :)
|
||
338 | $query2 = "INSERT INTO glpi_users(name,email,realname,firstname,FK_profiles,FK_entities,auth_method) VALUES( |
||
339 | '$usermail',
|
||
340 | '$usermail',
|
||
341 | '$userlastname',
|
||
342 | '$userfirstname',
|
||
343 | '0',
|
||
344 | '$identity',
|
||
345 | '1'
|
||
346 | )";
|
||
347 | $result2 = $DB->query($query2); |
||
348 | $send_mail = 1; |
||
349 | if($result2) { |
||
350 | $message .= "<li>Création du compte utilisateur $usermail : <font color=\"green\">OK</font></li>\n"; |
||
351 | add_user_and_update_link($usermail,$identity,$userlastname,$userrfirstname,$tag); |
||
352 | } |
||
353 | else {
|
||
354 | $message .= "<li>Création du compte utilisateur $usermail : <font color=\"red\">ERROR</font></li>\n"; |
||
355 | } |
||
356 | } |
||
357 | } |
||
358 | |||
359 | //Vite une session
|
||
360 | session_start(); |
||
361 | 7c12ea40 | root | //print_r($_SESSION);
|
362 | |||
363 | 1c14bcc4 | Eric Seigne | if(trim($_GET['reset']) != "") { |
364 | // Finalement, on détruit la session.
|
||
365 | session_destroy(); |
||
366 | header('Location: http://abuledu.net/epack/register/'); |
||
367 | } |
||
368 | 7c12ea40 | root | |
369 | 1c14bcc4 | Eric Seigne | //recupration des variables de l'url
|
370 | $g_http_request = $_SERVER['REQUEST_URI']; |
||
371 | e213dd82 | root | |
372 | 1c14bcc4 | Eric Seigne | if($_SESSION['epack_session'] > 1) { |
373 | $pass = strtoupper($_SESSION['epack_pass']); |
||
374 | $code = strtoupper($_SESSION['epack_code']); |
||
375 | if(isset($_POST['login_email'])) { |
||
376 | $login_email = $_POST['login_email']; |
||
377 | $login_pass = $_POST['login_pass']; |
||
378 | } |
||
379 | if(isset($_SESSION['login_email'])) { |
||
380 | $login_email = $_SESSION['login_email']; |
||
381 | $login_pass = $_SESSION['login_pass']; |
||
382 | } |
||
383 | } |
||
384 | else {
|
||
385 | e213dd82 | root | $debug .= "Pas de session\n"; |
386 | 1c14bcc4 | Eric Seigne | //Si on est sur un formulaire POST (on casse la limite de la taille de la requete GET)
|
387 | if(isset($_POST["pass"])) { |
||
388 | e213dd82 | root | $debug .= "Passage en POST\n"; |
389 | |||
390 | 1c14bcc4 | Eric Seigne | $pass = $_POST["pass"]; |
391 | $code = strtoupper($_POST["code"]); |
||
392 | $datapost = array(); |
||
393 | e213dd82 | root | |
394 | $debug .= "<p>Req::" . $_SERVER['REQUEST_URI'] . "</p>\n"; |
||
395 | |||
396 | 1c14bcc4 | Eric Seigne | foreach($_POST as $key=>$value) { |
397 | $datapost[$key]=$value; |
||
398 | e213dd82 | root | $debug .= "<p>" . $key . " -> " . $value . "</p>\n"; |
399 | 1c14bcc4 | Eric Seigne | } |
400 | } |
||
401 | else {
|
||
402 | ereg(".*pass=(.*).code=(.*).data=(.*)",$_SERVER['REQUEST_URI'],$regs); |
||
403 | $pass = addslashes($regs[1]); |
||
404 | $code = strtoupper(addslashes($regs[2])); |
||
405 | $keyvalue_list=explode("&",base64_decode($regs[3])); |
||
406 | $datapost = array(); |
||
407 | e213dd82 | root | |
408 | $debug .= "<p>Req::" . $_SERVER['REQUEST_URI'] . "</p>\n"; |
||
409 | 1c14bcc4 | Eric Seigne | foreach($keyvalue_list as $key=>$value) { |
410 | // Explode each individual key/value into an array
|
||
411 | $keyvalue=explode("=",$value); |
||
412 | // Make sure we have a "key=value" array
|
||
413 | if(count($keyvalue)==2) { |
||
414 | $datapost[$keyvalue[0]]=$keyvalue[1]; |
||
415 | e213dd82 | root | $debug .= "<p>" . $keyvalue[0] . " -> " . $keyvalue[1] . "</p>\n"; |
416 | 1c14bcc4 | Eric Seigne | } |
417 | else {
|
||
418 | e213dd82 | root | $debug .= "<p>XXX:" . $value . "</p>\n"; |
419 | 1c14bcc4 | Eric Seigne | } |
420 | } |
||
421 | } |
||
422 | |||
423 | //Ou du POST
|
||
424 | if(trim($pass) == "" || trim($code) == "") { |
||
425 | $pass = addslashes($_POST['pass']); |
||
426 | $code = addslashes(strtoupper($_POST['code'])); |
||
427 | } |
||
428 | } |
||
429 | e213dd82 | root | |
430 | 1c14bcc4 | Eric Seigne | $_SERVER['REQUEST_URI'] = ""; |
431 | $_SERVER['HTTP_REFERER'] = ""; |
||
432 | e213dd82 | root | |
433 | 1c14bcc4 | Eric Seigne | define('GLPI_ROOT', '..'); |
434 | include (GLPI_ROOT . "/inc/includes.php"); |
||
435 | |||
436 | include ("ryxeo.php"); |
||
437 | abd6eaaa | Eric Seigne | include('Mail.php'); |
438 | include('Mail/mime.php'); |
||
439 | 1c14bcc4 | Eric Seigne | |
440 | 84a3aa0e | Eric Seigne | //Si epack ryxeo de tests
|
441 | if(stripos($code, "RYXEO-TESTS-")) { |
||
442 | abd6eaaa | Eric Seigne | if(is_array($datapost)) { |
443 | $k = array_keys($datapost); |
||
444 | for($i = 0; $i < count($k); $i++) { |
||
445 | $key = $k[$i]; |
||
446 | $debug .= $key . "=" . $datapost[$key] . "\n"; |
||
447 | } |
||
448 | 1c14bcc4 | Eric Seigne | } |
449 | ea4a2a64 | Eric Seigne | } |
450 | 84a3aa0e | Eric Seigne | if(isset($datapost["MINIWEBADMIN"]) && stripos($code, "-TESTS-")) { |
451 | ea4a2a64 | Eric Seigne | $message .= "<p><h2>Vous pouvez maintenant passer à l'étape suivante: <a href=\"/maj/\">la 1ere mise à jour de votre serveur.</a></h2></p>\n"; |
452 | //le flag qui indique a miniwebadmin que le epack est enregistre
|
||
453 | $commande .= "\n touch /tmp/epack.ok \n"; |
||
454 | } |
||
455 | abd6eaaa | Eric Seigne | |
456 | 7c12ea40 | root | $debug .= "<p>Du cote abuledu.net ... $g_http_request</p>\n"; |
457 | e213dd82 | root | |
458 | 7c12ea40 | root | if($log_debug != "") { |
459 | if($fp = fopen($log_file,"a")) { |
||
460 | fwrite($fp, $debug); |
||
461 | fwrite($fp, "**********************************"); |
||
462 | fwrite($fp, $message); |
||
463 | fwrite($fp, "**********************************"); |
||
464 | fclose($fp); |
||
465 | } |
||
466 | } |
||
467 | ea4a2a64 | Eric Seigne | |
468 | f8c1248f | Eric Seigne | //On ne fait pas tout le bazaaar, on teste / valide la procedure uniquement
|
469 | if(stripos($code, "-TESTS-")) { |
||
470 | make_pdf($pass,$code,$datapost); |
||
471 | send_mail_installation($pass,$code,$datapost); |
||
472 | 7c12ea40 | root | |
473 | 84a3aa0e | Eric Seigne | $object = array(); |
474 | $object['message'] = "<h1>Enregistrement de votre serveur avec un ePack</h1>\n"; |
||
475 | $object['message'] .= $message; |
||
476 | $object['command'] = $commande; |
||
477 | |||
478 | print serialize($object); |
||
479 | 6fd1e9d9 | Eric Seigne | return;
|
480 | ea4a2a64 | Eric Seigne | } |
481 | 1c14bcc4 | Eric Seigne | |
482 | 7c12ea40 | root | //erics special pour cemea la reunion
|
483 | //$datapost['MAC0'] = "00215e69371a";
|
||
484 | |||
485 | 1c14bcc4 | Eric Seigne | //print "<pre>";
|
486 | //print_r($datapost);
|
||
487 | //$message .= implode("::",$datapost);
|
||
488 | //print "</pre>";
|
||
489 | //reset ...
|
||
490 | //print_r($_SESSION);
|
||
491 | //unset($_SESSION['epack_session']);
|
||
492 | if(trim($pass) != "" && trim($code) != "") { |
||
493 | $query = "SELECT * FROM glpi_plugin_anet_epacks |
||
494 | LEFT JOIN glpi_entities AS g ON FK_client=g.ID
|
||
495 | WHERE code='$code' AND password='$pass'";
|
||
496 | $result = $DB->query($query); |
||
497 | e213dd82 | root | //$message = "$query";
|
498 | 1c14bcc4 | Eric Seigne | $mac0 = trim(strtolower($datapost['MAC0'])); |
499 | $mac1 = trim(strtolower($datapost['MAC1'])); |
||
500 | //$data=$DB->fetch_assoc($result);
|
||
501 | //$nbresultat = $DB->numrows($result);
|
||
502 | e213dd82 | root | //print_r($data);
|
503 | //exit;
|
||
504 | 1c14bcc4 | Eric Seigne | if($DB->numrows($result)>0) { |
505 | $data=$DB->fetch_assoc($result); |
||
506 | |||
507 | //$message .= "Eric ... " . $mac0 . ": $code : $mac1";
|
||
508 | if( ! verification_data() ) {
|
||
509 | $message .= "<p><font color=\"red\">Erreur, il manque des informations ou certaines informations ne sont pas correctes sur la <a href=\"/installation/\">fiche d'identité du serveur</a>. Merci de les corriger tout de suite et de repasser ensuite sur cette page !!!</font></p>\n"; |
||
510 | } |
||
511 | //pack deja attribué à un serveur ?
|
||
512 | else if($data['FK_serveur'] > 0) { |
||
513 | af8e09aa | Eric Seigne | // make_conffiles($datapost['MAC0'],$pass,$code);
|
514 | 1c14bcc4 | Eric Seigne | if( strlen($mac0) == 12 && strlen($mac1) == 12) { |
515 | //Petite vérification, si c'est le même serveur qu'on a réinstallé x fois on laisse faire
|
||
516 | $query2 = "SELECT * FROM glpi_computers WHERE os_license_number LIKE '" . $mac0 . "%' OR os_license_number LIKE '" . $mac1 . "%' "; |
||
517 | $result2 = $DB->query($query2); |
||
518 | $data2=$DB->fetch_assoc($result2); |
||
519 | //Ce pack a été utilisé pour ce serveur ... ok
|
||
520 | if($data2['ID'] == $data['FK_serveur']) { |
||
521 | $nbu = $data['nbused']; |
||
522 | make_conffiles($datapost['MAC0'],$pass,$code); |
||
523 | |||
524 | $message .= "<p>Ce pack a déjà été utilisé $nbu fois pour ce serveur. Si vous avez des difficultés pour utiliser ou configurer AbulÉdu, prennez contact avec la communauté des utilisateurs <a href=\"http://forum.abuledu.org\">sur les forums</a> ou par courriel avec la <a href=\"mailto:contact@ryxeo.com\">société RyXéo</a>, éditrice d'AbulÉdu.</p>\n"; |
||
525 | $message .= "<h4>Rappel des informations concernant ce serveur: </h4>"; |
||
526 | $message .= "<ul> |
||
527 | <li>Nom: " . $data2['name'] . "</li> |
||
528 | <li>Commentaires: " . $data2['comments'] . "</li> |
||
529 | </ul>\n";
|
||
530 | $message .= "<p>Merci d'avoir enregistré ce serveur. Pour toute demande de modification, veuillez utiliser votre compte abuledu.net ou prendre <a href=\"mailto:contact@ryxeo.com\">contact avec RyXéo</a></p>"; |
||
531 | |||
532 | d6c34dc8 | Eric Seigne | if(isset($datapost["MINIWEBADMIN"])) { |
533 | 6fd1e9d9 | Eric Seigne | $message .= "<p>Vous pouvez maintenant passer à l'étape suivante: <a href=\"/maj/\">la 1ere mise à jour de votre serveur.</a></p>\n"; |
534 | d6c34dc8 | Eric Seigne | //le flag qui indique a miniwebadmin que le epack est enregistre
|
535 | $commande .= "\n touch /tmp/epack.ok \n"; |
||
536 | } |
||
537 | 1c14bcc4 | Eric Seigne | //On incremente le compteur qui permettra de detecter les serveur tres souvent reinstalles
|
538 | $nbu = $data['nbused'] + 1; |
||
539 | $query3 = "UPDATE glpi_plugin_anet_epacks SET nbused='$nbu' WHERE code='$code' AND password='$pass'"; |
||
540 | $result3 = $DB->query($query3); |
||
541 | |||
542 | //On update les liens etc. (si on a change les comptes utilisateurs par ex.)
|
||
543 | //TODO
|
||
544 | $query1 = "SELECT * FROM glpi_entities WHERE name='" . addslashes($datapost['INAME']) . "' AND parentID='" . $data['FK_client'] . "'"; |
||
545 | $result1 = $DB->query($query1); |
||
546 | if($DB->numrows($result1) > 0) { |
||
547 | //L'entité existe déjà ...
|
||
548 | $data1 = $DB->fetch_assoc($result1); |
||
549 | $identityenduser = $data1['ID']; |
||
550 | } |
||
551 | b069f62c | root | else {
|
552 | //$message .= "<p>Erreur : $query1</p>";
|
||
553 | } |
||
554 | d485029b | root | //$message .= "<li>Entity: $query1</li>\n";
|
555 | 1c14bcc4 | Eric Seigne | add_user_and_update_link($datapost['IEMAIL'], $identityenduser,$datapost['INAME'],$datapost['ICITY'],"Installation"); |
556 | add_user_and_update_link($datapost['ADM_EMAIL'], $identityenduser,$datapost['ADM_LASTNAME'],$datapost['ADM_FIRSTNAME'],"Directrice ou directeur"); |
||
557 | add_user_and_update_link($datapost['PR_EMAIL'], $identityenduser,$datapost['PR_LASTNAME'],$datapost['PR_FIRSTNAME'],"Autre contact"); |
||
558 | add_user_and_update_link($datapost['ATICE_EMAIL'], $identityenduser,$datapost['ATICE_LASTNAME'],$datapost['ATICE_FIRSTNAME'],"Animateur TICE"); |
||
559 | |||
560 | make_conffiles($datapost['MAC0'],$pass,$code); |
||
561 | 7c12ea40 | root | make_pdf($pass,$code,$datapost); |
562 | send_mail_installation($pass,$code,$datapost); |
||
563 | 1c14bcc4 | Eric Seigne | } |
564 | //Sinon, c'est louche, on informe ryxeo et on avertis l'utilisateur
|
||
565 | else {
|
||
566 | $message .= "<p>Attention, Ce pack a déjà été attribué à un serveur !</p>\n"; |
||
567 | $message .= "<p>Les packs sont à usage unique, merci d'acheter un nouveau pack pour ce serveur ou <a href=\"mailto:contact@ryxeo.com\">contactez-nous</a> si vous pensez qu'il s'agit d'une erreur.</p>\n"; |
||
568 | |||
569 | $mail_content = " |
||
570 | Bonjour,
|
||
571 | le pack $pass :: $code vient d'être utilisé pour enregistrer un serveur alors que ce pack a déjà
|
||
572 | été utilisé. Merci de vérifier s'il ne s'agit pas d'une tentative de réinstallation multiple ...
|
||
573 |
|
||
574 | Informations brutes récoltées:
|
||
575 |
|
||
576 | ";
|
||
577 | foreach ($datapost as $key => $value) { |
||
578 | $mail_content .= "$key -> $value\n"; |
||
579 | } |
||
580 | |||
581 | $mail_content .= " |
||
582 |
|
||
583 | --
|
||
584 | abuledu.net est un service de RyXéo SARL, société éditrice d'AbulÉdu
|
||
585 | 7c12ea40 | root | (register.php sur abuledu.net)
|
586 | 1c14bcc4 | Eric Seigne |
|
587 | ";
|
||
588 | ryxeo_mail("anet@ryxeo.com",$mail_content,"contact@ryxeo.com","Pack déjà activé plusieurs fois !"); |
||
589 | } |
||
590 | } |
||
591 | } |
||
592 | //pack deja utilise ? si oui c'est qu'il a bien été activé
|
||
593 | else if($data['FK_activation'] > 0) { |
||
594 | $notes = "Données collectées lors de l'enregistrement du serveur le " . date("Y-m-d") . "\n\n"; |
||
595 | foreach ($datapost as $key => $value) { |
||
596 | $notes .= "$key = $value\n"; |
||
597 | } |
||
598 | //On créé l'entité de l'école dans l'entité du client qui est elle même dans l'entité du revendeur
|
||
599 | $query1 = "SELECT * FROM glpi_entities WHERE name='" . addslashes($datapost['INAME']) . "' AND parentID='" . $data['FK_client'] . "'"; |
||
600 | $result1 = $DB->query($query1); |
||
601 | if($DB->numrows($result1) > 0) { |
||
602 | //L'entité existe déjà ...
|
||
603 | $data1 = $DB->fetch_assoc($result1); |
||
604 | $identityenduser = $data1['ID']; |
||
605 | } |
||
606 | else {
|
||
607 | //L'entité n'existe pas, on l'ajoute
|
||
608 | $query1 = "INSERT INTO glpi_entities VALUES('','" . addslashes($datapost['INAME']) . "'," . $data['FK_client'] . ",'" . $data['completename'] . " > " . addslashes($datapost['INAME']) . "','',5)"; |
||
609 | $result1 = $DB->query($query1); |
||
610 | $send_mail = 1; |
||
611 | } |
||
612 | $query1 = "SELECT * from glpi_entities WHERE name='" . addslashes($datapost['INAME']) . "' AND parentID='" . $data['FK_client'] . "';"; |
||
613 | $result1 = $DB->query($query1); |
||
614 | $data1 = $DB->fetch_assoc($result1); |
||
615 | //Creation ok
|
||
616 | $identityenduser = $data1['ID']; |
||
617 | if($DB->numrows($result1) > 0) { |
||
618 | $query1 = "INSERT INTO glpi_entities_data VALUES('',$identityenduser,'" . |
||
619 | addslashes($datapost['IADDRESS0'] . " " . $datapost['IADDRESS1'] ) . "','" . |
||
620 | addslashes($datapost['IPOSTALCODE']) . "','" . |
||
621 | addslashes($datapost['ICITY']) . "','" . |
||
622 | "','" .
|
||
623 | addslashes($datapost['ICOUNTRY']) . "','" . |
||
624 | "','" .
|
||
625 | addslashes($datapost['ITEL']) . "','" . |
||
626 | "','" .
|
||
627 | addslashes($datapost['IEMAIL']) . "','" . |
||
628 | "','" .
|
||
629 | "','" .
|
||
630 | "');";
|
||
631 | $result1 = $DB->query($query1); |
||
632 | //print $query1;
|
||
633 | //print_r($data1);
|
||
634 | $message .= "<ul>\n"; |
||
635 | if($result1) |
||
636 | $message .= "<li>Création de l'école: <font color=\"green\">OK</font></li>\n"; |
||
637 | else {
|
||
638 | $message .= "<li>Création de l'école: <font color=\"red\">ERROR</font></li>\n"; |
||
639 | } |
||
640 | |||
641 | } |
||
642 | |||
643 | //Il faut inserer le serveur dans le compte du client final et faire le toutim
|
||
644 | $query2 = "INSERT INTO glpi_computers(FK_entities,name,date_mod,os_license_number,comments,notes,state) |
||
645 | VALUES(
|
||
646 | '" . $identityenduser . "', |
||
647 | '" . addslashes($datapost['INAME']) . "', |
||
648 | NOW(),
|
||
649 | '" . $mac0 . ".dip.abuledu.net', |
||
650 | '" . addslashes($datapost['ICOMMENT']) . "', |
||
651 | '" . addslashes($notes) . "', |
||
652 | '1'
|
||
653 | )";
|
||
654 | $result2 = $DB->query($query2); |
||
655 | $send_mail = 1; |
||
656 | |||
657 | $query2 = "SELECT * from glpi_computers WHERE name='" . addslashes($datapost['INAME']) . "' AND os_license_number='" . $mac0 . ".dip.abuledu.net';"; |
||
658 | // print "select $query2";
|
||
659 | $result2 = $DB->query($query2); |
||
660 | $data2 = $DB->fetch_assoc($result2); |
||
661 | // print_r($data2);
|
||
662 | //Creation ok
|
||
663 | $idserver = $data2['ID']; |
||
664 | if($DB->numrows($result2) > 0) { |
||
665 | $message .= "<li>Ajout du serveur sur AbulÉdu.net: <font color=\"green\">OK</font></li>\n"; |
||
666 | |||
667 | //On attribue le pack au serveur
|
||
668 | $nbu = $data['nbused'] + 1; |
||
669 | $query3 = "UPDATE glpi_plugin_anet_epacks SET FK_serveur='" . $idserver . "', FK_enduser='" . $identityenduser . "', nbused='$nbu' WHERE code='$code' AND password='$pass'"; |
||
670 | $result3 = $DB->query($query3); |
||
671 | |||
672 | |||
673 | $query3 = "INSERT INTO glpi_computer_device(specificity,device_type,FK_device,FK_computers) |
||
674 | VALUES('" . $datapost['CPU'] . "','2','2','$idserver'), |
||
675 | ('" . $datapost['RAM'] . "','3','2','$idserver'), |
||
676 | ('" . $datapost['HDD0'] . "','4','4','$idserver'),"; |
||
677 | if(trim($datapost['HDD1'])) |
||
678 | $query3 .= "('" . $datapost['HDD1'] . "','4','4','$idserver'),"; |
||
679 | $query3 .= "('" . $datapost['MAC0'] . "','5','2','$idserver'), |
||
680 | ('" . $datapost['MAC1'] . "','5','2','$idserver');"; |
||
681 | $result3 = $DB->query($query3); |
||
682 | $send_mail = 1; |
||
683 | if($result3) |
||
684 | $message .= "<li>Ajout des pièces détachées du serveur: <font color=\"green\">OK</font></li>\n"; |
||
685 | else
|
||
686 | $message .= "<li>Ajout des pièces détachées du serveur: <font color=\"red\">ERROR</font></li>\n"; |
||
687 | //Insertion des pièces détachées ok
|
||
688 | |||
689 | //Ajout des contacts liés à ce serveur ?
|
||
690 | add_user_and_update_link($datapost['IEMAIL'], $identityenduser,$datapost['INAME'],$datapost['ICITY'],"Installation"); |
||
691 | add_user_and_update_link($datapost['ADM_EMAIL'], $identityenduser,$datapost['ADM_LASTNAME'],$datapost['ADM_FIRSTNAME'],"Directrice ou directeur"); |
||
692 | add_user_and_update_link($datapost['PR_EMAIL'], $identityenduser,$datapost['PR_LASTNAME'],$datapost['PR_FIRSTNAME'],"Autre contact"); |
||
693 | add_user_and_update_link($datapost['ATICE_EMAIL'], $identityenduser,$datapost['ATICE_LASTNAME'],$datapost['ATICE_FIRSTNAME'],"Animateur TICE"); |
||
694 | |||
695 | //Création des fichiers de conf pour se rattacher a la maintenance (?) ... mais si pas de maintenance ?
|
||
696 | //On gerera ça sur les paiements des contrats associés
|
||
697 | make_conffiles($datapost['MAC0'],$pass,$code); |
||
698 | |||
699 | f8c1248f | Eric Seigne | //Mail d'information a ryxeo + pdf au rvendeur
|
700 | make_pdf($pass,$code,$datapost); |
||
701 | 6fd1e9d9 | Eric Seigne | send_mail_installation($pass,$code,$datapost); |
702 | 7c12ea40 | root | |
703 | af8e09aa | Eric Seigne | if(isset($datapost["MINIWEBADMIN"])) { |
704 | $message .= "</ul>\n<p>Vous pouvez maintenant passer à l'étape suivante: <a href=\"/maj/\">la 1ere mise à jour de votre serveur.</a></p>\n"; |
||
705 | //le flag qui indique a miniwebadmin que le epack est enregistre
|
||
706 | $commande .= "\n touch /tmp/epack.ok \n"; |
||
707 | } |
||
708 | else {
|
||
709 | $message .= "<li><font color=\"green\">Bravo</font> votre serveur est maintenant bien enregistré sur abuledu.net. Vous pouvez passer à l'étape de création automatique du <a href=\"recette.php\">cahier de recettes</a></li>\n"; |
||
710 | $message .= "</ul>\n"; |
||
711 | } |
||
712 | 1c14bcc4 | Eric Seigne | } |
713 | else
|
||
714 | $message .= "<li>Ajout du serveur sur anet: <font color=\"red\">ERROR</font></li>\n"; |
||
715 | } |
||
716 | else if ($data['activation_date'] == "0000-00-00") { |
||
717 | 6fd1e9d9 | Eric Seigne | $message .= "<p><font color=\"red\">Erreur, ce packs n'a pas été activé !!! Vous devez activer votre ePack tout de suite à l'adresse suivante, <a href=\"http://www.abuledu.net/epack/new\" target=\"_blank\">abuledu.net/epack/new</a> comme indiqué sur la fiche ePack.</font></p>\n"; |
718 | 1c14bcc4 | Eric Seigne | } |
719 | else {
|
||
720 | $message .= "<p><font color=\"red\">Erreur, ce pack a déjà été utilisé ou n'a pas encore été activé !!!</font></p>\n"; |
||
721 | } |
||
722 | } |
||
723 | else {
|
||
724 | $message .= "<p><font color=\"red\">Erreur de code ou de mot de passe epack !!!</font></p>\n"; |
||
725 | } |
||
726 | } |
||
727 | else {
|
||
728 | $message .= "<p><font color=\"red\">Erreur: code ou mot de passe epack invalide.</font></p>\n"; |
||
729 | } |
||
730 | |||
731 | $object = array(); |
||
732 | 84a3aa0e | Eric Seigne | if(trim($message) == "") |
733 | 1c14bcc4 | Eric Seigne | $message .= "<p><font color=\"red\">Erreur non prévue, merci de contacter RyXéo sans tarder...</font></p>"; |
734 | $object['message'] = "<h1>Enregistrement de votre serveur avec un ePack</h1>\n"; |
||
735 | $object['message'] .= $message; |
||
736 | $object['command'] = $commande; |
||
737 | |||
738 | //On touche le fichier pour forcer un update de gnudip et des accreditations ... uniquement si epack valide
|
||
739 | if($send_mail) { |
||
740 | @touch("/tmp/update-anet"); |
||
741 | @chmod("/tmp/update-anet",0666); |
||
742 | } |
||
743 | print serialize($object); |
||
744 | 7c12ea40 | root | |
745 | if($log_debug != "") { |
||
746 | if($fp = fopen($log_file,"a")) { |
||
747 | fwrite($fp, $debug); |
||
748 | fwrite($fp, "======================================="); |
||
749 | fwrite($fp, $message); |
||
750 | fwrite($fp, "======================================="); |
||
751 | fclose($fp); |
||
752 | } |
||
753 | } |
||
754 | 1c14bcc4 | Eric Seigne | |
755 | ?>
|