X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=philter%2Fphilter%2Finclude%2Fphilter.inc.php;h=463f772f9703fc9dab35e396c121e0d6f9b68513;hb=ca0523711dc4ec02f2effb2ccfd3f6b176a325d0;hp=8874dcdd0dc8f299816b2841115433f6845bd1b4;hpb=d821a8ac1e53741f9342a8c3b60acf91d7b85404;p=old-projects.git diff --git a/philter/philter/include/philter.inc.php b/philter/philter/include/philter.inc.php index 8874dcd..463f772 100644 --- a/philter/philter/include/philter.inc.php +++ b/philter/philter/include/philter.inc.php @@ -10,6 +10,8 @@ require_once("include/core.inc.php"); function i18n($_index) { global $philter; echo $philter->i18n($_index); } +function _i18n($_index) { global $philter; return $philter->i18n($_index); } +function bd() { global $philter; return ($philter->is_advanced() ? 'tmp_' : ''); } /** Philter base configuration class * This is the base class of Philter. @@ -29,12 +31,16 @@ class Philter { 'path' => array('procmail', 'spool'), 'match_plugins' => array(), 'action_plugins' => array(), - 'global_plugin' => array(), + 'global_plugins' => array(), 'i18n' => array() ); $this->err = ""; } + function is_advanced() { return isset($_SESSION['philter_adv']); } + function set_advanced() { $_SESSION['philter_adv'] = true; } + function del_advanced() { unset($_SESSION['philter_adv']); } + /** returns the i18n string * @param $_index the index of the string * @returns the string or false @@ -77,10 +83,16 @@ class Philter { } /** function that writes the procmailrc. + * @param &$procmail the string containing the procmail filter + * @param $filename the base filename of the procmailrc filter * @return true if all is ok */ - function write_procmailrc() { - // TODO + function write_procmailrc(&$procmail, $filename) { + $file = $this->config['path']['spool']."/".$filename; + $f = fopen($file.".tmp", "w"); + fwrite($f, $procmail, strlen($procmail)); + fclose($f); + rename($file.".tmp", $file); return true; } @@ -132,12 +144,12 @@ class Philter { return false; } - if(isset($this->config['global_plugin'][$rtti])) { + if(isset($this->config['global_plugins'][$rtti])) { $this->err = "Philter::register_global_plugin : a plugin is already registerd"; return false; } - $this->config['global_plugin'][$rtti] = $_plugin; + $this->config['global_plugins'][$rtti] = $_plugin; return true; }