From: cajus Date: Thu, 17 Jan 2008 16:49:22 +0000 (+0000) Subject: Moved spam/virus to services X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c9c165ebafc0c6369b294af80f66bf214acd4bf3;p=gosa.git Moved spam/virus to services git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8481 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc deleted file mode 100644 index 68c04e043..000000000 --- a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc +++ /dev/null @@ -1,357 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goSpamServer"); - var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule"); - var $StatusFlag = "saStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goSpamServer"); - var $Flags = array("B","b","C","R","D","P"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn = ""; - var $saStatus = ""; - - var $saRewriteHeader = ""; - var $saTrustedNetworks= array(); - var $TrustedNetworks = array(); - var $saRequiredScore = 0; - var $saFlags = ""; - var $Rules = array(); - var $saRule = array(); - - var $saFlagsB = false; - var $saFlagsb = false; - var $saFlagsC = false; - var $saFlagsR = false; - var $saFlagsD = false; - var $saFlagsP = false; - - var $ui = NULL; - var $acl = NULL; - var $view_logged =FALSE; - - function gospamserver(&$config,$dn, $parent= NULL) - { - /* Init class */ - goService::goService($config,$dn, $parent); - $this->DisplayName = _("Spamassassin"); - - /* Get userinfo & acls */ - $this->ui = get_userinfo(); - - /* Get Flags */ - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - if(preg_match("/".$flag."/",$this->saFlags)){ - $this->$var = TRUE; - } - } - - /* Get trusted networks */ - $this->TrustedNetworks = array(); - if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){ - $var = $this->attrs['saTrustedNetworks']; - for($i = 0 ; $i < $var['count'] ; $i ++ ){ - $var2 = $this->attrs['saTrustedNetworks'][$i]; - $this->TrustedNetworks[ $var2 ] = $var2; - } - } - - /* Get rules */ - $this->Rules = array(); - if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){ - $var = $this->attrs['saRule']; - for($i = 0 ; $i < $var['count'] ; $i ++ ){ - $var2 = $this->attrs['saRule'][$i]; - $name = preg_replace("/:.*$/","",$var2); - $value= base64_decode(preg_replace("/^.*:/","",$var2)); - $this->Rules[ $name ] = $value; - } - } - } - - - function execute() - { - $display =""; - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* If displayed, it is ever true*/ - $this->is_account =true; - - /* Get acls */ - $tmp = $this->plinfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Add new trusted network */ - if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ - $this->AddTrust($_POST['NewTrustName']); - } - - /* Delete selected trusted network */ - if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ - $this->DelTrust($_POST['TrustedNetworks']); - } - - /* Add a new rule */ - if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){ - $this->dialog = new goSpamServerRule($this->config,$this->dn); - } - - /* Cancel adding/editing specified rule */ - if(isset($_POST['CancelRule'])){ - $this->dialog = FALSE; - } - - /* Handle post to delete rules */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){ - $once = false; - $entry = preg_replace("/^editRule_/","",$name); - $entry = preg_replace("/_(x|y)$/","",$entry); - $rule = $this->Rules[$entry]; - $name = $entry; - $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule); - } - if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){ - $once = false; - $entry = preg_replace("/^delRule_/","",$name); - $entry = preg_replace("/_(x|y)$/","",$entry); - unset($this->Rules[$entry]); - } - } - - /* Save rules */ - if(isset($_POST['SaveRule'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }elseif($this->acl_is_writeable("saRule")){ - $ret = $this->dialog->save(); - if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){ - unset($this->Rules[$ret['orig_name']]); - } - $this->Rules[$ret['name']] = $ret['rule']; - $this->dialog = FALSE; - } - } - - /* Display dialog if available */ - if($this->dialog && $this->dialog->config){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /* Assign smarty vars */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign checkbox states */ - foreach($this->Flags as $Flag){ - $var = "saFlags".$Flag; - $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag)); - if($this->$var){ - $smarty->assign("saFlags".$Flag."CHK"," checked " ); - }else{ - $smarty->assign("saFlags".$Flag."CHK",""); - } - } - - /* Create divlist */ - $DivRules = new divSelectBox("SpamRules"); - $DivRules->SetHeight(130); - - if($this->acl_is_writeable("saTrustedNetworks")){ - $actions = ""; - }else{ - - $actions = ""; - if($this->acl_is_writeable("saRule")){ - $actions.= ""; - } - } - - foreach($this->Rules as $key => $net){ - $field1 = array("string" => $key ); - $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'"); - $DivRules->AddEntry(array($field1,$field2)); - } - $smarty->assign("divRules",$DivRules->DrawList()); - $smarty->assign("TrustedNetworks",$this->TrustedNetworks); - - /* Create Spam score select box entries */ - $tmp = array(); - for($i = 0 ; $i <= 20 ; $i ++ ){ - $tmp[$i] = $i; - } - $smarty->assign("SpamScore",$tmp); - - return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__)))); - } - - - /* Add $post to list of configured trusted */ - function AddTrust($post) - { - if(!empty($post)){ - if(tests::is_ip($post) || tests::is_domain($post) || (tests::is_ip_with_subnetmask($post))){ - $this->TrustedNetworks[$post] = $post; - }else{ - print_red(_("Specified value is not a valid 'trusted network' value.")); - } - } - } - - - /* Delete trusted network */ - function DelTrust($posts) - { - foreach($posts as $post){ - if(isset($this->TrustedNetworks[$post])){ - unset($this->TrustedNetworks[$post]); - } - } - } - - function save() - { - if(!$this->is_account) return; - plugin::save(); - - /* Create Flags */ - $this->attrs['saFlags'] = array(); - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - if($this->$var){ - $this->attrs['saFlags'].=$flag; - } - } - - /* Create trusted network entries */ - $this->attrs['saTrustedNetworks'] = array(); - foreach($this->TrustedNetworks as $net){ - $this->attrs['saTrustedNetworks'][] = $net; - } - - /* Rules */ - $this->attrs['saRule'] = array(); - foreach($this->Rules as $name => $rule){ - $this->attrs['saRule'][] = $name.":".base64_encode($rule); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn)); - } - - function check() - { - $message = plugin::check(); - - /* Check if required score is numeric */ - if(!is_numeric($this->saRequiredScore)){ - $message[] = _("Required score must be a numeric value."); - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goSpamServer'])){ - - plugin::save_object(); - - /* Check flags */ - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - - if($this->acl_is_writeable($var)){ - if(isset($_POST[$var])){ - $this->$var = TRUE; - }else{ - $this->$var = FALSE; - } - } - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Spamassassin"), - "plDescription" => _("Spamassassin")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 89, - "plSection" => array("administration"), - "plCategory" => array("server"), - "plProvidedAcls"=> array( - - "saRewriteHeader" => _("Rewrite header"), - "saTrustedNetworks" => _("Trusted networks"), - "saRequiredScore" => _("Required score"), - "saRule" => _("Rules"), - - "saFlagB" => _("Enable use of bayes filtering"), - "saFlagb" => _("Enabled bayes auto learning"), - "saFlagC" => _("Enable RBL checks"), - "saFlagR" => _("Enable use of Razor"), - "saFlagD" => _("Enable use of DDC"), - "saFlagP" => _("Enable use of Pyzor")) - )); - } - - /* For newer service management dialogs */ - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Spamassassin"); - $fields['AllowEdit'] = true; - return($fields); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc deleted file mode 100644 index c8eed5d4e..000000000 --- a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc +++ /dev/null @@ -1,61 +0,0 @@ -name = $this->orig_name= $name; - $this->rule = $rule; - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - - function save() - { - $ret =array(); - $ret['orig_name'] = $this->orig_name; - $ret['name'] = $this->name; - $ret['rule'] = $this->rule; - return($ret); - } - - function check() - { - $messages = plugin::check(); - return($messages); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl deleted file mode 100644 index c8b58852f..000000000 --- a/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - -

Spam tagging

- - - - - - - - - - -
- {t}Rewrite header{/t} - -{render acl=$saRewriteHeaderACL} - -{/render} -
- {t}Required score{/t} - -{render acl=$saRequiredScoreACL} - -{/render} -
- -

Trusted networks

- - - - - -
-{render acl=$saTrustedNetworksACL} -
-{/render} -{render acl=$saTrustedNetworksACL} -   -{/render} -{render acl=$saTrustedNetworksACL} - -{/render} -{render acl=$saTrustedNetworksACL} - -{/render} -
- -
-

 

-
-

Flags

- - - - - -
-{render acl=$saFlagsBACL} -  {t}Enable use of bayes filtering{/t}
-{/render} -{render acl=$saFlagsbACL} -  {t}Enable bayes auto learning{/t}
-{/render} -{render acl=$saFlagsCACL} -  {t}Enable RBL checks{/t} -{/render} -
-
- - - - -
-{render acl=$saFlagsRACL} -  {t}Enable use of Razor{/t}
-{/render} -{render acl=$saFlagsDACL} -  {t}Enable use of DDC{/t}
-{/render} -{render acl=$saFlagsPACL} -  {t}Enable use of Pyzor{/t} -{/render} -
- -
-

 

-

Rules

- - - - - -
- {$divRules}
-{render acl=$saTrustedNetworksACL} - -{/render} -
- -
- - -

 

-
- -   - -
- diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl deleted file mode 100644 index 6448ab556..000000000 --- a/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl +++ /dev/null @@ -1,25 +0,0 @@ -

Edit spam rule

- - - - - - - - - -
- {t}Name{/t} - - -
- {t}Rule{/t} - -
-

 

-
- -   - -
- diff --git a/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc b/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc deleted file mode 100644 index f91c5f5ae..000000000 --- a/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc +++ /dev/null @@ -1,248 +0,0 @@ -DisplayName = _("Anti virus"); - - /* Get userinfo & acls */ - $this->ui = get_userinfo(); - - /* Get Flags */ - foreach($this->Flags as $flag){ - $var = "avFlags".$flag; - if(preg_match("/".$flag."/",$this->avFlags)){ - $this->$var = TRUE; - } - } - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display = ""; - $smarty->assign("servtabs",FALSE); - $this->is_account = true; - - /* Assign smarty vars */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign checkbox states */ - foreach($this->Flags as $Flag){ - $var = "avFlags".$Flag; - if($this->$var){ - $smarty->assign("avFlags".$Flag."CHK"," checked " ); - }else{ - $smarty->assign("avFlags".$Flag."CHK",""); - } - } - - /* Assign value for max thread select box */ - $tmp = array(); - for($i = 1 ; $i <= 20 ; $i ++){ - $tmp[$i] = $i; - } - $smarty->assign("ThreadValues",$tmp); - - if($this->avFlagsA){ - $smarty->assign("avFlagsAState" , "" ); - }else{ - $smarty->assign("avFlagsAState" , " disabled " ); - } - - return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function save() - { - if(!$this->is_account) return; - - /* Create Flags */ - $this->avFlags = ""; - foreach($this->Flags as $flag){ - $var = "avFlags".$flag; - if($this->$var){ - $this->avFlags .=$flag; - } - } - - plugin::save(); - - if(!$this->avFlagsA){ - $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio"); - foreach($arr as $attr){ - $this->attrs[$attr] = array(); - } - $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn)); - } - - function check() - { - $message = plugin::check(); - - $mustBeNumeric = array( - "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), - "avMaxThreads" =>_("Maximum threads"), - "avArchiveMaxFileSize" =>_("Maximum file size"), - "avArchiveMaxRecursion" =>_("Maximum recursions"), - "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), - "avChecksPerDay" =>_("Checks per day")); - - foreach($mustBeNumeric as $key => $trans){ - if(!is_numeric($this->$key)){ - $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans); - } - } - - foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){ - if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){ - $message[] = sprintf(_("Please specify a valid value for '%s'."),$name); - } - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goVirusServer'])){ - plugin::save_object(); - foreach($this->Flags as $flag){ - - $var = "avFlags".$flag; - if($this->acl_is_writeable($var)){ - if(isset($_POST[$var])){ - $this->$var = TRUE; - }else{ - $this->$var = FALSE; - } - } - } - } - } - - - /* For newer service management dialogs */ - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['AllowEdit'] = true; - $fields['Message'] = _("Anti virus"); - return($fields); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Anti virus"), - "plDescription" => _("Anti virus")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 96, - "plSection" => array("administration"), - "plCategory" => array("server"), - "plProvidedAcls"=> array( - - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - - "avFlagsD" =>_("Enable debugging"), - "avFlagsS" =>_("Enable mail scanning"), - "avFlagsA" =>_("Enable scanning of archives"), - "avFlagsE" =>_("Block encrypted archives"), - - "avMaxThreads" =>_("Maximum threads"), - "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), - "avUser" =>_("Anti virus user"), - "avArchiveMaxFileSize" =>_("Maximum file size"), - "avArchiveMaxRecursion" =>_("Maximum recursions"), - "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), - "avDatabaseMirror" =>_("Database mirror"), - "avChecksPerDay" =>_("Checks per day"), - "avHttpProxyURL" =>_("Http proxy URL")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl b/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl deleted file mode 100644 index af14a2b1c..000000000 --- a/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - -
-

{t}Generic virus filtering{/t}

-
- - - - - - - - - - - - - - - - - -
- {t}Database user{/t} - -{render acl=$avUserACL} - -{/render} -
- {t}Database mirror{/t} - -{render acl=$avDatabaseMirrorACL} - -{/render} -
- {t}Http proxy URL{/t} - -{render acl=$avHttpProxyURLACL} - -{/render} -
- {t}Maximum threads{/t} - -{render acl=$avMaxThreadsACL} - -{/render} -
- -
- - - - - - - - - - - - - - - - -
- {t}Max directory recursions{/t} - -{render acl=$avMaxDirectoryRecursionsACL} - -{/render} -
- {t}Checks per day{/t} - -{render acl=$avChecksPerDayACL} - -{/render} -
-{render acl=$avFlagsDACL} - -{/render} - {t}Enable debugging{/t} -
-{render acl=$avFlagsSACL} - -{/render} - {t}Enable mail scanning{/t} -
-
-

 

-

{t}Archive scanning{/t}

-
- - - - - - - -
-{render acl=$avFlagsAACL} - -{/render} - {t}Enable scanning of archives{/t} -
-{render acl=$avFlagsEACL} - -{/render} - {t}Block encrypted archives{/t} -
- -
- - - - - - - - - - - - - -
{t}Maximum file size{/t} - -{render acl=$avArchiveMaxFileSizeACL} - -{/render} -
{t}Maximum recursion{/t} - -{render acl=$avArchiveMaxRecursionACL} - -{/render} -
{t}Maximum compression ratio{/t} - -{render acl=$avArchiveMaxCompressionRatioACL} - -{/render} -
- -
- -

 

-
- -   - -
- diff --git a/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc new file mode 100644 index 000000000..68c04e043 --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc @@ -0,0 +1,357 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goSpamServer"); + var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule"); + var $StatusFlag = "saStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goSpamServer"); + var $Flags = array("B","b","C","R","D","P"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn = ""; + var $saStatus = ""; + + var $saRewriteHeader = ""; + var $saTrustedNetworks= array(); + var $TrustedNetworks = array(); + var $saRequiredScore = 0; + var $saFlags = ""; + var $Rules = array(); + var $saRule = array(); + + var $saFlagsB = false; + var $saFlagsb = false; + var $saFlagsC = false; + var $saFlagsR = false; + var $saFlagsD = false; + var $saFlagsP = false; + + var $ui = NULL; + var $acl = NULL; + var $view_logged =FALSE; + + function gospamserver(&$config,$dn, $parent= NULL) + { + /* Init class */ + goService::goService($config,$dn, $parent); + $this->DisplayName = _("Spamassassin"); + + /* Get userinfo & acls */ + $this->ui = get_userinfo(); + + /* Get Flags */ + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + if(preg_match("/".$flag."/",$this->saFlags)){ + $this->$var = TRUE; + } + } + + /* Get trusted networks */ + $this->TrustedNetworks = array(); + if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){ + $var = $this->attrs['saTrustedNetworks']; + for($i = 0 ; $i < $var['count'] ; $i ++ ){ + $var2 = $this->attrs['saTrustedNetworks'][$i]; + $this->TrustedNetworks[ $var2 ] = $var2; + } + } + + /* Get rules */ + $this->Rules = array(); + if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){ + $var = $this->attrs['saRule']; + for($i = 0 ; $i < $var['count'] ; $i ++ ){ + $var2 = $this->attrs['saRule'][$i]; + $name = preg_replace("/:.*$/","",$var2); + $value= base64_decode(preg_replace("/^.*:/","",$var2)); + $this->Rules[ $name ] = $value; + } + } + } + + + function execute() + { + $display =""; + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* If displayed, it is ever true*/ + $this->is_account =true; + + /* Get acls */ + $tmp = $this->plinfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Add new trusted network */ + if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ + $this->AddTrust($_POST['NewTrustName']); + } + + /* Delete selected trusted network */ + if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ + $this->DelTrust($_POST['TrustedNetworks']); + } + + /* Add a new rule */ + if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){ + $this->dialog = new goSpamServerRule($this->config,$this->dn); + } + + /* Cancel adding/editing specified rule */ + if(isset($_POST['CancelRule'])){ + $this->dialog = FALSE; + } + + /* Handle post to delete rules */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){ + $once = false; + $entry = preg_replace("/^editRule_/","",$name); + $entry = preg_replace("/_(x|y)$/","",$entry); + $rule = $this->Rules[$entry]; + $name = $entry; + $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule); + } + if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){ + $once = false; + $entry = preg_replace("/^delRule_/","",$name); + $entry = preg_replace("/_(x|y)$/","",$entry); + unset($this->Rules[$entry]); + } + } + + /* Save rules */ + if(isset($_POST['SaveRule'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }elseif($this->acl_is_writeable("saRule")){ + $ret = $this->dialog->save(); + if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){ + unset($this->Rules[$ret['orig_name']]); + } + $this->Rules[$ret['name']] = $ret['rule']; + $this->dialog = FALSE; + } + } + + /* Display dialog if available */ + if($this->dialog && $this->dialog->config){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /* Assign smarty vars */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign checkbox states */ + foreach($this->Flags as $Flag){ + $var = "saFlags".$Flag; + $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag)); + if($this->$var){ + $smarty->assign("saFlags".$Flag."CHK"," checked " ); + }else{ + $smarty->assign("saFlags".$Flag."CHK",""); + } + } + + /* Create divlist */ + $DivRules = new divSelectBox("SpamRules"); + $DivRules->SetHeight(130); + + if($this->acl_is_writeable("saTrustedNetworks")){ + $actions = ""; + }else{ + + $actions = ""; + if($this->acl_is_writeable("saRule")){ + $actions.= ""; + } + } + + foreach($this->Rules as $key => $net){ + $field1 = array("string" => $key ); + $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'"); + $DivRules->AddEntry(array($field1,$field2)); + } + $smarty->assign("divRules",$DivRules->DrawList()); + $smarty->assign("TrustedNetworks",$this->TrustedNetworks); + + /* Create Spam score select box entries */ + $tmp = array(); + for($i = 0 ; $i <= 20 ; $i ++ ){ + $tmp[$i] = $i; + } + $smarty->assign("SpamScore",$tmp); + + return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__)))); + } + + + /* Add $post to list of configured trusted */ + function AddTrust($post) + { + if(!empty($post)){ + if(tests::is_ip($post) || tests::is_domain($post) || (tests::is_ip_with_subnetmask($post))){ + $this->TrustedNetworks[$post] = $post; + }else{ + print_red(_("Specified value is not a valid 'trusted network' value.")); + } + } + } + + + /* Delete trusted network */ + function DelTrust($posts) + { + foreach($posts as $post){ + if(isset($this->TrustedNetworks[$post])){ + unset($this->TrustedNetworks[$post]); + } + } + } + + function save() + { + if(!$this->is_account) return; + plugin::save(); + + /* Create Flags */ + $this->attrs['saFlags'] = array(); + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + if($this->$var){ + $this->attrs['saFlags'].=$flag; + } + } + + /* Create trusted network entries */ + $this->attrs['saTrustedNetworks'] = array(); + foreach($this->TrustedNetworks as $net){ + $this->attrs['saTrustedNetworks'][] = $net; + } + + /* Rules */ + $this->attrs['saRule'] = array(); + foreach($this->Rules as $name => $rule){ + $this->attrs['saRule'][] = $name.":".base64_encode($rule); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn)); + } + + function check() + { + $message = plugin::check(); + + /* Check if required score is numeric */ + if(!is_numeric($this->saRequiredScore)){ + $message[] = _("Required score must be a numeric value."); + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goSpamServer'])){ + + plugin::save_object(); + + /* Check flags */ + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + + if($this->acl_is_writeable($var)){ + if(isset($_POST[$var])){ + $this->$var = TRUE; + }else{ + $this->$var = FALSE; + } + } + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Spamassassin"), + "plDescription" => _("Spamassassin")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 89, + "plSection" => array("administration"), + "plCategory" => array("server"), + "plProvidedAcls"=> array( + + "saRewriteHeader" => _("Rewrite header"), + "saTrustedNetworks" => _("Trusted networks"), + "saRequiredScore" => _("Required score"), + "saRule" => _("Rules"), + + "saFlagB" => _("Enable use of bayes filtering"), + "saFlagb" => _("Enabled bayes auto learning"), + "saFlagC" => _("Enable RBL checks"), + "saFlagR" => _("Enable use of Razor"), + "saFlagD" => _("Enable use of DDC"), + "saFlagP" => _("Enable use of Pyzor")) + )); + } + + /* For newer service management dialogs */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Spamassassin"); + $fields['AllowEdit'] = true; + return($fields); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc new file mode 100644 index 000000000..c8eed5d4e --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc @@ -0,0 +1,61 @@ +name = $this->orig_name= $name; + $this->rule = $rule; + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + function save() + { + $ret =array(); + $ret['orig_name'] = $this->orig_name; + $ret['name'] = $this->name; + $ret['rule'] = $this->rule; + return($ret); + } + + function check() + { + $messages = plugin::check(); + return($messages); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl b/gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl new file mode 100644 index 000000000..c8b58852f --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + +

Spam tagging

+ + + + + + + + + + +
+ {t}Rewrite header{/t} + +{render acl=$saRewriteHeaderACL} + +{/render} +
+ {t}Required score{/t} + +{render acl=$saRequiredScoreACL} + +{/render} +
+ +

Trusted networks

+ + + + + +
+{render acl=$saTrustedNetworksACL} +
+{/render} +{render acl=$saTrustedNetworksACL} +   +{/render} +{render acl=$saTrustedNetworksACL} + +{/render} +{render acl=$saTrustedNetworksACL} + +{/render} +
+ +
+

 

+
+

Flags

+ + + + + +
+{render acl=$saFlagsBACL} +  {t}Enable use of bayes filtering{/t}
+{/render} +{render acl=$saFlagsbACL} +  {t}Enable bayes auto learning{/t}
+{/render} +{render acl=$saFlagsCACL} +  {t}Enable RBL checks{/t} +{/render} +
+
+ + + + +
+{render acl=$saFlagsRACL} +  {t}Enable use of Razor{/t}
+{/render} +{render acl=$saFlagsDACL} +  {t}Enable use of DDC{/t}
+{/render} +{render acl=$saFlagsPACL} +  {t}Enable use of Pyzor{/t} +{/render} +
+ +
+

 

+

Rules

+ + + + + +
+ {$divRules}
+{render acl=$saTrustedNetworksACL} + +{/render} +
+ +
+ + +

 

+
+ +   + +
+ diff --git a/gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl b/gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl new file mode 100644 index 000000000..6448ab556 --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl @@ -0,0 +1,25 @@ +

Edit spam rule

+ + + + + + + + + +
+ {t}Name{/t} + + +
+ {t}Rule{/t} + +
+

 

+
+ +   + +
+ diff --git a/gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc b/gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc new file mode 100644 index 000000000..f91c5f5ae --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc @@ -0,0 +1,248 @@ +DisplayName = _("Anti virus"); + + /* Get userinfo & acls */ + $this->ui = get_userinfo(); + + /* Get Flags */ + foreach($this->Flags as $flag){ + $var = "avFlags".$flag; + if(preg_match("/".$flag."/",$this->avFlags)){ + $this->$var = TRUE; + } + } + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display = ""; + $smarty->assign("servtabs",FALSE); + $this->is_account = true; + + /* Assign smarty vars */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign checkbox states */ + foreach($this->Flags as $Flag){ + $var = "avFlags".$Flag; + if($this->$var){ + $smarty->assign("avFlags".$Flag."CHK"," checked " ); + }else{ + $smarty->assign("avFlags".$Flag."CHK",""); + } + } + + /* Assign value for max thread select box */ + $tmp = array(); + for($i = 1 ; $i <= 20 ; $i ++){ + $tmp[$i] = $i; + } + $smarty->assign("ThreadValues",$tmp); + + if($this->avFlagsA){ + $smarty->assign("avFlagsAState" , "" ); + }else{ + $smarty->assign("avFlagsAState" , " disabled " ); + } + + return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function save() + { + if(!$this->is_account) return; + + /* Create Flags */ + $this->avFlags = ""; + foreach($this->Flags as $flag){ + $var = "avFlags".$flag; + if($this->$var){ + $this->avFlags .=$flag; + } + } + + plugin::save(); + + if(!$this->avFlagsA){ + $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio"); + foreach($arr as $attr){ + $this->attrs[$attr] = array(); + } + $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn)); + } + + function check() + { + $message = plugin::check(); + + $mustBeNumeric = array( + "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), + "avMaxThreads" =>_("Maximum threads"), + "avArchiveMaxFileSize" =>_("Maximum file size"), + "avArchiveMaxRecursion" =>_("Maximum recursions"), + "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), + "avChecksPerDay" =>_("Checks per day")); + + foreach($mustBeNumeric as $key => $trans){ + if(!is_numeric($this->$key)){ + $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans); + } + } + + foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){ + if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){ + $message[] = sprintf(_("Please specify a valid value for '%s'."),$name); + } + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goVirusServer'])){ + plugin::save_object(); + foreach($this->Flags as $flag){ + + $var = "avFlags".$flag; + if($this->acl_is_writeable($var)){ + if(isset($_POST[$var])){ + $this->$var = TRUE; + }else{ + $this->$var = FALSE; + } + } + } + } + } + + + /* For newer service management dialogs */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['AllowEdit'] = true; + $fields['Message'] = _("Anti virus"); + return($fields); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Anti virus"), + "plDescription" => _("Anti virus")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 96, + "plSection" => array("administration"), + "plCategory" => array("server"), + "plProvidedAcls"=> array( + + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + + "avFlagsD" =>_("Enable debugging"), + "avFlagsS" =>_("Enable mail scanning"), + "avFlagsA" =>_("Enable scanning of archives"), + "avFlagsE" =>_("Block encrypted archives"), + + "avMaxThreads" =>_("Maximum threads"), + "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), + "avUser" =>_("Anti virus user"), + "avArchiveMaxFileSize" =>_("Maximum file size"), + "avArchiveMaxRecursion" =>_("Maximum recursions"), + "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), + "avDatabaseMirror" =>_("Database mirror"), + "avChecksPerDay" =>_("Checks per day"), + "avHttpProxyURL" =>_("Http proxy URL")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl b/gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl new file mode 100644 index 000000000..af14a2b1c --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + +
+

{t}Generic virus filtering{/t}

+
+ + + + + + + + + + + + + + + + + +
+ {t}Database user{/t} + +{render acl=$avUserACL} + +{/render} +
+ {t}Database mirror{/t} + +{render acl=$avDatabaseMirrorACL} + +{/render} +
+ {t}Http proxy URL{/t} + +{render acl=$avHttpProxyURLACL} + +{/render} +
+ {t}Maximum threads{/t} + +{render acl=$avMaxThreadsACL} + +{/render} +
+ +
+ + + + + + + + + + + + + + + + +
+ {t}Max directory recursions{/t} + +{render acl=$avMaxDirectoryRecursionsACL} + +{/render} +
+ {t}Checks per day{/t} + +{render acl=$avChecksPerDayACL} + +{/render} +
+{render acl=$avFlagsDACL} + +{/render} + {t}Enable debugging{/t} +
+{render acl=$avFlagsSACL} + +{/render} + {t}Enable mail scanning{/t} +
+
+

 

+

{t}Archive scanning{/t}

+
+ + + + + + + +
+{render acl=$avFlagsAACL} + +{/render} + {t}Enable scanning of archives{/t} +
+{render acl=$avFlagsEACL} + +{/render} + {t}Block encrypted archives{/t} +
+ +
+ + + + + + + + + + + + + +
{t}Maximum file size{/t} + +{render acl=$avArchiveMaxFileSizeACL} + +{/render} +
{t}Maximum recursion{/t} + +{render acl=$avArchiveMaxRecursionACL} + +{/render} +
{t}Maximum compression ratio{/t} + +{render acl=$avArchiveMaxCompressionRatioACL} + +{/render} +
+ +
+ +

 

+
+ +   + +
+