示例#1
0
 /**
  * Sets a script running on the backend.
  *
  * @param array $script  The filter script information. Passed elements:
  *                       - 'name': (string) the script name.
  *                       - 'recipes': (array) the filter recipe objects.
  *                       - 'script': (string) the filter script.
  *
  * @throws Ingo_Exception
  */
 public function setScriptActive($script)
 {
     $this->_connect();
     if (!strlen($script['script'])) {
         Ingo_Exception_Pear::catchError($this->_sieve->setActive(''));
         Ingo_Exception_Pear::catchError($this->_sieve->removeScript($script['name']));
         return;
     }
     Ingo_Exception_Pear::catchError($this->_sieve->haveSpace($script['name'], strlen($script['script'])));
     Ingo_Exception_Pear::catchError($this->_sieve->installScript($script['name'], $script['script'], true));
 }
示例#2
0
    echo "  script '{$sieve_script_name1}' removed ok!\n";
} else {
    echo "  there was an error trying to remove the script '{$sieve_script_name1}'. The error is: " . $error->getMessage() . "\n";
}
echo "\n";
/*
echo "I'll check if the server has space to store '$sieve_script_name1' script .....";
if(!PEAR::isError( $error = $sieve->haveSpace($sieve_script_name1, strlen($sieve_script1)))){
    echo "  ok! the server has a lot of space!\n";
}else{
    echo "  the server can't store the script. The error is: " . $error->getMessage() . "\n" ;
}
echo "\n";
*/
echo "I install the script '{$sieve_script_name1}' and mark it active.....\n";
if (!PEAR::isError($error = $sieve->installScript($sieve_script_name1, $sieve_script1, true))) {
    echo "  script '{$sieve_script_name1}' installed ok!\n";
} else {
    echo "  there was an error trying to install the script '{$sieve_script_name1}'. The error is: " . $error->getMessage() . "\n";
}
echo "\n";
echo "This is the script I just installed.....\n";
if (!PEAR::isError($error = $sieve->getScript($sieve_script_name1))) {
    echo "  script '{$sieve_script_name1}':\n{$error}\n";
} else {
    echo "  there was an error trying to install the script '{$sieve_script_name1}'. The error is: " . $error->getMessage() . "\n";
}
echo "I install the script '{$sieve_script_name2}' but it is not marked as active.....\n";
if (!PEAR::isError($error = $sieve->installScript($sieve_script_name2, $sieve_script2))) {
    echo "  script '{$sieve_script_name2}' installed ok!\n";
} else {