$timezone = array(); foreach ($zones as $zone) { $timezone['timezones'][$zone] = $Time->setTimezone(new DateTimeZone($zone))->format('O'); } $localtime = localtime(time(), true); $timezone['isDaylightSaving'] = !!$localtime['tm_isdst'] ? 1 : 0; echo '<script type="text/javascript"> var Timezone = ' . json_encode($timezone) . '</script>'; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////// Verifica se o usuario esta fora do escritorio imprime a variavel javascript "outOfficeFlag" //////////////// include_once __DIR__ . '/../prototype/library/Net/Sieve.php'; $sieveConf = parse_ini_file(__DIR__ . "/../prototype/config/Sieve.srv", true); $sieveConf = $sieveConf['config']; $sieve = new Net_Sieve(); $inVacation = false; @$sieve->connect($sieveConf['host'], $sieveConf['port'], $sieveConf['options'], $sieveConf['useTLS']); @$sieve->login($_SESSION['wallet']['Sieve']['user'], $_SESSION['wallet']['Sieve']['password'], $sieveConf['loginType']); $script = $sieve->getScript($sieve->getActive()); $old_rule = strripos($script, "##PSEUDO script start"); if ($old_rule) { if (preg_match("/^ *#vacation/im", $script)) { $inVacation = true; } } else { $pos = strripos($script, "#PseudoScript#"); $pseudo_script = substr($script, $pos + 17); $sieveRules = json_decode($pseudo_script, true); if (count($sieveRules) > 0) { foreach ($sieveRules as $i => $v) { if ($v['id'] == 'vacation' && $v['enabled'] == 'true') { $inVacation = true; }
// 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_script1 = "require \"vacation\";\nvacation\n:days 7\n:addresses [\"matthew@de-construct.com\"]\n:subject \"This is a test\"\n\"I'm on my holiday!\nsadfafs\";"; //$sieve=new Net_Sieve($user, $passwd, $host , $port , 'PLAIN'); //$sieve=new Net_Sieve($user, $passwd, $host , $port, 'DIGEST-MD5' ); //$sieve=new Net_Sieve($user, $passwd, $host , $port); $sieve = new Net_Sieve(); $sieve->setDebug(true); if (PEAR::isError($error = $sieve->connect($host, $port))) { echo " there was an error trying to connect to the server. The error is: " . $error->getMessage() . "\n"; exit; } //if(PEAR::isError($error = $sieve->login($user, $passwd , 'PLAIN' , '', false ) ) ){ if (PEAR::isError($error = $sieve->login($user, $passwd, null, '', false))) { echo " there was an error trying to connect to the server. The error is: " . $error->getMessage() . "\n"; exit; } // I list the scripts that I Have installed echo "These are the scripts that I have in the server:\n"; print_r($sieve->listScripts()); echo "\n"; echo "I remove script 1 ({$sieve_script_name1})......\n"; if (!PEAR::isError($error = $sieve->removeScript($sieve_script_name1))) { 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"; // I try to delete again de same script, the method must fail