1 | <? |
---|
2 | require_once("m_mail.php"); |
---|
3 | |
---|
4 | class m_mail_egw extends m_mail { |
---|
5 | |
---|
6 | |
---|
7 | function __construct () { |
---|
8 | global $mail; |
---|
9 | $mail = $this; |
---|
10 | } |
---|
11 | // function _createpop($mail,$dom,$pass) { |
---|
12 | // global $err,$cuid,$db; |
---|
13 | // $err->log("mail","_createpop",$mail."@".$dom); |
---|
14 | // $m=substr($mail,0,1); |
---|
15 | // $gecos=$mail; |
---|
16 | // if (!$mail) { |
---|
17 | // // Cas du CATCH-ALL |
---|
18 | // $gecos="Catch-All"; |
---|
19 | // $m="_"; |
---|
20 | // } |
---|
21 | // $db->query("INSERT INTO mail_users (uid,alias,path,password) VALUES ('$cuid','".$mail."_".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."','"._md5cr($pass)."');"); |
---|
22 | // $db->query("INSERT INTO mail_users (uid,alias,path,password) VALUES ('$cuid','".$mail."@".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."','"._md5cr($pass)."');"); |
---|
23 | // $db->query("INSERT INTO mail_alias (mail,alias) VALUES ('".$mail."_".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."/Maildir/');"); |
---|
24 | // |
---|
25 | // $f=fopen("/var/lib/squirrelmail/data/".$mail."_".$dom.".pref","wb"); |
---|
26 | // $g=0; $g=@fopen("/etc/squirrelmail/default_pref","rb"); |
---|
27 | // fputs($f,"email_address=$mail@$dom\nchosen_theme=default_theme.php\n"); |
---|
28 | // if ($g) { |
---|
29 | // while ($s=fgets($g,1024)) { |
---|
30 | // if (substr($s,0,14)!="email_address=" && substr($s,0,13)!="chosen_theme=") { |
---|
31 | // fputs($f,$s); |
---|
32 | // } |
---|
33 | // } |
---|
34 | // fclose($g); |
---|
35 | // } |
---|
36 | // fclose($f); |
---|
37 | // @copy("/var/lib/squirrelmail/data/".$mail."_".$dom.".pref","/var/lib/squirrelmail/data/".$mail."@".$dom.".pref"); |
---|
38 | // exec("/usr/lib/alternc/mail_add ".$mail."_".$dom." ".$cuid); |
---|
39 | // return true; |
---|
40 | // } |
---|
41 | |
---|
42 | function _createpop($mail,$dom,$pass) { |
---|
43 | |
---|
44 | if ($this->_add_egw_account($mail,$dom,$pass) ) |
---|
45 | if (parent::__createpop($mail,$dom,$pass)) |
---|
46 | return true; |
---|
47 | else |
---|
48 | return false; |
---|
49 | else |
---|
50 | return false; |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | function _add_egw_account($mail,$dom,$pass) { |
---|
55 | |
---|
56 | $res = true; |
---|
57 | if (substr($dom,-10) == "cta.org.ar") { |
---|
58 | |
---|
59 | $admincli= "/var/alternc/html/i/intranet/intranet.redcta.org.ar/wwws/stable/admin/admin-cli.php"; |
---|
60 | $command= "--edit-user"; // Command to be performed |
---|
61 | $adminuser = $GLOBALS["L_adminuser_egw"]; |
---|
62 | $adminclave = $GLOBALS["L_adminclave_egw"]; |
---|
63 | // $account - we use the email address which is extracted from the DB |
---|
64 | // $firstname - we use the left side of the email adress, which will be extracted from the database |
---|
65 | $lastname= "-"; // we have a generic lastname |
---|
66 | // $passwd will be generated with some magic |
---|
67 | // $email you know that, from the db |
---|
68 | $expires= "never"; |
---|
69 | $canchangepw= "yes"; |
---|
70 | $anonuser= "no"; |
---|
71 | $primarygroup = substr($dom,-10); |
---|
72 | $secondarygroup = substr($dom,0,-11); |
---|
73 | |
---|
74 | $lastname = "-"; |
---|
75 | $firstname = $mail; |
---|
76 | $email = $account = $mail ."@" .$dom; |
---|
77 | |
---|
78 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; |
---|
79 | |
---|
80 | if (isset($secondarygroup)) { |
---|
81 | $go= $go ."," .$secondarygroup; |
---|
82 | } |
---|
83 | echo ($go); |
---|
84 | exit(); |
---|
85 | $cod = exec($go); |
---|
86 | if ($cod) |
---|
87 | { |
---|
88 | die ($cod); |
---|
89 | $res = false; |
---|
90 | } |
---|
91 | } |
---|
92 | return $res; |
---|
93 | |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | ?> |
---|