idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
5,700
private function establishSocketConnection ( ) { $ host = $ this -> params [ 'host' ] ; if ( ! empty ( $ this -> params [ 'protocol' ] ) ) { $ host = $ this -> params [ 'protocol' ] . '://' . $ host ; } $ timeout = 15 ; if ( ! empty ( $ this -> params [ 'timeout' ] ) ) { $ timeout = $ this -> params [ 'timeout' ] ; } $...
Establishes a connection to a remote server .
5,701
protected function sendMessage1 ( Swift_Transport_SmtpAgent $ agent ) { $ message = $ this -> createMessage1 ( ) ; return $ agent -> executeCommand ( sprintf ( "AUTH %s %s\r\n" , $ this -> getAuthKeyword ( ) , base64_encode ( $ message ) ) , [ 334 ] ) ; }
Send our auth message and returns the response .
5,702
protected function readSubBlock ( $ block ) { $ block = substr ( $ block , 0 , - 8 ) ; $ length = strlen ( $ block ) ; $ offset = 0 ; $ data = [ ] ; while ( $ offset < $ length ) { $ blockLength = hexdec ( substr ( substr ( $ block , $ offset , 8 ) , - 4 ) ) / 256 ; $ offset += 8 ; $ data [ ] = hex2bin ( substr ( $ blo...
Read the blob information in from message2 .
5,703
protected function sendMessage3 ( $ response , $ username , $ password , $ timestamp , $ client , Swift_Transport_SmtpAgent $ agent , $ v2 = true ) { list ( $ domain , $ username ) = $ this -> getDomainAndUsername ( $ username ) ; list ( $ challenge , , , , , $ workstation , , , $ blob ) = $ this -> parseMessage2 ( $ r...
Send our final message with all our data .
5,704
protected function createMessage3 ( $ domain , $ username , $ workstation , $ lmResponse , $ ntlmResponse ) { $ domainSec = $ this -> createSecurityBuffer ( $ domain , 64 ) ; $ domainInfo = $ this -> readSecurityBuffer ( bin2hex ( $ domainSec ) ) ; $ userSec = $ this -> createSecurityBuffer ( $ username , ( $ domainInf...
Create our message 3 .
5,705
protected function getDomainAndUsername ( $ name ) { if ( false !== strpos ( $ name , '\\' ) ) { return explode ( '\\' , $ name ) ; } if ( false !== strpos ( $ name , '@' ) ) { list ( $ user , $ domain ) = explode ( '@' , $ name ) ; return [ $ domain , $ user ] ; } return [ '' , $ name ] ; }
Get domain and username from our username .
5,706
protected function createLMPassword ( $ password , $ challenge ) { $ password = $ this -> createByte ( strtoupper ( $ password ) , 14 , false ) ; list ( $ key1 , $ key2 ) = str_split ( $ password , 7 ) ; $ desKey1 = $ this -> createDesKey ( $ key1 ) ; $ desKey2 = $ this -> createDesKey ( $ key2 ) ; $ constantDecrypt = ...
Create LMv1 response .
5,707
protected function createNTLMPassword ( $ password , $ challenge ) { $ ntlmHash = $ this -> createByte ( $ this -> md4Encrypt ( $ password ) , 21 , false ) ; list ( $ key1 , $ key2 , $ key3 ) = str_split ( $ ntlmHash , 7 ) ; $ desKey1 = $ this -> createDesKey ( $ key1 ) ; $ desKey2 = $ this -> createDesKey ( $ key2 ) ;...
Create NTLMv1 response .
5,708
protected function getCorrectTimestamp ( $ time ) { $ time = number_format ( $ time , 0 , '.' , '' ) ; $ time = bcadd ( $ time , '11644473600000' , 0 ) ; $ time = bcmul ( $ time , 10000 , 0 ) ; $ binary = $ this -> si2bin ( $ time , 64 ) ; $ timestamp = '' ; for ( $ i = 0 ; $ i < 8 ; ++ $ i ) { $ timestamp .= chr ( bin...
Convert a normal timestamp to a tenth of a microtime epoch time .
5,709
protected function createLMv2Password ( $ password , $ username , $ domain , $ challenge , $ client ) { $ lmPass = '00' ; if ( strlen ( $ password ) <= 15 ) { $ ntlmHash = $ this -> md4Encrypt ( $ password ) ; $ ntml2Hash = $ this -> md5Encrypt ( $ ntlmHash , $ this -> convertTo16bit ( strtoupper ( $ username ) . $ dom...
Create LMv2 response .
5,710
protected function createNTLMv2Hash ( $ password , $ username , $ domain , $ challenge , $ targetInfo , $ timestamp , $ client ) { $ ntlmHash = $ this -> md4Encrypt ( $ password ) ; $ ntml2Hash = $ this -> md5Encrypt ( $ ntlmHash , $ this -> convertTo16bit ( strtoupper ( $ username ) . $ domain ) ) ; $ blob = $ this ->...
Create NTLMv2 response .
5,711
protected function createSecurityBuffer ( $ value , $ offset , $ is16 = false ) { $ length = strlen ( bin2hex ( $ value ) ) ; $ length = $ is16 ? $ length / 2 : $ length ; $ length = $ this -> createByte ( str_pad ( dechex ( $ length ) , 2 , '0' , STR_PAD_LEFT ) , 2 ) ; return $ length . $ length . $ this -> createByte...
Create our security buffer depending on length and offset .
5,712
protected function readSecurityBuffer ( $ value ) { $ length = floor ( hexdec ( substr ( $ value , 0 , 4 ) ) / 256 ) * 2 ; $ offset = floor ( hexdec ( substr ( $ value , 8 , 4 ) ) / 256 ) * 2 ; return [ $ length , $ offset ] ; }
Read our security buffer to fetch length and offset of our value .
5,713
protected function createByte ( $ input , $ bytes = 4 , $ isHex = true ) { if ( $ isHex ) { $ byte = hex2bin ( str_pad ( $ input , $ bytes * 2 , '00' ) ) ; } else { $ byte = str_pad ( $ input , $ bytes , "\x00" ) ; } return $ byte ; }
Right padding with 0 to certain length .
5,714
protected function md5Encrypt ( $ key , $ msg ) { $ blocksize = 64 ; if ( strlen ( $ key ) > $ blocksize ) { $ key = pack ( 'H*' , md5 ( $ key ) ) ; } $ key = str_pad ( $ key , $ blocksize , "\0" ) ; $ ipadk = $ key ^ str_repeat ( "\x36" , $ blocksize ) ; $ opadk = $ key ^ str_repeat ( "\x5c" , $ blocksize ) ; return p...
MD5 Encryption .
5,715
protected function md4Encrypt ( $ input ) { $ input = $ this -> convertTo16bit ( $ input ) ; return function_exists ( 'hash' ) ? hex2bin ( hash ( 'md4' , $ input ) ) : mhash ( MHASH_MD4 , $ input ) ; }
MD4 Encryption .
5,716
public function setQPDotEscape ( $ dotEscape ) { $ dotEscape = ! empty ( $ dotEscape ) ; Swift_DependencyContainer :: getInstance ( ) -> register ( 'mime.qpcontentencoder' ) -> asNewInstanceOf ( 'Swift_Mime_ContentEncoder_QpContentEncoder' ) -> withDependencies ( [ 'mime.charstream' , 'mime.bytecanonicalizer' ] ) -> ad...
Set the QuotedPrintable dot escaper preference .
5,717
public function write ( $ bytes ) { $ this -> out += strlen ( $ bytes ) ; foreach ( $ this -> mirrors as $ stream ) { $ stream -> write ( $ bytes ) ; } }
Called when a message is sent so that the outgoing counter can be increased .
5,718
public function addPart ( $ body , $ contentType = null , $ charset = null ) { return $ this -> attach ( ( new Swift_MimePart ( $ body , $ contentType , $ charset ) ) -> setEncoder ( $ this -> getEncoder ( ) ) ) ; }
Add a MimePart to this Message .
5,719
public function attachSigner ( Swift_Signer $ signer ) { if ( $ signer instanceof Swift_Signers_HeaderSigner ) { $ this -> headerSigners [ ] = $ signer ; } elseif ( $ signer instanceof Swift_Signers_BodySigner ) { $ this -> bodySigners [ ] = $ signer ; } return $ this ; }
Attach a new signature handler to the message .
5,720
public function detachSigner ( Swift_Signer $ signer ) { if ( $ signer instanceof Swift_Signers_HeaderSigner ) { foreach ( $ this -> headerSigners as $ k => $ headerSigner ) { if ( $ headerSigner === $ signer ) { unset ( $ this -> headerSigners [ $ k ] ) ; return $ this ; } } } elseif ( $ signer instanceof Swift_Signer...
Detach a signature handler from a message .
5,721
protected function doSign ( ) { foreach ( $ this -> bodySigners as $ signer ) { $ altered = $ signer -> getAlteredHeaders ( ) ; $ this -> saveHeaders ( $ altered ) ; $ signer -> signMessage ( $ this ) ; } foreach ( $ this -> headerSigners as $ signer ) { $ altered = $ signer -> getAlteredHeaders ( ) ; $ this -> saveHea...
loops through signers and apply the signatures .
5,722
protected function saveMessage ( ) { $ this -> savedMessage = [ 'headers' => [ ] ] ; $ this -> savedMessage [ 'body' ] = $ this -> getBody ( ) ; $ this -> savedMessage [ 'children' ] = $ this -> getChildren ( ) ; if ( count ( $ this -> savedMessage [ 'children' ] ) > 0 && '' != $ this -> getBody ( ) ) { $ this -> setCh...
save the message before any signature is applied .
5,723
protected function saveHeaders ( array $ altered ) { foreach ( $ altered as $ head ) { $ lc = strtolower ( $ head ) ; if ( ! isset ( $ this -> savedMessage [ 'headers' ] [ $ lc ] ) ) { $ this -> savedMessage [ 'headers' ] [ $ lc ] = $ this -> getHeaders ( ) -> getAll ( $ head ) ; } } }
save the original headers .
5,724
protected function restoreHeaders ( ) { foreach ( $ this -> savedMessage [ 'headers' ] as $ name => $ savedValue ) { $ headers = $ this -> getHeaders ( ) -> getAll ( $ name ) ; foreach ( $ headers as $ key => $ value ) { if ( ! isset ( $ savedValue [ $ key ] ) ) { $ this -> getHeaders ( ) -> remove ( $ name , $ key ) ;...
Remove or restore altered headers .
5,725
protected function restoreMessage ( ) { $ this -> setBody ( $ this -> savedMessage [ 'body' ] ) ; $ this -> setChildren ( $ this -> savedMessage [ 'children' ] ) ; $ this -> restoreHeaders ( ) ; $ this -> savedMessage = [ ] ; }
Restore message body .
5,726
public function setCharset ( $ charset ) { $ this -> charset = $ charset ; $ this -> factory -> charsetChanged ( $ charset ) ; $ this -> notifyHeadersOfCharset ( $ charset ) ; }
Set the charset used by these headers .
5,727
public function addIdHeader ( $ name , $ ids = null ) { $ this -> storeHeader ( $ name , $ this -> factory -> createIdHeader ( $ name , $ ids ) ) ; }
Add a new ID header for Message - ID or Content - ID .
5,728
public function set ( Swift_Mime_Header $ header , $ index = 0 ) { $ this -> storeHeader ( $ header -> getFieldName ( ) , $ header , $ index ) ; }
Set a header in the HeaderSet .
5,729
public function listAll ( ) { $ headers = $ this -> headers ; if ( $ this -> canSort ( ) ) { uksort ( $ headers , [ $ this , 'sortHeaders' ] ) ; } return array_keys ( $ headers ) ; }
Return the name of all Headers .
5,730
public function toString ( ) { $ string = '' ; $ headers = $ this -> headers ; if ( $ this -> canSort ( ) ) { uksort ( $ headers , [ $ this , 'sortHeaders' ] ) ; } foreach ( $ headers as $ collection ) { foreach ( $ collection as $ header ) { if ( $ this -> isDisplayed ( $ header ) || '' != $ header -> getFieldBody ( )...
Returns a string with a representation of all headers .
5,731
private function storeHeader ( $ name , Swift_Mime_Header $ header , $ offset = null ) { if ( ! isset ( $ this -> headers [ strtolower ( $ name ) ] ) ) { $ this -> headers [ strtolower ( $ name ) ] = [ ] ; } if ( ! isset ( $ offset ) ) { $ this -> headers [ strtolower ( $ name ) ] [ ] = $ header ; } else { $ this -> he...
Save a Header to the internal collection
5,732
private function notifyHeadersOfCharset ( $ charset ) { foreach ( $ this -> headers as $ headerGroup ) { foreach ( $ headerGroup as $ header ) { $ header -> setCharset ( $ charset ) ; } } }
Notify all Headers of the new charset
5,733
public function setSubject ( $ subject ) { if ( ! $ this -> setHeaderFieldModel ( 'Subject' , $ subject ) ) { $ this -> getHeaders ( ) -> addTextHeader ( 'Subject' , $ subject ) ; } return $ this ; }
Set the subject of this message .
5,734
public function setDate ( DateTimeInterface $ dateTime ) { if ( ! $ this -> setHeaderFieldModel ( 'Date' , $ dateTime ) ) { $ this -> getHeaders ( ) -> addDateHeader ( 'Date' , $ dateTime ) ; } return $ this ; }
Set the date at which this message was created .
5,735
public function detach ( Swift_Mime_SimpleMimeEntity $ entity ) { $ newChildren = [ ] ; foreach ( $ this -> getChildren ( ) as $ child ) { if ( $ entity !== $ child ) { $ newChildren [ ] = $ child ; } } $ this -> setChildren ( $ newChildren ) ; return $ this ; }
Remove an already attached entity .
5,736
protected function becomeMimePart ( ) { $ part = new parent ( $ this -> getHeaders ( ) -> newInstance ( ) , $ this -> getEncoder ( ) , $ this -> getCache ( ) , $ this -> getIdGenerator ( ) , $ this -> userCharset ) ; $ part -> setContentType ( $ this -> userContentType ) ; $ part -> setBody ( $ this -> getBody ( ) ) ; ...
Turn the body of this message into a child of itself if needed
5,737
private function getTopNestingLevel ( ) { $ highestLevel = $ this -> getNestingLevel ( ) ; foreach ( $ this -> getChildren ( ) as $ child ) { $ childLevel = $ child -> getNestingLevel ( ) ; if ( $ highestLevel < $ childLevel ) { $ highestLevel = $ childLevel ; } } return $ highestLevel ; }
Get the highest nesting level nested inside this message
5,738
public function setAddress ( $ address ) { if ( null === $ address ) { $ this -> address = null ; } elseif ( '' == $ address ) { $ this -> address = '' ; } else { $ this -> assertValidAddress ( $ address ) ; $ this -> address = $ address ; } $ this -> setCachedValue ( null ) ; }
Set the Address which should appear in this Header .
5,739
public function setTimeout ( $ timeout ) { $ this -> params [ 'timeout' ] = ( int ) $ timeout ; $ this -> buffer -> setParam ( 'timeout' , ( int ) $ timeout ) ; return $ this ; }
Set the connection timeout .
5,740
public function setExtensionHandlers ( array $ handlers ) { $ assoc = [ ] ; foreach ( $ handlers as $ handler ) { $ assoc [ $ handler -> getHandledKeyword ( ) ] = $ handler ; } uasort ( $ assoc , function ( $ a , $ b ) { return $ a -> getPriorityOver ( $ b -> getHandledKeyword ( ) ) ; } ) ; $ this -> handlers = $ assoc...
Set ESMTP extension handlers .
5,741
protected function doHeloCommand ( ) { try { $ response = $ this -> executeCommand ( sprintf ( "EHLO %s\r\n" , $ this -> domain ) , [ 250 ] ) ; } catch ( Swift_TransportException $ e ) { return parent :: doHeloCommand ( ) ; } if ( $ this -> params [ 'tls' ] ) { try { $ this -> executeCommand ( "STARTTLS\r\n" , [ 220 ] ...
Overridden to perform EHLO instead
5,742
protected function doMailFromCommand ( $ address ) { $ address = $ this -> addressEncoder -> encodeString ( $ address ) ; $ handlers = $ this -> getActiveHandlers ( ) ; $ params = [ ] ; foreach ( $ handlers as $ handler ) { $ params = array_merge ( $ params , ( array ) $ handler -> getMailParams ( ) ) ; } $ paramStr = ...
Overridden to add Extension support
5,743
private function getCapabilities ( $ ehloResponse ) { $ capabilities = [ ] ; $ ehloResponse = trim ( $ ehloResponse ) ; $ lines = explode ( "\r\n" , $ ehloResponse ) ; array_shift ( $ lines ) ; foreach ( $ lines as $ line ) { if ( preg_match ( '/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di' , $ line , $ matches ) ) { $ k...
Determine ESMTP capabilities by function group
5,744
private function setHandlerParams ( ) { foreach ( $ this -> handlers as $ keyword => $ handler ) { if ( array_key_exists ( $ keyword , $ this -> capabilities ) ) { $ handler -> setKeywordParams ( $ this -> capabilities [ $ keyword ] ) ; } } }
Set parameters which are used by each extension handler
5,745
private function getActiveHandlers ( ) { $ handlers = [ ] ; foreach ( $ this -> handlers as $ keyword => $ handler ) { if ( array_key_exists ( $ keyword , $ this -> capabilities ) ) { $ handlers [ ] = $ handler ; } } return $ handlers ; }
Get ESMTP handlers which are currently ok to use
5,746
public function importByteStream ( Swift_OutputByteStream $ os ) { if ( ! isset ( $ this -> charReader ) ) { $ this -> charReader = $ this -> charReaderFactory -> getReaderFor ( $ this -> charset ) ; } $ startLength = $ this -> charReader -> getInitialByteSize ( ) ; while ( false !== $ bytes = $ os -> read ( $ startLen...
Overwrite this character stream using the byte sequence in the byte stream .
5,747
public function getId ( ) { $ tmp = ( array ) $ this -> getHeaderFieldModel ( $ this -> getIdField ( ) ) ; return $ this -> headers -> has ( $ this -> getIdField ( ) ) ? current ( $ tmp ) : $ this -> id ; }
Get the CID of this entity .
5,748
public function setId ( $ id ) { if ( ! $ this -> setHeaderFieldModel ( $ this -> getIdField ( ) , $ id ) ) { $ this -> headers -> addIdHeader ( $ this -> getIdField ( ) , $ id ) ; } $ this -> id = $ id ; return $ this ; }
Set the CID of this entity .
5,749
public function setDescription ( $ description ) { if ( ! $ this -> setHeaderFieldModel ( 'Content-Description' , $ description ) ) { $ this -> headers -> addTextHeader ( 'Content-Description' , $ description ) ; } return $ this ; }
Set the description of this entity .
5,750
public function setChildren ( array $ children , $ compoundLevel = null ) { $ compoundLevel = $ compoundLevel ?? $ this -> getCompoundLevel ( $ children ) ; $ immediateChildren = [ ] ; $ grandchildren = [ ] ; $ newContentType = $ this -> userContentType ; foreach ( $ children as $ child ) { $ level = $ this -> getNeede...
Set all children of this entity .
5,751
public function getBody ( ) { return $ this -> body instanceof Swift_OutputByteStream ? $ this -> readStream ( $ this -> body ) : $ this -> body ; }
Get the body of this entity as a string .
5,752
public function setEncoder ( Swift_Mime_ContentEncoder $ encoder ) { if ( $ encoder !== $ this -> encoder ) { $ this -> clearCache ( ) ; } $ this -> encoder = $ encoder ; $ this -> setEncoding ( $ encoder -> getName ( ) ) ; $ this -> notifyEncoderChanged ( $ encoder ) ; return $ this ; }
Set the encoder used for the body of this entity .
5,753
public function getBoundary ( ) { if ( ! isset ( $ this -> boundary ) ) { $ this -> boundary = '_=_swift_' . time ( ) . '_' . bin2hex ( random_bytes ( 16 ) ) . '_=_' ; } return $ this -> boundary ; }
Get the boundary used to separate children in this entity .
5,754
protected function bodyToString ( ) { $ string = '' ; if ( isset ( $ this -> body ) && empty ( $ this -> immediateChildren ) ) { if ( $ this -> cache -> hasKey ( $ this -> cacheKey , 'body' ) ) { $ body = $ this -> cache -> getString ( $ this -> cacheKey , 'body' ) ; } else { $ body = "\r\n" . $ this -> encoder -> enco...
Get this entire entity as a string .
5,755
protected function fixHeaders ( ) { if ( count ( $ this -> immediateChildren ) ) { $ this -> setHeaderParameter ( 'Content-Type' , 'boundary' , $ this -> getBoundary ( ) ) ; $ this -> headers -> remove ( 'Content-Transfer-Encoding' ) ; } else { $ this -> setHeaderParameter ( 'Content-Type' , 'boundary' , null ) ; $ thi...
Re - evaluate what content type and encoding should be used on this entity .
5,756
public function connect ( ) { if ( isset ( $ this -> connection ) ) { $ this -> connection -> connect ( ) ; } else { if ( ! isset ( $ this -> socket ) ) { if ( ! $ socket = fsockopen ( $ this -> getHostString ( ) , $ this -> port , $ errno , $ errstr , $ this -> timeout ) ) { throw new Swift_Plugins_Pop_Pop3Exception (...
Connect to the POP3 host and authenticate .
5,757
public function disconnect ( ) { if ( isset ( $ this -> connection ) ) { $ this -> connection -> disconnect ( ) ; } else { $ this -> command ( "QUIT\r\n" ) ; if ( ! fclose ( $ this -> socket ) ) { throw new Swift_Plugins_Pop_Pop3Exception ( sprintf ( 'POP3 host [%s] connection could not be stopped' , $ this -> host ) )...
Disconnect from the POP3 host .
5,758
public function setLocalDomain ( $ domain ) { if ( '[' !== substr ( $ domain , 0 , 1 ) ) { if ( filter_var ( $ domain , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { $ domain = '[' . $ domain . ']' ; } elseif ( filter_var ( $ domain , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) { $ domain = '[IPv6:' . $ domain . ']' ; } } ...
Set the name of the local domain which Swift will identify itself as .
5,759
public function start ( ) { if ( ! $ this -> started ) { if ( $ evt = $ this -> eventDispatcher -> createTransportChangeEvent ( $ this ) ) { $ this -> eventDispatcher -> dispatchEvent ( $ evt , 'beforeTransportStarted' ) ; if ( $ evt -> bubbleCancelled ( ) ) { return ; } } try { $ this -> buffer -> initialize ( $ this ...
Start the SMTP connection .
5,760
public function stop ( ) { if ( $ this -> started ) { if ( $ evt = $ this -> eventDispatcher -> createTransportChangeEvent ( $ this ) ) { $ this -> eventDispatcher -> dispatchEvent ( $ evt , 'beforeTransportStopped' ) ; if ( $ evt -> bubbleCancelled ( ) ) { return ; } } try { $ this -> executeCommand ( "QUIT\r\n" , [ 2...
Stop the SMTP connection .
5,761
protected function doMailFromCommand ( $ address ) { $ address = $ this -> addressEncoder -> encodeString ( $ address ) ; $ this -> executeCommand ( sprintf ( "MAIL FROM:<%s>\r\n" , $ address ) , [ 250 ] , $ failures , true ) ; }
Send the MAIL FROM command
5,762
protected function streamMessage ( Swift_Mime_SimpleMessage $ message ) { $ this -> buffer -> setWriteTranslations ( [ "\r\n." => "\r\n.." ] ) ; try { $ message -> toByteStream ( $ this -> buffer ) ; $ this -> buffer -> flushBuffers ( ) ; } catch ( Swift_TransportException $ e ) { $ this -> throwException ( $ e ) ; } $...
Stream the contents of the message over the buffer
5,763
protected function throwException ( Swift_TransportException $ e ) { if ( $ evt = $ this -> eventDispatcher -> createTransportExceptionEvent ( $ this , $ e ) ) { $ this -> eventDispatcher -> dispatchEvent ( $ evt , 'exceptionThrown' ) ; if ( ! $ evt -> bubbleCancelled ( ) ) { throw $ e ; } } else { throw $ e ; } }
Throw a TransportException first sending it to any listeners
5,764
protected function assertResponseCode ( $ response , $ wanted ) { if ( ! $ response ) { $ this -> throwException ( new Swift_TransportException ( 'Expected response code ' . implode ( '/' , $ wanted ) . ' but got an empty response' ) ) ; } list ( $ code ) = sscanf ( $ response , '%3d' ) ; $ valid = ( empty ( $ wanted )...
Throws an Exception if a response code is incorrect
5,765
protected function getFullResponse ( $ seq ) { $ response = '' ; try { do { $ line = $ this -> buffer -> readLine ( $ seq ) ; $ response .= $ line ; } while ( null !== $ line && false !== $ line && ' ' != $ line [ 3 ] ) ; } catch ( Swift_TransportException $ e ) { $ this -> throwException ( $ e ) ; } catch ( Swift_IoEx...
Get an entire multi - line response using its sequence number
5,766
private function doMailTransaction ( $ message , $ reversePath , array $ recipients , array & $ failedRecipients ) { $ sent = 0 ; $ this -> doMailFromCommand ( $ reversePath ) ; foreach ( $ recipients as $ forwardPath ) { try { $ this -> doRcptToCommand ( $ forwardPath ) ; ++ $ sent ; } catch ( Swift_TransportException...
Send an email to the given recipients from the given reverse path
5,767
public function createIdHeader ( $ name , $ ids = null ) { $ header = new Swift_Mime_Headers_IdentificationHeader ( $ name , $ this -> emailValidator ) ; if ( isset ( $ ids ) ) { $ header -> setFieldBodyModel ( $ ids ) ; } $ this -> setHeaderCharset ( $ header ) ; return $ header ; }
Create a new ID header for Message - ID or Content - ID .
5,768
public function charsetChanged ( $ charset ) { $ this -> charset = $ charset ; $ this -> encoder -> charsetChanged ( $ charset ) ; $ this -> paramEncoder -> charsetChanged ( $ charset ) ; }
Notify this observer that the entity s charset has changed .
5,769
private function setHeaderCharset ( Swift_Mime_Header $ header ) { if ( isset ( $ this -> charset ) ) { $ header -> setCharset ( $ this -> charset ) ; } }
Apply the charset to the Header
5,770
public function shouldBuffer ( $ buffer ) { if ( '' === $ buffer ) { return false ; } $ endOfBuffer = substr ( $ buffer , - 1 ) ; foreach ( ( array ) $ this -> search as $ needle ) { if ( false !== strpos ( $ needle , $ endOfBuffer ) ) { return true ; } } return false ; }
Returns true if based on the buffer passed more bytes should be buffered .
5,771
private function filterHeaderSet ( Swift_Mime_SimpleHeaderSet $ headerSet , $ type ) { foreach ( $ headerSet -> getAll ( $ type ) as $ headers ) { $ headers -> setNameAddresses ( $ this -> filterNameAddresses ( $ headers -> getNameAddresses ( ) ) ) ; } }
Filter header set against a whitelist of regular expressions .
5,772
private function filterNameAddresses ( array $ recipients ) { $ filtered = [ ] ; foreach ( $ recipients as $ address => $ name ) { if ( $ this -> isWhitelisted ( $ address ) ) { $ filtered [ $ address ] = $ name ; } } return $ filtered ; }
Filtered list of addresses = > name pairs .
5,773
protected function isWhitelisted ( $ recipient ) { if ( in_array ( $ recipient , ( array ) $ this -> recipient ) ) { return true ; } foreach ( $ this -> whitelist as $ pattern ) { if ( preg_match ( $ pattern , $ recipient ) ) { return true ; } } return false ; }
Matches address against whitelist of regular expressions .
5,774
public function setSignCertificate ( $ certificate , $ privateKey = null , $ signOptions = PKCS7_DETACHED , $ extraCerts = null ) { $ this -> signCertificate = 'file://' . str_replace ( '\\' , '/' , realpath ( $ certificate ) ) ; if ( null !== $ privateKey ) { if ( is_array ( $ privateKey ) ) { $ this -> signPrivateKey...
Set the certificate location to use for signing .
5,775
public function setEncryptCertificate ( $ recipientCerts , $ cipher = null ) { if ( is_array ( $ recipientCerts ) ) { $ this -> encryptCert = [ ] ; foreach ( $ recipientCerts as $ cert ) { $ this -> encryptCert [ ] = 'file://' . str_replace ( '\\' , '/' , realpath ( $ cert ) ) ; } } else { $ this -> encryptCert = 'file...
Set the certificate location to use for encryption .
5,776
public function signMessage ( Swift_Message $ message ) { if ( null === $ this -> signCertificate && null === $ this -> encryptCert ) { return $ this ; } if ( $ this -> signThenEncrypt ) { $ this -> smimeSignMessage ( $ message ) ; $ this -> smimeEncryptMessage ( $ message ) ; } else { $ this -> smimeEncryptMessage ( $...
Change the Swift_Message to apply the signing .
5,777
protected function smimeSignMessage ( Swift_Message $ message ) { if ( null === $ this -> signCertificate ) { return ; } $ signMessage = clone $ message ; $ signMessage -> clearSigners ( ) ; if ( $ this -> wrapFullMessage ) { $ signMessage = $ this -> wrapMimeMessage ( $ signMessage ) ; } else { $ this -> clearAllHeade...
Sign a Swift message .
5,778
protected function smimeEncryptMessage ( Swift_Message $ message ) { if ( null === $ this -> encryptCert ) { return ; } $ encryptMessage = clone $ message ; $ encryptMessage -> clearSigners ( ) ; if ( $ this -> wrapFullMessage ) { $ encryptMessage = $ this -> wrapMimeMessage ( $ encryptMessage ) ; } else { $ this -> cl...
Encrypt a Swift message .
5,779
protected function copyHeaders ( Swift_Message $ fromMessage , Swift_Message $ toMessage , array $ headers = [ ] ) { foreach ( $ headers as $ header ) { $ this -> copyHeader ( $ fromMessage , $ toMessage , $ header ) ; } }
Copy named headers from one Swift message to another .
5,780
protected function copyHeader ( Swift_Message $ fromMessage , Swift_Message $ toMessage , $ headerName ) { $ header = $ fromMessage -> getHeaders ( ) -> get ( $ headerName ) ; if ( ! $ header ) { return ; } $ headers = $ toMessage -> getHeaders ( ) ; switch ( $ header -> getFieldType ( ) ) { case Swift_Mime_Header :: T...
Copy a single header from one Swift message to another .
5,781
protected function clearAllHeaders ( Swift_Message $ message ) { $ headers = $ message -> getHeaders ( ) ; foreach ( $ headers -> listAll ( ) as $ header ) { $ headers -> removeAll ( $ header ) ; } }
Remove all headers from a Swift message .
5,782
protected function streamToMime ( Swift_OutputByteStream $ fromStream , Swift_Message $ message ) { list ( $ headers , $ messageStream ) = $ this -> parseStream ( $ fromStream ) ; $ messageHeaders = $ message -> getHeaders ( ) ; $ encoding = '' ; $ messageHeaders -> removeAll ( 'Content-Transfer-Encoding' ) ; if ( isse...
Merges an OutputByteStream from OpenSSL to a Swift_Message .
5,783
protected function parseStream ( Swift_OutputByteStream $ emailStream ) { $ bufferLength = 78 ; $ headerData = '' ; $ headerBodySeparator = "\r\n\r\n" ; $ emailStream -> setReadPointer ( 0 ) ; while ( false !== ( $ buffer = $ emailStream -> read ( $ bufferLength ) ) ) { $ headerData .= $ buffer ; $ headersPosEnd = strp...
This message will parse the headers of a MIME email byte stream and return an array that contains the headers as an associative array and the email body as a string .
5,784
public function setCharset ( $ charset ) { $ this -> setHeaderParameter ( 'Content-Type' , 'charset' , $ charset ) ; if ( $ charset !== $ this -> userCharset ) { $ this -> clearCache ( ) ; } $ this -> userCharset = $ charset ; parent :: charsetChanged ( $ charset ) ; return $ this ; }
Set the character set of this entity .
5,785
public function setDelSp ( $ delsp = true ) { $ this -> setHeaderParameter ( 'Content-Type' , 'delsp' , $ delsp ? 'yes' : null ) ; $ this -> userDelSp = $ delsp ; return $ this ; }
Turn delsp on or off for this entity .
5,786
protected function fixHeaders ( ) { parent :: fixHeaders ( ) ; if ( count ( $ this -> getChildren ( ) ) ) { $ this -> setHeaderParameter ( 'Content-Type' , 'charset' , null ) ; $ this -> setHeaderParameter ( 'Content-Type' , 'format' , null ) ; $ this -> setHeaderParameter ( 'Content-Type' , 'delsp' , null ) ; } else {...
Fix the content - type and encoding of this entity
5,787
protected function convertString ( $ string ) { $ charset = strtolower ( $ this -> getCharset ( ) ) ; if ( ! in_array ( $ charset , [ 'utf-8' , 'iso-8859-1' , 'iso-8859-15' , '' ] ) ) { return mb_convert_encoding ( $ string , $ charset , 'utf-8' ) ; } return $ string ; }
Encode charset when charset is not utf - 8
5,788
protected function sendCacheControlHeader ( ) { if ( Yii :: app ( ) -> session -> isStarted ) { Yii :: app ( ) -> session -> setCacheLimiter ( 'public' ) ; header ( 'Pragma:' , true ) ; } header ( 'Cache-Control: ' . $ this -> cacheControl , true ) ; }
Sends the cache control header to the client
5,789
protected function getViewFile ( $ file ) { if ( $ this -> useRuntimePath ) { $ crc = sprintf ( '%x' , crc32 ( get_class ( $ this ) . Yii :: getVersion ( ) . dirname ( $ file ) ) ) ; $ viewFile = Yii :: app ( ) -> getRuntimePath ( ) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $ crc . DIRECTORY_SEPARATOR . b...
Generates the resulting view file path .
5,790
public function up ( ) { $ transaction = $ this -> getDbConnection ( ) -> beginTransaction ( ) ; try { if ( $ this -> safeUp ( ) === false ) { $ transaction -> rollback ( ) ; return false ; } $ transaction -> commit ( ) ; } catch ( Exception $ e ) { echo "Exception: " . $ e -> getMessage ( ) . ' (' . $ e -> getFile ( )...
This method contains the logic to be executed when applying this migration . Child classes may implement this method to provide actual migration logic .
5,791
public function down ( ) { $ transaction = $ this -> getDbConnection ( ) -> beginTransaction ( ) ; try { if ( $ this -> safeDown ( ) === false ) { $ transaction -> rollback ( ) ; return false ; } $ transaction -> commit ( ) ; } catch ( Exception $ e ) { echo "Exception: " . $ e -> getMessage ( ) . ' (' . $ e -> getFile...
This method contains the logic to be executed when removing this migration . Child classes may override this method if the corresponding migrations can be removed .
5,792
public function insert ( $ table , $ columns ) { echo " > insert into $table ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> insert ( $ table , $ columns ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; }
Creates and executes an INSERT SQL statement . The method will properly escape the column names and bind the values to be inserted .
5,793
public function insertMultiple ( $ table , $ data ) { echo " > insert into $table ..." ; $ time = microtime ( true ) ; $ builder = $ this -> getDbConnection ( ) -> getSchema ( ) -> getCommandBuilder ( ) ; $ command = $ builder -> createMultipleInsertCommand ( $ table , $ data ) ; $ command -> execute ( ) ; echo " do...
Creates and executes an INSERT SQL statement with multiple data . The method will properly escape the column names and bind the values to be inserted .
5,794
public function update ( $ table , $ columns , $ conditions = '' , $ params = array ( ) ) { echo " > update $table ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> update ( $ table , $ columns , $ conditions , $ params ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ...
Creates and executes an UPDATE SQL statement . The method will properly escape the column names and bind the values to be updated .
5,795
public function delete ( $ table , $ conditions = '' , $ params = array ( ) ) { echo " > delete from $table ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> delete ( $ table , $ conditions , $ params ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( true ) - $ time )...
Creates and executes a DELETE SQL statement .
5,796
public function createTable ( $ table , $ columns , $ options = null ) { echo " > create table $table ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> createTable ( $ table , $ columns , $ options ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( true ) - $ time ) . ...
Builds and executes a SQL statement for creating a new DB table .
5,797
public function renameTable ( $ table , $ newName ) { echo " > rename table $table to $newName ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> renameTable ( $ table , $ newName ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; }
Builds and executes a SQL statement for renaming a DB table .
5,798
public function dropColumn ( $ table , $ column ) { echo " > drop column $column from table $table ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> dropColumn ( $ table , $ column ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; }
Builds and executes a SQL statement for dropping a DB column .
5,799
public function renameColumn ( $ table , $ name , $ newName ) { echo " > rename column $name in table $table to $newName ..." ; $ time = microtime ( true ) ; $ this -> getDbConnection ( ) -> createCommand ( ) -> renameColumn ( $ table , $ name , $ newName ) ; echo " done (time: " . sprintf ( '%.3f' , microtime ( tru...
Builds and executes a SQL statement for renaming a column .