code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
protected static function escapeCommentedCDATA($string) { return preg_replace_callback( '#<!--//--><!\[CDATA\[//><!--(.+?)//--><!\]\]>#s', array('HTMLPurifier_Lexer', 'CDATACallback'), $string ); }
Special CDATA case that is especially convoluted for <script> @param string $string HTML string to process. @return string HTML with CDATA sections escaped.
escapeCommentedCDATA
php
boonex/dolphin.pro
plugins/htmlpurifier/HTMLPurifier.standalone.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/HTMLPurifier.standalone.php
MIT
protected static function removeIEConditional($string) { return preg_replace( '#<!--\[if [^>]+\]>.*?<!\[endif\]-->#si', // probably should generalize for all strings '', $string ); }
Special Internet Explorer conditional comments should be removed. @param string $string HTML string to process. @return string HTML with conditional comments removed.
removeIEConditional
php
boonex/dolphin.pro
plugins/htmlpurifier/HTMLPurifier.standalone.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/HTMLPurifier.standalone.php
MIT
protected static function CDATACallback($matches) { // not exactly sure why the character set is needed, but whatever return htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8'); }
Callback function for escapeCDATA() that does the work. @warning Though this is public in order to let the callback happen, calling it directly is not recommended. @param array $matches PCRE matches array, with index 0 the entire match and 1 the inside of the CDATA section. @return string Escaped internals of the CDATA section.
CDATACallback
php
boonex/dolphin.pro
plugins/htmlpurifier/HTMLPurifier.standalone.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/HTMLPurifier.standalone.php
MIT
public function prepareGenerator($config) { $all = $config->getAll(); $context = new HTMLPurifier_Context(); $this->generator = new HTMLPurifier_Generator($config, $context); }
Give generator necessary configuration if possible @param HTMLPurifier_Config $config
prepareGenerator
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
MIT
protected function row($name, $value) { if (is_bool($value)) { $value = $value ? 'On' : 'Off'; } return $this->start('tr') . "\n" . $this->element('th', $name) . "\n" . $this->element('td', $value) . "\n" . $this->end('tr'); }
Prints a simple key/value row in a table. @param string $name Key @param mixed $value Value @return string
row
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
MIT
protected function escape($string) { $string = HTMLPurifier_Encoder::cleanUTF8($string); $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8'); return $string; }
Escapes a string for HTML output. @param string $string String to escape @return string
escape
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
MIT
protected function listify($array, $polite = false) { if (empty($array)) { return 'None'; } $ret = ''; $i = count($array); foreach ($array as $value) { $i--; $ret .= $value; if ($i > 0 && !($polite && $i == 1)) { $ret .= ', '; } if ($polite && $i == 1) { $ret .= 'and '; } } return $ret; }
Takes a list of strings and turns them into a single list @param string[] $array List of strings @param bool $polite Bool whether or not to add an end before the last @return string
listify
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer.php
MIT
public function setTextareaDimensions($cols = null, $rows = null) { if ($cols) { $this->fields['default']->cols = $cols; } if ($rows) { $this->fields['default']->rows = $rows; } }
Sets default column and row size for textareas in sub-printers @param $cols Integer columns of textarea, null to use default @param $rows Integer rows of textarea, null to use default
setTextareaDimensions
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
MIT
public static function getCSS() { return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); }
Retrieves styling, in case it is not accessible by webserver
getCSS
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
MIT
public static function getJavaScript() { return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); }
Retrieves JavaScript, in case it is not accessible by webserver
getJavaScript
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Printer/ConfigForm.php
MIT
protected function styleCallback($matches) { $this->_styleMatches[] = $matches[1]; }
Save the contents of CSS blocks to style matches @param array $matches preg_replace style $matches array
styleCallback
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/Filter/ExtractStyleBlocks.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/Filter/ExtractStyleBlocks.php
MIT
public function validateId($id) { $id_string = $id->toString(); $this->context[] = "id '$id_string'"; if (!$id instanceof HTMLPurifier_ConfigSchema_Interchange_Id) { // handled by InterchangeBuilder $this->error(false, 'is not an instance of HTMLPurifier_ConfigSchema_Interchange_Id'); } // keys are now unconstrained (we might want to narrow down to A-Za-z0-9.) // we probably should check that it has at least one namespace $this->with($id, 'key') ->assertNotEmpty() ->assertIsString(); // implicit assertIsString handled by InterchangeBuilder array_pop($this->context); }
Validates a HTMLPurifier_ConfigSchema_Interchange_Id object. @param HTMLPurifier_ConfigSchema_Interchange_Id $id
validateId
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
public function validateDirective($d) { $id = $d->id->toString(); $this->context[] = "directive '$id'"; $this->validateId($d->id); $this->with($d, 'description') ->assertNotEmpty(); // BEGIN - handled by InterchangeBuilder $this->with($d, 'type') ->assertNotEmpty(); $this->with($d, 'typeAllowsNull') ->assertIsBool(); try { // This also tests validity of $d->type $this->parser->parse($d->default, $d->type, $d->typeAllowsNull); } catch (HTMLPurifier_VarParserException $e) { $this->error('default', 'had error: ' . $e->getMessage()); } // END - handled by InterchangeBuilder if (!is_null($d->allowed) || !empty($d->valueAliases)) { // allowed and valueAliases require that we be dealing with // strings, so check for that early. $d_int = HTMLPurifier_VarParser::$types[$d->type]; if (!isset(HTMLPurifier_VarParser::$stringTypes[$d_int])) { $this->error('type', 'must be a string type when used with allowed or value aliases'); } } $this->validateDirectiveAllowed($d); $this->validateDirectiveValueAliases($d); $this->validateDirectiveAliases($d); array_pop($this->context); }
Validates a HTMLPurifier_ConfigSchema_Interchange_Directive object. @param HTMLPurifier_ConfigSchema_Interchange_Directive $d
validateDirective
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
public function validateDirectiveAllowed($d) { if (is_null($d->allowed)) { return; } $this->with($d, 'allowed') ->assertNotEmpty() ->assertIsLookup(); // handled by InterchangeBuilder if (is_string($d->default) && !isset($d->allowed[$d->default])) { $this->error('default', 'must be an allowed value'); } $this->context[] = 'allowed'; foreach ($d->allowed as $val => $x) { if (!is_string($val)) { $this->error("value $val", 'must be a string'); } } array_pop($this->context); }
Extra validation if $allowed member variable of HTMLPurifier_ConfigSchema_Interchange_Directive is defined. @param HTMLPurifier_ConfigSchema_Interchange_Directive $d
validateDirectiveAllowed
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
protected function with($obj, $member) { return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->getFormattedContext(), $obj, $member); }
Convenience function for generating HTMLPurifier_ConfigSchema_ValidatorAtom for validating simple member variables of objects. @param $obj @param $member @return HTMLPurifier_ConfigSchema_ValidatorAtom
with
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
protected function error($target, $msg) { if ($target !== false) { $prefix = ucfirst($target) . ' in ' . $this->getFormattedContext(); } else { $prefix = ucfirst($this->getFormattedContext()); } throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix . ' ' . $msg)); }
Emits an error, providing helpful context. @throws HTMLPurifier_ConfigSchema_Exception
error
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
protected function getFormattedContext() { return implode(' in ', array_reverse($this->context)); }
Returns a formatted context string. @return string
getFormattedContext
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Validator.php
MIT
public function build($interchange, $hash) { if (!$hash instanceof HTMLPurifier_StringHash) { $hash = new HTMLPurifier_StringHash($hash); } if (!isset($hash['ID'])) { throw new HTMLPurifier_ConfigSchema_Exception('Hash does not have any ID'); } if (strpos($hash['ID'], '.') === false) { if (count($hash) == 2 && isset($hash['DESCRIPTION'])) { $hash->offsetGet('DESCRIPTION'); // prevent complaining } else { throw new HTMLPurifier_ConfigSchema_Exception('All directives must have a namespace'); } } else { $this->buildDirective($interchange, $hash); } $this->_findUnused($hash); }
Builds an interchange object based on a hash. @param HTMLPurifier_ConfigSchema_Interchange $interchange HTMLPurifier_ConfigSchema_Interchange object to build @param HTMLPurifier_StringHash $hash source data @throws HTMLPurifier_ConfigSchema_Exception
build
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
MIT
protected function evalArray($contents) { return eval('return array(' . $contents . ');'); }
Evaluates an array PHP code string without array() wrapper @param string $contents
evalArray
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
MIT
protected function lookup($array) { $ret = array(); foreach ($array as $val) { $ret[$val] = true; } return $ret; }
Converts an array list into a lookup array. @param array $array @return array
lookup
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
MIT
protected function id($id) { return HTMLPurifier_ConfigSchema_Interchange_Id::make($id); }
Convenience function that creates an HTMLPurifier_ConfigSchema_Interchange_Id object based on a string Id. @param string $id @return HTMLPurifier_ConfigSchema_Interchange_Id
id
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
MIT
protected function _findUnused($hash) { $accessed = $hash->getAccessed(); foreach ($hash as $k => $v) { if (!isset($accessed[$k])) { trigger_error("String hash key '$k' not used by builder", E_USER_NOTICE); } } }
Triggers errors for any unused keys passed in the hash; such keys may indicate typos, missing values, etc. @param HTMLPurifier_StringHash $hash Hash to check.
_findUnused
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
MIT
public function addDirective($directive) { if (isset($this->directives[$i = $directive->id->toString()])) { throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); } $this->directives[$i] = $directive; }
Adds a directive array to $directives @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive @throws HTMLPurifier_ConfigSchema_Exception
addDirective
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange.php
MIT
public function validate() { $validator = new HTMLPurifier_ConfigSchema_Validator(); return $validator->validate($this); }
Convenience function to perform standard validation. Throws exception on failed validation.
validate
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange.php
MIT
public function toString() { return $this->key; }
@return string @warning This is NOT magic, to ensure that people don't abuse SPL and cause problems for PHP 5.0 support.
toString
php
boonex/dolphin.pro
plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange/Id.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/Interchange/Id.php
MIT
public function setInput($filename = null) { // reset previously retrieved results $this->_reset(); // check and open file if (!file_exists($filename) || !($this->_fp = fopen($filename, 'rb'))) { return 'cannot open file: '.$filename; } // get size of file $this->_filesize = filesize($filename); // empty file? if ($this->_filesize == 0) { return 'file '.$filename.' seems to be empty!'; } // parse file's atoms while (!feof($this->_fp) && ftell($this->_fp) < $this->_filesize) { $this->_fileAtoms[] = $this->_parseAtomsFromInput(); } $moovEOFCheck = $this->_moovAtomAtEOF(); if ($moovEOFCheck !== true) { return $moovEOFCheck; } else { // successful parsed the file! $this->_successfullyParsed = true; } // success return true; }
sets the input file to process this method sets the input file @param string $filename The input file to fix @return mixed The error-message (string) if opening the inputfile failed, otherwise TRUE @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
setInput
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _parseAtomsFromInput() { // reset file stream pointer to position of the lastAtom.offset + size if ((isset($this->_fileAtoms[count($this->_fileAtoms) - 1]))) { $lastAtom = $this->_fileAtoms[count($this->_fileAtoms) - 1]; $position = $lastAtom->getSize() + $lastAtom->getOffset(); if (ftell($this->_fp) <= $position) { fseek($this->_fp, $position); } } // get 8 bytes -> get totalSize and boxType $atomData = unpack('NtotalSize/NboxType', fread($this->_fp, 8)); // store offset, size and type $offset = ftell($this->_fp) - 8; $size = $atomData['totalSize']; $type = pack('N', $atomData['boxType']); // check 64 bit size (files > 4GB) if ($size == 1) { $highInt = $atomData['totalSize']; $size = ($highInt << 32) | $atomData['totalSize']; } // positioning of file-pointer fseek($this->_fp, ($size + $offset)); // give back atom return self::factory($offset, $size, $type); }
parse atoms / just parse and store / no check parse atoms / just parse and store / no check @return object An object of type Atom @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_parseAtomsFromInput
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _isValidQTFile() { // check if file was succesfully parsed if (!$this->_successfullyParsed) { return 'please open a file first!'; } // get first atom $firstAtom = $this->_fileAtoms[0]; // check first for being valid (first atom MUST be ftyp) if ($firstAtom->getType() != Atom::FTYP_ATOM) { $this->_fileValid = false; return 'encountered non-QT top-level atom (is this a Quicktime file?)'; } // check last for being valid $lastAtom = $this->_fileAtoms[count($this->_fileAtoms) - 1]; if (!Atom::isValidAtom($lastAtom->getType())) { $this->_fileValid = false; return 'encountered non-QT top-level atom (is this a Quicktime file?'; } // store validity return $this->_fileValid = true; }
checks for valid qt-file checks for valid qt-file @return boolean True if everything wents fine, otherwise false @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_isValidQTFile
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _moovAtomAtEOF() { if ($this->_fileAtoms[count($this->_fileAtoms) - 1]->getType() != Atom::MOOV_ATOM) { return 'The moov-atom isn\'t located at the end of the file, the file is allready ready for progressive download or it is a invalid file'; } // moov is at end of file... return true; }
check moov atoms position check moov atoms position @return mixed True if everything wents fine, otherwise string error-message @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_moovAtomAtEOF
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public function setOutput($filename) { // store filename $this->_outputFile = $filename; // success return true; }
set output file set output file @param string $filename The filename ( + path) to put result (fixed data) in @return boolean True if everything wents fine, otherwise false @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
setOutput
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public function relocateMoovAtom($filename, $outputFilename = null, $overwrite = false) { // read file, preprocess (parse atoms/boxes) $result = $this->setInput($filename); if ($result !== true) { return $result; } if (is_null($outputFilename) && $overwrite === true) { $fileResult = $filename; } else { $fileResult = $outputFilename; } // set the output filename and path $result = $this->setOutput($fileResult); if ($result !== true) { return $result; } // moov positioning fix $result = $this->fix(); if ($result !== true) { return $result; } // success return true; }
input, output and fix call - shortcut input, output and fix call - shortcut @param string $filename The input filename @param string $outputFilename The output filename @param boolean $overwrite The overwrite status @return mixed True if everything wents fine, otherwise error-message as string @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
relocateMoovAtom
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public function fix() { // check if file was succesfully parsed if (!$this->_successfullyParsed) { return 'please open a file first! (syntax: '.__CLASS__.'->setInput($filename);)'; } if (!$this->_outputFile) { return 'please set an outputfile first! (syntax: '.__CLASS__.'->setOutput($file);)'; } // check if moov atom is allready at beginning of file if (!$this->_moovAtomAtEOF()) { return 'nothing to do! moov allready at begin of file!'; } // Bytearray's holding bytes from file $this->_ftypBytes = new Bytearray(); $this->_middleBytes = new Bytearray(); $this->_moovBytes = new Bytearray(); // read in file's bytes $result = $this->_readBytes(); if ($result !== true) { return $result; } // now start swapping $result = $this->_swapIndex(); if ($result !== true) { return $result; } // write new file $result = $this->_writeFile(); if ($result !== true) { return $result; } // everythings fine! return true; }
fix moov-atom location fix moov-atom location @return mixed True if everything wents fine, otherwise error-message as string @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
fix
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _readBytes() { // read bytes from all found atoms for ($atom = 0; $atom < count($this->_fileAtoms); $atom++) { // get the current atom/box $currentAtom = $this->_fileAtoms[$atom]; $currentAtomType = $currentAtom->getType(); // keep ftyp atom if ($currentAtomType == Atom::FTYP_ATOM) { // set file pointer to begin of file fseek($this->_fp, 0); $bytes = fread($this->_fp, $currentAtom->getSize()); $this->_ftypBytes->writeBytes($bytes); } else if ($currentAtomType == Atom::MOOV_ATOM) { $bytes = fread($this->_fp, $currentAtom->getSize()); $this->_moovBytes->writeBytes($bytes); } else { $bytes = fread($this->_fp, $currentAtom->getSize()); $this->_middleBytes->writeBytes($bytes); } } return true; }
reads all bytes from all found atoms reads all bytes from all found atoms @return mixed True if everything wents fine, otherwise error-message as string @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_readBytes
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _swapIndex() { $moovSize = $this->_moovBytes->bytesAvailable(); $moovAType = ''; $moovASize = 0; $offsetCount = 0; $compressionCheck = $this->_moovBytes->readBytes(12, 4); if ($compressionCheck == Atom::CMOV_ATOM) { throw new Exception('compressed MP4/QT-file can\'t do this file: '.$file); } // begin of metadata $metaDataOffsets = array(); $metaDataStrings = array(); $metaDataCurrentLevel = 0; $moovStartOffset = 12; for ($i = $moovStartOffset; $i < $moovSize - $moovStartOffset; $i++) { $moovAType = $this->_moovBytes->readUTFBytes($i, 4); if (Atom::isValidAtom($moovAType)) { $moovASize = $this->_moovBytes->readUnsignedInt($i - 4); if (($moovASize > 8) && ($moovASize + $i < ($moovSize - $moovStartOffset))) { try { $containerLength = 0; $containerString = $moovAType; for ($mi = count($metaDataOffsets) - 1; $mi > - 1; $mi--) { $containerLength = $metaDataOffsets[$mi]; if ($i - $moovStartOffset < $containerLength && $i - $moovStartOffset + $moovASize > $containerLength) { throw new Exception('bad atom nested size'); } if ($i - $moovStartOffset == $containerLength) { array_pop($metaDataOffsets); array_pop($metaDataStrings); } else { $containerString = $metaDataStrings[$mi].".".$containerString; } } if (($i - $moovStartOffset) <= $containerLength) { array_push($metaDataOffsets, ($i - $moovStartOffset + $moovASize)); array_push($metaDataStrings, $moovAType); } if ($moovAType != Atom::STCO_ATOM && $moovAType != Atom::CO64_ATOM) { $i += 4; } elseif ($moovAType == Atom::URL_ATOM || $moovAType == Atom::XML_ATOM) { $i += $moovASize - 4; } } catch(Exception $e) { echo 'EXCEPTION: '.$e->getMessage(); } } } if ($moovAType == Atom::STCO_ATOM) { $moovASize = $this->_moovBytes->readUnsignedInt($i - 4); if ($i + $moovASize - $moovStartOffset > $moovSize) { throw new Exception('bad atom size'); return; } $offsetCount = $this->_moovBytes->readUnsignedInt($i + 8); for ($j = 0; $j < $offsetCount; $j++) { $position = ($i + 12 + $j * 4); $currentOffset = $this->_moovBytes->readUnsignedInt($position); // cause of mooving the moov-atom right before the rest of data // (behind ftyp) the new offset is caluclated: // current-offset + size of moov atom (box) = new offset $currentOffset += $moovSize; $this->_moovBytes->writeBytes(Transform::toUInt32BE($currentOffset), $position + 1); } $i += $moovASize - 4; } else if ($moovAType == Atom::CO64_ATOM) { $moovASize = $this->_moovBytes->readUnsignedInt($i - 4); if ($i + $moovASize - $moovStartOffset > $moovSize) { throw new Exception('bad atom size'); return; } $offsetCount = $this->_moovBytes->readDouble($i + 8); for ($j2 = 0; $j2 < $offsetCount; $j2++) { $position = ($i + 12 + $j * 8); $currentOffset = $this->_moovBytes->readUnsignedInt($position); // cause of mooving the moov-atom right before the rest of data // (behind ftyp) the new offset is caluclated: // current-offset + size of moov atom (box) = new offset $currentOffset += $moovSize; // TODO implement! //$this->_moovBytes->writeBytes(Transform::toUInt64BE($currentOffset), $position+1); } $i += $moovASize - 4; } } return true; }
swaps the index from end to beginning swaps the index from end to beginning @return mixed True if everything wents fine, otherwise error-message as string @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_swapIndex
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _writeFile() { // check if we need to unlink exisiting outputfile if (file_exists($this->_outputFile)) { // close handle if ($this->_fp) { @fclose($this->_fp); $this->_fp = null; } if (!@unlink($this->_outputFile)) { return 'error deleting file: '.$this->_outputFile.' outputfile "'.$this->_outputFile.'" exists (overwite = true)!'; } } // open predefined output file if (!$fh = fopen($this->_outputFile, 'wb+')) { return 'error opening outputfile: '.$this->_outputFile.' for wb+ access!'; } // put ftyp atom/box in if (!fwrite($fh, $this->_ftypBytes->readAllBytes())) { return 'error writing ftyp-atom to outputfile: '.$this->_outputFile; } // put moov atom in if (!fwrite($fh, $this->_moovBytes->readAllBytes())) { return 'error writing moov-atom to outputfile: '.$this->_outputFile; } // put rest data in if (!fwrite($fh, $this->_middleBytes->readAllBytes())) { return 'error writing other atom(s) to outputfile: '.$this->_outputFile; } // close handle fclose($fh); // everything's fine return true; }
write the new byteorder to a new file write the new byteorder to a new file @return mixed True if everything wents fine, otherwise error-message as string @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access private
_writeFile
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public static function factory($offset, $size, $type) { // instanciate a new atom-object $atom = new Atom(); // setup ... $atom->setOffset($offset); $atom->setSize($size); $atom->setType($type); // and give back ... return $atom; }
factory for creating atom object instances factory for creating atom object instances @param integer $offset The offset of the atom (in bytes) @param integer $size The size of the atom (in bytes) @param string $type The type of the atom @return object An instance of the Atom-class @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
factory
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function _reset() { $this->_fileAtoms = array(); $this->_lastAtom = null; $this->_successfullyParsed = false; $this->_fileValid = null; if ($this->_fp) { @fclose($this->_fp); } }
resets the state of the last operation to defaults This method is intend to reset the state of the last operation to defaults. @return void @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.2 @access public
_reset
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
instance singleton requester method for singleton instantiation of this class @return object Instance of this class @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1 @access public
getInstance
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
private function __clone() { // empty container }
prevents cloning of the class this method prevents the cloning of a class - but can be overridden by child @return void @access private @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1
__clone
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public function __destruct() { // close handle $this->_reset(); }
gets called on garbage collecting (object destroyed) destruct method - gets called when instance of this class get collected from garbage collector. close the open filehandel on destruction. @return void @access public @author Benjamin Carl <[email protected]> @version 0.1 @since Method available since Release 0.1
__destruct
php
boonex/dolphin.pro
plugins/moovrelocator/lib/Moovrelocator.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/Moovrelocator.class.php
MIT
public static function isValidAtom($fourByteString) { if (preg_match('/[@a-zA-Z][a-zA-Z0-9][a-zA-Z0-9 ][a-zA-Z0-9 ]/', $fourByteString) && in_array($fourByteString, self::$validAtoms)) { return true; } else { return false; } }
returns true if $fourByteString is a character string and atom type (ISO code of the atom) is valid ($validAtoms)
isValidAtom
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function getType() { return $this->_type; }
returns the atom type (ISO code of the atom) i.e.: moov, ftyp, mdat etc...
getType
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function setType($type) { $this->_type = $type; }
sets the atom type (ISO code of the atom) i.e.: moov, ftyp, mdat etc...
setType
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function getSize() { return $this->_size; }
returns the size of atom in bytes
getSize
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function setSize($value) { $this->_size = $value; if ($value == 1) { $this->_is64 = true; } }
sets the size of atom in bytes
setSize
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function getOffset() { return $this->_offset; }
returns the offset of where the atom/box resides in the file in bytes
getOffset
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function setOffset($value) { $this->_offset = $value; }
sets the offset of where the atom/box resides in the file in bytes
setOffset
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
public function toString() { return '[type: ' . $this->_type . ',size: ' . $this->_size . ',offset: ' . $this->_offset . ']'; }
returns formatted informations about the instance
toString
php
boonex/dolphin.pro
plugins/moovrelocator/lib/atom/Atom.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/atom/Atom.class.php
MIT
private function __construct() {}
Default private constructor for a static class.
__construct
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function isLittleEndian() { return self::fromInt32("\x01\x00\x00\x00") == 1; }
Returns whether the current machine endian order is little endian. @return boolean
isLittleEndian
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function isBigEndian() { return self::fromInt32("\x00\x00\x00\x01") == 1; }
Returns whether the current machine endian order is big endian. @return boolean
isBigEndian
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt64LE($value) { return pack("V*", $value & 0xffffffff, $value / (0xffffffff+1)); }
Returns 64-bit float as little-endian ordered binary data string. @param integer $value The input value. @return string
toInt64LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt64LE($value) { list(, $lolo, $lohi, $hilo, $hihi) = unpack("v*", $value); return ($hihi * (0xffff+1) + $hilo) * (0xffffffff+1) + ($lohi * (0xffff+1) + $lolo); }
Returns little-endian ordered binary data as 64-bit float. PHP does not support 64-bit integers as the long integer is of 32-bits but using aritmetic operations it is implicitly converted into floating point which is of 64-bits long. @param string $value The binary data string. @return integer
fromInt64LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt64BE($value) { return pack("N*", $value / (0xffffffff+1), $value & 0xffffffff); }
Returns 64-bit float as big-endian ordered binary data string. @param integer $value The input value. @return string
toInt64BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt64BE($value) { list(, $hihi, $hilo, $lohi, $lolo) = unpack("n*", $value); return ($hihi * (0xffff+1) + $hilo) * (0xffffffff+1) + ($lohi * (0xffff+1) + $lolo); }
Returns big-endian ordered binary data as 64-bit float. PHP does not support 64-bit integers as the long integer is of 32-bits but using aritmetic operations it is implicitly converted into floating point which is of 64-bits long. @param string $value The binary data string. @return integer
fromInt64BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt32($value) { return pack("l*", $value); }
Returns signed 32-bit integer as machine-endian ordered binary data. @param integer $value The input value. @return string
toInt32
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt32($value) { list(, $int) = unpack("l*", $value); return $int; }
Returns machine-endian ordered binary data as signed 32-bit integer. @param string $value The binary data string. @return integer
fromInt32
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt32LE($value) { if (self::isBigEndian()) return strrev(self::toInt32($value)); else return self::toInt32($value); }
Returns signed 32-bit integer as little-endian ordered binary data. @param integer $value The input value. @return string
toInt32LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt32LE($value) { if (self::isBigEndian()) return self::fromInt32(strrev($value)); else return self::fromInt32($value); }
Returns little-endian ordered binary data as signed 32-bit integer. @param string $value The binary data string. @return integer
fromInt32LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt32BE($value) { if (self::isBigEndian()) return self::toInt32($value); else return strrev(self::toInt32($value)); }
Returns signed 32-bit integer as big-endian ordered binary data. @param integer $value The input value. @return string
toInt32BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt32BE($value) { if (self::isBigEndian()) return self::fromInt32($value); else return self::fromInt32(strrev($value)); }
Returns big-endian ordered binary data as signed 32-bit integer. @param string $value The binary data string. @return integer
fromInt32BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toUInt32LE($value) { return pack("V*", $value); }
Returns unsigned 32-bit integer as little-endian ordered binary data. @param integer $value The input value. @return string
toUInt32LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromUInt32LE($value) { if (PHP_INT_SIZE < 8) { list(, $lo, $hi) = unpack("v*", $value); return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo } else { list(, $int) = unpack("V*", $value); return $int; } }
Returns little-endian ordered binary data as unsigned 32-bit integer. @param string $value The binary data string. @return integer
fromUInt32LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toUInt32BE($value) { return pack("N*", $value); }
Returns unsigned 32-bit integer as big-endian ordered binary data. @param integer $value The input value. @return string
toUInt32BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromUInt32BE($value) { if (PHP_INT_SIZE < 8) { list(, $hi, $lo) = unpack("n*", $value); return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo } else { list(, $int) = unpack("N*", $value); return $int; } }
Returns big-endian ordered binary data as unsigned 32-bit integer. @param string $value The binary data string. @return integer
fromUInt32BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt16($value) { return pack("s*", $value); }
Returns signed 16-bit integer as machine endian ordered binary data. @param integer $value The input value. @return string
toInt16
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt16($value) { list(, $int) = unpack("s*", $value); return $int; }
Returns machine endian ordered binary data as signed 16-bit integer. @param string $value The binary data string. @return integer
fromInt16
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt16LE($value) { if (self::isBigEndian()) return strrev(self::toInt16($value)); else return self::toInt16($value); }
Returns signed 16-bit integer as little-endian ordered binary data. @param integer $value The input value. @return string
toInt16LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt16LE($value) { if (self::isBigEndian()) return self::fromInt16(strrev($value)); else return self::fromInt16($value); }
Returns little-endian ordered binary data as signed 16-bit integer. @param string $value The binary data string. @return integer
fromInt16LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt16BE($value) { if (self::isBigEndian()) return self::toInt16($value); else return strrev(self::toInt16($value)); }
Returns signed 16-bit integer as big-endian ordered binary data. @param integer $value The input value. @return string
toInt16BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt16BE($value) { if (self::isBigEndian()) return self::fromInt16($value); else return self::fromInt16(strrev($value)); }
Returns big-endian ordered binary data as signed 16-bit integer. @param string $value The binary data string. @return integer
fromInt16BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
private static function fromUInt16($value, $order = self::MACHINE_ENDIAN_ORDER) { list(, $int) = unpack (($order == self::BIG_ENDIAN_ORDER ? "n" : ($order == self::LITTLE_ENDIAN_ORDER ? "v" : "S")) . "*", $value); return $int; }
Returns machine endian ordered binary data as unsigned 16-bit integer. @param string $value The binary data string. @param integer $order The byte order of the binary data string. @return integer
fromUInt16
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toUInt16LE($value) { return pack("v*", $value); }
Returns unsigned 16-bit integer as little-endian ordered binary data. @param integer $value The input value. @return string
toUInt16LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromUInt16LE($value) { return self::fromUInt16($value, self::LITTLE_ENDIAN_ORDER); }
Returns little-endian ordered binary data as unsigned 16-bit integer. @param string $value The binary data string. @return integer
fromUInt16LE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toUInt16BE($value) { return pack("n*", $value); }
Returns unsigned 16-bit integer as big-endian ordered binary data. @param integer $value The input value. @return string
toUInt16BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromUInt16BE($value) { return self::fromUInt16($value, self::BIG_ENDIAN_ORDER); }
Returns big-endian ordered binary data as unsigned 16-bit integer. @param string $value The binary data string. @return integer
fromUInt16BE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toInt8($value) { return pack("c*", $value); }
Returns an 8-bit integer as binary data. @param integer $value The input value. @return integer
toInt8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromInt8($value) { list(, $int) = unpack("c*", $value); return $int; }
Returns binary data as 8-bit integer. @param string $value The binary data string. @return integer
fromInt8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toUInt8($value) { return pack("C*", $value); }
Returns an unsigned 8-bit integer as binary data. @param integer $value The input value. @return integer
toUInt8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromUInt8($value) { list(, $int) = unpack("C*", $value); return $int; }
Returns binary data as an unsigned 8-bit integer. @param string $value The binary data string. @return integer
fromUInt8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toFloat($value) { return pack("f*", $value); }
Returns a floating point number as machine endian ordered binary data. @param float $value The input value. @return string
toFloat
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromFloat($value) { list(, $float) = unpack("f*", $value); return $float; }
Returns machine endian ordered binary data as a floating point number. @param string $value The binary data string. @return float
fromFloat
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toFloatLE($value) { if (self::isBigEndian()) return strrev(self::toFloat($value)); else return self::toFloat($value); }
Returns a floating point number as little-endian ordered binary data. @param float $value The input value. @return string
toFloatLE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromFloatLE($value) { if (self::isBigEndian()) return self::fromFloat(strrev($value)); else return self::fromFloat($value); }
Returns little-endian ordered binary data as a floating point number. @param string $value The binary data string. @return float
fromFloatLE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toFloatBE($value) { if (self::isBigEndian()) return self::toFloat($value); else return strrev(self::toFloat($value)); }
Returns a floating point number as big-endian ordered binary data. @param float $value The input value. @return string
toFloatBE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromFloatBE($value) { if (self::isBigEndian()) return self::fromFloat($value); else return self::fromFloat(strrev($value)); }
Returns big-endian ordered binary data as a float point number. @param string $value The binary data string. @return float
fromFloatBE
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toString8($value, $length = false, $padding = "\0") { if ($length === false) $length = strlen($value); if ($length < ($tmp = strlen($value))) $length = $tmp + $length; return str_pad($value, $length, $padding); }
Returns string as binary data padded to given length with zeros. If length is smaller than the length of the string, it is considered as the length of the padding. @param string $value The input value. @param integer $length The length to which to pad the value. @param string $padding The padding character. @return string
toString8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromString8($value) { return rtrim($value, "\0"); }
Returns binary data as string. Removes terminating zero. @param string $value The binary data string. @return string
fromString8
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toHHex($value) { return pack("H*", $value); }
Returns hexadecimal string having high nibble first as binary data. @param string $value The input value. @return string
toHHex
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromHHex($value) { list($hex) = unpack("H*0", $value); return $hex; }
Returns binary data as hexadecimal string having high nibble first. @param string $value The binary data string. @return string
fromHHex
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toLHex($value) { return pack("h*", $value); }
Returns hexadecimal string having low nibble first as binary data. @param string $value The input value. @return string
toLHex
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromLHex($value) { list($hex) = unpack("h*0", $value); return $hex; }
Returns binary data as hexadecimal string having low nibble first. @param string $value The binary data string. @return string
fromLHex
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function toGUID($value) { $string = ""; $C = preg_split("/-/", $value); return pack ("V1v2N2", hexdec($C[0]), hexdec($C[1]), hexdec($C[2]), hexdec($C[3] . substr($C[4], 0, 4)), hexdec(substr($C[4], 4))); }
Returns big-endian ordered hexadecimal GUID string as little-endian ordered binary data string. @param string $value The input value. @return string
toGUID
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public static function fromGUID($value) { $C = @unpack("V1V/v2v/N2N", $value); list($hex) = @unpack("H*0", pack ("NnnNN", $C["V"], $C["v1"], $C["v2"], $C["N1"], $C["N2"])); /* Fixes a bug in PHP versions earlier than Jan 25 2006 */ if (implode("", unpack("H*", pack("H*", "a"))) == "a00") $hex = substr($hex, 0, -1); return preg_replace ("/^(.{8})(.{4})(.{4})(.{4})/", "\\1-\\2-\\3-\\4-", $hex); }
Returns the little-endian ordered binary data as big-endian ordered hexadecimal GUID string. @param string $value The binary data string. @return string
fromGUID
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Transform.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Transform.class.php
MIT
public function setPosition($position) { $this->_lastPosition = $this->_position; $this->_position = $position; }
sets the current position of pointer sets the position of Bytearray pointer after writing bytes to Bytearray @param integer $position current position of the pointer @return void @access public @author Benjamin Carl <[email protected]> @since Method available since Release 1.0.0 @version 1.0
setPosition
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Bytearray.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Bytearray.class.php
MIT
public function getPosition() { return $this->_position; }
returns the current position of pointer returns the current position of Bytearray pointer @param void @return integer current position of the pointer @access public @author Benjamin Carl <[email protected]> @since Method available since Release 1.0.0 @version 1.0
getPosition
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Bytearray.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Bytearray.class.php
MIT
public function getLastPosition() { return $this->_lastPosition; }
returns the last position of pointer returns the last position - the position of pointer before last write operation @param void @return integer last position of the pointer @access public @author Benjamin Carl <[email protected]> @since Method available since Release 1.0.0 @version 1.0
getLastPosition
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Bytearray.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Bytearray.class.php
MIT
public function readBytes($offset, $length) { return substr($this->_bytes, $offset, $length); }
read bytes from Bytearray read bytes from Bytearray with given offset and length @param void @return void @access public @author Benjamin Carl <[email protected]> @since Method available since Release 1.0.0 @version 1.0
readBytes
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Bytearray.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Bytearray.class.php
MIT
public function readAllBytes() { return $this->_bytes; }
read all bytes from Bytearray read all bytes from Bytearray @param void @return void @access public @author Benjamin Carl <[email protected]> @since Method available since Release 1.0.0 @version 1.0
readAllBytes
php
boonex/dolphin.pro
plugins/moovrelocator/lib/bytes/Bytearray.class.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/moovrelocator/lib/bytes/Bytearray.class.php
MIT
protected function _selectorsCB($m) { // remove ws around the combinators return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]); }
Replace what looks like a set of selectors @param array $m regex matches @return string
_selectorsCB
php
boonex/dolphin.pro
plugins/minify/lib/Minify/CSS/Compressor.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/minify/lib/Minify/CSS/Compressor.php
MIT