sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
parent::nusoap_base();
$this->debug('nusoap_xmlschema class instantiated, inside constructor');
// files
$this->schema = $schema;
$this->xml = $xml;
// namespaces
$this->enclosingNamespaces = $namespaces;
$this->namespaces = ar... | constructor
@param string $schema schema document URI
@param string $xml xml document URI
@param string $namespaces namespaces defined in enclosing XML
@access public | entailment |
function schemaCharacterData($parser, $data){
$pos = $this->depth_array[$this->depth - 1];
$this->message[$pos]['cdata'] .= $data;
} | element content handler
@param string $parser XML parser object
@param string $data element content
@access private | entailment |
function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
$this->simpleTypes[$name] = array(
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'type' => $restrictionBase,
'enumeration' => $enumeration
... | adds a simple type to the schema
@param string $name
@param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
@param string $typeClass (should always be simpleType)
@param string $phpType (should always be scalar)
@param array $enumeration array of values
@access public
@see nuso... | entailment |
public function offsetGet($offset)
{
$this->validateKeyType($offset);
$this->validateKeyBounds($offset);
return $this->container[$offset];
} | identical to at, implemented for ArrayAccess | entailment |
function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
parent::nusoap_base();
$this->name = $name;
$this->type = $type;
$this->value = $value;
$this->element_ns = $element_ns;
$this->type_ns = $type_ns;
$this->attributes = $attributes;
} | constructor
@param string $name optional name
@param mixed $type optional type name
@param mixed $value optional value
@param mixed $element_ns optional namespace of value
@param mixed $type_ns optional namespace of type
@param mixed $attributes associative array of attributes to add to element serialization
@ac... | entailment |
function debug($string){
if ($this->debugLevel > 0) {
$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
}
} | adds debug data to the instance debug string with formatting
@param string $string debug data
@access private | entailment |
function isArraySimpleOrStruct($val) {
$keyList = array_keys($val);
foreach ($keyList as $keyListValue) {
if (!is_int($keyListValue)) {
return 'arrayStruct';
}
}
return 'arraySimple';
} | detect if array is a simple array or a struct (associative array)
@param mixed $val The PHP array
@return string (arraySimple|arrayStruct)
@access private | entailment |
function contractQname($qname){
// get element namespace
//$this->xdebug("Contract $qname");
if (strrpos($qname, ':')) {
// get unqualified name
$name = substr($qname, strrpos($qname, ':') + 1);
// get ns
$ns = substr($qname, 0, strrpos($qname, ':'));
$p = $this->getPrefixFromNamespace($ns)... | contracts (changes namespace to prefix) a qualified name
@param string $qname qname
@return string contracted qname
@access private | entailment |
function expandQname($qname){
// get element prefix
if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
// get unqualified name
$name = substr(strstr($qname,':'),1);
// get ns prefix
$prefix = substr($qname,0,strpos($qname,':'));
if(isset($this->namespaces[$prefix])){
return $th... | expands (changes prefix to namespace) a qualified name
@param string $qname qname
@return string expanded qname
@access private | entailment |
function getNamespaceFromPrefix($prefix){
if (isset($this->namespaces[$prefix])) {
return $this->namespaces[$prefix];
}
//$this->setError("No namespace registered for prefix '$prefix'");
return false;
} | pass it a prefix, it returns a namespace
@param string $prefix The prefix
@return mixed The namespace, false if no namespace has the specified prefix
@access public | entailment |
function getmicrotime() {
if (function_exists('gettimeofday')) {
$tod = gettimeofday();
$sec = $tod['sec'];
$usec = $tod['usec'];
} else {
$sec = time();
$usec = 0;
}
return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
} | returns the time in ODBC canonical form with microseconds
@return string The time in ODBC canonical form with microseconds
@access public | entailment |
function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
$this->fplock = array();
$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
$this->cache_lifetime = $cache_lifetime;
} | constructor
@param string $cache_dir directory for cache-files
@param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
@access public | entailment |
function put($wsdl_instance) {
$filename = $this->createFilename($wsdl_instance->wsdl);
$s = serialize($wsdl_instance);
if ($this->obtainMutex($filename, "w")) {
$fp = fopen($filename, "w");
if (! $fp) {
$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
$this->releaseMut... | adds a wsdl instance to the cache
@param object wsdl $wsdl_instance The wsdl instance to add
@return boolean WSDL successfully cached
@access public | entailment |
function releaseMutex($filename) {
$ret = flock($this->fplock[md5($filename)], LOCK_UN);
fclose($this->fplock[md5($filename)]);
unset($this->fplock[md5($filename)]);
if (! $ret) {
$this->debug("Not able to release lock for $filename");
}
return $ret;
} | releases the local mutex
@param string $filename The Filename of the Cache to lock
@return boolean Lock successfully released
@access private | entailment |
function remove($wsdl) {
$filename = $this->createFilename($wsdl);
if (!file_exists($filename)) {
$this->debug("$wsdl ($filename) not in cache to be removed");
return false;
}
// ignore errors obtaining mutex
$this->obtainMutex($filename, "w");
$ret = unlink($filename);
$this->debug("Remove... | removes a wsdl instance from the cache
@param string $wsdl The URL of the wsdl instance
@return boolean Whether there was an instance to remove
@access public | entailment |
public function groupBy($callback)
{
$group = new Map();
foreach ($this as $value) {
$key = $callback($value);
if (!$group->containsKey($key)) {
$element = $this instanceof VectorInterface ? new static([$value]) : new Vector([$value]);
$group->... | {@inheritDoc}
@return $this | entailment |
public function indexBy($callback)
{
$group = new Map();
foreach ($this as $value) {
$key = $callback($value);
$group->set($key, $value);
}
return $group;
} | {@inheritDoc}
@return $this | entailment |
public function reduce(callable $callback, $initial = null)
{
foreach ($this as $element) {
$initial = $callback($initial, $element);
}
return $initial;
} | {@inheritdoc} | entailment |
public function set($key, $value)
{
$this->validateKeyType($key);
$this->container[$key] = $value;
return $this;
} | Stores a value into the Vector with the specified key, overwriting the
previous value associated with the key. If the key is not present,
an exception is thrown. "$vec->set($k,$v)" is semantically equivalent
to "$vec[$k] = $v" (except that set() returns the Vector).
@param $key
@param $value
@return $this | entailment |
public function setAll($items)
{
$this->validateTraversable($items);
foreach ($items as $key => $item) {
if (is_array($item)) {
$item = new static($item);
}
$this->set($key, $item);
}
return $this;
} | {@inheritdoc} | entailment |
public function removeKey($key)
{
$this->validateKeyType($key);
$this->validateKeyBounds($key);
array_splice($this->container, $key, 1);
return $this;
} | {@inheritdoc} | entailment |
public function splice($offset, $length = null)
{
if (!is_int($offset)) {
throw new \InvalidArgumentException('Parameter offset must be an integer');
}
if (!is_null($length) && !is_int($length)) {
throw new \InvalidArgumentException('Parameter len must be null or an ... | {@inheritdoc} | entailment |
public static function fromArray(array $arr)
{
$map = new static();
foreach ($arr as $k => $v) {
if (is_array($v)) {
$map[$k] = new static($v);
} else {
$map[$k] = $v;
}
}
return $map;
} | {@inheritdoc} | entailment |
public function zip($traversable)
{
if (is_array($traversable)) {
$traversable = new ImmVector($traversable);
}
if ($traversable instanceof \Traversable) {
return new static(new LazyZipIterable($this, $traversable));
} else {
throw new \InvalidArg... | {@inheritDoc}
@return $this | entailment |
public function last()
{
if ($this->isEmpty()) {
return null;
}
$lastItem = array_slice($this->container, -1, 1);
return current($lastItem);
} | {@inheritDoc}
@return $this | entailment |
public function add($pair)
{
if (!($pair instanceof Pair)) {
throw new \InvalidArgumentException('Parameter must be an instance of Pair');
}
list($key, $value) = $pair;
$this->validateKeyExists($key);
$this->set($key, $value);
return $this;
} | {@inheritdoc} | entailment |
public function remove($element)
{
$key = array_search($element, $this->container);
if (false === $key) {
throw new \OutOfBoundsException('No element found in the collection');
}
$this->removeKey($key);
return $this;
} | {@inheritdoc} | entailment |
public function toArray()
{
$arr = [];
foreach ($this as $k => $v) {
if ($v instanceof Enumerable) {
$arr[] = $v->toArray();
} else {
$arr[] = $v;
}
}
return $arr;
} | Returns an array containing the values from this VectorLike. | entailment |
public function add($item)
{
if ($this->contains($item)) {
throw ElementAlreadyExists::duplicatedElement($item);
}
$this->container[] = $item;
return $this;
} | {@inheritdoc} | entailment |
function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
parent::nusoap_base();
$this->endpoint = $endpoint;
$this->proxyhost = $proxyhost;
$this->proxyport = $proxyport;
$th... | constructor
@param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
@param mixed $wsdl optional, set to 'wsdl' or true if using WSDL
@param string $proxyhost optional
@param string $proxyport optional
@param string $proxyusername optional
@param string $proxypassword optional
@pa... | entailment |
function getOperationData($operation){
if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
$this->loadWSDL();
if ($this->getError())
return false;
}
if(isset($this->operations[$operation])){
return $this->operations[$operation];
}
$this->debug("No data for operation: $operation"... | get available data pertaining to an operation
@param string $operation operation name
@return array array of data pertaining to the operation
@access public | entailment |
function setCurlOption($option, $value) {
$this->debug("setCurlOption option=$option, value=");
$this->appendDebug($this->varDump($value));
$this->curl_options[$option] = $value;
} | sets user-specified cURL options
@param mixed $option The cURL option (always integer?)
@param mixed $value The cURL option value
@access public | entailment |
function setHeaders($headers){
$this->debug("setHeaders headers=");
$this->appendDebug($this->varDump($headers));
$this->requestHeaders = $headers;
} | set the SOAP headers
@param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
@access public | entailment |
function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
$this->appendDebug($this->varDump($certRequest));
$this->username = $username;
$this->password = $password;
$this->authtype = $au... | if authenticating, set user credentials here
@param string $username
@param string $password
@param string $authtype (basic|digest|certificate|ntlm)
@param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding ... | entailment |
function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
parent::nusoap_base();
$this->faultcode = $faultcode;
$this->faultactor = $faultactor;
$this->faultstring = $faultstring;
$this->faultdetail = $faultdetail;
} | constructor
@param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
@param string $faultactor only used when msg routed between multiple actors
@param string $faultstring human readable error message
@param mixed $faultdetail detail, typically a string or array of string | entailment |
function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
parent::nusoap_base();
$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
$this->proxyhost = $proxyho... | constructor
@param string $wsdl WSDL document URL
@param string $proxyhost
@param string $proxyport
@param string $proxyusername
@param string $proxypassword
@param integer $timeout set the connection timeout
@param integer $response_timeout set the response timeout
@param array $curl_options user-specified cURL optio... | entailment |
function fetchWSDL($wsdl) {
$this->debug("parse and process WSDL path=$wsdl");
$this->wsdl = $wsdl;
// parse wsdl file
if ($this->wsdl != "") {
$this->parseWSDL($this->wsdl);
}
// imports
// TODO: handle imports more properly, grabbing them in-line and nes... | fetches the WSDL document and parses it
@access public | entailment |
function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
} elseif ($bindingType == 'soap12') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
}
// loop thru ports
foreach($this->po... | returns an associative array of data necessary for calling an operation
@param string $soapAction soapAction for operation
@param string $bindingType type of binding eg: soap, soap12
@return array
@access public | entailment |
function getTypeDef($type, $ns) {
$this->debug("in getTypeDef: type=$type, ns=$ns");
if ((! $ns) && isset($this->namespaces['tns'])) {
$ns = $this->namespaces['tns'];
$this->debug("in getTypeDef: type namespace forced to $ns");
}
if (!isset($this->schemas[$ns])) {
foreach ($this->schemas as $ns0... | returns an array of information about a given type
returns false if no type exists by the given name
typeDef = array(
'elements' => array(), // refs to elements array
'restrictionBase' => '',
'phpType' => '',
'order' => '(sequence|all)',
'attrs' => array() // refs to attributes array
)
@param string $type the type
@p... | entailment |
function serialize($debug = 0)
{
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$xml .= "\n<definitions";
foreach($this->namespaces as $k => $v) {
$xml .= " xmlns:$k=\"$v\"";
}
// 10.9.02 - add poulter fix for wsdl and tns declarations
if (isset($this->namespaces['wsdl'])) {
$xml .= ... | serialize the parsed wsdl
@param mixed $debug whether to put debug=1 in endpoint URL
@return string serialization of WSDL
@access public | entailment |
function parametersMatchWrapped($type, &$parameters) {
$this->debug("in parametersMatchWrapped type=$type, parameters=");
$this->appendDebug($this->varDump($parameters));
// split type into namespace:unqualified-type
if (strpos($type, ':')) {
$uqType = substr($type, strrpos($type, ':') + 1);
$ns =... | determine whether a set of parameters are unwrapped
when they are expect to be wrapped, Microsoft-style.
@param string $type the type (element name) of the wrapper
@param array $parameters the parameter values for the SOAP call
@return boolean whether they parameters are unwrapped (and should be wrapped)
@access priva... | entailment |
function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
$this->appendDebug('parameters=' . $this->varDump($parameters));
... | serialize PHP values according to a WSDL message definition
contrary to the method name, this is not limited to RPC
TODO
- multi-ref serialization
- validate PHP values against type definitions, return errors if invalid
@param string $operation operation name
@param string $direction (input|output)
@param mixed $para... | entailment |
function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
$this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
$xml = '';
if (isset($typeDef['extensionBase'])) {
$nsx = $this->getPrefix($typeDef['extensionBase']);
$uqTypex = $this->getLocalPart($typeDef['exten... | serializes the attributes for a complexType
@param array $typeDef our internal representation of an XML schema type (or element)
@param mixed $value a native PHP value (parameter value)
@param string $ns the namespace of the type
@param string $uqType the local part of the type
@return string value serialized as an XM... | entailment |
function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
$xml = '';
if (isset($typeDef['extensionBase'])) {
$nsx = $this->getPrefix($typeDef['extensionBase']);
$uqTypex ... | serializes the elements for a complexType
@param array $typeDef our internal representation of an XML schema type (or element)
@param mixed $value a native PHP value (parameter value)
@param string $ns the namespace of the type
@param string $uqType the local part of the type
@param string $use use for part (encoded|l... | entailment |
function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->name... | adds an XML Schema simple type to the WSDL types
@param string $name
@param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
@param string $typeClass (should always be simpleType)
@param string $phpType (should always be scalar)
@param array $enumeration array of values
@see nus... | entailment |
function addElement($attrs) {
$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addElement($attrs);
} | adds an element to the WSDL types
@param array $attrs attributes that must include name and type
@see nusoap_xmlschema
@access public | entailment |
function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
if ($use == 'encoded' && $encodingStyle == '') {
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
}
if ($style == 'doc... | register an operation with the server
@param string $name operation (method) name
@param array $in assoc array of input values: key = param name, value = param type
@param array $out assoc array of output values: key = param name, value = param type
@param string $namespace optional The namespace for the operation
@pa... | entailment |
public function concat($Enumerable)
{
if (is_array($Enumerable)) {
$Enumerable = new ImmVector($Enumerable);
}
if ($Enumerable instanceof \Traversable) {
return new ImmVector(new LazyConcatIterator($this, $Enumerable));
} else {
throw new \Invalid... | {@inheritDoc} | entailment |
public function at($key)
{
$this->validateKeyType($key);
$this->validateKeyBounds($key);
return $this->container[$key];
} | {@inheritdoc} | entailment |
public function sort(ComparerInterface $comparer = null)
{
if ($comparer === null) {
$comparer = $this->getDefaultComparer();
}
usort($this->container, array($comparer, 'compare'));
return $this;
} | Sorts the elements in the entire Collection<T> using the specified comparer.
@param ComparerInterface $comparer The ComparerInterface implementation to use when comparing elements, or null
to use the default comparer Comparer<T>.Default.
@return $this | entailment |
public function sortByKey(ComparerInterface $comparer = null)
{
if ($comparer === null) {
$comparer = $this->getDefaultComparer();
}
uksort($this->container, array($comparer, 'compare'));
return $this;
} | Sorts the keys in the entire Collection<T> using the specified comparer.
@param ComparerInterface $comparer The ComparerInterface implementation to use when comparing elements, or
null to use the default comparer Comparer<T>.Default.
@return $this | entailment |
public function addAll($items)
{
$this->validateTraversable($items);
$isMap = $items instanceof MapInterface;
foreach ($items as $key => $value) {
if (is_array($value)) {
$value = new static($value);
}
if ($isMap && !$value instanceof Pai... | {@inheritdoc} | entailment |
public function concat($Enumerable)
{
if ($Enumerable instanceof Enumerable) {
$Enumerable = $Enumerable->toArray();
}
return new static(array_merge_recursive($this->toArray(), $Enumerable));
} | {@inheritDoc} | entailment |
function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'ogg';
// Warn about illegal tags - only vorbiscomments are allowed
if (isset($info['id3v2'])) {
$info['warning'][] = 'Illegal ID3v2 tag present.';
}
if (isset($info['id3v1'])) {
$info['warning'][] = 'Illegal ID3v1 tag present.... | true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory | entailment |
public function addTo($email, $name = '', $type = 'to')
{
$this->to[] = array('email' => $email, 'name' => $name, 'type' => $type);
return $this;
} | Add a recipient
@param string $email
@param string $name
@param string $type
@return Message | entailment |
public function addGlobalMergeVar($name, $content)
{
$this->globalMergeVars[] = array(
'name' => $name,
'content' => $content,
);
$this->setMerge(true);
return $this;
} | Set global merge variable to use for all recipients.
You can override these per recipient.
@param string $name
@param string $content
@return Message | entailment |
public function addMergeVar($recipient, $name, $content)
{
$this->mergeVars[] = array(
'rcpt' => $recipient,
'vars' => array(
array(
'name' => $name,
'content' => $content
)
)
);
$thi... | Add per-recipient merge variable,
which override global merge variables with the same name.
@param string $recipient
@param string $name
@param string $content
@return Message | entailment |
public function addMergeVars($recipient, $data)
{
$vars = array();
foreach ( $data as $name => $content ) {
$vars[] = array('name' => $name, 'content' => $content);
}
$this->mergeVars[] = array(
'rcpt' => $recipient,
'vars' => $vars
);
... | Add several per-recipient merge variables,
which override global merge variables with the same name.
@param string $recipient
@param array $data
@return Message | entailment |
public function addMetadata($data)
{
if (is_array($data)) {
foreach ($data as $k => $v) {
$this->metadata[$k] = $v;
}
}
else {
$this->metadata[] = $data;
}
return $this;
} | Add global metadata.
Mandrill will store this metadata and make it available for retrieval.
In addition, you can select up to 10 metadata fields to index and
make searchable using the Mandrill search api.
@param string|array $data
@return Message | entailment |
public function addRecipientMetadata($recipient, $data)
{
foreach ($this->recipientMetadata as $idx => $rcptMetadata) {
if (isset($rcptMetadata['rcpt']) && $rcptMetadata['rcpt'] == $recipient) {
if (is_array($data)) {
foreach ($data as $k => $v) {
... | Add Per-recipient metadata that will override the global
values specified in the metadata parameter.
@param string $recipient
@param string|array $data
@return Message | entailment |
public function addAttachment($type, $name, $data)
{
$this->attachments[] = array(
'type' => $type,
'name' => $name,
'content' => $data
);
return $this;
} | Add supported attachments to add to the message
@param string $type - the MIME type of the attachment - allowed types are text/*, image/*, and application/pdf
@param string $name - the file name of the attachment
@param string $data - base64 encoded attachment data
@return Message | entailment |
public function addImage($type, $name, $data)
{
$this->images[] = array(
'type' => $type,
'name' => $name,
'content' => $data
);
return $this;
} | Add images embedded in the message
@param string $type - the MIME type of the image - must start with "image/"
@param string $name - the Content-ID of the embedded image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
@param string $data - base64 encoded image data
@return Message | entailment |
public function getIpVersion($ip)
{
if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return self::IPv6;
}
else if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return self::IPv4;
}
// invalid ip
retu... | Get IP verison
@param string $ip
@return integer|boolean Returns version or false on invalid address | entailment |
public function getIp6array($ip){
// expand - example: "2600:3c00::" -> "2600:3c00:0000:0000:0000:0000:0000:0000"
$hex = unpack("H*hex", inet_pton($ip));
$ipStr = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
$ipIntArray = array();
$ipStrArray = explo... | Ipv6 to array
@param string $ip
@return array | entailment |
public function account()
{
$this->logger->debug("account: start");
if (empty($this->access_key)) {
throw new \Exception("access key not set");
}
$accountUrl = sprintf("%s/%s", $this->api_url, "account");
$client = new \GuzzleHttp\Client();
$result = $c... | Check your subscription
@return array | entailment |
public function setUA($ua)
{
$this->logger->debug('setting: set useragent string to ' . $ua);
$this->ua = $ua;
return true;
} | Set the useragent string
@param string
@return bool | entailment |
public function setIP($ip)
{
$this->logger->debug('setting: set IP address to ' . $ip);
$this->ip = $ip;
return true;
} | Set the IP address
@param string
@return bool | entailment |
public function parse()
{
$this->setDBdat();
// validate
if (is_null($this->dbdat) === true) {
$this->logger->debug('db: data file not found, download the data manually from http://data.udger.com/');
return array('flag' => 3,
'errortext' => 'data file... | Parse the useragent string and/or IP
@return array | entailment |
protected function setDBdat()
{
if (is_null($this->dbdat)) {
$this->logger->debug(sprintf("db: open file: %s", $this->path));
$this->dbdat = new \SQLite3($this->path, SQLITE3_OPEN_READONLY);
}
} | Open DB file | entailment |
protected function setCache($key, $value) {
$this->logger->debug('LRUcache: set to key' . $key);
$this->cache[$key] = $value;
if (count($this->cache) > $this->cacheSize) {
array_shift($this->cache);
}
} | LRU cashe set | entailment |
protected function getCache($key) {
$this->logger->debug('LRUcache: get key' . $key);
if ( ! isset($this->cache[$key])) {
$this->logger->debug('LRUcache: key' . $key . ' Not Found' );
return null;
}
// Put the value gotten to last.
$tmpValue = $this->cache... | LRU cashe get | entailment |
public function setCacheEnable($set)
{
$this->cacheEnable = $set;
$log = $set ? 'true' : 'false';
$this->logger->debug('LRUcache: enable/disable: ' . $log );
return true;
} | Set LRU cache enable/disable
@param bool
@return bool | entailment |
public function setCacheSize($size)
{
$this->cacheSize = $size;
$this->logger->debug('LRUcache: set size: ' . $size );
return true;
} | Set LRU cache enable/disable
@param Int
@return bool | entailment |
public function setDataFile($path)
{
if (false === file_exists($path)) {
throw new \Exception(sprintf("%s does not exist", $path));
}
$this->path = $path;
return true;
} | Set path to sqlite file
@param string
@return bool | entailment |
public function setAccessKey($access_key)
{
$this->logger->debug('setting: set accesskey to ' . $access_key);
$this->access_key = $access_key;
return true;
} | Set the account access key
@param string
@return bool | entailment |
public function handleRequest(Request $request): Promise {
$method = $request->getMethod();
$path = \rawurldecode($request->getUri()->getPath());
$toMatch = "{$method}\0{$path}";
if (null === $match = $this->cache->get($toMatch)) {
$match = $this->routeDispatcher->dispatch(... | Route a request and dispatch it to the appropriate handler.
@param Request $request
@return Promise<\Amp\Http\Server\Response> | entailment |
private function makeNotFoundResponse(Request $request): Promise {
return $this->errorHandler->handleError(Status::NOT_FOUND, null, $request);
} | Create a response if no routes matched and no fallback has been set.
@param Request $request
@return Promise<\Amp\Http\Server\Response> | entailment |
private function makeMethodNotAllowedResponse(array $methods, Request $request): Promise {
return call(function () use ($methods, $request) {
/** @var \Amp\Http\Server\Response $response */
$response = yield $this->errorHandler->handleError(Status::METHOD_NOT_ALLOWED, null, $request);
... | Create a response if the requested method is not allowed for the matched path.
@param string[] $methods
@param Request $request
@return Promise<\Amp\Http\Server\Response> | entailment |
public function merge(self $router) {
if ($this->running) {
throw new \Error("Cannot merge routers after the server has started");
}
foreach ($router->routes as $route) {
$route[1] = \ltrim($router->prefix, "/") . $route[1];
$route[2] = Middleware\stack($rout... | Merge another router's routes into this router.
Doing so might improve performance for request dispatching.
@param self $router Router to merge. | entailment |
public function prefix(string $prefix) {
if ($this->running) {
throw new \Error("Cannot alter routes after the server has started");
}
$prefix = \trim($prefix, "/");
if ($prefix !== "") {
$this->prefix = "/" . $prefix . $this->prefix;
}
} | Prefix all currently defined routes with a given prefix.
If this method is called multiple times, the second prefix will be before the first prefix and so on.
@param string $prefix Path segment to prefix, leading and trailing slashes will be normalized. | entailment |
public function addRoute(string $method, string $uri, RequestHandler $requestHandler, Middleware ...$middlewares) {
if ($this->running) {
throw new \Error(
"Cannot add routes once the server has started"
);
}
if ($method === "") {
throw new \E... | Define an application route.
Matched URI route arguments are made available to request handlers as a request attribute
which may be accessed with:
$request->getAttribute(Router::class)
Route URIs ending in "/?" (without the quotes) allow a URI match with or without
the trailing slash. Temporary redirects are used to... | entailment |
public function stack(Middleware ...$middlewares) {
if ($this->running) {
throw new \Error("Cannot set middlewares after the server has started");
}
$this->middlewares = array_merge($middlewares, $this->middlewares);
} | Specifies a set of middlewares that is applied to every route, but will not be applied to the fallback request
handler.
All middlewares are called in the order they're passed, so the first middleware is the outer middleware.
On repeated calls, the later call will wrap the passed middlewares around the previous stack.... | entailment |
function analyze($filename) {
try {
if (!$this->openfile($filename)) {
return $this->info;
}
// Handle tags
foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
$option_tag = 'option_tag_'.$tag_name;
if ($this->$option_tag) {
... | public: analyze file | entailment |
function error($message) {
$this->CleanUp();
if (!isset($this->info['error'])) {
$this->info['error'] = array();
}
$this->info['error'][] = $message;
return $this->info;
} | private: error handling | entailment |
function GetFileFormatArray() {
static $format_info = array();
if (empty($format_info)) {
$format_info = array(
// Audio formats
// AC-3 - audio - Dolby AC-3 / Dolby Digital
'ac3' => array(
'pattern' => '^\x0B\x77',
'group' => 'audio',
'module' => 'ac3',
... | return array containing information about all supported formats | entailment |
function CharConvert(&$array, $encoding) {
// identical encoding - end here
if ($encoding == $this->encoding) {
return;
}
// loop thru array
foreach ($array as $key => $value) {
// go recursive
if (is_array($value)) {
$this->CharConvert($array[$key], $encoding);
}
// convert string
e... | converts array to $encoding charset from $this->encoding | entailment |
public function AnalyzeString(&$string) {
// Enter string mode
$this->data_string_flag = true;
$this->data_string = $string;
// Save info
$saved_avdataoffset = $this->getid3->info['avdataoffset'];
$saved_avdataend = $this->getid3->info['avdataend'];
$save... | Analyze from string instead | entailment |
function Analyze() {
$info = &$this->getid3->info;
$initialOffset = $info['avdataoffset'];
if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) {
if ($this->allow_bruteforce) {
$info['error'][] = 'Rescanning file in BruteForce mode';
$this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info)... | forces getID3() to scan the file byte-by-byte and log all the valid audio frame headers - extremely slow, unrecommended, but may provide data from otherwise-unusuable files | entailment |
public function command($args)
{
// Access items in container
$settings = $this->container->get('settings');
// Throw if no arguments provided
if (empty($args)) {
throw new RuntimeException("No arguments passed to command");
}
$firstArg = $args[0... | SampleTask command
@param array $args
@return void | entailment |
function Analyze() {
$info = &$this->getid3->info;
// http://flac.sourceforge.net/format.html
$this->fseek($info['avdataoffset'], SEEK_SET);
$StreamMarker = $this->fread(4);
$magic = 'fLaC';
if ($StreamMarker != $magic) {
$info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '... | true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('slot_mandrill');
$rootNode
->children()
->arrayNode('default')
->isRequired()
->children()
->scalarNode('sender'... | {@inheritDoc} | entailment |
static function hash_data($file, $offset, $end, $algorithm) {
static $tempdir = '';
if (!getid3_lib::intValueSupported($end)) {
return false;
}
switch ($algorithm) {
case 'md5':
$hash_function = 'md5_file';
$unix_call = 'md5sum';
$windows_call = 'md5sum.exe';
$hash_length = 32;
... | getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position | entailment |
static function iconv_fallback_iso88591_utf8($string, $bom=false) {
if (function_exists('utf8_encode')) {
return utf8_encode($string);
}
// utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
$newcharstring = '';
if ($bom) {
$newcharstrin... | ISO-8859-1 => UTF-8 | entailment |
static function iconv_fallback_utf16be_utf8($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
$newcharstring .= getid3_lib... | UTF-16BE => UTF-8 | entailment |
static function iconv_fallback_utf16_iso88591($string) {
$bom = substr($string, 0, 2);
if ($bom == "\xFE\xFF") {
return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
} elseif ($bom == "\xFF\xFE") {
return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
}
return $strin... | UTF-16 (BOM) => ISO-8859-1 | entailment |
static function iconv_fallback_utf16_utf8($string) {
$bom = substr($string, 0, 2);
if ($bom == "\xFE\xFF") {
return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
} elseif ($bom == "\xFF\xFE") {
return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
}
return $string;
} | UTF-16 (BOM) => UTF-8 | entailment |
private function parseEBML(&$info)
{
// http://www.matroska.org/technical/specs/index.html#EBMLBasics
$this->current_offset = $info['avdataoffset'];
while ($this->getEBMLelement($top_element, $info['avdataend'])) {
switch ($top_element['id']) {
case EBML_ID_EBML:
$info['fileformat'] = 'matroska'... | ///////////////////////////////////// | entailment |
public function send(Message $message, $templateName = '', $templateContent = array(), $async = false, $ipPool = null, $sendAt = null)
{
if ($this->disableDelivery) {
return false;
}
if (strlen($message->getFromEmail()) == 0) {
$message->setFromEmail($this->defaultSe... | Send a message
@param Message $message
@param string $templateName
@param array $templateContent
@param bool $async
@param string $ipPool
@param string $sendAt
@return array|bool | entailment |
public function command($args)
{
// Throw if no arguments provided and args less than 2
if (empty($args) || count($args) < 2) {
throw new RuntimeException("Invalid argument count");
}
$secondArg = $args[1];
// Output the second argument
return $secondArg... | SampleTask command
@param array $args
@return void | entailment |
static function OptimFROGencoderNameLookup($EncoderID) {
// version = (encoderID >> 4) + 4500
// system = encoderID & 0xF
$EncoderVersion = number_format(((($EncoderID & 0xF0) >> 4) + 4500) / 1000, 3);
$EncoderSystemID = ($EncoderID & 0x0F);
static $OptimFROGencoderSystemLookup = array(
0x00 => 'Windo... | } | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.