|
From: Alexandros V. <av...@us...> - 2004-12-06 17:45:51
|
Update of /cvsroot/sieve-php/sieve-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7591 Modified Files: sieve-php.lib.php Log Message: Patch 927030, Support for REFERRAL Index: sieve-php.lib.php =================================================================== RCS file: /cvsroot/sieve-php/sieve-php/sieve-php.lib.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sieve-php.lib.php 6 Dec 2004 17:43:13 -0000 1.6 --- sieve-php.lib.php 6 Dec 2004 17:45:41 -0000 1.7 *************** *** 101,104 **** --- 101,110 ---- var $error_raw; var $responses; + + // lastcmd is for referral processing + var $lastcmd; + var $reftok; + var $refsv; + //maybe we should add an errorlvl that the user will pass to new sieve = sieve(,,,,E_WARN) *************** *** 208,211 **** --- 214,251 ---- } /* end elseif */ + elseif(strstr($this->token[1], '(REFERRAL "' ) ){ + /* process a referral, retry the lastcmd, return the results. this is + sort of messy, really I should probably try to use parse_for_quotes + but the problem is I still have the ( )'s to deal with. This is + atleast true for timsieved as it sits in 2.1.16, if someone has a + BYE (REFERRAL ...) example for later timsieved please forward it to + me and I'll code it in proper-like! - ml...@wg... */ + $this->reftok = split(" ", $this->token[1], 3); + $this->refsv = substr($this->reftok[1], 0, -2); + $this->refsv = substr($this->refsv, 1); + $this->host = $this->refsv; + $this->loggedin = false; + /* flush buffers or anything? probably not, and the remote has already closed it's + end by now! */ + fclose($this->fp); + + if( sieve::sieve_login() ) { + fputs($this->fp, $this->lastcmd); + return sieve::get_response(); + } /* end good case happy ending */ + else{ + /* what to do? login failed, should we punt and die? or log back into the referrer? + i'm electing to retn EC_UNKNOWN for now and set the error string. */ + + $this->loggedin = false; + fclose($this->fp); + $this->error = EC_UNKNOWN; + $this->error_raw = 'UNABLE TO REFERRAL - ' . $this->line; + return false; + } /* end else of the unhappy ending */ + + /* should never make it here! */ + + } /* end elseif */ else{ $this->error = EC_UNKNOWN; *************** *** 495,501 **** $this->script=stripslashes($script); $len=strlen($this->script); ! fputs($this->fp, "PUTSCRIPT \"$scriptname\" \{$len+}\r\n"); ! fputs($this->fp, "$this->script\r\n"); ! return sieve::get_response(); --- 535,541 ---- $this->script=stripslashes($script); $len=strlen($this->script); ! ! $this->lastcmd = "PUTSCRIPT \"$scriptname\" \{$len+}\r\n$this->script\r\n"; ! fputs($this->fp, $this->lastcmd); return sieve::get_response(); *************** *** 522,526 **** if($this->loggedin==false) return false; ! fputs($this->fp, "HAVESPACE \"$scriptname\" $scriptsize\r\n"); return sieve::get_response(); } --- 562,568 ---- if($this->loggedin==false) return false; ! ! $this->lastcmd = "HAVESPACE \"$scriptname\" $scriptsize\r\n"; ! fputs($this->fp, $this->lastcmd); return sieve::get_response(); } *************** *** 535,540 **** if($this->loggedin==false) return false; ! ! fputs($this->fp, "SETACTIVE \"$scriptname\"\r\n"); return sieve::get_response(); --- 577,583 ---- if($this->loggedin==false) return false; ! ! $this->lastcmd = "SETACTIVE \"$scriptname\"\r\n"; ! fputs($this->fp, $this->lastcmd); return sieve::get_response(); *************** *** 554,559 **** if($this->loggedin==false) return false; ! ! fputs($this->fp, "GETSCRIPT \"$scriptname\"\r\n"); return sieve::get_response(); } --- 597,603 ---- if($this->loggedin==false) return false; ! ! $this->lastcmd = "GETSCRIPT \"$scriptname\"\r\n"; ! fputs($this->fp, $this->lastcmd); return sieve::get_response(); } *************** *** 571,576 **** if($this->loggedin==false) return false; ! ! fputs($this->fp, "DELETESCRIPT \"$scriptname\"\r\n"); return sieve::get_response(); --- 615,621 ---- if($this->loggedin==false) return false; ! ! $this->lastcmd = "DELETESCRIPT \"$scriptname\"\r\n"; ! fputs($this->fp, $this->lastcmd); return sieve::get_response(); *************** *** 588,592 **** */ function sieve_listscripts() { ! fputs($this->fp, "LISTSCRIPTS\r\n"); sieve::get_response(); //should always return true, even if there are no scripts... if(isset($this->found_script) and $this->found_script) --- 633,638 ---- */ function sieve_listscripts() { ! $this->lastcmd = "LISTSCRIPTS\r\n"; ! fputs($this->fp, $this->lastcmd); sieve::get_response(); //should always return true, even if there are no scripts... if(isset($this->found_script) and $this->found_script) |