<?
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license,      |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Author: Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>       |
// +----------------------------------------------------------------------+


include_once('Net/Sieve.php');
error_reporting(E_ALL);



$user='user';
$pass='password';
$host='localhost';




$sieve_script_name1='test script1';
// The script
$sieve_script1="require \"fileinto\";\n\rif header :contains \"From:\" \"@cnba.uba.ar\" \n\r{fileinto \"INBOX.Test1\";}\r\nelse \r\n{fileinto \"INBOX\";}";


$sieve_script_name2='test script2';
$sieve_script2="require \"fileinto\";\n\rif header :contains \"From:\" \"@cnba.uba.ar\" \n\r{fileinto \"INBOX.Test\";}\r\nelse \r\n{fileinto \"INBOX\";}";




$sieve=new Net_Sieve($user, $pass, $host );

//$sieve->setDebug(true);


// I list the scripts that I Have installed
print_r($sieve->listScripts());




$sieve->removeScript($sieve_script_name);
// I install the script $sieve_script1 and mark it active
$sieve->installScript($sieve_script_name1, $sieve_script1,true);

// I install the script $sieve_script2 but it is not marked as active
$sieve->installScript($sieve_script_name2, $sieve_script2;



// Now set script 2 as active
print_r($sieve->setActive($sieve_script_name2));

// Now get the active script
print_r($sieve->getActive());

//print_r($sieve);

echo "\n";




?>