idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
40,200
function Spreadsheet_Excel_Writer_Parser ( $ byte_order , $ biff_version ) { $ this -> _current_char = 0 ; $ this -> _BIFF_version = $ biff_version ; $ this -> _current_token = '' ; $ this -> _formula = '' ; $ this -> _lookahead = '' ; $ this -> _parse_tree = '' ; $ this -> _initializeHashes ( ) ; $ this -> _byte_order...
The class constructor
40,201
function _convertFunction ( $ token , $ num_args ) { $ args = $ this -> _functions [ $ token ] [ 1 ] ; $ volatile = $ this -> _functions [ $ token ] [ 3 ] ; if ( $ args >= 0 ) { return pack ( "Cv" , $ this -> ptg [ 'ptgFuncV' ] , $ this -> _functions [ $ token ] [ 0 ] ) ; } if ( $ args == - 1 ) { return pack ( "CCv" , ...
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes .
40,202
public function getDefaultStrategy ( $ filename ) { if ( ! is_string ( $ this -> defaultStrategy ) && is_callable ( $ this -> defaultStrategy ) ) { return call_user_func ( $ this -> defaultStrategy , $ filename ) ; } return $ this -> defaultStrategy ; }
Gets the default strategy to use when not defined by the user .
40,203
public static function GetCurrentUser ( $ guid = "CURRENT_USER" ) { if ( self :: $ user == null ) { self :: Init ( ) ; if ( isset ( $ _SESSION [ $ guid ] ) ) { self :: $ user = unserialize ( $ _SESSION [ $ guid ] ) ; } } return self :: $ user ; }
Returns the currently authenticated user or null
40,204
public static function SetCurrentUser ( IAuthenticatable $ user , $ guid = "CURRENT_USER" ) { self :: UnsetAllSessionVars ( ) ; self :: $ user = $ user ; $ _SESSION [ $ guid ] = serialize ( $ user ) ; }
Set the given IAuthenticable object as the currently authenticated user . UnsetAllSessionVars will be called before setting the current user
40,205
public static function ClearAuthentication ( $ guid = "CURRENT_USER" ) { self :: Init ( ) ; self :: $ user = null ; unset ( $ _SESSION [ $ guid ] ) ; self :: UnsetAllSessionVars ( ) ; @ session_destroy ( ) ; }
Forcibly clear all _SESSION variables and destroys the session
40,206
public function setFitToHeight ( $ pValue = 1 , $ pUpdate = TRUE ) { $ this -> _fitToHeight = $ pValue ; if ( $ pUpdate ) { $ this -> _fitToPage = TRUE ; } return $ this ; }
Set Fit To Height
40,207
public function setFitToWidth ( $ pValue = 1 , $ pUpdate = TRUE ) { $ this -> _fitToWidth = $ pValue ; if ( $ pUpdate ) { $ this -> _fitToPage = TRUE ; } return $ this ; }
Set Fit To Width
40,208
public function getOutput ( $ tpl = null ) { $ output = $ this -> fetch ( $ tpl ) ; if ( $ this -> isError ( $ output ) ) { $ text = $ this -> __config [ 'error_text' ] ; return $ this -> escape ( $ text ) ; } else { return $ output ; } }
Returns output including error_text if an error occurs .
40,209
function _storeEof ( ) { $ record = 0x000A ; $ length = 0x0000 ; $ header = pack ( "vv" , $ record , $ length ) ; $ this -> _append ( $ header ) ; }
Writes Excel EOF record to indicate the end of a BIFF stream .
40,210
public function add ( ApnsPHP_Message $ message ) { $ sMessagePayload = $ message -> getPayload ( ) ; $ nRecipients = $ message -> getRecipientsNumber ( ) ; $ nMessageQueueLen = count ( $ this -> _aMessageQueue ) ; for ( $ i = 0 ; $ i < $ nRecipients ; $ i ++ ) { $ nMessageID = $ nMessageQueueLen + $ i + 1 ; $ this -> ...
Adds a message to the message queue .
40,211
protected function _getBinaryNotification ( $ sDeviceToken , $ sPayload , $ nMessageID = 0 , $ nExpire = 604800 ) { $ nTokenLength = strlen ( $ sDeviceToken ) ; $ nPayloadLength = strlen ( $ sPayload ) ; $ sRet = pack ( 'CNNnH*' , self :: COMMAND_PUSH , $ nMessageID , $ nExpire > 0 ? time ( ) + $ nExpire : 0 , self :: ...
Generate a binary notification from a device token and a JSON - encoded payload .
40,212
protected function _updateQueue ( $ aErrorMessage = null ) { $ aStreamErrorMessage = $ this -> _readErrorMessage ( ) ; if ( ! isset ( $ aErrorMessage ) && ! isset ( $ aStreamErrorMessage ) ) { return false ; } else if ( isset ( $ aErrorMessage , $ aStreamErrorMessage ) ) { if ( $ aStreamErrorMessage [ 'identifier' ] <=...
Checks for error message and deletes messages successfully sent from message queue .
40,213
protected function _removeMessageFromQueue ( $ nMessageID , $ bError = false ) { if ( ! is_numeric ( $ nMessageID ) || $ nMessageID <= 0 ) { throw new ApnsPHP_Push_Exception ( 'Message ID format is not valid.' ) ; } if ( ! isset ( $ this -> _aMessageQueue [ $ nMessageID ] ) ) { throw new ApnsPHP_Push_Exception ( "The M...
Remove a message from the message queue .
40,214
static function Escape ( $ str , $ escapeQuotes = false ) { if ( $ escapeQuotes ) { $ str = str_replace ( VerySimpleXmlUtil :: $ replacementsAttrib , VerySimpleXmlUtil :: $ replacementsTempAttrib , $ str ) ; $ str = str_replace ( VerySimpleXmlUtil :: $ reservedAttrib , VerySimpleXmlUtil :: $ replacementsAttrib , $ str ...
Escapes special characters that will corrupt XML
40,215
static function RecurseXmlObjToArr ( $ obj , & $ arr ) { $ children = $ obj -> children ( ) ; foreach ( $ children as $ elementName => $ node ) { $ nextIdx = count ( $ arr ) ; $ arr [ $ nextIdx ] = array ( ) ; $ arr [ $ nextIdx ] [ '@name' ] = strtolower ( ( string ) $ elementName ) ; $ arr [ $ nextIdx ] [ '@attributes...
This is method RecurseXmlObjToArr
40,216
static function ToXML ( $ var , $ root = "" ) { $ xml = "" ; if ( is_object ( $ var ) ) { $ name = strlen ( $ root ) > 0 && is_numeric ( $ root ) == false ? $ root : get_class ( $ var ) ; $ xml .= "<" . $ name . ">\n" ; $ props = get_object_vars ( $ var ) ; foreach ( array_keys ( $ props ) as $ key ) { $ xml .= VerySim...
Recurses value and serializes it as an XML string
40,217
static function GetInnerText ( XMLReader $ xml , $ default = "" ) { if ( $ xml -> isEmptyElement == false && $ xml -> read ( ) && $ xml -> nodeType == XMLReader :: TEXT ) { return $ xml -> value ; } else { return $ default ; } }
For a node that is known to have inner text and no other child nodes this returns the inner text and advances the reader curser to the next element . If there is no text the curser is not advanced
40,218
static function ConvertReader ( XMLReader $ xml ) { $ node_types = array ( 0 => "XMLReader::NONE" , 1 => "XMLReader::ELEMENT" , 2 => "XMLReader::ATTRIBUTE" , 3 => "XMLReader::TEXT" , 4 => "XMLReader::CDATA" , 5 => "XMLReader::ENTITY_REF" , 6 => "XMLReader::ENTITY" , 7 => "XMLReader::PI" , 8 => "XMLReader::COMMENT" , 9 ...
Given an XMLReader returns an object that can be inspected using print_r
40,219
public static function GetServerRootUrl ( ) { $ url = self :: GetCurrentURL ( false ) ; $ parts = explode ( '/' , $ url ) ; if ( count ( $ parts ) < 2 ) throw new Exception ( 'RequestUtil is unable to determine the server root' ) ; return $ parts [ 0 ] . '//' . $ parts [ 2 ] . '/' ; }
Returns the root url of the server without any subdirectories
40,220
public static function GetRequestHeaders ( ) { if ( function_exists ( 'getallheaders' ) ) return getallheaders ( ) ; $ headers = array ( ) ; foreach ( $ _SERVER as $ k => $ v ) { if ( substr ( $ k , 0 , 5 ) == "HTTP_" ) { $ k = str_replace ( '_' , ' ' , substr ( $ k , 5 ) ) ; $ k = str_replace ( ' ' , '-' , ucwords ( s...
Return all request headers using the best method available for the server environment
40,221
public static function GetCurrentURL ( $ include_querystring = true , $ append_post_vars = false ) { $ server_protocol = isset ( $ _SERVER [ "SERVER_PROTOCOL" ] ) ? $ _SERVER [ "SERVER_PROTOCOL" ] : "" ; $ http_host = isset ( $ _SERVER [ "HTTP_HOST" ] ) ? $ _SERVER [ "HTTP_HOST" ] : "" ; $ server_port = isset ( $ _SERV...
Returns the full URL of the PHP page that is currently executing
40,222
public static function GetFile ( $ fieldname , $ b64encode = true , $ ignore_empty = false , $ max_kb = 0 , $ ok_types = null ) { $ fupload = self :: GetFileUpload ( $ fieldname , $ ignore_empty , $ max_kb , $ ok_types ) ; return ( $ fupload ) ? $ fupload -> ToXML ( $ b64encode ) : null ; }
Returns a form upload as an xml document with the file data base64 encoded . suitable for storing in a clob or blob
40,223
public static function HasNonAsciiChars ( $ fieldname ) { require_once ( "verysimple/String/VerySimpleStringUtil.php" ) ; $ val = isset ( $ _REQUEST [ $ fieldname ] ) ? $ _REQUEST [ $ fieldname ] : '' ; return VerySimpleStringUtil :: EncodeToHTML ( $ val ) != $ val ; }
Returns true if the given form field has non - ascii characters
40,224
public static function GetPersisted ( $ fieldname , $ default = "" , $ escape = false ) { if ( isset ( $ _REQUEST [ $ fieldname ] ) ) { $ _SESSION [ "_PERSISTED_" . $ fieldname ] = self :: Get ( $ fieldname , $ default , $ escape ) ; } if ( ! isset ( $ _SESSION [ "_PERSISTED_" . $ fieldname ] ) ) { $ _SESSION [ "_PERSI...
Returns a form parameter and persists it in the session . If the form parameter was not passed again then it returns the session value . if the session value doesn t exist then it returns the default setting
40,225
public static function GetAsDate ( $ fieldname , $ default = "date('Y-m-d')" , $ includetime = false ) { $ returnVal = self :: Get ( $ fieldname , $ default ) ; if ( $ returnVal == "date('Y-m-d')" ) { return date ( 'Y-m-d' ) ; } elseif ( $ returnVal == "date('Y-m-d H:i:s')" ) { return date ( 'Y-m-d H:i:s' ) ; } elseif ...
Returns a form parameter as a date formatted for mysql YYYY - MM - DD expects some type of date format . if default value is not provided will return today . if default value is empty string will return empty string .
40,226
public function getContent ( Smarty_Template_Source $ source ) { $ this -> fetch ( $ source -> name , $ content , $ timestamp ) ; if ( isset ( $ content ) ) { return $ content ; } throw new SmartyException ( "Unable to read template {$source->type} '{$source->name}'" ) ; }
Load template s source into current template object
40,227
private function _writeBIFF8CellRangeAddressFixed ( $ range = 'A1' ) { $ explodes = explode ( ':' , $ range ) ; $ firstCell = $ explodes [ 0 ] ; if ( count ( $ explodes ) == 1 ) { $ lastCell = $ firstCell ; } else { $ lastCell = $ explodes [ 1 ] ; } $ firstCellCoordinates = PHPExcel_Cell :: coordinateFromString ( $ fir...
Write a cell range address in BIFF8 always fixed range See section 2 . 5 . 14 in OpenOffice . org s Documentation of the Microsoft Excel File Format
40,228
function setOutline ( $ visible = true , $ symbols_below = true , $ symbols_right = true , $ auto_style = false ) { $ this -> _outline_on = $ visible ; $ this -> _outline_below = $ symbols_below ; $ this -> _outline_right = $ symbols_right ; $ this -> _outline_style = $ auto_style ; if ( $ this -> _outline_on ) { $ thi...
This method sets the properties for outlining and grouping . The defaults correspond to Excel s defaults .
40,229
private function _writeString ( $ row , $ col , $ str , $ xfIndex ) { $ this -> _writeLabelSst ( $ row , $ col , $ str , $ xfIndex ) ; }
Write a LABELSST record or a LABEL record . Which one depends on BIFF version
40,230
private function _writeRichTextString ( $ row , $ col , $ str , $ xfIndex , $ arrcRun ) { $ record = 0x00FD ; $ length = 0x000A ; $ str = PHPExcel_Shared_String :: UTF8toBIFF8UnicodeShort ( $ str , $ arrcRun ) ; if ( ! isset ( $ this -> _str_table [ $ str ] ) ) { $ this -> _str_table [ $ str ] = $ this -> _str_unique +...
Write a LABELSST record or a LABEL record . Which one depends on BIFF version It differs from _writeString by the writing of rich text strings .
40,231
private function _writeStringRecord ( $ stringValue ) { $ record = 0x0207 ; $ data = PHPExcel_Shared_String :: UTF8toBIFF8UnicodeLong ( $ stringValue ) ; $ length = strlen ( $ data ) ; $ header = pack ( 'vv' , $ record , $ length ) ; $ this -> _append ( $ header . $ data ) ; }
Write a STRING record . This
40,232
function _writeUrlInternal ( $ row1 , $ col1 , $ row2 , $ col2 , $ url ) { $ record = 0x01B8 ; $ length = 0x00000 ; $ url = preg_replace ( '/^internal:/' , '' , $ url ) ; $ unknown1 = pack ( "H*" , "D0C9EA79F9BACE118C8200AA004BA90B02000000" ) ; $ options = pack ( "V" , 0x08 ) ; $ url .= "\0" ; $ url_len = PHPExcel_Shar...
Used to write internal reference hyperlinks such as Sheet1!A1 .
40,233
private function _writeDefaultRowHeight ( ) { $ defaultRowHeight = $ this -> _phpSheet -> getDefaultRowDimension ( ) -> getRowHeight ( ) ; if ( $ defaultRowHeight < 0 ) { return ; } $ defaultRowHeight = ( int ) 20 * $ defaultRowHeight ; $ record = 0x0225 ; $ length = 0x0004 ; $ header = pack ( "vv" , $ record , $ lengt...
Write BIFF record DEFAULTROWHEIGHT .
40,234
private function _writeMergedCells ( ) { $ mergeCells = $ this -> _phpSheet -> getMergeCells ( ) ; $ countMergeCells = count ( $ mergeCells ) ; if ( $ countMergeCells == 0 ) { return ; } $ maxCountMergeCellsPerRecord = 1027 ; $ record = 0x00E5 ; $ i = 0 ; $ j = 0 ; $ recordData = '' ; foreach ( $ mergeCells as $ mergeC...
Store the MERGEDCELLS records for all ranges of merged cells
40,235
private function _writeSheetLayout ( ) { if ( ! $ this -> _phpSheet -> isTabColorSet ( ) ) { return ; } $ recordData = pack ( 'vvVVVvv' , 0x0862 , 0x0000 , 0x00000000 , 0x00000000 , 0x00000014 , $ this -> _colors [ $ this -> _phpSheet -> getTabColor ( ) -> getRGB ( ) ] , 0x0000 ) ; $ length = strlen ( $ recordData ) ; ...
Write SHEETLAYOUT record
40,236
private function _writeRangeProtection ( ) { foreach ( $ this -> _phpSheet -> getProtectedCells ( ) as $ range => $ password ) { $ cellRanges = explode ( ' ' , $ range ) ; $ cref = count ( $ cellRanges ) ; $ recordData = pack ( 'vvVVvCVvVv' , 0x0868 , 0x00 , 0x0000 , 0x0000 , 0x02 , 0x0 , 0x0000 , $ cref , 0x0000 , 0x0...
Write BIFF record RANGEPROTECTION
40,237
private function _writeAutoFilterInfo ( ) { $ record = 0x009D ; $ length = 0x0002 ; $ rangeBounds = PHPExcel_Cell :: rangeBoundaries ( $ this -> _phpSheet -> getAutoFilter ( ) -> getRange ( ) ) ; $ iNumFilters = 1 + $ rangeBounds [ 1 ] [ 0 ] - $ rangeBounds [ 0 ] [ 0 ] ; $ header = pack ( "vv" , $ record , $ length ) ;...
Write the AUTOFILTERINFO BIFF record . This is used to configure the number of autofilter select used in the sheet .
40,238
private function _writeBreaks ( ) { $ vbreaks = array ( ) ; $ hbreaks = array ( ) ; foreach ( $ this -> _phpSheet -> getBreaks ( ) as $ cell => $ breakType ) { $ coordinates = PHPExcel_Cell :: coordinateFromString ( $ cell ) ; switch ( $ breakType ) { case PHPExcel_Worksheet :: BREAK_COLUMN : $ vbreaks [ ] = PHPExcel_C...
Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records .
40,239
function insertBitmap ( $ row , $ col , $ bitmap , $ x = 0 , $ y = 0 , $ scale_x = 1 , $ scale_y = 1 ) { $ bitmap_array = ( is_resource ( $ bitmap ) ? $ this -> _processBitmapGd ( $ bitmap ) : $ this -> _processBitmap ( $ bitmap ) ) ; list ( $ width , $ height , $ size , $ data ) = $ bitmap_array ; $ width *= $ scale_x...
Insert a 24bit bitmap image in a worksheet .
40,240
private function _writeMsoDrawing ( ) { if ( isset ( $ this -> _escher ) ) { $ writer = new PHPExcel_Writer_Excel5_Escher ( $ this -> _escher ) ; $ data = $ writer -> close ( ) ; $ spOffsets = $ writer -> getSpOffsets ( ) ; $ spTypes = $ writer -> getSpTypes ( ) ; $ spOffsets [ 0 ] = 0 ; $ nm = count ( $ spOffsets ) - ...
Write MSODRAWING record
40,241
private function _writePageLayoutView ( ) { $ record = 0x088B ; $ length = 0x0010 ; $ rt = 0x088B ; $ grbitFrt = 0x0000 ; $ reserved = 0x0000000000000000 ; $ wScalvePLV = $ this -> _phpSheet -> getSheetView ( ) -> getZoomScale ( ) ; if ( $ this -> _phpSheet -> getSheetView ( ) -> getView ( ) == PHPExcel_Worksheet_Sheet...
Write PLV Record
40,242
private function _writeCFHeader ( ) { $ record = 0x01B0 ; $ length = 0x0016 ; $ numColumnMin = null ; $ numColumnMax = null ; $ numRowMin = null ; $ numRowMax = null ; $ arrConditional = array ( ) ; foreach ( $ this -> _phpSheet -> getConditionalStylesCollection ( ) as $ cellCoordinate => $ conditionalStyles ) { foreac...
Write CFHeader record
40,243
public function setShrinkToFit ( $ pValue = FALSE ) { if ( $ pValue == '' ) { $ pValue = FALSE ; } if ( $ this -> _isSupervisor ) { $ styleArray = $ this -> getStyleArray ( array ( 'shrinkToFit' => $ pValue ) ) ; $ this -> getActiveSheet ( ) -> getStyle ( $ this -> getSelectedCells ( ) ) -> applyFromArray ( $ styleArra...
Set Shrink to fit
40,244
protected static function parseResourceName ( $ resource_name , $ default_resource , & $ name , & $ type ) { $ parts = explode ( ':' , $ resource_name , 2 ) ; if ( ! isset ( $ parts [ 1 ] ) || ! isset ( $ parts [ 0 ] [ 1 ] ) ) { $ type = $ default_resource ; $ name = $ resource_name ; } else { $ type = $ parts [ 0 ] ; ...
extract resource_type and resource_name from template_resource and config_resource
40,245
function Next ( ) { if ( $ this -> UnableToCache ) { require_once ( "verysimple/Util/ExceptionFormatter.php" ) ; $ info = ExceptionFormatter :: FormatTrace ( debug_backtrace ( ) ) ; $ this -> _phreezer -> Observe ( "(DataSet.Next: unable to cache query with cursor) " . $ info . " " . $ this -> _sql , OBSERVE_DEBUG ) ;...
Next returns the next object in the collection .
40,246
private function _verifyRs ( ) { if ( $ this -> _rs == null ) { $ this -> _phreezer -> IncludeModel ( $ this -> _objectclass ) ; $ this -> _rs = $ this -> _phreezer -> DataAdapter -> Select ( $ this -> _sql ) ; } }
Executes the sql statement and fills the resultset if necessary
40,247
function Count ( ) { if ( ! $ this -> CountIsKnown ( ) ) { $ cachekey = $ this -> _sql . " COUNT" ; $ this -> _totalcount = $ this -> GetDelayedCache ( $ cachekey ) ; if ( $ this -> _totalcount != null ) { $ this -> _phreezer -> Observe ( "DataSet.Count: skipping count query because cache exists" , OBSERVE_DEBUG ) ; } ...
Count returns the number of objects in the collection . If the count is not available a count statement will be executed to determine the total number of rows available
40,248
function GetLabelArray ( $ val_prop , $ label_prop ) { $ cachekey = $ this -> _sql . " VAL=" . $ val_prop . " LABEL=" . $ label_prop ; $ arr = $ this -> GetDelayedCache ( $ cachekey ) ; if ( $ arr != null ) { $ this -> _phreezer -> Observe ( "(DataSet.GetLabelArray: skipping query because cache exists) " . $ this -> _s...
Returns the entire collection as an associative array that can be easily used for Smarty dropdowns
40,249
function signature ( $ request , $ base_string , $ consumer_secret , $ token_secret ) { $ s .= '&' . $ request -> urlencode ( $ consumer_secret ) . '&' . $ request -> urlencode ( $ token_secret ) ; $ md5 = md5 ( $ base_string ) ; $ bin = '' ; for ( $ i = 0 ; $ i < strlen ( $ md5 ) ; $ i += 2 ) { $ bin .= chr ( hexdec (...
Calculate the signature using MD5 Binary md5 digest as distinct from PHP s built - in hexdigest . This function is copyright Andy Smith 2007 .
40,250
static function GetTraceAsString ( $ msg = "DEBUG" , $ depth = 0 , $ join = " :: " , $ show_lines = true ) { $ error = new Exception ( $ msg ) ; return self :: FormatTrace ( $ error -> getTrace ( ) , $ depth , $ join , $ show_lines ) ; }
This is a utility function for tracing errors . It will return a string that displys the current execution stack
40,251
function GetColumnNameByIndex ( $ index , $ remove_prefix = true ) { $ count = 0 ; foreach ( $ this -> Columns as $ column ) { if ( $ count == $ index ) return ( $ remove_prefix ) ? $ column -> NameWithoutPrefix : $ column -> Name ; } throw new Exception ( 'Index out of bounds' ) ; }
Returns the name of the column at the given index
40,252
function GetDescriptorName ( $ remove_prefix = true ) { foreach ( $ this -> Columns as $ column ) { if ( $ column -> Type == "varchar" ) { return ( $ remove_prefix ) ? $ this -> RemovePrefix ( $ column -> Name ) : $ column -> Name ; } } return $ this -> GetPrimaryKeyName ( $ remove_prefix ) ; }
Returns name of the first varchar field which could be used as a label
40,253
public function GetObjectName ( ) { if ( is_numeric ( substr ( $ this -> Name , 0 , 1 ) ) ) { return self :: $ NUMERIC_TABLE_PREFIX . $ this -> Name ; } return $ this -> Name ; }
Returns a name that is acceptable to be used as the object name in generated code
40,254
private function LoadColumns ( ) { $ sql = "describe `" . $ this -> Name . "`" ; $ rs = $ this -> Schema -> Server -> Connection -> Select ( $ sql ) ; while ( $ row = $ this -> Schema -> Server -> Connection -> Next ( $ rs ) ) { $ this -> Columns [ $ row [ "Field" ] ] = new DBColumn ( $ this , $ row ) ; } $ this -> Sch...
Inspects the current table and loads all Columns
40,255
public function onShutdown ( ) { if ( posix_getpid ( ) == $ this -> _nParentPid ) { $ this -> _log ( 'INFO: Parent shutdown, cleaning memory...' ) ; @ shm_remove ( $ this -> _hShm ) && @ shm_detach ( $ this -> _hShm ) ; @ sem_remove ( $ this -> _hSem ) ; } }
When the parent process exits cleans shared memory and semaphore .
40,256
public function start ( ) { for ( $ i = 0 ; $ i < $ this -> _nProcesses ; $ i ++ ) { $ this -> _nCurrentProcess = $ i ; $ this -> _aPids [ $ i ] = $ nPid = pcntl_fork ( ) ; if ( $ nPid == - 1 ) { $ this -> _log ( 'WARNING: Could not fork' ) ; } else if ( $ nPid > 0 ) { $ this -> _log ( "INFO: Forked process PID {$nPid}...
Starts the server forking all processes and return immediately .
40,257
public function add ( ApnsPHP_Message $ message ) { static $ n = 0 ; if ( $ n >= $ this -> _nProcesses ) { $ n = 0 ; } sem_acquire ( $ this -> _hSem ) ; $ aQueue = $ this -> _getQueue ( self :: SHM_MESSAGES_QUEUE_KEY_START , $ n ) ; $ aQueue [ ] = $ message ; $ this -> _setQueue ( self :: SHM_MESSAGES_QUEUE_KEY_START ,...
Adds a message to the inter - process message queue .
40,258
protected function _mainLoop ( ) { while ( true ) { pcntl_signal_dispatch ( ) ; if ( posix_getppid ( ) != $ this -> _nParentPid ) { $ this -> _log ( "INFO: Parent process {$this->_nParentPid} died unexpectedly, exiting..." ) ; break ; } sem_acquire ( $ this -> _hSem ) ; $ this -> _setQueue ( self :: SHM_ERROR_MESSAGES_...
The process main loop .
40,259
protected function _getQueue ( $ nQueueKey , $ nProcess = 0 ) { if ( ! shm_has_var ( $ this -> _hShm , $ nQueueKey + $ nProcess ) ) { return array ( ) ; } return shm_get_var ( $ this -> _hShm , $ nQueueKey + $ nProcess ) ; }
Returns the queue from the shared memory .
40,260
protected function _setQueue ( $ nQueueKey , $ nProcess = 0 , $ aQueue = array ( ) ) { if ( ! is_array ( $ aQueue ) ) { $ aQueue = array ( ) ; } return shm_put_var ( $ this -> _hShm , $ nQueueKey + $ nProcess , $ aQueue ) ; }
Store the queue into the shared memory .
40,261
protected function checkLoopUsageCondition ( Twig_TokenStream $ stream , Twig_NodeInterface $ node ) { if ( $ node instanceof Twig_Node_Expression_GetAttr && $ node -> getNode ( 'node' ) instanceof Twig_Node_Expression_Name && 'loop' == $ node -> getNode ( 'node' ) -> getAttribute ( 'name' ) ) { throw new Twig_Error_Sy...
the loop variable cannot be used in the condition
40,262
public function signature ( $ request , $ base_string , $ consumer_secret , $ token_secret ) { $ cert = $ this -> fetch_private_cert ( $ request ) ; $ privatekeyid = openssl_get_privatekey ( $ cert ) ; $ sig = false ; $ ok = openssl_sign ( $ base_string , $ sig , $ privatekeyid ) ; openssl_free_key ( $ privatekeyid ) ;...
Calculate the signature using RSA - SHA1 This function is copyright Andy Smith 2008 .
40,263
public function verify ( $ request , $ base_string , $ consumer_secret , $ token_secret , $ signature ) { $ decoded_sig = base64_decode ( $ request -> urldecode ( $ signature ) ) ; $ cert = $ this -> fetch_public_cert ( $ request ) ; $ publickeyid = openssl_get_publickey ( $ cert ) ; $ ok = openssl_verify ( $ base_stri...
Check if the request signature is the same as the one calculated for the request .
40,264
public function openTag ( $ compiler , $ openTag , $ data = null ) { array_push ( $ compiler -> _tag_stack , array ( $ openTag , $ data ) ) ; }
Push opening tag name on stack
40,265
static function ReplaceFirst ( $ s , $ r , $ str ) { $ l = strlen ( $ str ) ; $ a = strpos ( $ str , $ s ) ; $ b = $ a + strlen ( $ s ) ; $ temp = substr ( $ str , 0 , $ a ) . $ r . substr ( $ str , $ b , ( $ l - $ b ) ) ; return $ temp ; }
replace the first occurrance only within a string
40,266
static function ConvertEmailToMailTo ( $ text , $ sanitize = false ) { if ( $ sanitize ) $ text = VerySimpleStringUtil :: Sanitize ( $ text ) ; $ regex = "/([a-z0-9_\-\.]+)" . "@" . "([a-z0-9-]{1,64})" . "\." . "([a-z]{2,10})/i" ; return preg_replace ( $ regex , '<a href="mailto:\\1@\\2.\\3">\\1@\\2.\\3</a>' , $ text )...
Takes the given text and converts any email address into mailto links returning HTML content .
40,267
static function ConvertUrlToLink ( $ text , $ sanitize = false ) { if ( $ sanitize ) $ text = VerySimpleStringUtil :: Sanitize ( $ text ) ; $ regex = "/[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]/i" ; return preg_replace ( $ regex , '<a href=\"\\0\">\\0</a>' , $ text ) ; }
Takes the given text and converts any URLs into links returning HTML content .
40,268
static function EncodeSpecialCharacters ( $ string , $ escapeQuotes = true , $ numericEncodingOnly = true , $ replaceSmartQuotes = false ) { if ( strlen ( $ string ) == 0 ) return "" ; $ result = $ string ; if ( $ replaceSmartQuotes ) $ result = self :: ReplaceSmartQuotes ( $ result ) ; if ( $ escapeQuotes ) $ result =...
This HTML encodes special characters and returns an ascii safe version . This function extends EncodeToHTML to additionally strip out characters that may be disruptive when used in HTML or XML data
40,269
static function UTF8ToHTML ( $ content = "" ) { $ contents = self :: unicode_string_to_array ( $ content ) ; $ swap = "" ; $ iCount = count ( $ contents ) ; for ( $ o = 0 ; $ o < $ iCount ; $ o ++ ) { $ contents [ $ o ] = self :: unicode_entity_replace ( $ contents [ $ o ] ) ; $ swap .= $ contents [ $ o ] ; } return mb...
Converts UTF - 8 character set into html encoded goodness
40,270
static function unicode_string_to_array ( $ string ) { $ array = array ( ) ; $ strlen = mb_strlen ( $ string ) ; while ( $ strlen ) { $ array [ ] = mb_substr ( $ string , 0 , 1 , "UTF-8" ) ; $ string = mb_substr ( $ string , 1 , $ strlen , "UTF-8" ) ; $ strlen = mb_strlen ( $ string ) ; } return $ array ; }
takes a unicode string and turns it into an array of UTF - 8 characters
40,271
static function unicode_entity_replace ( $ c ) { $ h = ord ( $ c { 0 } ) ; if ( $ h <= 0x7F ) { return $ c ; } else if ( $ h < 0xC2 ) { return $ c ; } if ( $ h <= 0xDF ) { $ h = ( $ h & 0x1F ) << 6 | ( ord ( $ c { 1 } ) & 0x3F ) ; $ h = "&#" . $ h . ";" ; return $ h ; } else if ( $ h <= 0xEF ) { $ h = ( $ h & 0x0F ) <<...
Uses scary binary math to replace a character with it s html entity
40,272
public static function Convert ( $ amount , $ from , $ to ) { $ converted_amount = 0 ; $ qs = $ amount . ' ' . $ from . ' in ' . $ to ; $ url = "http://www.google.com/search?q=" . urlEncode ( $ qs ) ; $ g_response = strip_tags ( HttpRequest :: Get ( $ url ) ) ; if ( preg_match ( "/Rates provided for information only - ...
Converts currency using google . throws an exception if something went wrong
40,273
public function getColourByIndex ( $ index = 0 ) { if ( isset ( $ this -> _colourMap [ $ index ] ) ) { return $ this -> _colourMap [ $ index ] ; } return null ; }
Get colour Map Value by Position
40,274
function setDebug ( $ bool ) { $ this -> dbug = ( boolean ) $ bool ; $ this -> cfs_http -> setDebug ( $ this -> dbug ) ; }
Toggle debugging of instance and back - end HTTP module
40,275
function get_info ( ) { list ( $ status , $ reason , $ container_count , $ total_bytes ) = $ this -> cfs_http -> head_account ( ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): " . $ this -> cfs_http -> get_error ( ) ) ; } return array ( $ containe...
Cloud Files account information
40,276
function delete_container ( $ container = NULL ) { $ container_name = NULL ; if ( is_object ( $ container ) ) { if ( get_class ( $ container ) == "CF_Container" ) { $ container_name = $ container -> name ; } } if ( is_string ( $ container ) ) { $ container_name = $ container ; } if ( ! $ container_name ) { throw new Sy...
Delete a Container
40,277
function get_container ( $ container_name = NULL ) { list ( $ status , $ reason , $ count , $ bytes ) = $ this -> cfs_http -> head_container ( $ container_name ) ; if ( $ status == 404 ) { throw new NoSuchContainerException ( "Container not found." ) ; } if ( $ status < 200 || $ status > 299 ) { throw new InvalidRespon...
Return a Container instance
40,278
function get_containers ( $ limit = 0 , $ marker = NULL ) { list ( $ status , $ reason , $ container_info ) = $ this -> cfs_http -> list_containers_info ( $ limit , $ marker ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid response: " . $ this -> cfs_http -> get_error ( ) ) ; ...
Return array of Container instances
40,279
function list_containers ( $ limit = 0 , $ marker = NULL ) { list ( $ status , $ reason , $ containers ) = $ this -> cfs_http -> list_containers ( $ limit , $ marker ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): " . $ this -> cfs_http -> get_err...
Return list of remote Containers
40,280
function list_containers_info ( $ limit = 0 , $ marker = NULL ) { list ( $ status , $ reason , $ container_info ) = $ this -> cfs_http -> list_containers_info ( $ limit , $ marker ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): " . $ this -> cfs_h...
Return array of information about remote Containers
40,281
function list_public_containers ( ) { list ( $ status , $ reason , $ containers ) = $ this -> cfs_http -> list_cdn_containers ( ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): " . $ this -> cfs_http -> get_error ( ) ) ; } return $ containers ; }
Return list of Containers that have been published to the CDN .
40,282
function make_public ( $ ttl = 86400 ) { if ( $ this -> cfs_http -> getCDNMUrl ( ) == NULL ) { throw new CDNNotEnabledException ( "Authentication response did not indicate CDN availability" ) ; } if ( $ this -> cdn_uri != NULL ) { list ( $ status , $ reason , $ cdn_uri ) = $ this -> cfs_http -> update_cdn_container ( $...
Enable Container content to be served via CDN or modify CDN attributes
40,283
function acl_user_agent ( $ cdn_acl_user_agent = "" ) { if ( $ this -> cfs_http -> getCDNMUrl ( ) == NULL ) { throw new CDNNotEnabledException ( "Authentication response did not indicate CDN availability" ) ; } list ( $ status , $ reason ) = $ this -> cfs_http -> update_cdn_container ( $ this -> name , $ this -> cdn_tt...
Enable ACL restriction by User Agent for this container .
40,284
function make_private ( ) { if ( $ this -> cfs_http -> getCDNMUrl ( ) == NULL ) { throw new CDNNotEnabledException ( "Authentication response did not indicate CDN availability" ) ; } list ( $ status , $ reason ) = $ this -> cfs_http -> remove_cdn_container ( $ this -> name ) ; if ( ! in_array ( $ status , array ( 202 ,...
Disable the CDN sharing for this container
40,285
function list_objects ( $ limit = 0 , $ marker = NULL , $ prefix = NULL , $ path = NULL ) { list ( $ status , $ reason , $ obj_list ) = $ this -> cfs_http -> list_objects ( $ this -> name , $ limit , $ marker , $ prefix , $ path ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid...
Return a list of Objects
40,286
function get_objects ( $ limit = 0 , $ marker = NULL , $ prefix = NULL , $ path = NULL ) { list ( $ status , $ reason , $ obj_array ) = $ this -> cfs_http -> get_objects ( $ this -> name , $ limit , $ marker , $ prefix , $ path ) ; if ( $ status < 200 || $ status > 299 ) { throw new InvalidResponseException ( "Invalid ...
Return an array of Objects
40,287
function delete_object ( $ obj ) { $ obj_name = NULL ; if ( is_object ( $ obj ) ) { if ( get_class ( $ obj ) == "CF_Object" ) { $ obj_name = $ obj -> name ; } } if ( is_string ( $ obj ) ) { $ obj_name = $ obj ; } if ( ! $ obj_name ) { throw new SyntaxException ( "Object name not set." ) ; } $ status = $ this -> cfs_htt...
Delete a remote storage Object
40,288
function create_paths ( $ path_name ) { if ( $ path_name [ 0 ] == '/' ) { $ path_name = mb_substr ( $ path_name , 0 , 1 ) ; } $ elements = explode ( '/' , $ path_name , - 1 ) ; $ build_path = "" ; foreach ( $ elements as $ idx => $ val ) { if ( ! $ build_path ) { $ build_path = $ val ; } else { $ build_path .= "/" . $ ...
Helper function to create path elements for a given Object name
40,289
function public_uri ( ) { if ( $ this -> container -> cdn_enabled ) { return $ this -> container -> cdn_uri . "/" . $ this -> name ; } return NULL ; }
String representation of the Object s public URI
40,290
function read ( $ hdrs = array ( ) ) { list ( $ status , $ reason , $ data ) = $ this -> container -> cfs_http -> get_object_to_string ( $ this , $ hdrs ) ; if ( ( $ status < 200 ) || ( $ status > 299 && $ status != 412 && $ status != 304 ) ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): ...
Read the remote Object s data
40,291
function stream ( & $ fp , $ hdrs = array ( ) ) { list ( $ status , $ reason ) = $ this -> container -> cfs_http -> get_object_to_stream ( $ this , $ fp , $ hdrs ) ; if ( ( $ status < 200 ) || ( $ status > 299 && $ status != 412 && $ status != 304 ) ) { throw new InvalidResponseException ( "Invalid response (" . $ stat...
Streaming read of Object s data
40,292
function sync_metadata ( ) { if ( ! empty ( $ this -> metadata ) ) { $ status = $ this -> container -> cfs_http -> update_object ( $ this ) ; if ( $ status != 202 ) { throw new InvalidResponseException ( "Invalid response (" . $ status . "): " . $ this -> container -> cfs_http -> get_error ( ) ) ; } return True ; } ret...
Store new Object metadata
40,293
function write ( $ data = NULL , $ bytes = 0 , $ verify = True ) { if ( ! $ data ) { throw new SyntaxException ( "Missing data source." ) ; } if ( $ bytes > MAX_OBJECT_SIZE ) { throw new SyntaxException ( "Bytes exceeds maximum object size." ) ; } if ( $ verify ) { if ( ! $ this -> _etag_override ) { $ this -> etag = $...
Upload Object s data to Cloud Files
40,294
function load_from_filename ( $ filename , $ verify = True ) { $ fp = @ fopen ( $ filename , "r" ) ; if ( ! $ fp ) { throw new IOException ( "Could not open file for reading: " . $ filename ) ; } clearstatcache ( ) ; $ size = ( float ) sprintf ( "%u" , filesize ( $ filename ) ) ; if ( $ size > MAX_OBJECT_SIZE ) { throw...
Upload Object data from local filename
40,295
function save_to_filename ( $ filename ) { $ fp = @ fopen ( $ filename , "wb" ) ; if ( ! $ fp ) { throw new IOException ( "Could not open file for writing: " . $ filename ) ; } $ result = $ this -> stream ( $ fp ) ; fclose ( $ fp ) ; return $ result ; }
Save Object s data to local filename
40,296
function compute_md5sum ( & $ data ) { if ( function_exists ( "hash_init" ) && is_resource ( $ data ) ) { $ ctx = hash_init ( 'md5' ) ; while ( ! feof ( $ data ) ) { $ buffer = fgets ( $ data , 65536 ) ; hash_update ( $ ctx , $ buffer ) ; } $ md5 = hash_final ( $ ctx , false ) ; rewind ( $ data ) ; } elseif ( ( string ...
Compute the MD5 checksum
40,297
function signature ( $ request , $ base_string , $ consumer_secret , $ token_secret ) { $ key = $ request -> urlencode ( $ consumer_secret ) . '&' . $ request -> urlencode ( $ token_secret ) ; if ( function_exists ( 'hash_hmac' ) ) { $ signature = base64_encode ( hash_hmac ( "sha1" , $ base_string , $ key , true ) ) ; ...
Calculate the signature using HMAC - SHA1 This function is copyright Andy Smith 2007 .
40,298
function signature ( $ request , $ base_string , $ consumer_secret , $ token_secret ) { return $ request -> urlencode ( $ request -> urlencode ( $ consumer_secret ) . '&' . $ request -> urlencode ( $ token_secret ) ) ; }
Calculate the signature using PLAINTEXT
40,299
function DoSearch ( $ query , $ start = 0 , $ max = 10 , $ filter = false , $ restrict = "" , $ safe = false , $ lr = "" , $ ie = "" , $ oe = "" ) { $ result = null ; $ continue = true ; $ counter = 0 ; while ( $ continue ) { $ counter ++ ; try { $ result = $ this -> _googleSoap ( $ query , $ start , $ max , $ filter ,...
Queries google for the specified search query