require_once("m_mail.php"); class m_mail_egw extends m_mail { function _createpop($mail,$dom,$pass) { if ($this->_add_egw_account($mail,$dom,$pass) ) if (parent::_createpop($mail,$dom,$pass)) return true; else return false; else return false; } function _deletepop($mail,$dom) { if ($this->_del_egw_account($mail,$dom) ) if (parent::_deletepop($mail,$dom)) return true; else return false; else return false; } function _updatepop($mail,$dom,$pass) { if ($this->_update_passwd_egw_account($mail,$dom,$pass) ) if (parent::_updatepop($mail,$dom,$pass)) return true; else return false; else return false; } function _add_egw_account($mail,$dom,$pass) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--edit-user"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; $firstname = $mail; // the left side of the email $lastname= "-"; // we have a generic lastname $email = $account = $mail ."@" .$dom; // account and email are the same $expires= "never"; $canchangepw= "yes"; $anonuser= "no"; $primarygroup = $domain[$size-3]; // domains in .ar starts at the third level $secondarygroup = $domain[$size-4]; // the sub-domain is used as a secondary group $homedir = "/home/". $mail ."_" .$dom; // everyone can have a home $loginshell = "/bin/bash"; // everyone can have a shell $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; if (isset($secondarygroup)) { $go= $go ."," .$secondarygroup ; } $go= $go ."," .$homedir ."," .$loginshell ; echo "
"; echo $cod; echo "
"; //$res = false; } } return $res; } function _del_egw_account($mail,$dom) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--delete-user"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; $email = $account = $mail ."@" .$dom; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; echo ""; echo $cod; echo "
"; //$res = false; } } return $res; } function _update_passwd_egw_account($mail,$dom,$pass) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--change-pw"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; $email = $account = $mail ."@" .$dom; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; echo ""; echo $cod; echo "
"; //$res = false; } } return $res; } } ?>