This repository has been archived by the owner on Nov 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
traiterml.php
48 lines (42 loc) · 1.63 KB
/
traiterml.php
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
<?php
require("db.php");
function genpass(){
$s = "abcdefghijklmnopqrstuvwxyz";
$str = "";
for($i=0;$i<8;$i++)
$str .= $s[rand(0,25)];
return $str;
}
$stmt = $db->prepare("SELECT Asso, Extension FROM gesmail WHERE Type LIKE 'ml' AND MLPassword IS NULL");
$stmt->bind_result($asso, $extension);
$stmt->execute();
$stmt->store_result();
while($stmt->fetch()){
$output = '';
$box = escapeshellarg("$asso-$extension");
$owner = escapeshellarg("$asso@assos.utc.fr");
$pass = genpass();
exec("/usr/lib/mailman/bin/newlist -q $box $owner $pass", $output, $return);
if($return == 0){
$dossier = escapeshellarg("/var/lib/mailman/lists/$asso-$extension");
exec("ln -s ../extend.py $dossier", $output2, $return2);
if($return2 == 0){
$uppass = $db->prepare("UPDATE gesmail SET MLPassword = ? WHERE Asso LIKE ? AND Extension LIKE ?");
$uppass->bind_param("sss", $pass, $asso, $extension);
$uppass->execute();
$uppass->close();
$message = "Bonjour,
Votre liste $asso-$extension@assos.utc.fr vient d'être créée. Rendez-vous sur Gesmail [34m| l'adresse http://assos.utc.fr/gesmail pour la remplir !
Cordialement,
L'équipe du SiMDE";
mail("$asso@assos.utc.fr", "[Gesmail] Création de votre liste", $message, "From: simde@assos.utc.fr");
}
}
$warn = "";
if(!empty($return))
$warn .= print_r($output, true);
if(!empty($return2))
$warn .= "\n\n".print_r($output2, true);
if(!empty($warn))
mail("simde@assos.utc.fr", "[Gesmail] Problème création liste", "Problème lors de la création de la liste $asso-$extension@assos.utc.fr :\n\n $warn", "From: simde@assos.utc.fr");
}