diff --git a/apps/maarch_entreprise/class/cmis/PropertyBoolean.class.php b/apps/maarch_entreprise/class/cmis/PropertyBoolean.class.php deleted file mode 100755 index 9f9a964d50402627df71077f9f04607d9abe1f89..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyBoolean.class.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -class PropertyBoolean extends propertyCMIS{ - - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyDateTime.class.php b/apps/maarch_entreprise/class/cmis/PropertyDateTime.class.php deleted file mode 100755 index bf5e1ca28261eb152d2be4cf740b7420c66bd422..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyDateTime.class.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -class PropertyDateTime extends propertyCMIS{ - - private $resolution; // string enum: Year, Date, Time - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyDecimal.class.php b/apps/maarch_entreprise/class/cmis/PropertyDecimal.class.php deleted file mode 100755 index 01c1775576724e77071c53df3f1778cc9c552281..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyDecimal.class.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -class PropertyDecimal extends propertyCMIS{ - - private $precision; //integer enum: 32, 64 - private $minValue; //decimal - private $maxValue; //decimal - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyHtml.class.php b/apps/maarch_entreprise/class/cmis/PropertyHtml.class.php deleted file mode 100755 index ff64da27045e2f310ec3e4c81051a7e3d99fd8b4..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyHtml.class.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -class PropertyHtml extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyId.class.php b/apps/maarch_entreprise/class/cmis/PropertyId.class.php deleted file mode 100755 index 1cf3d8dea7689c91b0d5d332df78e0a9ea7ec01b..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyId.class.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -class PropertyId extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyInteger.class.php b/apps/maarch_entreprise/class/cmis/PropertyInteger.class.php deleted file mode 100755 index 746e6d8e9efb8e65ddad42173885e166201373d3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyInteger.class.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -class PropertyInteger extends propertyCMIS{ - - - private $maxValue; //Integer - private $minValue; //Integer - - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyString.class.php b/apps/maarch_entreprise/class/cmis/PropertyString.class.php deleted file mode 100755 index be7e34133e3b920c7f4c10688dacd33c399355ac..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyString.class.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -class PropertyString extends propertyCMIS{ - - private $maxLength; - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - -} diff --git a/apps/maarch_entreprise/class/cmis/PropertyUri.class.php b/apps/maarch_entreprise/class/cmis/PropertyUri.class.php deleted file mode 100755 index 022209e029da9f91d481e99d65823c559745e5d1..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/PropertyUri.class.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -class PropertyUri extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - -} diff --git a/apps/maarch_entreprise/class/cmis/Rendition.class.php b/apps/maarch_entreprise/class/cmis/Rendition.class.php deleted file mode 100755 index 2cab691a8ea17258b2c4b322921dca5a2a139347..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/Rendition.class.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -class Rendition{ - /* - * ID - * Identifies the rendition stream - */ - private $streamId; - - /* - * String - * The MIME type of the rendition stream. - */ - private $mimeType; - - /* - * Integer (optional) - * The length of the rendition stream in bytes. - */ - private $length; - - /* - * String (optional) - * Human readable information about the rendition. - */ - private $title; - - /* - * String - * A categorization String associated with the rendition. - */ - private $kind; - - - /* - * Integer (optional) - * Typically used for 'image' renditions (expressed as pixels). SHOULD be present if kind = cmis:thumbnail - */ - private $height; - - - /* - * Integer (optional) - * Typically used for 'image' renditions (expressed as pixels). SHOULD be present if kind = cmis:thumbnail - */ - private $width; - - - /* - *ID (optional) - */ - private $renditionDocumentId; - - - - - - -} - - diff --git a/apps/maarch_entreprise/class/cmis/cmis_class_exception.php b/apps/maarch_entreprise/class/cmis/cmis_class_exception.php deleted file mode 100755 index ea87601cf106d0cd35064df42ae3e964221cb081..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_class_exception.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - - -class CMISException extends Exception{ - - private $cause; - - public function __construct($message, $code, $cause){ - parent::__construct($message, $code); - $this->cause = $cause; - } - - public function toXml(){ - - $doc = new DOMDocument('1.0', 'utf-8'); - $doc->formatOutput = true; - - $root = $doc->createElement('Exception'); - $doc->appendChild($root); - - $eCode = $doc->createElement('code',$this->getCode()); - $eCause = $doc->createElement('cause',$this->getCause()); - $eMessage = $doc->createElement('message',$this->getMessage()); - - $root->appendChild($eCode); - $root->appendChild($eCause); - $root->appendChild($eMessage); - - return $doc->saveXML(); - } - - public function getCause(){ - return $this->getCause(); - } - -} - diff --git a/apps/maarch_entreprise/class/cmis/cmis_class_object.php b/apps/maarch_entreprise/class/cmis/cmis_class_object.php deleted file mode 100755 index dc39926bd26c58f1ab383d1b2287a19859470638..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_class_object.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -abstract class objectCMIS -{ - - protected $objectId ; - protected $createdBy ; - protected $creationDate ; - protected $lastModifiedBy ; - protected $lastModificationDate ; - protected $changeToken ; - protected $localName; - protected $localNamespace; - protected $queryName; - protected $displayName; - protected $baseId; - protected $parentId; - protected $description ; - protected $creatable ; - protected $fileable ; - protected $queryable ; - protected $controllablePolicy; - protected $controllableACL; - protected $fulltextIndexed; - protected $includedInSupertypeQuery; - - protected $accessControlList; - protected $properties; - - public static function getFeed($objects, $title=null, $parentObject=null){ - $doc = new DOMDocument('1.0', 'utf-8'); - $doc->formatOutput = true; - - //TODO add xmlns - $root = $doc->createElementNS('http://www.w3.org/2005/Atom', 'feed'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:cmisra', 'http://docs.oasis-open.org/ns/cmis/restatom/200908/'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:cmis', 'http://docs.oasis-open.org/ns/cmis/core/200909/'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:maarch', 'http://www.maarch.org'); - $doc->appendChild($root); - - $eAuthor = $doc->createElement('author'); - $root->appendChild($eAuthor); - $name = $_SESSION['user']['FirstName'].' '.$_SESSION['user']['LastName']; //'name'; - $eName = $doc->createElement('name', $name); - $eAuthor->appendChild($eName); - - - if(isset($title) && !empty($title)){ - $eTitle = $doc->createElement('title', $title); - $root->appendChild($eTitle); - } - - // cmis:properties - $eProperties = $doc->createElement('cmis:properties'); - $root->appendChild($eProperties); - - if($parentObject != null){ - // cmis properties of parent - foreach($parentObject->propertiesInXml as $property){ - $propertyValue = $property->getValue(); - if($propertyValue!=null && $property->valueIsSet()){ - $eProperty = $doc->createElement('cmis:property'.$property->getPropertyType()); - $eProperties->appendChild($eProperty); - $eProperty->setAttribute('localName', $property->getLocalName()); - $eProperty->setAttribute('propertyDefinitionId', $property->getId()); - - if(strcmp($property->getCardinality(), 'Single')==0 ){ - $eValue = $doc->createElement('cmis:value', $propertyValue); //echo $propertyValue.'<br />'; - $eProperty->appendChild($eValue); - } - else{ - //au moins une valeur non nulle - foreach($propertyValue as $value){ - if($value != null){ - $eValue = $doc->createElement('cmis:value', $value); - $eProperty->appendChild($eValue); - } - } - } - } - } - } - - $eNumItems = $doc->createElement('cmisra:numItems', count($objects)); - $root->appendChild($eNumItems); - - foreach($objects as $object){ - $object->getAtomXmlEntry($doc, $root); - } - - return $doc; - } - -} diff --git a/apps/maarch_entreprise/class/cmis/cmis_class_property.php b/apps/maarch_entreprise/class/cmis/cmis_class_property.php deleted file mode 100755 index afb6796b9ffcec5789d251f292d267c19d40b46f..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_class_property.php +++ /dev/null @@ -1,450 +0,0 @@ -<?php - -abstract class propertyCMIS{ - - //protected $propertyName; - protected $id; - protected $localName; - protected $localNamespace; - protected $queryName; - protected $displayName; - protected $description; - protected $propertyType; - protected $cardinality; - protected $value; - protected $updatability; - protected $inherited; - protected $required; - protected $queryable; - protected $orderable; - protected $choices; - protected $openChoice; - protected $defaultValue; - - public function __construct(){ - $this->value = 'notset'; - $this->openChoice = true; - } - - public function getQueryName(){ - return $this->queryName; - } - - public function isQueryable(){ - return $this->queryable; - } - - public function isOrderable(){ - return $this->orderable; - } - - public function isRequired(){ - return $this->required; - } - - public function setId($id) { - $this->id = $id; - $this->localName = 'rm_'.$id; - } - - public function valueIsSet(){ - return ($this->value!=null && strcmp( $this->value, 'notset') != 0); - } - - public function setNames($localName, $localNamespace, $queryName, $displayName){ - $this->localName = $localName; - $this->localNamespace = $localNamespace; - $this->queryName = $queryName; - $this->displayName = $displayName; - } - - /*public function setNames($name){ - $this->localName = $name; - $this->queryName = $name; - $this->displayName = $name; - }*/ - - public function setLocalName($localName) { - $this->localName = $localName; - } - public function setLocalNamespace($localNamespace) { - $this->localNamespace = $localNamespace; - } - public function setQueryName($queryName) { - $this->queryName = $queryName; - } - public function setDisplayName($displayName) { - $this->displayName = $displayName; - } - public function setDescription($description) { - $this->description = $description; - } - public function setPropertyType($propertyType) { - $this->propertyType = $propertyType; - } - public function setCardinality($cardinality) { - $this->cardinality = $cardinality; - } - public function setUpdatability($updatability) { - $this->updatability = $updatability; - } - public function setInherited($inherited) { - $this->inherited = $inherited; - } - public function setRequired($required) { - $this->required = $required; - } - public function setQueryable($queryable) { - $this->queryable = $queryable; - } - public function setOrderable($orderable) { - $this->orderable = $orderable; - } - public function setChoices($choices) { - $this->choices = $choices; - } - public function setOpenChoice($openChoice) { - $this->openChoice = $openChoice; - } - public function setDefaultValue($defaultValue) { - $this->defaultValue = $defaultValue; - } - - public function setValue($value) { - $this->value = $value; - } - - public function getCardinality(){ - return $this->cardinality; - } - - public function getLocalName(){ - return $this->localName; - } - - public function getId(){ - return $this->id; - } - - public function getValue(){ - return $this->value ; - } - - public function getPropertyType() { - return $this->propertyType; - } - - protected function valueSuitable($value){ - - $isSuitable = false; - - if(is_string($value) && strcmp('notset',$value)==0) { - return true; - } - - - if($this->openChoice === true || strcmp('NotApplicable',$this->openChoice)==0){ - $isSuitable = true; - //OpenChoice is true or NotApplicable: ; - } - else if($this->openChoice === false){ - if((strcmp('Single',$this->cardinality)==0) && in_array($value, $this->choices, true)){ - $isSuitable = true; - //Cardinality = Single and value in choices; - } - else if((strcmp('Multi',$this->cardinality)==0)){ - $valueOk = true; - $i=0; - while($valueOk && $item=$value[$i++]){ - $valueOk = in_array($item, $this->choices, true); - } - $isSuitable = $valueOk; - //IF isSuitable : Cardinality = Multi and value in choices - //ELSE : Cardinality = Multi but value not in choices - } - } - - return $isSuitable; - } - - -} - - - - -class PropertyUri extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function setValue($value){ - if(is_string($value)){ - $value = trim($value); - if( $this->valueSuitable($value) === true){ - $this->value = $value; - } - } - } -} - - - - -class PropertyBoolean extends propertyCMIS{ - - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function setValue($value){ - if(is_string($value)){ - if(strcmp(trim($value), 'true')==0){ - $value = true; - } - else if(strcmp(trim($value), 'false')==0){ - $value = false; - } - } - if(is_bool($value) && $this->valueSuitable($value) === true){ - $this->value = $value; - } - } -} - - -class PropertyDateTime extends propertyCMIS{ - - private $resolution; // string enum: Year, Date, Time - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function setValue($value){ - if(is_string($value)){ - $value = trim($value); - if($this->valueSuitable($value) === true){ - //if regex ok - $this->value = $value; - } - } - } -} - - - -class PropertyDecimal extends propertyCMIS{ - - private $precision; //integer enum: 32, 64 - private $minValue; //decimal - private $maxValue; //decimal - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function _setValue($value){ - if(is_string($value)){ - $value = floatval($value); - } - if (is_float($value) && $this->valueSuitable($value) === true){ - $this->value = $value; - } - } -} - - - - -class PropertyHtml extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function _setValue($value){ - if(is_string($value)){ - $value = trim($value); - if($this->valueSuitable($value) === true){ - $this->value = $value; - } - } - } - -} - - - - - -class PropertyId extends propertyCMIS{ - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function setValue($value){ - if(is_string($value)){ - $value = trim($value); - } - if($this->valueSuitable($value) === true){ - $this->value = $value; - } - } - -} - - - -class PropertyInteger extends propertyCMIS{ - - - private $maxValue; //Integer - private $minValue; //Integer - - - public function __construct( $required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function _setValue($value){ - if(is_string($value)){ - $value = intval($value); - } - if (is_int($value) && $this->valueSuitable($value) === true){ - $this->value = $value; - } - } -} - - -class PropertyString extends propertyCMIS{ - - private $maxLength; - - - public function __construct($required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable){ - - $this->value = 'notset'; - $this->required = $required ; - $this->inherited = $inherited ; - $this->propertyType = $propertyType; - $this->cardinality = $cardinality ; - $this->updatability = $updatability ; - $this->choices = $choices ; - $this->openChoice = $openChoice ; - $this->queryable = $queryable ; - $this->orderable = $orderable; - - } - - public function setValue($value){ - - if(is_string($value)){ - $value = trim($value); - if($this->valueSuitable($value) === true){ - $this->value = $value; - } - } - } - -} - - - diff --git a/apps/maarch_entreprise/class/cmis/cmis_class_query.php b/apps/maarch_entreprise/class/cmis/cmis_class_query.php deleted file mode 100755 index 68b798a228eee38fa5361122d307b75f6622f683..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_class_query.php +++ /dev/null @@ -1,342 +0,0 @@ -<?php - -class Query{ - - //string select + from + where - var $statement; - //boolean false - var $searchAllVersions; - //boolean false - var $includeAllowableActions; - //string : "none", "source", "target", "both" - var $includeRelationships; - //string - var $renditionFilter; - //integer : limit - var $maxItems; - //integer : offset - var $skipCount; - - - // - var $sqlStatement; - - var $keyWords = array ( - ' * ', - 'select ', - ' from ', - ' where ', - ' order ', - ' by ', - ' desc ', - ' asc ', - ' and ', - ' or ', - ' as ', - ' score ', - ' join ', - ' on ', - ' outer ', - ' inner ', - ' left ', - ' in ', - ' not ', - ' like ', - ' any ', - ' is ', - ' null ', - ' contains ', - ' in_folder ', - ' in_tree ', - ); - - var $notSupported = array( - " as ", - " join " , " outer ", " inner ", " on ", " left ", - " in_tree ", " in_tree(", - " contains ", " contains(", - " score ", " score(", - " in_folder ", " in_folder(" // TODO - ); - - var $maarchColumn = array( - //res properties - 'cmis:objectId' => 'res_id', - 'maarch:type' => 'type_label', - 'maarch:entity ' => 'entity_label', - 'maarch:dest_user' => 'dest_user', - 'maarch:doc_date' => 'doc_date', - 'maarch:process_limit_date' => 'process_limit_date', - 'cmis:creationDate' => 'doc_date' - ); - - var $maarchTable = array( - //res object type - "cmis:document" => "res_view_letterbox" - ); - - - - public function __construct(){ - $this->statement = ""; - $this->searchAllVersions = false; - $this->includeAllowableActions = false; - $this->includeRelationships = "none"; - $this->renditionFilter = ""; - $this->skipCount = 0; - } - - public function getStatement(){ - return $this->statement; - } - - public function setStatement($statement){ - $this->statement = trim($statement); - } - - public function setSearchAllVersions($searchAllVersions){ - //not supported - $this->searchAllVersions = $searchAllVersions; - } - - public function setIncludeAllowableActions($includeAllowableActions){ - //not supported - $this->includeAllowableActions = $includeAllowableActions; - } - - public function setIncludeRelationships($includeRelationships){ - // should be "none", "source", "target" or "both" - //not supported - $this->includeRelationships = $includeRelationships; - } - - public function setRenditionFilter($renditionFilter){ - //not supported - $this->renditionFilter = $renditionFilter ; - } - - public function setMaxItems($maxItems){ - //not supported - $this->maxItems = $maxItems ; - } - - public function setSkipCount($skipCount){ - //not supported - $this->skipCount = $skipCount; - } - - public function to_String(){ - return '<p><br />Query :' - .'<br /> Statement : '. $this->statement - .'<br /> SearchAllVersions : '. (($this->searchAllVersions)? 'true':'false') - .'<br /> IncludeAllowableActions : '. (($this->includeAllowableActions)? 'true':'false') - .'<br /> IncludeRelationships : '. $this->includeRelationships - .'<br /> RenditionFilter : '. $this->renditionFilter - .'<br /> MaxItems : '. $this->maxItems - .'<br /> SkipCount : '. $this->skipCount - .'<br /></p>'; - } - - - //TODO exceptions - public function executeQuery(){ - - //format : keywords to lower case - $tmpStatement = str_ireplace($this->keyWords, $this->keyWords, $this->statement); - $tmpStatement = str_replace('(', ' ( ', $tmpStatement); - $tmpStatement = str_replace(')', ' ) ', $tmpStatement); - - - //pas de requete imbriquee - if(substr_count(' '.$tmpStatement, ' select ') != 1 - || substr_count($tmpStatement , ' from ') != 1){ - //TODO throw notSupported - return null; - } - - - //not supported : contains(...), score(...), in_tree(...), in_folder(...) - $supportedTmpStatement = true; - foreach ($this->notSupported as $notSupportedClause){ - $supportedTmpStatement = ($supportedTmpStatement && (stripos($tmpStatement, $notSupportedClause) === false)); - if(!$supportedTmpStatement){ - //TODO throw notSupported - return null; - } - } - - - // - $arrayStatement = array(); - $patternSql = '#^select\s+(.+)\sfrom\s+(.+)(?:where\s+(.+))?(?:\sorder\s+by\s+(.+))?$#isU'; - if(($preg = preg_match($patternSql, $tmpStatement, $arrayStatement)) !== 1){ - //TODO throw notSupported or runtime - return null; - } - - - $sqlStatement = array( - 'simpletable' => array( - 'select' => trim($arrayStatement[1]), - 'from' => trim($arrayStatement[2]), - 'where' => trim($arrayStatement[3]), - ), - 'orderby' => trim($arrayStatement[4]) - ); - - - //from : query only on cmis:document, only document objects are returned - //object must be queryable - if(strcmp('cmis:document', $sqlStatement['simpletable']['from']) != 0){ - //TODO throw constraint ? - return null; - } - - - //list of selected properties - $selectProperties = explode(',', $sqlStatement['simpletable']['select']); - $res = new resCMIS(); - $res->DocumentCmis(); - foreach($selectProperties as $property){ - $objProperty = $res->getPropertyByQueryName($property); - if($objProperty == null){ - //TODO throw constraint ? - return null; - } - } - - - //TODO : where (extract properties) - //all column names must be valid queryName for queryable properties - //object type listed in from listed - $whereProperties = array(); - $wherePattern = '#(\w+\:\w+)#is'; - if(preg_match_all($wherePattern, $sqlStatement['simpletable']['where'], $whereProperties)){ - foreach($whereProperties[1] as $property){ - $objProperty = $res->getPropertyByQueryName($property); - if($objProperty == null || !$objProperty->isQueryable()){ - //TODO throw constraint ? - return null; - } - } - } - - - //list of ordered properties - $orderBy = str_ireplace(array('asc', 'desc'), array('','') , $sqlStatement['orderby']); - $orderByProperties = explode(',', $orderBy); - foreach($orderByProperties as $property){ - $objProperty = $res->getPropertyByQueryName($property); - if($objProperty == null || !$objProperty->isOrderable()){ - //TODO throw constraint ? - return null; - } - } - - - // - $tmpStatement = str_replace(array_keys($this->maarchColumn), $this->maarchColumn, $tmpStatement); - $tmpStatement = str_replace(array_keys($this->maarchTable ), $this->maarchTable, $tmpStatement); - $this->sqlStatement = $tmpStatement; - - - require_once('core/class/class_db_pdo.php'); - $db = new Database(); - - $result = $db->query($this->sqlStatement); - - $selectProperties = str_replace(array_keys($this->maarchColumn), $this->maarchColumn, $selectProperties); - $resArray = array(); - while ($recordset = $result->fetchObject()) { - $row = array(); - foreach($selectProperties as $selectedProperty){ - $selectedProperty = trim($selectedProperty); - $row[$selectedProperty] = $recordset->{$selectedProperty}; - } - $documentCmis = new resCMIS(); - $documentCmis->DocumentCmis(); - $documentCmis->setRes($row); - array_push($resArray, $documentCmis); - } - - return $resArray; - - } - - - - - - - - //TODO fct a supprimer : utiliser les regex - private function parseStatement(){ - $select = " select "; - $from = " from "; - $where = " where "; - $orderby = " order by "; - - //statement ::= simpletable [orderby] - //simpletable ::= SELECT <selectlist> <fromclause> [<whereclause>] - - - $sqlStatement = array( - "simpletable" => array( - "select" => array(), - "from" => array(),//should be "cmis:document" - "where" => array() - ), - "orderby" => array() - ); - - $tmpStatement = $this->statement; - - //select clause and from clause - if(stripos($tmpStatement , 'select ')===0 && substr_count($tmpStatement , $select)==0 && substr_count($tmpStatement , $from)==1){ - - //nb order by in tmpStatement - $nbOrderBy = substr_count($tmpStatement , $orderby); - - if( $nbOrderBy == 1){ - //one order by in statement - $explodedStatement = explode($orderby, $tmpStatement); - if(count($explodedStatement) == 2){ - $sqlStatement[$orderby][0] = $explodedStatement[1]; - $tmpStatement = $explodedStatement[0]; - $nbOrderBy--; - } - } - - if($nbOrderBy == 0){ - //where clause - $explodedStatement = explode($where, $tmpStatement, 2); - if(count($explodedStatement) == 2){ - $sqlStatement["simpletable"][$where][0] = $explodedStatement[1]; - $tmpStatement = $explodedStatement[0]; - } - $explodedStatement = explode($from, $tmpStatement); - $sqlStatement["simpletable"][$from][0] = $explodedStatement[1]; - $tmpStatement = $explodedStatement[0]; - $explodedStatement = explode($select, $tmpStatement,1); - $sqlStatement["simpletable"][$select][0] = $explodedStatement[0]; - - $this->sqlStatement = $sqlStatement; - } - else{ - //error - echo '<br /><strong>ERROR</strong><br />'; - - $this->sqlStatement = null; - } - } - else{ - //error - echo '<br /><strong>ERROR</strong><br />'; - - $this->sqlStatement = null; - } - - return $this->sqlStatement; - } - -} diff --git a/apps/maarch_entreprise/class/cmis/cmis_enum.php b/apps/maarch_entreprise/class/cmis/cmis_enum.php deleted file mode 100755 index ec55ef20a0da1c354838c48ceae7a03686c724db..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_enum.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php -class DecimalPrecision{ - public static $_32 = 32 ; - public static $_64 = 64 ; -} - - -class ContentStreamAllowed{ - public static $NotAllowed = "notallowed" ; - public static $Allowed = "allowed" ; - public static $Required = "required" ; -} - - -class Cardinality{ - public static $Single = "single" ; - public static $Multi = "multi" ; -} - - -class Updatability{ - public static $ReadOnly = "readonly" ; - public static $ReadWrite = "readwrite" ; - public static $WhenCheckedOut = "whencheckedout" ; - public static $OnCreate = "oncreate" ; -} - - -class DateTimeResolution{ - public static $Year = "year" ; - public static $Date = "date" ; - public static $Time = "time" ; -} - - -class PropertyType{ - public static $Boolean = "boolean" ; - public static $Id = "id" ; - public static $Integer = "integer" ; - public static $DateTime = "datetime" ; - public static $Decimal = "decimal" ; - public static $Html = "html" ; - public static $String = "string" ; - public static $Uri = "uri" ; -} - - -class BaseObjectTypeIds{ - public static $CmisDocument = "cmis:document" ; - public static $CmisFolder = "cmis:folder" ; - public static $CmisRelationship = "cmis:relationship" ; - public static $CmisPolicy = "cmis:policy" ; -} - - -class CapabilityQuery{ - public static $None = "none" ; - public static $MetadataOnly = "metadataonly" ; - public static $FulltextOnly = "fulltextonly" ; - public static $BothSeparate = "bothseparate" ; - public static $BothCombined = "bothcombined" ; -} - - -class CapabilityJoin{ - public static $None = "none" ; - public static $InnerOnly = "inneronly" ; - public static $InnerAndOut = "innerandouter" ; -} - - -class CapabilityContentStreamUpdates{ - public static $Anytime = "anytime" ; - public static $PwcOnly = "pwconly" ; - public static $None = "none" ; -} - - -class VersioningState{ - public static $None = "none" ; - public static $CheckedOut = "checkedout" ; - public static $Minor = "minor" ; - public static $Major = "major" ; -} - - -class UnfileObject{ - public static $Unfile = "unfile" ; - public static $DeleteSingleFiled = "deletesinglefiled" ; - public static $Delete = "delete" ; -} - - -class RelationshipDirection{ - public static $Source = "source" ; - public static $Target = "target" ; - public static $Either = "either" ; -} - - -class IncludeRelationships{ - public static $None = "none" ; - public static $Source = "source" ; - public static $Target = "target" ; - public static $Both = "both" ; -} - - -class PropertiesBase{ - public static $CmisName = "cmis:name" ; - public static $CmisObjectId = "cmis:objectId" ; - public static $CmisObjectTypeId = "cmis:objectTypeId" ; - public static $CmisBaseTypeId = "cmis:baseTypeId" ; - public static $CmisCreatedBy = "cmis:createdBy" ; - public static $CmisCreationDate = "cmis:creationDate" ; - public static $CmisLastModifiedBy = "cmis:lastModifiedBy" ; - public static $CmisLastModificationDate = "cmis:lastModificationDate" ; - public static $CmisChangeToken = "cmis:changeToken"; -} - - -class PropertiesDocument{ - public static $CmisIsImmutable = "cmis:isImmutable" ; - public static $CmisIsLatestVersion = "cmis:isLatestVersion" ; - public static $CmisIsMajorVersion = "cmis:isMajorVersion" ; - public static $CmisIsLatestMajorVersion = "cmis:isLatestMajorVersion" ; - public static $CmisVersionLabel = "cmis:versionLabel" ; - public static $CmisVersionSeriesId = "cmis:versionSeriesId" ; - public static $CmisIsVersionSeriesCheckOut = "cmis:isVersionSeriesCheckedOut" ; - public static $CmisVersionSeriesCheckedOutBy = "cmis:versionSeriesCheckedOutBy" ; - public static $CmisVersionSeriesCheckedOutId = "cmis:versionSeriesCheckedOutId" ; - public static $CmisCheckinComment = "cmis:checkinComment" ; - public static $CmisContentStreamLength = "cmis:contentStreamLength" ; - public static $CmisContentStreamMimeType = "cmis:contentStreamMimeType" ; - public static $CmisContentStreamFileName = "cmis:contentStreamFileName" ; - public static $CmisContentStreamId = "cmis:contentStreamId"; -} - - -class PropertiesFolder{ - public static $CmisParentId = "cmis:parentId" ; - public static $CmisAllowedChildObjectTypeIds = "cmis:allowedChildObjectTypeIds" ; - public static $CmisPath = "cmis:path"; -} - - -class PropertiesRelationship{ - public static $CmisSourceId = "cmis:sourceId" ; - public static $CmisTargetId = "cmis:targetId" ; -} - - -class PropertiesPolicy{ - public static $CmisPolicyText = "cmis:policyText"; -} - - -class TypeOfChanges{ - public static $Created= "created" ; - public static $Updated = "updated" ; - public static $Deleted = "deleted" ; - public static $Security = "security" ; -} - - -class CapabilityChanges{ - public static $None = "none" ; - public static $ObjectIdsOnly = "objectidsonly" ; - public static $Properties = "properties" ; - public static $All = "all" ; -} - - -class ACLPropagation{ - public static $RepositoryDetermined = "repositorydetermined" ; - public static $ObjectOnly = "objectonly" ; - public static $Propagate = "propagate" ; -} - -class CapabilityACL{ - public static $None = "none" ; - public static $Discover = "discover" ; - public static $Manage = "manage" ; -} - -class BasicPermissions{ - public static $CmisRead = "cmis:read" ; - public static $CmisWrite = "cmis:write" ; - public static $CmisAll = "cmis:all" ; -} - - - - -class AllowableActionsKey{ - public static $CanGetDescendentsFolder = "canGetDescendents.Folder" ; - public static $CanGetChildrenFolder = "canGetChildren.Folder" ; - public static $CanGetParentsFolder = "canGetParents.Folder" ; - public static $CanGetFolderParentObject = "canGetFolderParent.Object" ; - public static $CanCreateDocumentFolder = "canCreateDocument.Folder" ; - public static $CanCreateFolderFolder = "canCreateFolder.Folder" ; - public static $CanCreateRelationshipSource = "canCreateRelationship.Source" ; - public static $CanCreateRelationshipTarget = "canCreateRelationship.Target" ; - public static $CanGetPropertiesObject = "canGetProperties.Object" ; - public static $CanViewContentObject = "canViewContent.Object" ; - public static $CanUpdatePropertiObject = "canUpdateProperties.Object" ; - public static $CanMoveObject = "canMove.Object" ; - public static $CanMoveTarget = "canMove.Target" ; - public static $CanMoveSource = "canMove.Source" ; - public static $CanDeleteObject = "canDelete.Object" ; - public static $CanDeleteTreeFolder = "canDeleteTree.Folder" ; - public static $CanSetContentdocument = "canSetContent.Document" ; - public static $CanDeleteContentDocument = "canDeleteContent.Document" ; - public static $CanAddToFolderObject = "canAddToFolder.Object" ; - public static $CanAddToFolderFolder = "canAddToFolder.Folder" ; - public static $CanRemoveFromFolderObject = "canRemoveFromFolder.Object" ; - public static $CanRemoveFromFolderFolder = "canRemoveFromFolder.Folder" ; - public static $CanCheckoutDocument = "canCheckout.Document" ; - public static $CanCancelCheckoutDocument = "canCancelCheckout.Document" ; - public static $CanCheckinDocument = "canCheckin.Document" ; - public static $CanGetAllVersionsVersionSeries = "canGetAllVersions.VersionSeries" ; - public static $CanGetObjectRelationshipsObject = "canGetObjectRelationships.Object" ; - public static $CanAddPolicyObject = "canAddPolicy.Object" ; - public static $CanAddPolicyPolicy = "canAddPolicy.Policy" ; - public static $CanRemovePolicyObject = "canRemovePolicy.Object" ; - public static $CanRemovePolicyPolicy = "canRemovePolicy.Policy" ; - public static $CanGetAppliedPoliciesObject = "canGetAppliedPolicies.Object" ; - public static $CanGetACLObject = "canGetACL.Object" ; - public static $CanApplyACLObject = "canApplyACL.Object" ; -} - - -class SupportedPermissions{ - public static $Basic = "basic" ; - public static $Repository = "repository" ; - public static $Both = "both" ; -} - -class CapabilityRendition{ - public static $None = "none" ; - public static $Read = "read" ; -} - - -class RenditionKind{ - public static $CmisThumbnail = "cmis:thumbnail" ; -} - - - - - - - - - diff --git a/apps/maarch_entreprise/class/cmis/cmis_res_controller.php b/apps/maarch_entreprise/class/cmis/cmis_res_controller.php deleted file mode 100755 index 120608a7abbf2283ea47c1e607d9a3fe5240ace1..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/cmis_res_controller.php +++ /dev/null @@ -1,685 +0,0 @@ -<?php -require_once 'xmlParser.class.php'; -require_once 'cmis_class_object.php'; -require_once 'cmis_class_property.php'; -//require_once 'PropertyBoolean.class.php'; -//require_once 'PropertyDateTime.class.php'; -//require_once 'PropertyInteger.class.php'; -//require_once 'PropertyDecimal.class.php'; -//require_once 'PropertyHtml.class.php'; -//require_once 'PropertyId.class.php'; -//require_once 'PropertyString.class.php'; -//require_once 'PropertyUri.class.php'; - -class resCMIS extends objectCMIS -{ - var $strReturn = 'THE RESULT IS A RES WITH '; - - private $versionable; - private $contentStreamAllowed ; - - //private $renditions; - - //properties - private $name; - private $isImmutable; - /* // version : not supported - private $isLatestVersion; - private $isMajorVersion; - private $isLatestMajorVersion; - private $versionLabel; - private $versionSeriesId; - private $versionSeriesCheckedOut; - private $versionSeriesCheckedOutBy; - private $versionSeriesCheckedOutId; - private $checkinComment; - */ - private $contentStreamLength; - private $contentStreamBase64; - private $contentStreamMimeType; - private $contentStreamFileName; - private $contentStreamId; - - //res_id = objectId - private $type; - private $contact; - private $entity_label; - private $dest_user; - //doc_date = creationDate - private $process_limit_date; - private $url; - - private $propertiesInXml ; - - public function entryMethod($atomFileContent, $requestedResourceId, $requestedCollection) - { - $view = ''; - if (isset($requestedCollection) && !empty($requestedCollection)) { - $sec = new security(); - $view = $sec->retrieve_view_from_coll_id($requestedCollection); - } - if (empty($view)) { - echo "<br />ERREUR : the collection not exists.<br />"; - } - if (isset($atomFileContent) && !isset($requestedResourceId)) { - //new xml parser - $xmlParser = new xmlParser(); - //build a query from xml file - $query = $xmlParser->parseQuery($atomFileContent); - //get the list of documents : execute query - if ($documents = $query->executeQuery()){ - $title = 'Result for '.$query->getStatement(); - $resAtom = resCMIS::getFeed($documents, trim($title)); - echo $resAtom->saveXML(); - } else{ - //TODO throw constraintException or runtime - echo "<br />ERREUR : constraintException or runtime.<br />"; - } - } elseif (!isset($atomFileContent) && isset($requestedResourceId)){ - - //retrieve the document whose id is $requestedResourceId - if ($res = $this->getDocument(intval($requestedResourceId), $view)){ - $resAtom = $res->toAtomXml(); - echo $resAtom->saveXML(); - } else { - //TODO throw objectNotFound - echo "<br />ERREUR : objectNotFound.<br />"; - } - } else { - //TODO throw notSupported or invalidArgument - echo "<br />ERREUR : notSupported.<br />"; - } - //return $requestedResourceId . ' ' . $atomFileContent; - } - - - - public function DocumentCmis() - { - $this->id = "cmis:document"; - $this->queryName = "cmis:document"; - $this->baseId = "cmis:document"; - $this->versionable = false; - $this->fileable = true; - $this->localName = "cmis:document"; - $this->displayName = "cmis:document"; - $this->creatable = false; - - //properties - $this->name = new PropertyString($required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable); - $this->name->setId('cmis:name'); - $this->name->setInherited(false); - $this->name->setPropertyType('String'); - $this->name->setCardinality('Single'); - - $this->parentId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - - $this->objectId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->objectId->setId("cmis:objectId"); - $this->objectId->setQueryName("cmis:objectId"); - $this->objectId->setDisplayName("cmis:objectId"); - - $this->baseTypeId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->baseTypeId->setId("cmis:baseTypeId"); - $this->baseTypeId->setDisplayName("cmis:baseTypeId"); - - $this->objectTypeId = new PropertyId(true, false, 'Id', 'Single', - 'oncreate', 'NotApplicable', 'NotApplicable', false, false); - $this->objectTypeId->setId('objectTypeId'); - - $this->createdBy = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->createdBy->setId('createdBy'); - $this->createdBy->setQueryName("cmis:createdBy"); - - $this->creationDate = new PropertyDateTime(false, false, 'DateTime', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->creationDate->setId('creationDate'); - $this->creationDate->setQueryName("cmis:creationDate"); - - $this->lastModifiedBy = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->lastModifiedBy->setId('lastModifiedBy'); - $this->lastModifiedBy->setQueryName("cmis:lastModifiedBy"); - - $this->lastModificationDate = new PropertyDateTime(false, false, 'DateTime', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->lastModificationDate->setId('lastModificationDate'); - $this->lastModificationDate->setQueryName("cmis:lastModificationDate"); - - $this->changeToken = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->changeToken->setId('changeToken'); - - //true - $this->isImmutable = new PropertyBoolean(false, false, 'Boolean', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->isImmutable->setId('isImmutable'); - $this->isImmutable->setValue(true); - - /* - $this->isLatestVersion = new PropertyBoolean(false, false, 'Boolean', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->isLatestVersion->setId('isLatestVersion'); - - $this->isMajorVersion = new PropertyBoolean(false, false, 'Boolean', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->isMajorVersion->setId('isMajorVersion'); - - $this->isLatestMajorVersion = new PropertyBoolean(false, false, 'Boolean', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->isLatestMajorVersion->setId('isLatestMajorVersion'); - - $this->versionLabel = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->versionLabel->setId('versionLabel'); - - $this->versionSeriesId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->versionSeriesId->setId('versionSeriesId'); - - $this->versionSeriesCheckedOut = new PropertyBoolean(false, false, 'Boolean', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->versionSeriesCheckedOut->setId('versionSeriesCheckedOut'); - - $this->versionSeriesCheckedOutBy = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->versionSeriesCheckedOutBy->setId('versionSeriesCheckedOutBy'); - - $this->versionSeriesCheckedOutId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->versionSeriesCheckedOutId->setId('versionSeriesCheckedOutId'); - - $this->checkinComment = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->checkinComment->setId('checkinComment'); - */ - - $this->contentStreamLength = new PropertyInteger(false, false, 'Integer', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->contentStreamLength->setId('contentStreamLength'); - - $this->contentStreamBase64 = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->contentStreamBase64->setId('contentStreamBase64'); - - $this->contentStreamMimeType = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->contentStreamMimeType->setId('contentStreamMimeType'); - - $this->contentStreamFileName = new PropertyString($required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable); - $this->contentStreamFileName->setRequired(false); - $this->contentStreamFileName->setInherited(false); - $this->contentStreamFileName->setPropertyType('String'); - $this->contentStreamFileName->setCardinality('Single'); - $this->contentStreamFileName->setId('contentStreamFileName'); - - $this->contentStreamId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->contentStreamId->setId('contentStreamId'); - - $this->type = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->type->setId('type'); - $this->type->setQueryName("maarch:type"); - - $this->contact = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->contact->setId('contact'); - - $this->entity_label = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->entity_label->setId('entity_label'); - $this->entity_label->setQueryName("maarch:entity"); - - $this->dest_user = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->dest_user->setId('dest_user'); - $this->dest_user->setQueryName("maarch:dest_user"); - - //$this->doc_date; //=creationDate - $this->process_limit_date = new PropertyDateTime(false, false, 'DateTime', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->process_limit_date->setId('process_limit_date'); - - $this->url = new PropertyString(true, false, 'Url', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->url->setId('url'); - - $this->properties = array( - "name"=>$this->name, "objectId"=>$this->objectId, "baseTypeId"=>$this->baseTypeId, "objectTypeId"=>$this->objectTypeId, - "createdBy"=>$this->createdBy, "creationDate"=>$this->creationDate, "lastModifiedBy"=>$this->lastModifiedBy, - "lastModificationDate"=>$this->lastModificationDate, "changeToken"=>$this->changeToken, "isImmutable"=>$this->isImmutable, - //"isLatestVersion"=>$this->isLatestVersion, "isMajorVersion"=>$this->isMajorVersion, "isLatestMajorVersion"=>$this->isLatestMajorVersion, - //"versionLabel"=>$this->versionLabel, "versionSeriesId"=>$this->versionSeriesId, "versionSeriesCheckedOut"=>$this->versionSeriesCheckedOut, - //"versionSeriesCheckedOutBy"=>$this->versionSeriesCheckedOutBy, "versionSeriesCheckedOutId"=>$this->versionSeriesCheckedOutId, "checkinComment"=>$this->checkinComment, - "contentStreamLength"=>$this->contentStreamLength, "contentStreamBase64"=>$this->contentStreamBase64, "contentStreamMimeType"=>$this->contentStreamMimeType, - "contentStreamFileName"=>$this->contentStreamFileName, "contentStreamId"=>$this->contentStreamId, "type"=>$this->type, - "contact"=>$this->contact, "entity_label"=>$this->entity_label, "dest_user"=>$this->dest_user, "process_limit_date"=>$this->process_limit_date, - "url"=>$this->url - ); - - $this->propertiesInXml = array( - "objectId"=>$this->objectId, "type"=>$this->type, "contact"=>$this->contact, - "entity_label"=>$this->entity_label, "dest_user"=>$this->dest_user, - "process_limit_date"=>$this->process_limit_date, - "contentStreamLength"=>$this->contentStreamLength, "contentStreamBase64"=>$this->contentStreamBase64, - "contentStreamMimeType"=>$this->contentStreamMimeType, - "contentStreamFileName"=>$this->contentStreamFileName, "contentStreamId"=>$this->contentStreamId, - "url"=>$this->url - ); - } - - - public function getProperties() - { - return $this->properties; - } - - public function getDocument($id, $view) - { - require_once('core/class/class_db_pdo.php'); - require_once('core/class/class_security.php'); - $db = new Database(); - //$id = $db->escape_string($id); - $result = $db->query("select res_id, type_label, contact_society, contact_firstname, contact_lastname, " - ."entity_label, dest_user, doc_date, process_limit_date, author " - ."from " . $view . " " - ."where res_id = ? ", array($id)); - - //TODO - if ($result === false){ - //TODO throw objectNotFound or invalidArgument or runtime - echo "<br />ERREUR : requête non exécutée runtime.<br />"; - return null; - } - - if ($recordset = $result->fetchObject()) { - $resArray = array( - 'res_id' => $recordset->res_id, - 'type_label'=> $recordset->type_label, - 'contact_society' => $recordset->contact_society, - 'contact_firstname' => $recordset->contact_firstname, - 'contact_lastname' => $recordset->contact_lastname, - 'entity_label' => $recordset->entity_label, - 'dest_user' => $recordset->dest_user, - 'doc_date' => $recordset->doc_date, - 'process_limit_date' => $recordset->process_limit_date, - 'author' => $recordset->author - ); - - $documentCmis = new resCMIS(); - $documentCmis->DocumentCmis(); - $documentCmis->setRes($resArray); - - require_once('core/class/docservers_controler.php'); - $dsController = new docservers_controler(); - $theFileArray = array(); - $theFileArray = $dsController->viewResource($id, $view, '', true); - - if (strcmp($theFileArray['status'], 'ok') == 0){ - //$documentCmis->contentStreamLength->setValue($theFileArray['']); - $documentCmis->contentStreamBase64->setValue($theFileArray['file_content']); - $documentCmis->contentStreamMimeType->setValue($theFileArray['mime_type']); - //$documentCmis->contentStreamFileName->setValue($theFileArray['']); - //$documentCmis->contentStreamId->setValue($theFileArray['']); - } - - return $documentCmis; - } - - echo '<br />ERREUR : document inexistant.<br />'; - return null; - } - - public function setRes($document){ - - $this->objectId->setValue($document['res_id']); - $this->type->setValue($document['type_label']) ; - $this->contact->setValue($document['contact_society'].' '.$document['contact_firstname'].' '.$document['contact_lastname']) ; - $this->entity_label->setValue($document['entity_label']) ; - $this->dest_user->setValue($document['dest_user']) ; - $this->creationDate->setValue($document['doc_date']) ; - $this->process_limit_date->setValue($document['process_limit_date']) ; - $this->createdBy->setValue($document['author']) ; - } - - - public function getPropertyByQueryName($queryName){ - $queryName = trim($queryName); - $found = false; - $i = 0; - $properties = array_values($this->properties); - - while(!$found && ($property = $properties[$i++])){ - $found = (strcmp($queryName, $property->getQueryName()) == 0); - } - - return ($found) ? $property : null; - } - - - public function toAtomXml(){ - - - $doc = new DOMDocument('1.0', 'utf-8'); - $doc->xmlStandalone = true; - $doc->formatOutput = true; - - $this->getAtomXmlEntry($doc, $feed); - - return $doc; - } - - - - public function getAtomXmlEntry(&$doc, &$feed){ - - if (isset($feed)){ - $root = $doc->createElement('atom:entry'); - $feed->appendChild($root); - } - else{ - //atom:entry - $root = $doc->createElementNS('http://www.w3.org/2005/Atom', 'atom:entry'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:cmisra', 'http://docs.oasis-open.org/ns/cmis/restatom/200908/'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:cmis', 'http://docs.oasis-open.org/ns/cmis/core/200908/'); - $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:maarch', 'http://www.maarch.org'); - $doc->appendChild($root); - } - - - - //atom:author - $eAuthor = $doc->createElement('atom:author'); - $root->appendChild($eAuthor); - //$uri = 'uri'; - $name = $this->contact->getValue(); //'name'; - //$email = 'email'; - //$eUri = $doc->createElement('atom:uri', $uri); - $eName = $doc->createElement('atom:name', $name); - //$eEmail = $doc->createElement('atom:email', $email); - $eAuthor->appendChild($eName); - //$eAuthor->appendChild($eUri); - //$eAuthor->appendChild($eEmail); - - - //atom:content - $attSrcContent = 'src'; - $eContent = $doc->createElement('atom:content'); - $root->appendChild($eContent); - //$eContent->setAttribute('src', $attSrcContent); - - - //atom:id - //derived from cmis:objectId. This id MUST be compliant with atom's specification and be a valid URI - if ($this->objectId->valueIsSet()){ - $id = $this->objectId->getValue(); //'id'; - $eId = $doc->createElement('atom:id', $id); - $root->appendChild($eId); - } - - - //atom:title - //cmis:name property - if ($this->name->valueIsSet()){ - $title = $this->name->getValue(); //'title'; - $attTypeTitle = 'text'; - $eTitle = $doc->createElement('atom:title', $title); - $root->appendChild($eTitle); - $eTitle->setAttribute('type', $attTypeTitle); - } - - //atom:updated - //cmis:lastModificationDate - if ($this->lastModificationDate->valueIsSet()){ - $updated = $this->lastModificationDate->getValue(); //'updated'; - $eUpdated = $doc->createElement('atom:updated', $updated); - $root->appendChild($eUpdated); - } - - - //atom:published - //cmis:creationDate - if ($this->creationDate->valueIsSet()){ - $published = $this->creationDate->getValue(); //'published'; - $ePublished = $doc->createElement('atom:published', $published); - $root->appendChild($ePublished); - } - - //atom:summary - /*$summary = 'summary'; //$this->getSummary(); - $attTypeSummary = 'text'; - $eSummary = $doc->createElement('atom:summary', $summary); - $root->appendChild($eSummary); - $eSummary->setAttribute('type', $attTypeSummary);*/ - - - //atom:link rel="self" - //points to an URI that returns the atom entry for this document - /*$attHrefLinkSelf = 'href link self'; - $eLinkSelf = $doc->createElement('atom:link'); - $root->appendChild($eSummary); - $eLinkSelf->setAttribute('rel', 'self'); - $eLinkSelf->setAttribute('href', $attHrefLinkSelf);*/ - - - //atom:link rel="edit" - //points to an URI that accepts PUT of atom entry - /*$attHrefLinkEdit = 'href link edit'; - $eLinkEdit = $doc->createElement('atom:link'); - $root->appendChild($eSummary); - $eLinkEdit->setAttribute('rel', 'edit'); - $eLinkEdit->setAttribute('href', $attHrefLinkEdit);*/ - - - //atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" - //points to the allowable actions document for this object - - - //atom:link rel="describedby" - //points to the type definition as an atom entry for the type of this document entry - /*$attHrefLinkDesc = 'href link described by'; - $eLinkDesc = $doc->createElement('atom:link'); - $root->appendChild($eLinkDesc); - $eLinkDesc->setAttribute('rel', 'describedby'); - $eLinkDesc->setAttribute('type', 'application/atom+xml;type=entry'); - $eLinkDesc->setAttribute('href', $attHrefLinkDesc);*/ - - - //atom:link rel="working-copy" - //points to the private working copy if it exists - - //atom:link rel="service" - //points to service document containing the CMIS repository. - //The service document MUST contain only one workspace element - //Media Type: application/atomsvc+xml - /*$attHrefLinkService = 'href link service'; - $eLinkService = $doc->createElement('atom:link'); - $root->appendChild($eLinkService); - $eLinkService->setAttribute('rel', 'service'); - $eLinkService->setAttribute('type', 'application/atomsvc+xml'); - $eLinkService->setAttribute('href', $attHrefLinkService);*/ - - - //atom:link rel="edit-media" - //Same as setContentStream - /*$attHrefLinkEditMedia = 'href link edit media'; - $eLinkEditMedia = $doc->createElement('atom:link'); - $root->appendChild($eLinkEditMedia); - $eLinkEditMedia->setAttribute('rel', 'edit-media'); - $eLinkEditMedia->setAttribute('href', $attHrefLinkService);*/ - - - //atom:link rel="alternate" - //used to identify the renditions available for the specified object - /*$attHrefAlternate = 'href link alternate'; - $eLinkAlternate = $doc->createElement('atom:link'); - $root->appendChild($eLinkAlternate); - $eLinkAlternate->setAttribute('rel', 'alternate'); - $eLinkAlternate->setAttribute('href', $attHrefAlternate);*/ - - - //atom:link type="application/atom+xml;type=feed" rel="up" - //points to the atom feed containing the set of parents - //If there is only one parent, the repository MAY point this link relation directly to the atom entry of the parent - /*$attHrefLinkUp = 'href link up'; - $eLinkUp = $doc->createElement('atom:link'); - $root->appendChild($eLinkUp); - $eLinkUp->setAttribute('rel', 'up'); - $eLinkUp->setAttribute('type', 'application/atom+xml;type=feed'); - $eLinkUp->setAttribute('href', $attHrefLinkUp);*/ - - - //atom:link type="application/atom+xml;type=feed" rel="version-history" - //points to atom feed containing the versions of this document - //If the document is not versionable, this link relation may not be on the resource - /*if ($this->versionable){ - $attHrefLinkVersHist = 'href link version-history'; - $eLinkVersHist = $doc->createElement('atom:link'); - $root->appendChild($eLinkVersHist); - $eLinkVersHist->setAttribute('rel', 'version-history'); - $eLinkVersHist->setAttribute('type', 'application/atom+xml;type=feed'); - $eLinkVersHist->setAttribute('href', $attHrefLinkVersHist); - } - */ - - - //atom:link type="application/atom+xml;type=entry" rel="current-version" - //points to the latest version of the document - //Uses query parameter 'returnVersion' and enumReturnVersion - //If this version is the current-version, this link relation may not be on the resource - - - //atom:link type="application/atom+xml;type=feed" rel="http://docs.oasis-open.org/ns/cmis/link/200908/relationships" - //points to the relationships feed for this object - /*$attRel = 'rel link relationships'; - $eLinkRel = $doc->createElement('atom:link'); - $root->appendChild($eLinkRel); - $eLinkRel->setAttribute('rel', $attRel); - $eLinkRel->setAttribute('type', 'application/atom+xml;type=feed');*/ - - - //atom:link type="application/atom+xml;type=feed" rel="http://docs.oasis-open.org/ns/cmis/link/200908/policies" - //points to the policy feed for this object - /*$attPol = 'rel link policies'; - $eLinkPol = $doc->createElement('atom:link'); - $root->appendChild($eLinkPol); - $eLinkPol->setAttribute('rel', $attPol); - $eLinkPol->setAttribute('type', 'application/atom+xml;type=feed');*/ - - - //atom:link type="application/cmisacl+xml" rel="http://docs.oasis-open.org/ns/cmis/link/200908/acl" - //points to ACL document for this object - /*$attAcl = 'rel link acl'; - $eLinkAcl = $doc->createElement('atom:link'); - $root->appendChild($eLinkAcl); - $eLinkAcl->setAttribute('rel', $attAcl); - $eLinkAcl->setAttribute('type', 'application/atom+xml;type=feed');*/ - - - //cmisra:object - $eObject = $doc->createElement('cmisra:object'); - $root->appendChild($eObject); - - // cmis:properties - $eProperties = $doc->createElement('cmis:properties'); - $eObject->appendChild($eProperties); - - - // cmis:property - // cmis:value - foreach($this->propertiesInXml as $property){ - $propertyValue = $property->getValue(); - if ($property->valueIsSet()){ - $eProperty = $doc->createElement('cmis:property'.$property->getPropertyType()); - $eProperties->appendChild($eProperty); - $eProperty->setAttribute('localName', $property->getLocalName()); - $eProperty->setAttribute('propertyDefinitionId', $property->getId()); - - if (strcmp($property->getCardinality(), 'Single')==0 ){ - $eValue = $doc->createElement('cmis:value', $propertyValue); - $eProperty->appendChild($eValue); - } - else{ - //au moins une valeur non nulle - foreach($propertyValue as $value){ - if ($value != null){ - $eValue = $doc->createElement('cmis:value', $value); - $eProperty->appendChild($eValue); - } - } - } - } - } - - return $root; - } - - - - - - - public function setName($name){ - $this->name = $name; - } - - public function setObjectId($objectId){ - $this->objectId = $objectId; - } - - public function setBaseTypeId($baseTypeId){ - $this->baseTypeId = $baseTypeId; - } - - public function setObjectTypeId($objectTypeId){ - $this->objectTypeId = $objectTypeId; - } - - public function setCreatedBy($createdBy){ - $this->createdBy = $createdBy; - } - - public function setCreationDate($creationDate){ - $this->creationDate = $creationDate; - } - - public function setLastModifiedBy($lastModifiedBy){ - $this->lastModifiedBy = $lastModifiedBy; - } - - public function setLastModificationDate($lastModificationDate){ - $this->lastModificationDate = $lastModificationDate; - } - - public function setContentStreamLength($contentStreamLength){ - $this->contentStreamLength = $contentStreamLength; - } - - public function setContentStreamMimeType($contentStreamMimeType){ - $this->contentStreamMimeType = $contentStreamMimeType; - } - - public function setContentStreamFileName($contentStreamFileName){ - $this->contentStreamFileName = $contentStreamFileName; - } - - public function setContentStreamId($contentStreamId){ - $this->contentStreamId = $contentStreamId; - } - - public function setUrl($value){ - $this->url->setValue($value); - } - - -} - diff --git a/apps/maarch_entreprise/class/cmis/xmlParser.class.php b/apps/maarch_entreprise/class/cmis/xmlParser.class.php deleted file mode 100755 index a271479db8cbeb6652b511a035dfbe6e94585217..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/cmis/xmlParser.class.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -require_once 'cmis_class_query.php'; - -class xmlParser{ - - - - public function parseQuery($atomFileContent){ - - $query = new Query(); - //$atomXmlDocument = base64_decode($atomFileContent); - $atomXmlDocument = $atomFileContent; - - // - $example = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' - .'<cmis:query xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmism="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:maarch="http://www.maarch.org">' - .' <cmis:statement>SELECT * FROM cmis:document</cmis:statement>' - .' <cmis:searchAllVersions>true</cmis:searchAllVersions>' - .' <cmis:includeAllowableActions>false</cmis:includeAllowableActions>' - .' <cmis:includeRelationships>none</cmis:includeRelationships>' - .' <cmis:renditionFilter>*</cmis:renditionFilter>' - .' <cmis:maxItems>50</cmis:maxItems>' - .' <cmis:skipCount>0</cmis:skipCount>' - .'</cmis:query>'; - - $document_xml = new DomDocument('1.0', 'utf-8'); - $document_xml->loadXML($atomXmlDocument); - //$document_xml->loadXML($example); - - $elements = $document_xml->getElementsByTagName("query"); - $tree = $elements->item(0); - $children = $tree->childNodes; - - foreach($children as $child){ - $name = $child->nodeName; - //echo '<br />'.$name.'<br />'; - switch($name){ - case 'cmis:statement': - $query->setStatement($child->nodeValue);break; - case 'cmis:searchAllVersions': - $searchAllVersions = (strtolower($child->nodeValue)==='true'); - $query->setSearchAllVersions($searchAllVersions);break; - case 'cmis:includeAllowableActions': - $includeAllowableActions = (strtolower($child->nodeValue)==='true'); - $query->setIncludeAllowableActions($includeAllowableActions);break; - case 'cmis:includeRelationships': - $query->setIncludeRelationships($child->nodeValue);break; - case 'cmis:renditionFilter': - $query->setRenditionFilter($child->nodeValue);break; - case 'cmis:maxItems': - $query->setMaxItems(intval($child->nodeValue));break; - case 'cmis:skipCount': - $query->setSkipCount(intval($child->nodeValue));break; - default : ;break; - } - } - - return $query; - } - - - public function getCmisFolderFromXml($atomFileContent){ - - $newFolder = new folderCMIS(); - $newFolder->FolderCmis(); - - //$atomXmlDocument = base64_decode($atomFileContent); - $atomXmlDocument = $atomFileContent; - $document_xml = new DomDocument('1.0', 'utf-8'); - $document_xml->loadXML($atomXmlDocument); - - $elements = $document_xml->getElementsByTagName("entry"); - $tree = $elements->item(0); - $children = $tree->childNodes; - - //$error = true if cmis:objectTypeId != cmis:folder - $error = false; - - foreach($children as $child){ - if($error) break; - $name = $child->nodeName; - - switch($name){ - case 'title': - $newFolder->setNameValue($child->nodeValue); - break; - case 'cmisra:object': - $objectsChildren = $child->childNodes; - - //properties - foreach($objectsChildren as $objectsChild){ - if($error) break; - if(strcmp($objectsChild->nodeName, 'cmis:properties')==0 ){ - - //property - foreach($objectsChild->childNodes as $property){ - if($error) break; - if($property->hasAttributes()){ - - if((strcmp($property->nodeName, 'cmis:propertyId')==0)) { - $propertyDefinitionId= $property->attributes->getNamedItem('propertyDefinitionId')->nodeValue; - if(strcmp($propertyDefinitionId, 'cmis:objectTypeId')==0){ - foreach($property->childNodes as $node){ - if(strcmp($node->nodeName, 'value')==0){ - $error = (strcmp($value->nodeValue, 'cmis:folder')!=0); - } - } - } - elseif(strcmp($propertyDefinitionId, 'folderId')==0){ - foreach($property->childNodes as $node){ - if(strcmp($node->nodeName, 'cmis:value')==0){ - $newFolder->setFolderIdValue($node->nodeValue); - } - } - } - } - - } - } - } - } - break; - default : - break; - } - } - - - return $error ? null : $newFolder; - } - - - - -} - - diff --git a/apps/maarch_entreprise/class/contacts_controler_Abstract.php b/apps/maarch_entreprise/class/contacts_controler_Abstract.php index dedce71f0ea57227cf84549b7f38300e3f915456..1e86cc739ef325e5bc66d1ea9134b0c80e1a0517 100755 --- a/apps/maarch_entreprise/class/contacts_controler_Abstract.php +++ b/apps/maarch_entreprise/class/contacts_controler_Abstract.php @@ -68,161 +68,4 @@ abstract class contacts_controler_Abstract extends ObjectControler implements Ob { return true; } - - public function CreateContact($data) - { - - //try { - $func = new functions(); - $data = $func->object2array($data); - $db = new Database(); - $queryContactFields = '('; - $queryContactValues = '('; - $queryAddressFields = '('; - $queryAddressValues = '('; - $iContact = 0; - $iAddress = 0; - $currentContactId = "0"; - $currentAddressId = "0"; - - $enabled = "Y"; - foreach ($data as $key => $value) { - if (strtoupper($value['table']) == strtoupper('contact_addresses') && strtoupper($value['column']) == strtoupper('enabled')) { - $enabled = strtoupper($value['value']); - break; - } - } - - $countData = count($data); - - for ($i=0;$i<$countData;$i++) { - - if(strtoupper($data[$i]['column']) == strtoupper('email') && ($data[$i]['value'] == "" || $data[$i]['value'] == null)){ - $returnResArray = array( - 'returnCode' => (int) 0, - 'contactId' => '', - 'addressId' => '', - 'contactInfo' => 'No email attached to contact, skipped ...', - 'error' => '', - ); - return $returnResArray; - } - - if (strtoupper($data[$i]['column']) == strtoupper('email') && ($data[$i]['value'] <> "" || $data[$i]['value'] <> null)) { - $theString = str_replace(">", "", $data[$i]['value']); - $mail = explode("<", $theString); - $mail[0] = trim($mail[0]); - try { - $stmt = $db->query("SELECT contact_id, ca_id FROM view_contacts WHERE email = ? and enabled = ?", - array($mail[0], $enabled) - ); - $res = $stmt->fetchObject(); - if ($res->ca_id <> "") { - $contact_exists = true; - - } else { - $contact_exists = false; - } - } catch (Exception $e) { - $returnResArray = array( - 'returnCode' => (int) -1, - 'contactId' => '', - 'addressId' => '', - 'contactInfo' => '', - 'error' => 'unknown error: ' . $e->getMessage(), - ); - return $returnResArray; - } - - } - - $data[$i]['column'] = strtolower($data[$i]['column']); - $data[$i]['value'] = str_replace("'", "''", $data[$i]['value']); - - if ($data[$i]['table'] == "contacts_v2") { - //COLUMN - $queryContactFields .= $data[$i]['column'] . ','; - //VALUE - if ($data[$i]['type'] == 'string' || $data[$i]['type'] == 'date') { - $queryContactValues .= "'" . $data[$i]['value'] . "',"; - } else { - $queryContactValues .= $data[$i]['value'] . ","; - } - } else if ($data[$i]['table'] == "contact_addresses") { - //COLUMN - $queryAddressFields .= $data[$i]['column'] . ','; - //VALUE - if ($data[$i]['type'] == 'string' || $data[$i]['type'] == 'date') { - $queryAddressValues .= "'" . $data[$i]['value'] . "',"; - } else { - $queryAddressValues .= $data[$i]['value'] . ","; - } - } - } - - $queryContactFields .= "user_id, entity_id, creation_date)"; - $queryContactValues .= "'superadmin', 'SUPERADMIN', current_timestamp)"; - - if (!$contact_exists) { - try { - $queryContact = " INSERT INTO contacts_v2 " . $queryContactFields - . ' values ' . $queryContactValues ; - - $db->query($queryContact); - - $currentContactId = $db->lastInsertId('contact_v2_id_seq'); - - } catch (Exception $e) { - $returnResArray = array( - 'returnCode' => (int) -1, - 'contactId' => 'ERROR', - 'addressId' => 'ERROR', - 'contactInfo' => '', - 'error' => 'contact creation error : '. $e->getMessage(), - ); - - return $returnResArray; - } - try { - $queryAddressFields .= "contact_id, user_id, entity_id)"; - $queryAddressValues .= $currentContactId . ", 'superadmin', 'SUPERADMIN')"; - - $queryAddress = " INSERT INTO contact_addresses " . $queryAddressFields - . ' values ' . $queryAddressValues ; - - $db->query($queryAddress); - $currentAddressId = $db->lastInsertId('contact_addresses_id_seq'); - } catch (Exception $e) { - $returnResArray = array( - 'returnCode' => (int) -1, - 'contactId' => $currentContactId, - 'addressId' => 'ERROR', - 'contactInfo' => '', - 'error' => 'address creation error : '. $e->getMessage(), - ); - - return $returnResArray; - } - }else{ - $returnResArray = array( - 'returnCode' => (int) 0, - 'contactId' => $currentContactId, - 'addressId' => $currentAddressId, - 'contactInfo' => 'contact already exist, attached to doc ... '.$queryContactValues, - 'error' => '', - ); - - return $returnResArray; - } - - $returnResArray = array( - 'returnCode' => (int) 0, - 'contactId' => $currentContactId, - 'addressId' => $currentAddressId, - 'contactInfo' => 'contact created and attached to doc ... '.$queryContactValues, - 'error' => '', - ); - - return $returnResArray; - } -} +} \ No newline at end of file diff --git a/apps/maarch_entreprise/class/ws.php b/apps/maarch_entreprise/class/ws.php deleted file mode 100755 index bc2117eda8237209240ca1e7c769e0e93ec1e45e..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/class/ws.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; -global $REST_dispatch_map; - -$XMLRPC_dispatch_map['addContact'] = Array( - 'function' => 'addContact', - 'signature' => array(array('string','string')), - 'docstring' => '', - 'method' => "apps#contacts::save" - ); - -$SOAP_dispatch_map['addContact'] = Array( - 'in' => Array('in' => 'string'), - 'out' => Array('out' => 'string'), - 'method' => "apps#contacts::save" - ); - -$SOAP_typedef['returnId'] = array( 'returnCode'=>'int', - 'contactId'=>'string', - 'contactInfo'=>'string', - 'error'=>'string' - ); - -$SOAP_typedef['arrayOfDataContact'] = array( - array( - 'arrayOfDataContent' => '{urn:MaarchSoapServer}arrayOfDataContactContent' - ) -); - -$SOAP_typedef['arrayOfDataContactContent'] = array( - 'column' => 'string', - 'value' => 'string', - 'type' => 'string', - 'table' => 'string', -); - -$SOAP_dispatch_map['CreateContact'] = Array( - 'in' => Array('data' => '{urn:MaarchSoapServer}arrayOfDataContact'), - 'out' => Array('out' => '{urn:MaarchSoapServer}returnId'), - 'method' => "apps#contacts::CreateContact" - ); - -$REST_dispatch_map['res'] = Array( - 'pathToController' => "apps/maarch_entreprise/class/cmis/cmis_res_controller.php" -); \ No newline at end of file diff --git a/apps/maarch_entreprise/democmis/cmis.php b/apps/maarch_entreprise/democmis/cmis.php deleted file mode 100755 index 3be1f4e9b1ea8d78d6307822bd73d84907561266..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/democmis/cmis.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -//echo 'ici' . $_SESSION['config']['coreurl']; -//print_r($_SESSION['config']); -?> - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"><head> - <title>Démo CMIS</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <meta http-equiv="Content-Language" content="fr"> - <link rel="stylesheet" type="text/css" href="cmis_stylesheet.css" media="screen"> - </head> - <body> - <div> - <div align="center"> - <h3>Accès Maarch via CMIS</h3> - </div> - <div> - <p> - </p><h4>Voir un document (id = 101)</h4> - <!--div id="liencmis"> - <a href="<?php echo $_SESSION['config']['coreurl'];?>core/class/web_service/cmis_test/test_rest.php?collection=letterbox_coll&resource=res&idResource=101" target="_blank"> - <?php echo $_SESSION['config']['coreurl'];?>core/class/web_service/cmis_test/test_rest.php?collection=letterbox_collresource=res&idResource=101 - </a> - </div--> - <div id="liencmis"> - <a href="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/res/101" target="_blank"> - <?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/res/101 - </a> - </div> - <!--curl -X GET -ubblier:maarch "http://127.0.0.1/syleam_trunk/ws_server.php?REST/res/101"--> - <p></p> - <!--form method="post" action="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/folder" target="_blank"> - <p> - </p><h4>Créer un dossier</h4> - <div id="liencmis"> - <input name="xmlFile" value="testcreatefolder.atom.xml" type="hidden"> - Fichier : TEST - <br> - <input class="button" name="submit" value="Créer" type="submit"> - </div> - <p></p> - </form--> - <p> - </p><h4>Voir la liste des bannettes</h4> - <div id="liencmis"> - <a href="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/basket" target="_blank"> - <?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/basket - </a> - </div> - <!--curl -X GET -ubblier:maarch "<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?REST/basket"--> - <p></p> - <p> - </p><h4>Liste des documents d'une bannette</h4> - <div id="liencmis"> - <a href="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/basket/InitBasket" target="_blank"> - <?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/basket/InitBasket - </a> - </div> - <!--curl -X GET -ubblier:maarch "<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?REST/basket/MesCourriersATraiter"--> - <p></p> - <!--form method="post" action="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/res" target="_blank"> - <p> - </p><h4>Recherche avancée de documents</h4> - <div id="liencmis"> - <input name="xmlFile" value="query.xml" type="hidden"> - - Requête : SELECT cmis:objectId , maarch:type , maarch:entity , maarch:dest_user FROM cmis:document ORDER BY cmis:objectId asc - <br> - <input class="button" name="submit" value="Rechercher" type="submit"> - </div> - <p></p> - </form--> - <!--curl -X POST -ubblier:maarch "<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?REST/res" -d atomFileContent=thexmlcontentfile--> - <!--p> - </p><h4>Consulter un dossier (id = TEST)</h4> - <div id="liencmis"> - <a href="<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/folder/TEST" target="_blank"> - <?php echo $_SESSION['config']['coreurl'];?>ws_server.php?cmis/letterbox_coll/folder/TEST - </a> - </div--> - <!--curl -X GET -ubblier:maarch "<?php echo $_SESSION['config']['coreurl'];?>ws_server.php?REST/folder/RH"--> - <p></p> - </div> - </div> - </body> -</html> diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index 8f2ae96480e25250bda0fc64e86d288d0c36a4cf..e9358b473e7eec8e014c2fae5b2282fc10b6e89c 100755 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -4694,9 +4694,6 @@ if (!defined('_DOWNLOAD_MAIN_DOCUMENT')) { if (!defined('_SENDMAIL_PARAM')) { define('_SENDMAIL_PARAM', 'Mail server'); } -if (!defined('_ACCESS_SMARTPHONE')) { - define('_ACCESS_SMARTPHONE', 'Go to mobile mode ?'); -} if (!defined('_MAILING_CONFIRMATION')) { define('_MAILING_CONFIRMATION', 'Do you want to generate all attachments ?'); } diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 7b1fd38daaf80f9554eaac9876730df2b9ca01dd..fd5960f1a61c1afe03edcc53a37a50c75eca8c73 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -4818,9 +4818,6 @@ if (!defined('_DOWNLOAD_MAIN_DOCUMENT')) { if (!defined('_SENDMAIL_PARAM')) { define('_SENDMAIL_PARAM', 'Serveur mail'); } -if (!defined('_ACCESS_SMARTPHONE')) { - define('_ACCESS_SMARTPHONE', 'Accéder à la version mobile ?'); -} if (!defined('_MAILING_CONFIRMATION')) { define('_MAILING_CONFIRMATION', 'Voulez-vous générer toutes les pièces jointes ?'); } diff --git a/apps/maarch_entreprise/lang/nl.php b/apps/maarch_entreprise/lang/nl.php index 03197fbe6bd9db71c45ed861b244dd0ad8d31ef5..c04ce5e2a7443908a1d115865ab30bf3e0d4b932 100755 --- a/apps/maarch_entreprise/lang/nl.php +++ b/apps/maarch_entreprise/lang/nl.php @@ -1580,9 +1580,6 @@ if (!defined('_DOWNLOAD_MAIN_DOCUMENT')) { if (!defined('_SENDMAIL_PARAM')) { define('_SENDMAIL_PARAM', '_TO_TRANSLATE'); } -if (!defined('_ACCESS_SMARTPHONE')) { - define('_ACCESS_SMARTPHONE', '_TO_TRANSLATE'); -} if (!defined('_MAILING_CONFIRMATION')) { define('_MAILING_CONFIRMATION', 'Do you want to generate all attachments ? _TO_TRANSLATE'); } diff --git a/apps/maarch_entreprise/login.php b/apps/maarch_entreprise/login.php index a040116ee4a4d3b7e84c80d3866e4e779cb8b4c0..fbc17474c61ccc86c543ac8c1dfa5c14af6db4ed 100755 --- a/apps/maarch_entreprise/login.php +++ b/apps/maarch_entreprise/login.php @@ -34,13 +34,19 @@ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' } $_SESSION['slash_env'] = DIRECTORY_SEPARATOR; $tmpPath = explode( - DIRECTORY_SEPARATOR, str_replace( - '/', DIRECTORY_SEPARATOR, $_SERVER['SCRIPT_FILENAME'] + DIRECTORY_SEPARATOR, + str_replace( + '/', + DIRECTORY_SEPARATOR, + $_SERVER['SCRIPT_FILENAME'] ) ); $serverPath = implode( - DIRECTORY_SEPARATOR, array_slice( - $tmpPath, 0, array_search('apps', $tmpPath) + DIRECTORY_SEPARATOR, + array_slice( + $tmpPath, + 0, + array_search('apps', $tmpPath) ) ).DIRECTORY_SEPARATOR; @@ -84,17 +90,6 @@ $businessAppTools->compare_base_version( .DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'applicationVersion.xml' ); -//LGI TEST FOR SMARTPHONE -// if ($core->detectSmartphone()) { -// $confirmScript = '<script>'; -// $confirmScript .= 'if(confirm("' . _ACCESS_SMARTPHONE . '")){'; -// $confirmScript .= 'window.location.href="smartphone/hello.php"'; -// $confirmScript .= '}'; -// $confirmScript .= '</script>'; - -// echo $confirmScript; -// } - $core->load_html(); $core->load_header('', true, false); $time = $core->get_session_time_expire(); diff --git a/apps/maarch_entreprise/tools/PEAR/HTTP/Request.php b/apps/maarch_entreprise/tools/PEAR/HTTP/Request.php deleted file mode 100755 index e7c00edae9acf524ce0d3f3954d2b9048da60c0c..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/HTTP/Request.php +++ /dev/null @@ -1,1521 +0,0 @@ -<?php -/** - * Class for performing HTTP requests - * - * PHP versions 4 and 5 - * - * LICENSE: - * - * Copyright (c) 2002-2007, Richard Heyes - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * o Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * o Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * o The names of the authors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes <richard@phpguru.org> - * @author Alexey Borzov <avb@php.net> - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request.php,v 1.63 2008/10/11 11:07:10 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * PEAR and PEAR_Error classes (for error handling) - */ -require_once 'PEAR.php'; -/** - * Socket class - */ -require_once 'Net/Socket.php'; -/** - * URL handling class - */ -require_once 'Net/URL.php'; - -/**#@+ - * Constants for HTTP request methods - */ -define('HTTP_REQUEST_METHOD_GET', 'GET', true); -define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); -define('HTTP_REQUEST_METHOD_POST', 'POST', true); -define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); -define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); -define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); -define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); -/**#@-*/ - -/**#@+ - * Constants for HTTP request error codes - */ -define('HTTP_REQUEST_ERROR_FILE', 1); -define('HTTP_REQUEST_ERROR_URL', 2); -define('HTTP_REQUEST_ERROR_PROXY', 4); -define('HTTP_REQUEST_ERROR_REDIRECTS', 8); -define('HTTP_REQUEST_ERROR_RESPONSE', 16); -define('HTTP_REQUEST_ERROR_GZIP_METHOD', 32); -define('HTTP_REQUEST_ERROR_GZIP_READ', 64); -define('HTTP_REQUEST_ERROR_GZIP_DATA', 128); -define('HTTP_REQUEST_ERROR_GZIP_CRC', 256); -/**#@-*/ - -/**#@+ - * Constants for HTTP protocol versions - */ -define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); -define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); -/**#@-*/ - -if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - /** - * Whether string functions are overloaded by their mbstring equivalents - */ - define('HTTP_REQUEST_MBSTRING', true); -} else { - /** - * @ignore - */ - define('HTTP_REQUEST_MBSTRING', false); -} - -/** - * Class for performing HTTP requests - * - * Simple example (fetches yahoo.com and displays it): - * <code> - * $a = &new HTTP_Request('http://www.yahoo.com/'); - * $a->sendRequest(); - * echo $a->getResponseBody(); - * </code> - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes <richard@phpguru.org> - * @author Alexey Borzov <avb@php.net> - * @version Release: 1.4.4 - */ -class HTTP_Request -{ - /**#@+ - * @access private - */ - /** - * Instance of Net_URL - * @var Net_URL - */ - var $_url; - - /** - * Type of request - * @var string - */ - var $_method; - - /** - * HTTP Version - * @var string - */ - var $_http; - - /** - * Request headers - * @var array - */ - var $_requestHeaders; - - /** - * Basic Auth Username - * @var string - */ - var $_user; - - /** - * Basic Auth Password - * @var string - */ - var $_pass; - - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Proxy server - * @var string - */ - var $_proxy_host; - - /** - * Proxy port - * @var integer - */ - var $_proxy_port; - - /** - * Proxy username - * @var string - */ - var $_proxy_user; - - /** - * Proxy password - * @var string - */ - var $_proxy_pass; - - /** - * Post data - * @var array - */ - var $_postData; - - /** - * Request body - * @var string - */ - var $_body; - - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - var $_bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - */ - var $_bodyRequired = array('POST', 'PUT'); - - /** - * Files to post - * @var array - */ - var $_postFiles = array(); - - /** - * Connection timeout. - * @var float - */ - var $_timeout; - - /** - * HTTP_Response object - * @var HTTP_Response - */ - var $_response; - - /** - * Whether to allow redirects - * @var boolean - */ - var $_allowRedirects; - - /** - * Maximum redirects allowed - * @var integer - */ - var $_maxRedirects; - - /** - * Current number of redirects - * @var integer - */ - var $_redirects; - - /** - * Whether to append brackets [] to array variables - * @var bool - */ - var $_useBrackets = true; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Whether to save response body in response object property - * @var bool - */ - var $_saveBody = true; - - /** - * Timeout for reading from socket (array(seconds, microseconds)) - * @var array - */ - var $_readTimeout = null; - - /** - * Options to pass to Net_Socket::connect. See stream_context_create - * @var array - */ - var $_socketOptions = null; - /**#@-*/ - - /** - * Constructor - * - * Sets up the object - * @param string The url to fetch/access - * @param array Associative array of parameters which can have the following keys: - * <ul> - * <li>method - Method to use, GET, POST etc (string)</li> - * <li>http - HTTP Version to use, 1.0 or 1.1 (string)</li> - * <li>user - Basic Auth username (string)</li> - * <li>pass - Basic Auth password (string)</li> - * <li>proxy_host - Proxy server host (string)</li> - * <li>proxy_port - Proxy server port (integer)</li> - * <li>proxy_user - Proxy auth username (string)</li> - * <li>proxy_pass - Proxy auth password (string)</li> - * <li>timeout - Connection timeout in seconds (float)</li> - * <li>allowRedirects - Whether to follow redirects or not (bool)</li> - * <li>maxRedirects - Max number of redirects to follow (integer)</li> - * <li>useBrackets - Whether to append [] to array variable names (bool)</li> - * <li>saveBody - Whether to save response body in response object property (bool)</li> - * <li>readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))</li> - * <li>socketOptions - Options to pass to Net_Socket object (array)</li> - * </ul> - * @access public - */ - public function __construct($url = '', $params = array()) - { - $this->_method = HTTP_REQUEST_METHOD_GET; - $this->_http = HTTP_REQUEST_HTTP_VER_1_1; - $this->_requestHeaders = array(); - $this->_postData = array(); - $this->_body = null; - - $this->_user = null; - $this->_pass = null; - - $this->_proxy_host = null; - $this->_proxy_port = null; - $this->_proxy_user = null; - $this->_proxy_pass = null; - - $this->_allowRedirects = false; - $this->_maxRedirects = 3; - $this->_redirects = 0; - - $this->_timeout = null; - $this->_response = null; - - foreach ($params as $key => $value) { - $this->{'_' . $key} = $value; - } - - if (!empty($url)) { - $this->setURL($url); - } - - // Default useragent - $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); - - // We don't do keep-alives by default - $this->addHeader('Connection', 'close'); - - // Basic authentication - if (!empty($this->_user)) { - $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); - } - - // Proxy authentication (see bug #5913) - if (!empty($this->_proxy_user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); - } - - // Use gzip encoding if possible - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) { - $this->addHeader('Accept-Encoding', 'gzip'); - } - } - - /** - * Generates a Host header for HTTP/1.1 requests - * - * @access private - * @return string - */ - function _generateHostHeader() - { - if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { - $host = $this->_url->host . ':' . $this->_url->port; - - } else { - $host = $this->_url->host; - } - - return $host; - } - - /** - * Resets the object to its initial state (DEPRECATED). - * Takes the same parameters as the constructor. - * - * @param string $url The url to be requested - * @param array $params Associative array of parameters - * (see constructor for details) - * @access public - * @deprecated deprecated since 1.2, call the constructor if this is necessary - */ - function reset($url, $params = array()) - { - $this->HTTP_Request($url, $params); - } - - /** - * Sets the URL to be requested - * - * @param string The url to be requested - * @access public - */ - function setURL($url) - { - $this->_url = new Net_URL($url, $this->_useBrackets); - - if (!empty($this->_url->user) || !empty($this->_url->pass)) { - $this->setBasicAuth($this->_url->user, $this->_url->pass); - } - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { - $this->addHeader('Host', $this->_generateHostHeader()); - } - - // set '/' instead of empty path rather than check later (see bug #8662) - if (empty($this->_url->path)) { - $this->_url->path = '/'; - } - } - - /** - * Returns the current request URL - * - * @return string Current request URL - * @access public - */ - function getUrl() - { - return empty($this->_url)? '': $this->_url->getUrl(); - } - - /** - * Sets a proxy to be used - * - * @param string Proxy host - * @param int Proxy port - * @param string Proxy username - * @param string Proxy password - * @access public - */ - function setProxy($host, $port = 8080, $user = null, $pass = null) - { - $this->_proxy_host = $host; - $this->_proxy_port = $port; - $this->_proxy_user = $user; - $this->_proxy_pass = $pass; - - if (!empty($user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - } - - /** - * Sets basic authentication parameters - * - * @param string Username - * @param string Password - */ - function setBasicAuth($user, $pass) - { - $this->_user = $user; - $this->_pass = $pass; - - $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - - /** - * Sets the method to be used, GET, POST etc. - * - * @param string Method to use. Use the defined constants for this - * @access public - */ - function setMethod($method) - { - $this->_method = $method; - } - - /** - * Sets the HTTP version to use, 1.0 or 1.1 - * - * @param string Version to use. Use the defined constants for this - * @access public - */ - function setHttpVer($http) - { - $this->_http = $http; - } - - /** - * Adds a request header - * - * @param string Header name - * @param string Header value - * @access public - */ - function addHeader($name, $value) - { - $this->_requestHeaders[strtolower($name)] = $value; - } - - /** - * Removes a request header - * - * @param string Header name to remove - * @access public - */ - function removeHeader($name) - { - if (isset($this->_requestHeaders[strtolower($name)])) { - unset($this->_requestHeaders[strtolower($name)]); - } - } - - /** - * Adds a querystring parameter - * - * @param string Querystring parameter name - * @param string Querystring parameter value - * @param bool Whether the value is already urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->_url->addQueryString($name, $value, $preencoded); - } - - /** - * Sets the querystring to literally what you supply - * - * @param string The querystring data. Should be of the format foo=bar&x=y etc - * @param bool Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $this->_url->addRawQueryString($querystring, $preencoded); - } - - /** - * Adds postdata items - * - * @param string Post data name - * @param string Post data value - * @param bool Whether data is already urlencoded or not, default = not - * @access public - */ - function addPostData($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->_postData[$name] = $value; - } else { - $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); - } - } - - /** - * Recursively applies the callback function to the value - * - * @param mixed Callback function - * @param mixed Value to process - * @access private - * @return mixed Processed value - */ - function _arrayMapRecursive($callback, $value) - { - if (!is_array($value)) { - return call_user_func($callback, $value); - } else { - $map = array(); - foreach ($value as $k => $v) { - $map[$k] = $this->_arrayMapRecursive($callback, $v); - } - return $map; - } - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * @access public - * @param string name of file-upload field - * @param mixed file name(s) - * @param mixed content-type(s) of file(s) being uploaded - * @return bool true on success - * @throws PEAR_Error - */ - function addFile($inputName, $fileName, $contentType = 'application/octet-stream') - { - if (!is_array($fileName) && !is_readable($fileName)) { - return PEAR::raiseError("File '{$fileName}' is not readable", HTTP_REQUEST_ERROR_FILE); - } elseif (is_array($fileName)) { - foreach ($fileName as $name) { - if (!is_readable($name)) { - return PEAR::raiseError("File '{$name}' is not readable", HTTP_REQUEST_ERROR_FILE); - } - } - } - $this->addHeader('Content-Type', 'multipart/form-data'); - $this->_postFiles[$inputName] = array( - 'name' => $fileName, - 'type' => $contentType - ); - return true; - } - - /** - * Adds raw postdata (DEPRECATED) - * - * @param string The data - * @param bool Whether data is preencoded or not, default = already encoded - * @access public - * @deprecated deprecated since 1.3.0, method setBody() should be used instead - */ - function addRawPostData($postdata, $preencoded = true) - { - $this->_body = $preencoded ? $postdata : urlencode($postdata); - } - - /** - * Sets the request body (for POST, PUT and similar requests) - * - * @param string Request body - * @access public - */ - function setBody($body) - { - $this->_body = $body; - } - - /** - * Clears any postdata that has been added (DEPRECATED). - * - * Useful for multiple request scenarios. - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearPostData() - { - $this->_postData = null; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string $name cookie name - * @param string $value cookie value - * @access public - */ - function addCookie($name, $value) - { - $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; - $this->addHeader('Cookie', $cookies . $name . '=' . $value); - } - - /** - * Clears any cookies that have been added (DEPRECATED). - * - * Useful for multiple request scenarios - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearCookies() - { - $this->removeHeader('Cookie'); - } - - /** - * Sends the request - * - * @access public - * @param bool Whether to store response body in Response object property, - * set this to false if downloading a LARGE file and using a Listener - * @return mixed PEAR error on error, true otherwise - */ - function sendRequest($saveBody = true) - { - if (!is_a($this->_url, 'Net_URL')) { - return PEAR::raiseError('No URL given', HTTP_REQUEST_ERROR_URL); - } - - $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; - $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; - - if (strcasecmp($this->_url->protocol, 'https') == 0) { - // Bug #14127, don't try connecting to HTTPS sites without OpenSSL - if (version_compare(PHP_VERSION, '4.3.0', '<') || !extension_loaded('openssl')) { - return PEAR::raiseError('Need PHP 4.3.0 or later with OpenSSL support for https:// requests', - HTTP_REQUEST_ERROR_URL); - } elseif (isset($this->_proxy_host)) { - return PEAR::raiseError('HTTPS proxies are not supported', HTTP_REQUEST_ERROR_PROXY); - } - $host = 'ssl://' . $host; - } - - // magic quotes may fuck up file uploads and chunked response processing - $magicQuotes = ini_get('magic_quotes_runtime'); - ini_set('magic_quotes_runtime', false); - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && - 'Keep-Alive' == $this->_requestHeaders['connection']) - { - $this->removeHeader('connection'); - } - - $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || - (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); - $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); - $sockKey = $host . ':' . $port; - unset($this->_sock); - - // There is a connected socket in the "static" property? - if ($keepAlive && !empty($sockets[$sockKey]) && - !empty($sockets[$sockKey]->fp)) - { - $this->_sock =& $sockets[$sockKey]; - $err = null; - } else { - $this->_notify('connect'); - $this->_sock = new Net_Socket(); - $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); - } - PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); - - if (!PEAR::isError($err)) { - if (!empty($this->_readTimeout)) { - $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); - } - - $this->_notify('sentRequest'); - - // Read the response - $this->_response = new HTTP_Response($this->_sock, $this->_listeners); - $err = $this->_response->process( - $this->_saveBody && $saveBody, - HTTP_REQUEST_METHOD_HEAD != $this->_method - ); - - if ($keepAlive) { - $keepAlive = (isset($this->_response->_headers['content-length']) - || (isset($this->_response->_headers['transfer-encoding']) - && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); - if ($keepAlive) { - if (isset($this->_response->_headers['connection'])) { - $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; - } else { - $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; - } - } - } - } - - ini_set('magic_quotes_runtime', $magicQuotes); - - if (PEAR::isError($err)) { - return $err; - } - - if (!$keepAlive) { - $this->disconnect(); - // Store the connected socket in "static" property - } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - $sockets[$sockKey] =& $this->_sock; - } - - // Check for redirection - if ( $this->_allowRedirects - AND $this->_redirects <= $this->_maxRedirects - AND $this->getResponseCode() > 300 - AND $this->getResponseCode() < 399 - AND !empty($this->_response->_headers['location'])) { - - - $redirect = $this->_response->_headers['location']; - - // Absolute URL - if (preg_match('/^https?:\/\//i', $redirect)) { - $this->_url = new Net_URL($redirect); - $this->addHeader('Host', $this->_generateHostHeader()); - // Absolute path - } elseif ($redirect{0} == '/') { - $this->_url->path = $redirect; - - // Relative path - } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $redirect = Net_URL::resolvePath($redirect); - $this->_url->path = $redirect; - - // Filename, no path - } else { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $this->_url->path = $redirect; - } - - $this->_redirects++; - return $this->sendRequest($saveBody); - - // Too many redirects - } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { - return PEAR::raiseError('Too many redirects', HTTP_REQUEST_ERROR_REDIRECTS); - } - - return true; - } - - /** - * Disconnect the socket, if connected. Only useful if using Keep-Alive. - * - * @access public - */ - function disconnect() - { - if (!empty($this->_sock) && !empty($this->_sock->fp)) { - $this->_notify('disconnect'); - $this->_sock->disconnect(); - } - } - - /** - * Returns the response code - * - * @access public - * @return mixed Response code, false if not set - */ - function getResponseCode() - { - return isset($this->_response->_code) ? $this->_response->_code : false; - } - - /** - * Returns the response reason phrase - * - * @access public - * @return mixed Response reason phrase, false if not set - */ - function getResponseReason() - { - return isset($this->_response->_reason) ? $this->_response->_reason : false; - } - - /** - * Returns either the named header or all if no name given - * - * @access public - * @param string The header name to return, do not set to get all headers - * @return mixed either the value of $headername (false if header is not present) - * or an array of all headers - */ - function getResponseHeader($headername = null) - { - if (!isset($headername)) { - return isset($this->_response->_headers)? $this->_response->_headers: array(); - } else { - $headername = strtolower($headername); - return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; - } - } - - /** - * Returns the body of the response - * - * @access public - * @return mixed response body, false if not set - */ - function getResponseBody() - { - return isset($this->_response->_body) ? $this->_response->_body : false; - } - - /** - * Returns cookies set in response - * - * @access public - * @return mixed array of response cookies, false if none are present - */ - function getResponseCookies() - { - return isset($this->_response->_cookies) ? $this->_response->_cookies : false; - } - - /** - * Builds the request string - * - * @access private - * @return string The request string - */ - function _buildRequest() - { - $separator = ini_get('arg_separator.output'); - ini_set('arg_separator.output', '&'); - $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; - ini_set('arg_separator.output', $separator); - - $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; - $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; - $path = $this->_url->path . $querystring; - $url = $host . $port . $path; - - if (!strlen($url)) { - $url = '/'; - } - - $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; - - if (in_array($this->_method, $this->_bodyDisallowed) || - (0 == strlen($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || - (empty($this->_postData) && empty($this->_postFiles))))) - { - $this->removeHeader('Content-Type'); - } else { - if (empty($this->_requestHeaders['content-type'])) { - // Add default content-type - $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { - $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); - $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); - } - } - - // Request Headers - if (!empty($this->_requestHeaders)) { - foreach ($this->_requestHeaders as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $request .= $canonicalName . ': ' . $value . "\r\n"; - } - } - - // Method does not allow a body, simply add a final CRLF - if (in_array($this->_method, $this->_bodyDisallowed)) { - - $request .= "\r\n"; - - // Post data if it's an array - } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && - (!empty($this->_postData) || !empty($this->_postFiles))) { - - // "normal" POST request - if (!isset($boundary)) { - $postdata = implode('&', array_map( - create_function('$a', 'return $a[0] . \'=\' . $a[1];'), - $this->_flattenArray('', $this->_postData) - )); - - // multipart request, probably with file uploads - } else { - $postdata = ''; - if (!empty($this->_postData)) { - $flatData = $this->_flattenArray('', $this->_postData); - foreach ($flatData as $item) { - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; - $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; - } - } - foreach ($this->_postFiles as $name => $value) { - if (is_array($value['name'])) { - $varname = $name . ($this->_useBrackets? '[]': ''); - } else { - $varname = $name; - $value['name'] = array($value['name']); - } - foreach ($value['name'] as $key => $filename) { - $fp = fopen($filename, 'r'); - $basename = basename($filename); - $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; - - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; - $postdata .= "\r\nContent-Type: " . $type; - $postdata .= "\r\n\r\n" . fread($fp, filesize($filename)) . "\r\n"; - fclose($fp); - } - } - $postdata .= '--' . $boundary . "--\r\n"; - } - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . - "\r\n\r\n"; - $request .= $postdata; - - // Explicitly set request body - } elseif (0 < strlen($this->_body)) { - - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . - "\r\n\r\n"; - $request .= $this->_body; - - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - } else { - - if (in_array($this->_method, $this->_bodyRequired)) { - $request .= "Content-Length: 0\r\n"; - } - $request .= "\r\n"; - } - - return $request; - } - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @return array array with the following items: array('item name', 'item value'); - * @access private - */ - function _flattenArray($name, $values) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($this->_useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, $this->_flattenArray($newName, $v)); - } - return $ret; - } - } - - - /** - * Adds a Listener to the list of listeners that are notified of - * the object's events - * - * Events sent by HTTP_Request object - * - 'connect': on connection to server - * - 'sentRequest': after the request was sent - * - 'disconnect': on disconnection from server - * - * Events sent by HTTP_Response object - * - 'gotHeaders': after receiving response headers (headers are passed in $data) - * - 'tick': on receiving a part of response body (the part is passed in $data) - * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) - * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) - * - * @param HTTP_Request_Listener listener to attach - * @return boolean whether the listener was successfully attached - * @access public - */ - function attach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener')) { - return false; - } - $this->_listeners[$listener->getId()] =& $listener; - return true; - } - - - /** - * Removes a Listener from the list of listeners - * - * @param HTTP_Request_Listener listener to detach - * @return boolean whether the listener was successfully detached - * @access public - */ - function detach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener') || - !isset($this->_listeners[$listener->getId()])) { - return false; - } - unset($this->_listeners[$listener->getId()]); - return true; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::attach() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } -} - - -/** - * Response class to complement the Request class - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes <richard@phpguru.org> - * @author Alexey Borzov <avb@php.net> - * @version Release: 1.4.4 - */ -class HTTP_Response -{ - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Protocol - * @var string - */ - var $_protocol; - - /** - * Return code - * @var string - */ - var $_code; - - /** - * Response reason phrase - * @var string - */ - var $_reason; - - /** - * Response headers - * @var array - */ - var $_headers; - - /** - * Cookies set in response - * @var array - */ - var $_cookies; - - /** - * Response body - * @var string - */ - var $_body = ''; - - /** - * Used by _readChunked(): remaining length of the current chunk - * @var string - */ - var $_chunkLength = 0; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Bytes left to read from message-body - * @var null|int - */ - var $_toRead; - - /** - * Constructor - * - * @param Net_Socket socket to read the response from - * @param array listeners attached to request - */ - public function __construct(&$sock, &$listeners) - { - $this->_sock =& $sock; - $this->_listeners =& $listeners; - } - - - /** - * Processes a HTTP response - * - * This extracts response code, headers, cookies and decodes body if it - * was encoded in some way - * - * @access public - * @param bool Whether to store response body in object property, set - * this to false if downloading a LARGE file and using a Listener. - * This is assumed to be true if body is gzip-encoded. - * @param bool Whether the response can actually have a message-body. - * Will be set to false for HEAD requests. - * @throws PEAR_Error - * @return mixed true on success, PEAR_Error in case of malformed response - */ - function process($saveBody = true, $canHaveBody = true) - { - do { - $line = $this->_sock->readLine(); - if (!preg_match('!^(HTTP/\d\.\d) (\d{3})(?: (.+))?!', $line, $s)) { - return PEAR::raiseError('Malformed response', HTTP_REQUEST_ERROR_RESPONSE); - } else { - $this->_protocol = $s[1]; - $this->_code = intval($s[2]); - $this->_reason = empty($s[3])? null: $s[3]; - } - while ('' !== ($header = $this->_sock->readLine())) { - $this->_processHeader($header); - } - } while (100 == $this->_code); - - $this->_notify('gotHeaders', $this->_headers); - - // RFC 2616, section 4.4: - // 1. Any response message which "MUST NOT" include a message-body ... - // is always terminated by the first empty line after the header fields - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $canHaveBody = $canHaveBody && $this->_code >= 200 && - $this->_code != 204 && $this->_code != 304; - - // If response body is present, read it and decode - $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']); - $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']); - $hasBody = false; - if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) || - 0 != $this->_headers['content-length'])) - { - if ($chunked || !isset($this->_headers['content-length'])) { - $this->_toRead = null; - } else { - $this->_toRead = $this->_headers['content-length']; - } - while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) { - if ($chunked) { - $data = $this->_readChunked(); - } elseif (is_null($this->_toRead)) { - $data = $this->_sock->read(4096); - } else { - $data = $this->_sock->read(min(4096, $this->_toRead)); - $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - } - if ('' == $data && (!$this->_chunkLength || $this->_sock->eof())) { - break; - } else { - $hasBody = true; - if ($saveBody || $gzipped) { - $this->_body .= $data; - } - $this->_notify($gzipped? 'gzTick': 'tick', $data); - } - } - } - - if ($hasBody) { - // Uncompress the body if needed - if ($gzipped) { - $body = $this->_decodeGzip($this->_body); - if (PEAR::isError($body)) { - return $body; - } - $this->_body = $body; - $this->_notify('gotBody', $this->_body); - } else { - $this->_notify('gotBody'); - } - } - return true; - } - - - /** - * Processes the response header - * - * @access private - * @param string HTTP header - */ - function _processHeader($header) - { - if (false === strpos($header, ':')) { - return; - } - list($headername, $headervalue) = explode(':', $header, 2); - $headername = strtolower($headername); - $headervalue = ltrim($headervalue); - - if ('set-cookie' != $headername) { - if (isset($this->_headers[$headername])) { - $this->_headers[$headername] .= ',' . $headervalue; - } else { - $this->_headers[$headername] = $headervalue; - } - } else { - $this->_parseCookie($headervalue); - } - } - - - /** - * Parse a Set-Cookie header to fill $_cookies array - * - * @access private - * @param string value of Set-Cookie header - */ - function _parseCookie($headervalue) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($headervalue, ';')) { - $pos = strpos($headervalue, '='); - $cookie['name'] = trim(substr($headervalue, 0, $pos)); - $cookie['value'] = trim(substr($headervalue, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $headervalue); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->_cookies[] = $cookie; - } - - - /** - * Read a part of response body encoded with chunked Transfer-Encoding - * - * @access private - * @return string - */ - function _readChunked() - { - // at start of the next chunk? - if (0 == $this->_chunkLength) { - $line = $this->_sock->readLine(); - if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - $this->_chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // make this an eof() - return ''; - } - } else { - return ''; - } - } - $data = $this->_sock->read($this->_chunkLength); - $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // Trailing CRLF - } - return $data; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::_notify() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } - - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @access private - * @param string gzip-encoded data - * @return string decoded data - */ - function _decodeGzip($data) - { - if (HTTP_REQUEST_MBSTRING) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - return PEAR::raiseError('_decodeGzip(): unknown compression method', HTTP_REQUEST_ERROR_GZIP_METHOD); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - return PEAR::raiseError('_decodeGzip(): reserved bits are set', HTTP_REQUEST_ERROR_GZIP_DATA); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 1) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - return PEAR::raiseError('_decodeGzip(): header CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - return PEAR::raiseError('_decodeGzip(): gzinflate() call failed', HTTP_REQUEST_ERROR_GZIP_READ); - } elseif ($dataSize != strlen($unpacked)) { - return PEAR::raiseError('_decodeGzip(): data size check failed', HTTP_REQUEST_ERROR_GZIP_READ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - return PEAR::raiseError('_decodeGzip(): data CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC); - } - if (HTTP_REQUEST_MBSTRING) { - mb_internal_encoding($oldEncoding); - } - return $unpacked; - } -} // End class HTTP_Response -?> diff --git a/apps/maarch_entreprise/tools/PEAR/HTTP/Request/Listener.php b/apps/maarch_entreprise/tools/PEAR/HTTP/Request/Listener.php deleted file mode 100755 index b4fe444b35d2e5e65a84cd05b4d1b40acecaf9f9..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/HTTP/Request/Listener.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Listener for HTTP_Request and HTTP_Response objects - * - * PHP versions 4 and 5 - * - * LICENSE: - * - * Copyright (c) 2002-2007, Richard Heyes - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * o Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * o Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * o The names of the authors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request - * @author Alexey Borzov <avb@php.net> - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Listener.php,v 1.3 2007/05/18 10:33:31 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * Listener for HTTP_Request and HTTP_Response objects - * - * This class implements the Observer part of a Subject-Observer - * design pattern. - * - * @category HTTP - * @package HTTP_Request - * @author Alexey Borzov <avb@php.net> - * @version Release: 1.4.4 - */ -class HTTP_Request_Listener -{ - /** - * A listener's identifier - * @var string - */ - var $_id; - - /** - * Constructor, sets the object's identifier - * - * @access public - */ - function HTTP_Request_Listener() - { - $this->_id = md5(uniqid('http_request_', 1)); - } - - - /** - * Returns the listener's identifier - * - * @access public - * @return string - */ - function getId() - { - return $this->_id; - } - - - /** - * This method is called when Listener is notified of an event - * - * @access public - * @param object an object the listener is attached to - * @param string Event name - * @param mixed Additional data - * @abstract - */ - function update(&$subject, $event, $data = null) - { - echo "Notified of event: '$event'\n"; - if (null !== $data) { - echo "Additional data: "; - var_dump($data); - } - } -} -?> diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Base.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Base.php deleted file mode 100755 index b6dd3bfaf0e75078fae5b6452e264da7b0dbf40e..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Base.php +++ /dev/null @@ -1,1144 +0,0 @@ -<?php -/** - * This file loads all required libraries, defines constants used across the - * SOAP package, and defines the base classes that most other classes of this - * package extend. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** Define linebreak sequence for the Mail_Mime package. */ -define('MAIL_MIMEPART_CRLF', "\r\n"); - -require_once 'PEAR.php'; - -if (!defined('INF')) { - define('INF', 1.8e307); -} -if (!defined('NAN')) { - define('NAN', 0.0); -} - -define('SOAP_LIBRARY_VERSION', '0.12.0'); -define('SOAP_LIBRARY_NAME', 'PEAR-SOAP 0.12.0-beta'); - -// Set schema version. -define('SOAP_XML_SCHEMA_VERSION', 'http://www.w3.org/2001/XMLSchema'); -define('SOAP_XML_SCHEMA_INSTANCE', 'http://www.w3.org/2001/XMLSchema-instance'); -define('SOAP_XML_SCHEMA_1999', 'http://www.w3.org/1999/XMLSchema'); -define('SOAP_SCHEMA', 'http://schemas.xmlsoap.org/wsdl/soap/'); -define('SOAP_SCHEMA_ENCODING', 'http://schemas.xmlsoap.org/soap/encoding/'); -define('SOAP_ENVELOP', 'http://schemas.xmlsoap.org/soap/envelope/'); - -define('SCHEMA_DISCO', 'http://schemas.xmlsoap.org/disco/'); -define('SCHEMA_DISCO_SCL', 'http://schemas.xmlsoap.org/disco/scl/'); - -define('SCHEMA_SOAP', 'http://schemas.xmlsoap.org/wsdl/soap/'); -define('SCHEMA_SOAP12', 'http://schemas.xmlsoap.org/wsdl/soap12/'); -define('SCHEMA_SOAP_HTTP', 'http://schemas.xmlsoap.org/soap/http'); -define('SCHEMA_WSDL_HTTP', 'http://schemas.xmlsoap.org/wsdl/http/'); -define('SCHEMA_MIME', 'http://schemas.xmlsoap.org/wsdl/mime/'); -define('SCHEMA_WSDL', 'http://schemas.xmlsoap.org/wsdl/'); -define('SCHEMA_DIME', 'http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'); -define('SCHEMA_CONTENT', 'http://schemas.xmlsoap.org/ws/2002/04/content-type/'); -define('SCHEMA_REF', 'http://schemas.xmlsoap.org/ws/2002/04/reference/'); - -define('SOAP_DEFAULT_ENCODING', 'UTF-8'); - -/** - * @package SOAP - */ -class SOAP_Base_Object extends PEAR -{ - - /** - * Supported encodings, limited by XML extension. - * - * @var array $_encodings - */ - var $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8'); - - /** - * Fault code. - * - * @var string $_myfaultcode - */ - var $_myfaultcode = ''; - - /** - * Recent PEAR_Error object. - * - * @var PEAR_Error $fault - */ - var $fault = null; - - /** - * Constructor. - * - * @param string $faultcode Error code. - */ - public function __construct($faultcode = 'Client') - { - $this->_myfaultcode = $faultcode; - parent::PEAR('SOAP_Fault'); - } - - /** - * Raises a SOAP error. - * - * Please refer to the SOAP definition for an impression of what a certain - * parameter stands for. - * - * @param string|object $str Error message or object. - * @param string $detail Detailed error message. - * @param string $actorURI - * @param mixed $code - * @param mixed $mode - * @param mixed $options - * @param boolean $skipmsg - */ - function &_raiseSoapFault($str, $detail = '', $actorURI = '', $code = null, - $mode = null, $options = null, $skipmsg = false) - { - // Pass through previous faults. - $is_instance = isset($this) && is_a($this, 'SOAP_Base_Object'); - if (is_object($str)) { - $fault = $str; - } else { - if (!$code) { - $code = $is_instance ? $this->_myfaultcode : 'Client'; - } - require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php'; - $fault = new SOAP_Fault($str, $code, $actorURI, $detail, $mode, - $options); - } - if ($is_instance) { - $this->fault = $fault; - } - - return $fault; - } - - function _isfault() - { - return $this->fault != null; - } - - function &_getfault() - { - return $this->fault; - } - -} - -/** - * Common base class of all SOAP classes. - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - */ -class SOAP_Base extends SOAP_Base_Object -{ - var $_XMLSchema = array('http://www.w3.org/2001/XMLSchema', - 'http://www.w3.org/1999/XMLSchema'); - var $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; - - // load types into typemap array - var $_typemap = array( - 'http://www.w3.org/2001/XMLSchema' => array( - 'string' => 'string', - 'boolean' => 'boolean', - 'float' => 'float', - 'double' => 'float', - 'decimal' => 'float', - 'duration' => 'integer', - 'dateTime' => 'string', - 'time' => 'string', - 'date' => 'string', - 'gYearMonth' => 'integer', - 'gYear' => 'integer', - 'gMonthDay' => 'integer', - 'gDay' => 'integer', - 'gMonth' => 'integer', - 'hexBinary' => 'string', - 'base64Binary' => 'string', - // derived datatypes - 'normalizedString' => 'string', - 'token' => 'string', - 'language' => 'string', - 'NMTOKEN' => 'string', - 'NMTOKENS' => 'string', - 'Name' => 'string', - 'NCName' => 'string', - 'ID' => 'string', - 'IDREF' => 'string', - 'IDREFS' => 'string', - 'ENTITY' => 'string', - 'ENTITIES' => 'string', - 'integer' => 'integer', - 'nonPositiveInteger' => 'integer', - 'negativeInteger' => 'integer', - // longs (64bit ints) are not supported cross-platform. - 'long' => 'string', - 'int' => 'integer', - 'short' => 'integer', - 'byte' => 'string', - 'nonNegativeInteger' => 'integer', - 'unsignedLong' => 'integer', - 'unsignedInt' => 'integer', - 'unsignedShort' => 'integer', - 'unsignedByte' => 'integer', - 'positiveInteger' => 'integer', - 'anyType' => 'string', - 'anyURI' => 'string', - 'QName' => 'string' - ), - 'http://www.w3.org/1999/XMLSchema' => array( - 'i4' => 'integer', - 'int' => 'integer', - 'boolean' => 'boolean', - 'string' => 'string', - 'double' => 'float', - 'float' => 'float', - 'dateTime' => 'string', - 'timeInstant' => 'string', - 'base64Binary' => 'string', - 'base64' => 'string', - 'ur-type' => 'string' - ), - 'http://schemas.xmlsoap.org/soap/encoding/' => array( - 'base64' => 'string', - 'array' => 'array', - 'Array' => 'array', - 'Struct' => 'array') - ); - - /** - * Default class name to use for decoded response objects. - * - * @var string $_defaultObjectClassname - */ - var $_defaultObjectClassname = 'stdClass'; - - /** - * Hash with used namespaces. - * - * @var array - */ - var $_namespaces; - - /** - * The default namespace. - * - * @var string - */ - var $_namespace; - - var $_xmlEntities = array('&' => '&', - '<' => '<', - '>' => '>', - "'" => ''', - '"' => '"'); - - var $_doconversion = false; - - var $_attachments = array(); - - var $_wsdl = null; - - /** - * True if we use section 5 encoding, or false if this is literal. - * - * @var boolean $_section5 - */ - var $_section5 = true; - - // Handle type to class mapping. - var $_auto_translation = false; - var $_type_translation = array(); - - /** - * Constructor. - * - * @param string $faultcode Error code. - */ - public function __construct($faultcode = 'Client') - { - $SOAP_Base_Object = new SOAP_Base_Object($faultcode); - //parent::SOAP_Base_Object($faultcode); - $this->_resetNamespaces(); - } - - /** - * Sets the SOAP-ENV prefix and returns the current value. - * - * @access public - * - * @param string SOAP-ENV prefix - * - * @return string current SOAP-ENV prefix. - */ - function SOAPENVPrefix($prefix = null) - { - static $_soapenv_prefix = 'SOAP-ENV'; - if (!is_null($prefix)) { - $_soapenv_prefix = $prefix; - } - return $_soapenv_prefix; - } - - /** - * Sets the SOAP-ENC prefix and returns the current value. - * - * @access public - * - * @param string SOAP-ENC prefix - * - * @return string current SOAP-ENC prefix. - */ - public static function SOAPENCPrefix($prefix = null) - { - static $_soapenv_prefix = 'SOAP-ENC'; - if (!is_null($prefix)) { - $_soapenv_prefix = $prefix; - } - return $_soapenv_prefix; - } - - /** - * Sets the default namespace. - * - * @param string $namespace The default namespace. - */ - function setDefaultNamespace($namespace) - { - $this->_namespace = $namespace; - } - - function _resetNamespaces() - { - $this->_namespaces = array( - 'http://schemas.xmlsoap.org/soap/envelope/' => SOAP_BASE::SOAPENVPrefix(), - 'http://www.w3.org/2001/XMLSchema' => 'xsd', - 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi', - 'http://schemas.xmlsoap.org/soap/encoding/' => SOAP_BASE::SOAPENCPrefix()); - } - - /** - * Sets the schema version used in the SOAP message. - * - * @access private - * - * @param string $schemaVersion The schema version. - */ - function _setSchemaVersion($schemaVersion) - { - $this->_resetNamespaces(); - //var_dump($this->_namespaces);exit; - if (!in_array($schemaVersion, $this->_XMLSchema)) { - return $this->_raiseSoapFault("unsuported XMLSchema $schemaVersion"); - } - $this->_XMLSchemaVersion = $schemaVersion; - $tmpNS = array_flip($this->_namespaces); - $tmpNS['xsd'] = $this->_XMLSchemaVersion; - $tmpNS['xsi'] = $this->_XMLSchemaVersion . '-instance'; - $this->_namespaces = array_flip($tmpNS); - } - - function _getNamespacePrefix($ns) - { - if ($this->_namespace && $ns == $this->_namespace) { - return ''; - } - if (isset($this->_namespaces[$ns])) { - return $this->_namespaces[$ns]; - } - $prefix = 'ns' . count($this->_namespaces); - $this->_namespaces[$ns] = $prefix; - return $prefix; - } - - function _getNamespaceForPrefix($prefix) - { - $flipped = array_flip($this->_namespaces); - if (isset($flipped[$prefix])) { - return $flipped[$prefix]; - } - return null; - } - - /** - * Serializes a value, array or object according to the rules set by this - * object. - * - * @see SOAP_Value - * - * @param mixed $value The actual value. - * @param QName $name The value name. - * @param QName $type The value type. - * @param array $options A list of encoding and serialization options. - * @param array $attributes A hash of additional attributes. - * @param string $artype The type of any array elements. - */ - function _serializeValue($value, $name = null, $type = null, - $options = array(), $attributes = array(), - $artype = '') - { - $namespaces = array(); - $arrayType = $array_depth = $xmlout_value = null; - $typePrefix = $elPrefix = $xmlout_arrayType = ''; - $xmlout_type = $xmlns = $ptype = $array_type_ns = ''; - - if (!$name->name || is_numeric($name->name)) { - $name->name = 'item'; - } - - if ($this->_wsdl) { - list($ptype, $arrayType, $array_type_ns, $array_depth) - = $this->_wsdl->getSchemaType($type, $name); - } - - if (!$arrayType) { - $arrayType = $artype; - } - if (!$ptype) { - $ptype = $this->_getType($value); - } - if (!$type) { - $type = new QName($ptype); - } - - if (strcasecmp($ptype, 'Struct') == 0 || - strcasecmp($type->name, 'Struct') == 0) { - // Struct - $vars = is_object($value) ? get_object_vars($value) : $value; - if (is_array($vars)) { - foreach (array_keys($vars) as $k) { - // Hide private vars. - if ($k[0] == '_') { - continue; - } - - if (is_object($vars[$k])) { - if (is_a($vars[$k], 'SOAP_Value')) { - $xmlout_value .= $vars[$k]->serialize($this); - } else { - // XXX get the members and serialize them instead - // converting to an array is more overhead than we - // should really do. - $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), new QName($k, $this->_section5 ? null : $name->namepace), null, $options); - } - } else { - $xmlout_value .= $this->_serializeValue($vars[$k], new QName($k, $this->_section5 ? null : $name->namespace), false, $options); - } - } - } - } elseif (strcasecmp($ptype, 'Array') == 0 || - strcasecmp($type->name, 'Array') == 0) { - // Array. - $type = new QName('Array', SOAP_SCHEMA_ENCODING); - $numtypes = 0; - $value = (array)$value; - // XXX this will be slow on larger arrays. Basically, it flattens - // arrays to allow us to serialize multi-dimensional arrays. We - // only do this if arrayType is set, which will typically only - // happen if we are using WSDL - if (isset($options['flatten']) || - ($arrayType && - (strchr($arrayType, ',') || strstr($arrayType, '][')))) { - $numtypes = $this->_multiArrayType($value, $arrayType, - $ar_size, $xmlout_value); - } - - $array_type = $array_type_prefix = ''; - if ($numtypes != 1) { - $arrayTypeQName = new QName($arrayType); - $arrayType = $arrayTypeQName->name; - $array_types = array(); - $array_val = null; - - // Serialize each array element. - $ar_size = count($value); - foreach ($value as $array_val) { - if (is_a($array_val, 'SOAP_Value')) { - $array_type = $array_val->type; - $array_types[$array_type] = 1; - $array_type_ns = $array_val->type_namespace; - $xmlout_value .= $array_val->serialize($this); - } else { - $array_type = $this->_getType($array_val); - $array_types[$array_type] = 1; - if (empty($options['keep_arrays_flat'])) { - $xmlout_value .= $this->_serializeValue($array_val, new QName('item', $this->_section5 ? null : $name->namespace), new QName($array_type), $options); - } else { - $xmlout_value .= $this->_serializeValue($array_val, $name, new QName($array_type), $options, $attributes); - } - } - } - - if (!$arrayType) { - $numtypes = count($array_types); - if ($numtypes == 1) { - $arrayType = $array_type; - } - // Using anyType is more interoperable. - if ($array_type == 'Struct') { - $array_type = ''; - } elseif ($array_type == 'Array') { - $arrayType = 'anyType'; - $array_type_prefix = 'xsd'; - } else { - if (!$arrayType) { - $arrayType = $array_type; - } - } - } - } - if (!$arrayType || $numtypes > 1) { - // Should reference what schema we're using. - $arrayType = 'xsd:anyType'; - } else { - if ($array_type_ns) { - $array_type_prefix = $this->_getNamespacePrefix($array_type_ns); - } elseif (isset($this->_typemap[$this->_XMLSchemaVersion][$arrayType])) { - $array_type_prefix = $this->_namespaces[$this->_XMLSchemaVersion]; - } elseif (isset($this->_typemap[SOAP_SCHEMA_ENCODING][$arrayType])) { - $array_type_prefix = SOAP_BASE::SOAPENCPrefix(); - } - if ($array_type_prefix) { - $arrayType = $array_type_prefix . ':' . $arrayType; - } - } - - $xmlout_arrayType = ' ' . SOAP_BASE::SOAPENCPrefix() - . ':arrayType="' . $arrayType; - if ($array_depth != null) { - for ($i = 0; $i < $array_depth; $i++) { - $xmlout_arrayType .= '[]'; - } - } - $xmlout_arrayType .= "[$ar_size]\""; - } elseif (is_a($value, 'SOAP_Value')) { - $xmlout_value = $value->serialize($this); - } elseif ($type->name == 'string') { - $xmlout_value = htmlspecialchars($value); - } elseif ($type->name == 'rawstring') { - $xmlout_value = $value; - } elseif ($type->name == 'boolean') { - $xmlout_value = $value ? 'true' : 'false'; - } else { - $xmlout_value = $value; - } - - // Add namespaces. - if ($name->namespace) { - $elPrefix = $this->_getNamespacePrefix($name->namespace); - if ($elPrefix) { - $xmlout_name = $elPrefix . ':' . $name->name; - } else { - $xmlout_name = $name->name; - } - } else { - $xmlout_name = $name->name; - } - - if ($type->namespace) { - $typePrefix = false; - if (empty($options['no_type_prefix'])) { - $typePrefix = $this->_getNamespacePrefix($type->namespace); - } - if ($typePrefix) { - $xmlout_type = $typePrefix . ':' . $type->name; - } else { - $xmlout_type = $type->name; - } - } elseif ($type->name && - isset($this->_typemap[$this->_XMLSchemaVersion][$type->name])) { - $typePrefix = $this->_namespaces[$this->_XMLSchemaVersion]; - if ($typePrefix) { - $xmlout_type = $typePrefix . ':' . $type->name; - } else { - $xmlout_type = $type->name; - } - } - - // Handle additional attributes. - $xml_attr = ''; - if (count($attributes)) { - foreach ($attributes as $k => $v) { - $kqn = new QName($k); - $vqn = new QName($v); - $xml_attr .= ' ' . $kqn->fqn() . '="' . $vqn->fqn() . '"'; - } - } - - // Store the attachment for mime encoding. - if (isset($options['attachment']) && - !PEAR::isError($options['attachment'])) { - $this->_attachments[] = $options['attachment']; - } - - if ($this->_section5) { - if ($xmlout_type) { - $xmlout_type = " xsi:type=\"$xmlout_type\""; - } - if (is_null($xmlout_value)) { - $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . - "$xml_attr xsi:nil=\"true\"/>"; - } else { - $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . - "$xml_attr>$xmlout_value</$xmlout_name>"; - } - } elseif ($type->name == 'Array' && !empty($options['keep_arrays_flat'])) { - $xml = $xmlout_value; - } else { - if (is_null($xmlout_value)) { - $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>"; - } else { - $xml = "\r\n<$xmlout_name$xmlns$xml_attr>" . - $xmlout_value . "</$xmlout_name>"; - } - } - - return $xml; - } - - /** - * Converts a PHP type to a SOAP type. - * - * @param mixed $value The value to inspect. - * - * @return string The value's SOAP type. - */ - function _getType($value) - { - $type = gettype($value); - switch ($type) { - case 'object': - if (is_a($value, 'soap_value')) { - $type = $value->type; - } else { - $type = 'Struct'; - } - break; - - case 'array': - // Hashes are always handled as structs. - if ($this->_isHash($value)) { - $type = 'Struct'; - break; - } - if (count($value) > 1) { - // For non-wsdl structs that are all the same type - reset($value); - $value1 = next($value); - $value2 = next($value); - if (is_a($value1, 'SOAP_Value') && - is_a($value2, 'SOAP_Value') && - $value1->name != $value2->name) { - // This is a struct, not an array. - $type = 'Struct'; - break; - } - } - $type = 'Array'; - break; - - case 'integer': - case 'long': - $type = 'int'; - break; - - case 'boolean': - break; - - case 'double': - // double is deprecated in PHP 4.2 and later. - $type = 'float'; - break; - - case 'null': - $type = ''; - break; - - case 'string': - default: - break; - } - - return $type; - } - - function _multiArrayType($value, &$type, &$size, &$xml) - { - if (is_array($value)) { - // Seems we have a multi dimensional array, figure it out if we - // do. - for ($i = 0, $c = count($value); $i < $c; ++$i) { - $this->_multiArrayType($value[$i], $type, $size, $xml); - } - - $sz = count($value); - if ($size) { - $size = $sz . ',' . $size; - } else { - $size = $sz; - } - return 1; - } elseif (is_object($value)) { - $type = $value->type; - $xml .= $value->serialize($this); - } else { - $type = $this->_getType($value); - $xml .= $this->_serializeValue($value, new QName('item'), new QName($type)); - } - $size = null; - - return 1; - } - - /** - * Returns whether a type is a base64 type. - * - * @param string $type A type name. - * - * @return boolean True if the type name is a base64 type. - */ - function _isBase64Type($type) - { - return $type == 'base64' || $type == 'base64Binary'; - } - - /** - * Returns whether an array is a hash. - * - * @param array $a An array to check. - * - * @return boolean True if the specified array is a hash. - */ - function _isHash($a) - { - foreach (array_keys($a) as $k) { - // Checking the type is faster than regexp. - if (!is_int($k)) { - return true; - } - } - return false; - } - - function _un_htmlentities($string) - { - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - return strtr($string, $trans_tbl); - } - - /** - * Converts a SOAP_Value object into a PHP value. - */ - function _decode($soapval) - { - if (!is_a($soapval, 'SOAP_Value')) { - return $soapval; - } - - if (is_array($soapval->value)) { - $isstruct = $soapval->type != 'Array'; - if ($isstruct) { - $classname = $this->_defaultObjectClassname; - if (isset($this->_type_translation[$soapval->tqn->fqn()])) { - // This will force an error in PHP if the class does not - // exist. - $classname = $this->_type_translation[$soapval->tqn->fqn()]; - } elseif (isset($this->_type_translation[$soapval->type])) { - // This will force an error in PHP if the class does not - // exist. - $classname = $this->_type_translation[$soapval->type]; - } elseif ($this->_auto_translation) { - if (class_exists($soapval->type)) { - $classname = $soapval->type; - } elseif ($this->_wsdl) { - $t = $this->_wsdl->getComplexTypeNameForElement($soapval->name, $soapval->namespace); - if ($t && class_exists($t)) { - $classname = $t; - } - } - } - $return = new $classname; - } else { - $return = array(); - } - - foreach ($soapval->value as $item) { - if ($isstruct) { - if ($this->_wsdl) { - // Get this child's WSDL information. - // /$soapval->ns/$soapval->type/$item->ns/$item->name - $child_type = $this->_wsdl->getComplexTypeChildType( - $soapval->namespace, - $soapval->name, - $item->namespace, - $item->name); - if ($child_type) { - $item->type = $child_type; - } - } - if ($item->type == 'Array') { - if (isset($return->{$item->name}) && - is_object($return->{$item->name})) { - $return->{$item->name} = $this->_decode($item); - } elseif (isset($return->{$item->name}) && - is_array($return->{$item->name})) { - $return->{$item->name}[] = $this->_decode($item); - } elseif (isset($return->{$item->name})) { - $return->{$item->name} = array( - $return->{$item->name}, - $this->_decode($item) - ); - } elseif (is_array($return)) { - $return[] = $this->_decode($item); - } else { - $return->{$item->name} = $this->_decode($item); - } - } elseif (isset($return->{$item->name})) { - $d = $this->_decode($item); - if (count(get_object_vars($return)) == 1) { - $isstruct = false; - $return = array($return->{$item->name}, $d); - } else { - $return->{$item->name} = array($return->{$item->name}, $d); - } - } else { - $return->{$item->name} = $this->_decode($item); - } - // Set the attributes as members in the class. - if (method_exists($return, '__set_attribute')) { - foreach ($soapval->attributes as $key => $value) { - call_user_func_array(array(&$return, - '__set_attribute'), - array($key, $value)); - } - } - } else { - if ($soapval->arrayType && is_a($item, 'SOAP_Value')) { - if ($this->_isBase64Type($item->type) && - !$this->_isBase64Type($soapval->arrayType)) { - // Decode the value if we're losing the base64 - // type information. - $item->value = base64_decode($item->value); - } - $item->type = $soapval->arrayType; - } - $return[] = $this->_decode($item); - } - } - - return $return; - } - - if ($soapval->type == 'boolean') { - if ($soapval->value != '0' && - strcasecmp($soapval->value, 'false') != 0) { - $soapval->value = true; - } else { - $soapval->value = false; - } - } elseif ($soapval->type && - isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type])) { - // If we can, set variable type. - settype($soapval->value, - $this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]); - } elseif ($soapval->type == 'Struct') { - $soapval->value = null; - } - - return $soapval->value; - } - - /** - * Creates the SOAP envelope with the SOAP envelop data. - * - * @param SOAP_Value $method SOAP_Value instance with the method name as - * the name, and the method arguments as the - * value. - * @param array $headers A list of additional SOAP_Header objects. - * @param string $encoding The charset of the SOAP message. - * @param array $options A list of encoding/serialization options. - * - * @return string The complete SOAP message. - */ - function makeEnvelope($method, $headers, $encoding = SOAP_DEFAULT_ENCODING, - $options = array()) - { - $smsg = $header_xml = $ns_string = ''; - - if ($headers) { - for ($i = 0, $c = count($headers); $i < $c; $i++) { - $header_xml .= $headers[$i]->serialize($this); - } - $header_xml = sprintf("<%s:Header>\r\n%s\r\n</%s:Header>\r\n", - SOAP_BASE::SOAPENVPrefix(), $header_xml, - SOAP_BASE::SOAPENVPrefix()); - } - - if (!isset($options['input']) || $options['input'] == 'parse') { - if (is_array($method)) { - for ($i = 0, $c = count($method); $i < $c; $i++) { - $smsg .= $method[$i]->serialize($this); - } - } else { - $smsg = $method->serialize($this); - } - } else { - $smsg = $method; - } - $body = sprintf("<%s:Body>%s\r\n</%s:Body>\r\n", - SOAP_BASE::SOAPENVPrefix(), $smsg, - SOAP_BASE::SOAPENVPrefix()); - - foreach ($this->_namespaces as $k => $v) { - $ns_string .= "\r\n " . sprintf('xmlns:%s="%s"', $v, $k); - } - if ($this->_namespace) { - $ns_string .= "\r\n " . sprintf('xmlns="%s"', $this->_namespace); - } - - /* If 'use' == 'literal', do not put in the encodingStyle. This is - * denoted by $this->_section5 being false. 'use' can be defined at a - * more granular level than we are dealing with here, so this does not - * work for all services. */ - $xml = sprintf('<?xml version="1.0" encoding="%s"?>%s<%s:Envelope%s', - $encoding, "\r\n", SOAP_BASE::SOAPENVPrefix(), - $ns_string); - if ($this->_section5) { - $xml .= "\r\n " . sprintf('%s:encodingStyle="%s"', - SOAP_BASE::SOAPENVPrefix(), - SOAP_SCHEMA_ENCODING); - } - $xml .= sprintf('>%s%s%s</%s:Envelope>' . "\r\n", - "\r\n", $header_xml, $body, SOAP_BASE::SOAPENVPrefix()); - - return $xml; - } - - function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING) - { - if (!@include_once 'Mail/mimePart.php') { - return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); - } - - // Encode any attachments. See http://www.w3.org/TR/SOAP-attachments - // Now we have to mime encode the message. - $params = array('content_type' => 'multipart/related; type="text/xml"'); - $msg = new Mail_mimePart('', $params); - - // Add the xml part. - $params['content_type'] = 'text/xml'; - $params['charset'] = $encoding; - $msg->addSubPart($xml, $params); - - // Add the attachements - for ($i = 0, $c = count($this->_attachments); $i < $c; ++$i) { - $msg->addSubPart($this->_attachments[$i]['body'], - $this->_attachments[$i]); - } - - return $msg->encode(); - } - - // TODO: this needs to be used from the Transport system. - function _makeDIMEMessage($xml) - { - if (!@include_once 'Net/DIME.php') { - return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed'); - } - - // Encode any attachments. See - // http://search.ietf.org/internet-drafts/draft-nielsen-dime-soap-00.txt - // Now we have to DIME encode the message - $dime = new Net_DIME_Message(); - $msg = $dime->encodeData($xml, SOAP_ENVELOP, null, NET_DIME_TYPE_URI); - - // Add the attachments. - $c = count($this->_attachments); - for ($i = 0; $i < $c; $i++) { - $msg .= $dime->encodeData($this->_attachments[$i]['body'], - $this->_attachments[$i]['content_type'], - $this->_attachments[$i]['cid'], - NET_DIME_TYPE_MEDIA); - } - $msg .= $dime->endMessage(); - - return $msg; - } - - function _decodeMimeMessage(&$data, &$headers, &$attachments) - { - if (!@include_once 'Mail/mimeDecode.php') { - return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); - } - - $params['include_bodies'] = true; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - - // Lame thing to have to do for decoding. - $decoder = new Mail_mimeDecode($data); - $structure = $decoder->decode($params); - - if (isset($structure->body)) { - $data = $structure->body; - $headers = $structure->headers; - - return; - } elseif (isset($structure->parts)) { - $data = $structure->parts[0]->body; - $headers = array_merge($structure->headers, - $structure->parts[0]->headers); - if (count($structure->parts) <= 1) { - return; - } - - $mime_parts = array_splice($structure->parts, 1); - // Prepare the parts for the SOAP parser. - for ($i = 0, $c = count($mime_parts); $i < $c; $i++) { - $p = $mime_parts[$i]; - if (isset($p->headers['content-location'])) { - // TODO: modify location per SwA note section 3 - // http://www.w3.org/TR/SOAP-attachments - $attachments[$p->headers['content-location']] = $p->body; - } else { - $cid = 'cid:' . substr($p->headers['content-id'], 1, -1); - $attachments[$cid] = $p->body; - } - } - - return; - } - - $this->_raiseSoapFault('Mime parsing error', '', '', 'Server'); - } - - function _decodeDIMEMessage(&$data, &$headers, &$attachments) - { - if (!@include_once 'Net/DIME.php') { - return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed'); - } - - // This SHOULD be moved to the transport layer, e.g. PHP itself should - // handle parsing DIME ;) - $dime = new Net_DIME_Message(); - $err = $dime->decodeData($data); - if (PEAR::isError($err)) { - $this->_raiseSoapFault('Failed to decode the DIME message!', '', '', 'Server'); - return; - } - if (strcasecmp($dime->parts[0]['type'], SOAP_ENVELOP) != 0) { - $this->_raiseSoapFault('DIME record 1 is not a SOAP envelop!', '', '', 'Server'); - return; - } - - $data = $dime->parts[0]['data']; - // Fake it for now. - $headers['content-type'] = 'text/xml'; - $c = count($dime->parts); - for ($i = 0; $i < $c; $i++) { - $part =& $dime->parts[$i]; - // We need to handle URI's better. - $id = strncmp($part['id'], 'cid:', 4) - ? 'cid:' . $part['id'] - : $part['id']; - $attachments[$id] = $part['data']; - } - } - - /** - * Explicitly sets the translation for a specific class. - * - * Auto translation works for all cases, but opens ANY class in the script - * to be used as a data type, and may not be desireable. - * - * @param string $type A SOAP type. - * @param string $class A PHP class name. - */ - function setTypeTranslation($type, $class = null) - { - $tq = new QName($type); - if (!$class) { - $class = $tq->name; - } - $this->_type_translation[$type]=$class; - } - -} - -/** - * Class used to handle QNAME values in XML. - * - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - */ -class QName -{ - var $name = ''; - var $ns = ''; - var $namespace = ''; - - public function __construct($name, $namespace = '') - { - if ($name && $name[0] == '{') { - preg_match('/\{(.*?)\}(.*)/', $name, $m); - $this->name = $m[2]; - $this->namespace = $m[1]; - } elseif (substr_count($name, ':') == 1) { - $s = explode(':', $name); - $s = array_reverse($s); - $this->name = $s[0]; - $this->ns = $s[1]; - $this->namespace = $namespace; - } else { - $this->name = $name; - $this->namespace = $namespace; - } - - // A little more magic than should be in a qname. - $p = strpos($this->name, '['); - if ($p) { - // TODO: Need to re-examine this logic later. - // Chop off []. - $this->arraySize = explode(',', substr($this->name, $p + 1, -$p - 2)); - $this->arrayInfo = substr($this->name, $p); - $this->name = substr($this->name, 0, $p); - } - } - - function fqn() - { - if ($this->namespace) { - return '{' . $this->namespace . '}' . $this->name; - } elseif ($this->ns) { - return $this->ns . ':' . $this->name; - } - return $this->name; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Client.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Client.php deleted file mode 100755 index 5fb354a2c1e55c6db71123e0f05ac21975acb613..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Client.php +++ /dev/null @@ -1,838 +0,0 @@ -<?php -/** - * This file contains the code for the SOAP client. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Value */ -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Value.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Parser.php'; - -// Arnaud: the following code was taken from DataObject and adapted to suit - -// this will be horrifically slow!!!! -// NOTE: Overload SEGFAULTS ON PHP4 + Zend Optimizer -// these two are BC/FC handlers for call in PHP4/5 - -/** - * @package SOAP - */ -if (!class_exists('SOAP_Client_Overload')) { - if (substr(zend_version(), 0, 1) > 1) { - class SOAP_Client_Overload extends SOAP_Base { - function __call($method, $args) - { - $return = null; - $this->_call($method, $args, $return); - return $return; - } - } - } else { - if (!function_exists('clone')) { - eval('function clone($t) { return $t; }'); - } - eval(' - class SOAP_Client_Overload extends SOAP_Base { - function __call($method, $args, &$return) - { - return $this->_call($method, $args, $return); - } - }'); - } -} - -/** - * SOAP Client Class - * - * This class is the main interface for making soap requests. - * - * basic usage:<code> - * $soapclient = new SOAP_Client( string path [ , boolean wsdl] ); - * echo $soapclient->call( string methodname [ , array parameters] ); - * </code> - * or, if using PHP 5+ or the overload extension:<code> - * $soapclient = new SOAP_Client( string path [ , boolean wsdl] ); - * echo $soapclient->methodname( [ array parameters] ); - * </code> - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Stig Bakken <ssb@fast.no> Conversion to PEAR - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Client extends SOAP_Client_Overload -{ - /** - * Communication endpoint. - * - * Currently the following transport formats are supported: - * - HTTP - * - SMTP - * - * Example endpoints: - * http://www.example.com/soap/server.php - * https://www.example.com/soap/server.php - * mailto:soap@example.com - * - * @see SOAP_Client() - * @var string - */ - var $_endpoint = ''; - - /** - * The SOAP PORT name that is used by the client. - * - * @var string - */ - var $_portName = ''; - - /** - * Endpoint type e.g. 'wdsl'. - * - * @var string - */ - var $_endpointType = ''; - - /** - * The received xml. - * - * @var string - */ - var $xml; - - /** - * The outgoing and incoming data stream for debugging. - * - * @var string - */ - var $wire; - - /** - * The outgoing data stream for debugging. - * - * @var string - */ - var $_last_request = null; - - /** - * The incoming data stream for debugging. - * - * @var string - */ - var $_last_response = null; - - /** - * Options. - * - * @var array - */ - var $_options = array('trace' => false); - - /** - * The character encoding used for XML parser, etc. - * - * @var string - */ - var $_encoding = SOAP_DEFAULT_ENCODING; - - /** - * The array of SOAP_Headers that we are sending. - * - * @var array - */ - var $headersOut = null; - - /** - * The headers we recieved back in the response. - * - * @var array - */ - var $headersIn = null; - - /** - * Options for the HTTP_Request class (see HTTP/Request.php). - * - * @var array - */ - var $_proxy_params = array(); - - /** - * The SOAP_Transport instance. - * - * @var SOAP_Transport - */ - var $_soap_transport = null; - - /** - * Constructor. - * - * @access public - * - * @param string $endpoint An URL. - * @param boolean $wsdl Whether the endpoint is a WSDL file. - * @param string $portName The service's port name to use. - * @param array $proxy_params Options for the HTTP_Request class - * @see HTTP_Request - * @param boolean|string $cache Use WSDL caching? The cache directory if - * a string. - */ - public function __construct($endpoint, $wsdl = false, $portName = false, - $proxy_params = array(), $cache = false) - { - $SOAP_Base = new SOAP_Base('Client'); - //parent::SOAP_Base('Client'); - - $this->_endpoint = $endpoint; - $this->_portName = $portName; - $this->_proxy_params = $proxy_params; - - // This hack should perhaps be removed as it might cause unexpected - // behaviour. - $wsdl = $wsdl - ? $wsdl - : strtolower(substr($endpoint, -4)) == 'wsdl'; - - // make values - if ($wsdl) { - $this->_endpointType = 'wsdl'; - // instantiate wsdl class - $this->_wsdl = new SOAP_WSDL($this->_endpoint, - $this->_proxy_params, - $cache); - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - } - - function _reset() - { - $this->xml = null; - $this->wire = null; - $this->_last_request = null; - $this->_last_response = null; - $this->headersIn = null; - $this->headersOut = null; - } - - /** - * Sets the character encoding. - * - * Limited to 'UTF-8', 'US_ASCII' and 'ISO-8859-1'. - * - * @access public - * - * @param string encoding - * - * @return mixed SOAP_Fault on error. - */ - function setEncoding($encoding) - { - if (in_array($encoding, $this->_encodings)) { - $this->_encoding = $encoding; - return; - } - return $this->_raiseSoapFault('Invalid Encoding'); - } - - /** - * Adds a header to the envelope. - * - * @access public - * - * @param SOAP_Header $soap_value A SOAP_Header or an array with the - * elements 'name', 'namespace', - * 'mustunderstand', and 'actor' to send - * as a header. - */ - function addHeader($soap_value) - { - // Add a new header to the message. - if (is_a($soap_value, 'SOAP_Header')) { - $this->headersOut[] = $soap_value; - } elseif (is_array($soap_value)) { - // name, value, namespace, mustunderstand, actor - $this->headersOut[] = new SOAP_Header($soap_value[0], - null, - $soap_value[1], - $soap_value[2], - $soap_value[3]); - } else { - $this->_raiseSoapFault('Invalid parameter provided to addHeader(). Must be an array or a SOAP_Header.'); - } - } - - /** - * Calls a method on the SOAP endpoint. - * - * The namespace parameter is overloaded to accept an array of options - * that can contain data necessary for various transports if it is used as - * an array, it MAY contain a namespace value and a soapaction value. If - * it is overloaded, the soapaction parameter is ignored and MUST be - * placed in the options array. This is done to provide backwards - * compatibility with current clients, but may be removed in the future. - * The currently supported values are: - * - 'namespace' - * - 'soapaction' - * - 'timeout': HTTP socket timeout - * - 'transfer-encoding': SMTP transport, Content-Transfer-Encoding: header - * - 'from': SMTP transport, From: header - * - 'subject': SMTP transport, Subject: header - * - 'headers': SMTP transport, hash of extra SMTP headers - * - 'attachments': what encoding to use for attachments (Mime, Dime) - * - 'trace': whether to trace the SOAP communication - * - 'style': 'document' or 'rpc'; when set to 'document' the parameters - * are not wrapped inside a tag with the SOAP action name - * - 'use': 'literal' for literal encoding, anything else for section 5 - * encoding; when set to 'literal' SOAP types will be omitted. - * - 'keep_arrays_flat': use the tag name multiple times for each element - * when passing in an array in literal mode - * - 'no_type_prefix': supress adding of the namespace prefix - * - * @access public - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param string|array $namespace Namespace or hash with options. Note: - * most options need to be repeated for - * SOAP_Value instances. - * @param string $soapAction - * - * @return mixed The method result or a SOAP_Fault on error. - */ - function call($method, $params, $namespace = false, $soapAction = false) - { - $this->headersIn = null; - $this->_last_request = null; - $this->_last_response = null; - $this->wire = null; - $this->xml = null; - - $soap_data = $this->_generate($method, $params, $namespace, $soapAction); - if (PEAR::isError($soap_data)) { - $fault = $this->_raiseSoapFault($soap_data); - return $fault; - } - - // _generate() may have changed the endpoint if the WSDL has more - // than one service, so we need to see if we need to generate a new - // transport to hook to a different URI. Since the transport protocol - // can also change, we need to get an entirely new object. This could - // probably be optimized. - if (!$this->_soap_transport || - $this->_endpoint != $this->_soap_transport->url) { - $SOAP_TransportObj = new SOAP_Transport(); - $this->_soap_transport = $SOAP_TransportObj->getTransport($this->_endpoint); - if (PEAR::isError($this->_soap_transport)) { - $fault = $this->_raiseSoapFault($this->_soap_transport); - $this->_soap_transport = null; - return $fault; - } - } - $this->_soap_transport->encoding = $this->_encoding; - - // Send the message. - $transport_options = array_merge_recursive($this->_proxy_params, - $this->_options); - $this->xml = $this->_soap_transport->send($soap_data, $transport_options); - - // Save the wire information for debugging. - if ($this->_options['trace']) { - $this->_last_request = $this->_soap_transport->outgoing_payload; - $this->_last_response = $this->_soap_transport->incoming_payload; - $this->wire = $this->getWire(); - } - if ($this->_soap_transport->fault) { - $fault = $this->_raiseSoapFault($this->xml); - return $fault; - } - - if (isset($this->_options['result']) && - $this->_options['result'] != 'parse') { - return $this->xml; - } - - $this->__result_encoding = $this->_soap_transport->result_encoding; - - $result = $this->parseResponse($this->xml, $this->__result_encoding, - $this->_soap_transport->attachments); - return $result; - } - - /** - * Sets an option to use with the transport layers. - * - * For example: - * <code> - * $soapclient->setOpt('curl', CURLOPT_VERBOSE, 1) - * </code> - * to pass a specific option to curl if using an SSL connection. - * - * @access public - * - * @param string $category Category to which the option applies or option - * name. - * @param string $option An option name if $category is a category name, - * an option value if $category is an option name. - * @param string $value An option value if $category is a category - * name. - */ - function setOpt($category, $option, $value = null) - { - if (!is_null($value)) { - if (!isset($this->_options[$category])) { - $this->_options[$category] = array(); - } - $this->_options[$category][$option] = $value; - } else { - $this->_options[$category] = $option; - } - } - - /** - * Call method supporting the overload extension. - * - * If the overload extension is loaded, you can call the client class with - * a soap method name: - * <code> - * $soap = new SOAP_Client(....); - * $value = $soap->getStockQuote('MSFT'); - * </code> - * - * @access public - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param mixed $return_value Will get the method's return value - * assigned. - * - * @return boolean Always true. - */ - function _call($method, $params, &$return_value) - { - // Overloading lowercases the method name, we need to look into the - // WSDL and try to find the correct method name to get the correct - // case for the call. - if ($this->_wsdl) { - $this->_wsdl->matchMethod($method); - } - - $return_value = $this->call($method, $params); - - return true; - } - - /** - * Returns the XML content of the last SOAP request. - * - * @return string The last request. - */ - function getLastRequest() - { - return $this->_last_request; - } - - /** - * Returns the XML content of the last SOAP response. - * - * @return string The last response. - */ - function getLastResponse() - { - return $this->_last_response; - } - - /** - * Sets the SOAP encoding. - * - * The default encoding is section 5 encoded. - * - * @param string $use Either 'literal' or 'encoded' (section 5). - */ - function setUse($use) - { - $this->_options['use'] = $use; - } - - /** - * Sets the SOAP encoding style. - * - * The default style is rpc. - * - * @param string $style Either 'document' or 'rpc'. - */ - function setStyle($style) - { - $this->_options['style'] = $style; - } - - /** - * Sets whether to trace the traffic on the transport level. - * - * @see getWire() - * - * @param boolean $trace - */ - function setTrace($trace) - { - $this->_options['trace'] = $trace; - } - - /** - * Generates the complete XML SOAP message for an RPC call. - * - * @see call() - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param string|array $namespace Namespace or hash with options. Note: - * most options need to be repeated for - * SOAP_Value instances. - * @param string $soapAction - * - * @return string The SOAP message including envelope. - */ - function _generate($method, $params, $namespace = false, - $soapAction = false) - { - $this->fault = null; - $this->_options['input'] = 'parse'; - $this->_options['result'] = 'parse'; - $this->_options['parameters'] = false; - - if ($params && !is_array($params)) { - $params = array($params); - } - - if (is_array($namespace)) { - // Options passed as a hash. - foreach ($namespace as $optname => $opt) { - $this->_options[strtolower($optname)] = $opt; - } - } else { - // We'll place $soapAction into our array for usage in the - // transport. - if ($soapAction) { - $this->_options['soapaction'] = $soapAction; - } - if ($namespace) { - $this->_options['namespace'] = $namespace; - } - } - if (isset($this->_options['namespace'])) { - $namespace = $this->_options['namespace']; - } else { - $namespace = false; - } - - if ($this->_endpointType == 'wsdl') { - $this->_setSchemaVersion($this->_wsdl->xsd); - - // Get port name. - if (!$this->_portName) { - $this->_portName = $this->_wsdl->getPortName($method); - } - if (PEAR::isError($this->_portName)) { - return $this->_raiseSoapFault($this->_portName); - } - - // Get endpoint. - $this->_endpoint = $this->_wsdl->getEndpoint($this->_portName); - if (PEAR::isError($this->_endpoint)) { - return $this->_raiseSoapFault($this->_endpoint); - } - - // Get operation data. - $opData = $this->_wsdl->getOperationData($this->_portName, $method); - - if (PEAR::isError($opData)) { - return $this->_raiseSoapFault($opData); - } - $namespace = $opData['namespace']; - $this->_options['style'] = $opData['style']; - $this->_options['use'] = $opData['input']['use']; - $this->_options['soapaction'] = $opData['soapAction']; - - // Set input parameters. - if ($this->_options['input'] == 'parse') { - $this->_options['parameters'] = $opData['parameters']; - $nparams = array(); - if (isset($opData['input']['parts']) && - count($opData['input']['parts'])) { - foreach ($opData['input']['parts'] as $name => $part) { - $xmlns = ''; - $attrs = array(); - // Is the name a complex type? - if (isset($part['element'])) { - $xmlns = $this->_wsdl->namespaces[$part['namespace']]; - $part = $this->_wsdl->elements[$part['namespace']][$part['type']]; - $name = $part['name']; - } - if (isset($params[$name]) || - $this->_wsdl->getDataHandler($name, $part['namespace'])) { - $nparams[$name] =& $params[$name]; - } else { - // We now force an associative array for - // parameters if using WSDL. - return $this->_raiseSoapFault("The named parameter $name is not in the call parameters."); - } - if (gettype($nparams[$name]) != 'object' || - !is_a($nparams[$name], 'SOAP_Value')) { - // Type is likely a qname, split it apart, and get - // the type namespace from WSDL. - $qname = new QName($part['type']); - if ($qname->ns) { - $type_namespace = $this->_wsdl->namespaces[$qname->ns]; - } elseif (isset($part['namespace'])) { - $type_namespace = $this->_wsdl->namespaces[$part['namespace']]; - } else { - $type_namespace = null; - } - $qname->namespace = $type_namespace; - $pqname = $name; - if ($xmlns) { - $pqname = '{' . $xmlns . '}' . $name; - } - $nparams[$name] = new SOAP_Value($pqname, - $qname->fqn(), - $nparams[$name], - $attrs); - } else { - // WSDL fixups to the SOAP value. - } - } - } - $params =& $nparams; - unset($nparams); - } - } else { - $this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION); - } - - // Serialize the message. - $this->_section5 = (!isset($this->_options['use']) || - $this->_options['use'] != 'literal'); - - if (!isset($this->_options['style']) || - $this->_options['style'] == 'rpc') { - $this->_options['style'] = 'rpc'; - $this->docparams = true; - $mqname = new QName($method, $namespace); - $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params, - array(), $this->_options); - $soap_msg = $this->makeEnvelope($methodValue, - $this->headersOut, - $this->_encoding, - $this->_options); - } else { - if (!$params) { - $mqname = new QName($method, $namespace); - $params = new SOAP_Value($mqname->fqn(), 'Struct', null); - } elseif ($this->_options['input'] == 'parse') { - if (is_array($params)) { - $nparams = array(); - $keys = array_keys($params); - foreach ($keys as $k) { - if (gettype($params[$k]) != 'object') { - $nparams[] = new SOAP_Value($k, - false, - $params[$k]); - } else { - $nparams[] =& $params[$k]; - } - } - $params =& $nparams; - } - if ($this->_options['parameters']) { - $mqname = new QName($method, $namespace); - $params = new SOAP_Value($mqname->fqn(), - 'Struct', - $params); - } - } - $soap_msg = $this->makeEnvelope($params, - $this->headersOut, - $this->_encoding, - $this->_options); - } - $this->headersOut = null; - - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - - // Handle MIME or DIME encoding. - // TODO: DIME encoding should move to the transport, do it here for - // now and for ease of getting it done. - if (count($this->_attachments)) { - if ((isset($this->_options['attachments']) && - $this->_options['attachments'] == 'Mime') || - isset($this->_options['Mime'])) { - $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding); - } else { - // default is dime - $soap_msg = $this->_makeDIMEMessage($soap_msg, $this->_encoding); - $this->_options['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - } - - // Instantiate client. - if (is_array($soap_msg)) { - $soap_data = $soap_msg['body']; - if (count($soap_msg['headers'])) { - if (isset($this->_options['headers'])) { - $this->_options['headers'] = array_merge($this->_options['headers'], $soap_msg['headers']); - } else { - $this->_options['headers'] = $soap_msg['headers']; - } - } - } else { - $soap_data = $soap_msg; - } - - return $soap_data; - } - - /** - * Parses a SOAP response. - * - * - * @param string $response XML content of SOAP response. - * @param string $encoding Character set encoding, defaults to 'UTF-8'. - * @param array $attachments List of attachments. - */ - function parseResponse($response, $encoding, $attachments) - { - // Parse the response. - $response = new SOAP_Parser($response, $encoding, $attachments); - if ($response->fault) { - $fault = $this->_raiseSoapFault($response->fault); - return $fault; - } - - // Return array of parameters. - $return = $response->getResponse(); - $headers = $response->getHeaders(); - if ($headers) { - $this->headersIn = $this->_decodeResponse($headers, false); - } - - $decoded = $this->_decodeResponse($return); - return $decoded; - } - - /** - * Converts a complex SOAP_Value into a PHP Array - * - * @param SOAP_Value $response Value object. - * @param boolean $shift - * - * @return array - */ - function _decodeResponse($response, $shift = true) - { - if (!$response) { - $decoded = null; - return $decoded; - } - - // Check for valid response. - if (PEAR::isError($response)) { - $fault = $this->_raiseSoapFault($response); - return $fault; - } elseif (!is_a($response, 'soap_value')) { - $fault = $this->_raiseSoapFault("Didn't get SOAP_Value object back from client"); - return $fault; - } - - // Decode to native php datatype. - $returnArray = $this->_decode($response); - - // Fault? - if (PEAR::isError($returnArray)) { - $fault = $this->_raiseSoapFault($returnArray); - return $fault; - } - - if (is_object($returnArray) && - strcasecmp(get_class($returnArray), 'stdClass') == 0) { - $returnArray = get_object_vars($returnArray); - } - - if (is_array($returnArray)) { - if (isset($returnArray['faultcode']) || - isset($returnArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) { - $faultcode = $faultstring = $faultdetail = $faultactor = ''; - foreach ($returnArray as $k => $v) { - if (stristr($k, 'faultcode')) $faultcode = $v; - if (stristr($k, 'faultstring')) $faultstring = $v; - if (stristr($k, 'detail')) $faultdetail = $v; - if (stristr($k, 'faultactor')) $faultactor = $v; - } - $fault = $this->_raiseSoapFault($faultstring, $faultdetail, - $faultactor, $faultcode); - return $fault; - } - // Return array of return values. - if ($shift && count($returnArray) == 1) { - $decoded = array_shift($returnArray); - return $decoded; - } - return $returnArray; - } - - return $returnArray; - } - - /** - * Returns the outgoing and incoming traffic on the transport level. - * - * Tracing has to be enabled. - * - * @see setTrace() - * - * @return string The complete traffic between the client and the server. - */ - function getWire() - { - if ($this->_options['trace'] && - ($this->_last_request || $this->_last_response)) { - return "OUTGOING:\n\n" . - $this->_last_request . - "\n\nINCOMING\n\n" . - preg_replace("/></",">\r\n<", $this->_last_response); - } - - return null; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Disco.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Disco.php deleted file mode 100755 index 700e810d949f617fb87b062cafaf5d564597af96..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Disco.php +++ /dev/null @@ -1,406 +0,0 @@ -<?php -/** - * This file contains the code for the DISCO server, providing DISO and WSDL - * services. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dmitri Vinogradov <dimitri@vinogradov.de> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Jan Schneider <jan@horde.org> - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Base */ -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; - -/** - * @package SOAP - */ -class SOAP_DISCO_Server extends SOAP_Base_Object { - - var $namespaces = array(SCHEMA_WSDL => 'wsdl', SCHEMA_SOAP => 'soap'); - var $import_ns = array(); - var $wsdl = ''; - var $disco = ''; - var $_wsdl = array(); - var $_disco = array(); - var $_service_name = ''; - var $_service_ns = ''; - var $_service_desc = ''; - var $_portname = ''; - var $_bindingname = ''; - var $soap_server = NULL; - - - public function __construct($soap_server, $service_name, $service_desc = '', - $import_ns = null) - { - $SOAP_Base_Object = new SOAP_Base_Object('Server'); - //parent::SOAP_Base_Object('Server'); - - if ( !is_object($soap_server) - || !get_class($soap_server) == 'soap_server') return; - - $this->_service_name = $service_name; - $this->_service_ns = "urn:$service_name"; - $this->_service_desc = $service_desc; - $this->import_ns = isset($import_ns) ? $import_ns : $this->import_ns; - $this->soap_server = $soap_server; - $this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; - //var_dump($this->soap_server->dispatch_objects); - } - - function getDISCO() - { - $this->_generate_DISCO(); - return $this->disco; - } - - function getWSDL() - { - $this->_generate_WSDL(); - return $this->wsdl; - } - - function _generate_DISCO() - { - // DISCO - $this->_disco['disco:discovery']['attr']['xmlns:disco'] = SCHEMA_DISCO; - $this->_disco['disco:discovery']['attr']['xmlns:scl'] = SCHEMA_DISCO_SCL; - $this->_disco['disco:discovery']['scl:contractRef']['attr']['ref'] = - (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') - ? 'https://' . $this->host . $_SERVER['PHP_SELF'] . '?wsdl' - : 'http://' . $this->host . $_SERVER['PHP_SELF'] . '?wsdl'; - - // generate disco xml - $this->_generate_DISCO_XML($this->_disco); - } - - function _generate_WSDL() - { - // WSDL - if (is_array($this->soap_server->_namespaces)) { - //echo 'laaaaaaa';exit; - // need to get: typens, xsd & SOAP-ENC - $flipped = array_flip($this->soap_server->_namespaces); - $this->namespaces[$this->_service_ns] = 'tns'; - //$this->namespaces[$flipped['xsd']] = 'xsd'; - $this->namespaces['http://www.w3.org/2001/XMLSchema'] = 'xsd'; - //$this->namespaces[$flipped[SOAP_BASE::SOAPENCPrefix()]] = SOAP_BASE::SOAPENCPrefix(); - $this->namespaces['http://schemas.xmlsoap.org/soap/encoding/'] = 'SOAP-ENC'; - } - - // DEFINITIONS - $this->_wsdl['definitions']['attr']['name'] = $this->_service_name; - $this->_wsdl['definitions']['attr']['targetNamespace'] = $this->_service_ns; - foreach ($this->namespaces as $ns => $prefix) { - $this->_wsdl['definitions']['attr']['xmlns:' . $prefix] = $ns; - } - - $this->_wsdl['definitions']['attr']['xmlns'] = SCHEMA_WSDL;; - - // Import namespaces. Seems to not work yet: wsdl.exe fom .NET can't - // handle imported complete wsdl-definitions. - if (count($this->import_ns)) { - $i = 0; - foreach ($this->import_ns as $_ns => $_location) { - $this->_wsdl['definitions']['import'][$i]['attr']['location'] = $_location; - $this->_wsdl['definitions']['import'][$i]['attr']['namespace'] = $_ns; - $i++; - } - } - $this->_wsdl['definitions']['types']['attr']['xmlns']='http://schemas.xmlsoap.org/wsdl/'; - $this->_wsdl['definitions']['types']['schema']=array(); - - // Placeholder for messages - $this->_wsdl['definitions']['message'] = array(); - - // PORTTYPE-NAME - $this->_portname = $this->_service_name . 'Port'; - $this->_wsdl['definitions']['portType']['attr']['name'] = $this->_portname; - - // BINDING-NAME - $this->_bindingname = $this->_service_name . 'Binding'; - $this->_wsdl['definitions']['binding']['attr']['name'] = $this->_bindingname; - $this->_wsdl['definitions']['binding']['attr']['type'] = 'tns:' . $this->_portname; - $this->_wsdl['definitions']['binding']['soap:binding']['attr']['style'] = 'rpc'; - $this->_wsdl['definitions']['binding']['soap:binding']['attr']['transport'] = SCHEMA_SOAP_HTTP; - - // SERVICE - $this->_wsdl['definitions']['service']['attr']['name'] = $this->_service_name . 'Service'; - $this->_wsdl['definitions']['service']['documentation']['attr'] = ''; - $this->_wsdl['definitions']['service']['documentation'] = htmlentities($this->_service_desc); - $this->_wsdl['definitions']['service']['port']['attr']['name'] = $this->_portname; - $this->_wsdl['definitions']['service']['port']['attr']['binding'] = 'tns:' . $this->_bindingname; - $this->_wsdl['definitions']['service']['port']['soap:address']['attr']['location'] = - (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') - ? 'https://' . $this->host . $_SERVER['PHP_SELF'] - : 'http://' . $this->host . $_SERVER['PHP_SELF']; - - // - $dispatch_keys = array_keys($this->soap_server->dispatch_objects); - $dc = count($dispatch_keys); - for ($di = 0; $di < $dc; $di++) { - $namespace = $dispatch_keys[$di]; - $namespace_objects =& $this->soap_server->dispatch_objects[$namespace]; - $oc = count($namespace_objects); - for ($oi = 0; $oi < $oc; $oi++) { - $object = $namespace_objects[$oi]; - // types definitions - $this->addSchemaFromMap($object->__typedef); - // MESSAGES - $this->addMethodsFromMap($object->__dispatch_map, $namespace, get_class($object)); - } - } - if (isset($this->soap_server->dispatch_map)) { - $this->addMethodsFromMap($this->soap_server->dispatch_map, $namespace); - } - - // generate wsdl - $this->_generate_WSDL_XML(); - } - - function &_getSchema($namespace) - { - // SCHEMA - $c = count($this->_wsdl['definitions']['types']['schema']); - for($i = 0; $i < $c; $i++) { - if ($this->_wsdl['definitions']['types']['schema'][$i]['attr']['targetNamespace'] == $namespace) { - return $this->_wsdl['definitions']['types']['schema'][$i]; - } - } - - // don't have this namespace - $schema = array(); - //$schema['xsd:import'][0]['attr']['namespace'] = "http://schemas.xmlsoap.org/soap/encoding/"; - $schema['attr'] = array(); - $schema['complexType'] = array(); - $schema['attr']['xmlns'] = array_search('xsd',$this->namespaces); - $schema['attr']['targetNamespace'] = $namespace; - $this->_wsdl['definitions']['types']['schema'][] =& $schema; - - return $schema; - } - - function addSchemaFromMap(&$map) - { - if (!$map) { - return; - } - - foreach ($map as $_type_name => $_type_def) { - list($typens,$type) = $this->_getTypeNs($_type_name); - if ($typens == 'xsd') { - // cannot add to xsd, lets use method_namespace - $typens = 'tns'; - } - $schema =& $this->_getSchema(array_search($typens, $this->namespaces)); - if (!$this->_ifComplexTypeExists($schema['complexType'], $type)) { - $ctype =& $schema['complexType'][]; - $ctype['attr']['name'] = $type; - foreach ($_type_def as $_varname => $_vartype) { - if (!is_int($_varname)) { - list($_vartypens,$_vartype) = $this->_getTypeNs($_vartype); - $ctype['all']['attr'] = ''; - $el =& $ctype['all']['element'][]; - $el['attr']['name'] = $_varname; - $el['attr']['type'] = $_vartypens . ':' . $_vartype; - } else { - /*$ctype['complexContent']['attr'] = ''; - $ctype['complexContent']['restriction']['attr']['base'] = SOAP_BASE::SOAPENCPrefix().':Array'; - foreach ($_vartype as $array_type) { - list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = SOAP_BASE::SOAPENCPrefix().':arrayType'; - $ctype['complexContent']['restriction']['attribute']['attr']['wsdl:arrayType'] = $_vartypens . ':' . $_vartype . '[]'; - }*/ - $ctype['sequence']['attr'] = ''; - $theElement =& $ctype['sequence']['element'][]; - foreach ($_vartype as $array_type) { - $theElement['attr']['name']= 'datas'; - list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - $theElement['attr']['type']= $_vartypens . ':' . $_vartype; - $theElement['attr']['minOccurs']= '0'; - $theElement['attr']['maxOccurs']= 'unbounded'; - //list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - //$ctype['complexContent']['restriction']['attribute']['attr']['ref'] = SOAP_BASE::SOAPENCPrefix().':arrayType'; - //$ctype['complexContent']['restriction']['attribute']['attr']['wsdl:arrayType'] = $_vartypens . ':' . $_vartype . '[]'; - } - } - } - } - } - } - - function addMethodsFromMap(&$map, $namespace, $classname = null) - { - if (!$map) { - return; - } - - foreach ($map as $method_name => $method_types) { - if (array_key_exists('namespace', $method_types)) { - $method_namespace = $method_types['namespace']; - } else { - $method_namespace = $namespace; - } - - // INPUT - $input_message = array('attr' => array('name' => $method_name . 'Request')); - if (isset($method_types['in']) && is_array($method_types['in'])) { - foreach ($method_types['in'] as $name => $type) { - list($typens, $type) = $this->_getTypeNs($type); - $part = array(); - $part['attr']['name'] = $name; - $part['attr']['type'] = $typens . ':' . $type; - $input_message['part'][] = $part; - } - } - $this->_wsdl['definitions']['message'][] = $input_message; - - // OUTPUT - $output_message = array('attr' => array('name' => $method_name . 'Response')); - if (isset($method_types['out']) && is_array($method_types['out'])) { - foreach ($method_types['out'] as $name => $type) { - list($typens, $type) = $this->_getTypeNs($type); - $part = array(); - $part['attr']['name'] = $name; - $part['attr']['type'] = $typens . ':' . $type; - $output_message['part'][] = $part; - } - } - $this->_wsdl['definitions']['message'][] = $output_message; - - // PORTTYPES - $operation = array(); - $operation['attr']['name'] = $method_name; - // INPUT - $operation['input']['attr']['message'] = 'tns:' . $input_message['attr']['name']; - // OUTPUT - $operation['output']['attr']['message'] = 'tns:' . $output_message['attr']['name']; - $this->_wsdl['definitions']['portType']['operation'][] = $operation; - - // BINDING - $binding = array(); - $binding['attr']['name'] = $method_name; - $action = $method_namespace . ':' . ($classname ? $classname . ':' : '') . $method_name; - $binding['soap:operation']['attr']['soapAction'] = $action; - // INPUT - $binding['input']['attr'] = ''; - $binding['input']['soap:body']['attr']['use'] = 'literal'; - $binding['input']['soap:body']['attr']['namespace'] = $method_namespace; -// $binding['input']['soap:body']['attr']['encodingStyle'] = SOAP_SCHEMA_ENCODING; - // OUTPUT - $binding['output']['attr'] = ''; - $binding['output']['soap:body']['attr']['use'] = 'literal'; - $binding['output']['soap:body']['attr']['namespace'] = $method_namespace; -// $binding['output']['soap:body']['attr']['encodingStyle'] = SOAP_SCHEMA_ENCODING; - $this->_wsdl['definitions']['binding']['operation'][] = $binding; - } - } - - function _generate_DISCO_XML($disco_array) - { - $disco = '<?xml version="1.0"?>'; - foreach ($disco_array as $key => $val) { - $disco .= $this->_arrayToNode($key,$val); - } - $this->disco = $disco; - } - - function _generate_WSDL_XML() - { - $wsdl = '<?xml version="1.0"?>'; - foreach ($this->_wsdl as $key => $val) { - $wsdl .= $this->_arrayToNode($key, $val); - } - $this->wsdl = $wsdl; - } - - function _arrayToNode($node_name = '', $array) - { - $return = ''; - if (is_array($array)) { - // we have a node if there's key 'attr' - if (array_key_exists('attr',$array)) { - $return .= "<$node_name"; - if (is_array($array['attr'])) { - foreach ($array['attr'] as $attr_name => $attr_value) { - $return .= " $attr_name=\"$attr_value\""; - } - } - - // unset 'attr' and proceed other childs... - unset($array['attr']); - - if (count($array) > 0) { - $i = 0; - foreach ($array as $child_node_name => $child_node_value) { - $return .= $i == 0 ? ">\n" : ''; - $return .= $this->_arrayToNode($child_node_name,$child_node_value); - $i++; - } - $return .= "</$node_name>\n"; - } else { - $return .= " />\n"; - } - } else { - // we have no 'attr' key in array - so it's list of nodes with - // the same name ... - foreach ($array as $child_node_name => $child_node_value) { - $return .= $this->_arrayToNode($node_name,$child_node_value); - } - } - } else { - // $array is not an array - if ($array !='') { - // and its not empty - $return .= "<$node_name>$array</$node_name>\n"; - } else { - // and its empty... - $return .= "<$node_name />\n"; - } - } - return $return; - } - - function _getTypeNs($type) - { - preg_match_all("'\{(.*)\}'sm", $type, $m); - if (isset($m[1][0]) && $m[1][0] != '') { - if (!array_key_exists($m[1][0],$this->namespaces)) { - $ns_pref = 'ns' . count($this->namespaces); - $this->namespaces[$m[1][0]] = $ns_pref; - $this->_wsdl['definitions']['attr']['xmlns:' . $ns_pref] = $m[1][0]; - } - $typens = $this->namespaces[$m[1][0]]; - $type = preg_replace('/'.$m[0][0].'/', '', $type); - } else { - $typens = 'xsd'; - } - return array($typens,$type); - } - - function _ifComplexTypeExists($typesArray, $type_name) - { - if (is_array($typesArray)) { - foreach ($typesArray as $type_data) { - if ($type_data['attr']['name'] == $type_name) { - return true; - } - } - } - return false; - } -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php deleted file mode 100755 index 00c140c9e66b4697ae765e74118a273663f5290c..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -/** - * This file contains the SOAP_Fault class, used for all error objects in this - * package. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** PEAR_Error */ -require_once 'PEAR.php'; - -/** - * PEAR::Error wrapper used to match SOAP Faults to PEAR Errors - * - * SOAP_Fault can provide a complete backtrace of the error. Revealing these - * details in a public web services is a bad idea because it can be used by - * attackers. Thus you have to enable backtrace information in SOAP_Fault - * responses by putting the following code in your script after your - * "require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Server.php';" line: - * - * <code> - * $backtrace =& PEAR::getStaticProperty('SOAP_Fault', 'backtrace'); - * $backtrace = true; - * </code> - * - * @package SOAP - * @access public - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Fault extends PEAR_Error -{ - /** - * Constructor. - * - * @param string $faultstring Message string for fault. - * @param mixed $faultcode The faultcode. - * @param mixed $faultactor - * @param mixed $detail @see PEAR_Error - * @param array $mode @see PEAR_Error - * @param array $options @see PEAR_Error - */ - public function __construct($faultstring = 'unknown error', $faultcode = 'Client', - $faultactor = null, $detail = null, $mode = null, - $options = null) - { - parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail); - if ($faultactor) { - $this->error_message_prefix = $faultactor; - } - } - - /** - * Returns a SOAP XML message that can be sent as a server response. - * - * @return string - */ - function message($encoding = SOAP_DEFAULT_ENCODING) - { - $msg = new SOAP_Base(); - $params = array(); - $params[] = new SOAP_Value('faultcode', 'QName', $msg ->SOAPENVPrefix().':' . $this->code); - $params[] = new SOAP_Value('faultstring', 'string', $this->message); - $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix); - if (PEAR::getStaticProperty('SOAP_Fault', 'backtrace') && - isset($this->backtrace)) { - $params[] = new SOAP_Value('detail', 'string', $this->backtrace); - } else { - $params[] = new SOAP_Value('detail', 'string', $this->userinfo); - } - - $methodValue = new SOAP_Value('{' . SOAP_ENVELOP . '}Fault', 'Struct', $params); - $headers = null; - return $msg->makeEnvelope($methodValue, $headers, $encoding); - } - - /** - * Returns a simple native PHP array containing the fault data. - * - * @return array - */ - function getFault() - { - $fault = new stdClass(); - $fault->faultcode = $this->code; - $fault->faultstring = $this->message; - $fault->faultactor = $this->error_message_prefix; - $fault->detail = $this->userinfo; - return $fault; - } - - /** - * Returns the SOAP actor for the fault. - * - * @return string - */ - function getActor() - { - return $this->error_message_prefix; - } - - /** - * Returns the fault detail. - * - * @return string - */ - function getDetail() - { - return $this->userinfo; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Parser.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Parser.php deleted file mode 100755 index 1f9b7e48168dca9e3d78a1dcbdfd2c70dbd696f0..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Parser.php +++ /dev/null @@ -1,500 +0,0 @@ -<?php -/** - * This file contains the code for the SOAP message parser. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Value.php'; - -/** - * SOAP Parser - * - * This class is used by SOAP::Message and SOAP::Server to parse soap - * packets. Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Parser extends SOAP_Base -{ - var $status = ''; - var $position = 0; - var $depth = 0; - var $default_namespace = ''; - var $message = array(); - var $depth_array = array(); - var $parent = 0; - var $root_struct_name = array(); - var $header_struct_name = array(); - var $curent_root_struct_name = ''; - var $root_struct = array(); - var $header_struct = array(); - var $curent_root_struct = 0; - var $references = array(); - var $need_references = array(); - - /** - * Used to handle non-root elements before root body element. - * - * @var integer - */ - var $bodyDepth; - - /** - * Constructor. - * - * @param string $xml XML content. - * @param string $encoding Character set encoding, defaults to 'UTF-8'. - * @param array $attachments List of attachments. - */ - public function __construct($xml, $encoding = SOAP_DEFAULT_ENCODING, - $attachments = null) - { - $SOAP_Base = new SOAP_Base('Parser'); - //parent::SOAP_Base('Parser'); - $this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION); - - $this->attachments = $attachments; - - // Check the XML tag for encoding. - if (preg_match('/<\?xml[^>]+encoding\s*?=\s*?(\'([^\']*)\'|"([^"]*)")[^>]*?[\?]>/', $xml, $m)) { - $encoding = strtoupper($m[2] ? $m[2] : $m[3]); - } - - // Determine where in the message we are (envelope, header, body, - // method). Check whether content has been read. - if (!empty($xml)) { - // Prepare the XML parser. - $parser = xml_parser_create($encoding); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($parser, $this); - xml_set_element_handler($parser, '_startElement', '_endElement'); - xml_set_character_data_handler($parser, '_characterData'); - - // Some lame SOAP implementations add nul bytes at the end of the - // SOAP stream, and expat chokes on that. - if ($xml[strlen($xml) - 1] == 0) { - $xml = trim($xml); - } - - // Parse the XML file. - if (!xml_parse($parser, $xml, true)) { - $err = sprintf('XML error on line %d col %d byte %d %s', - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser), - xml_error_string(xml_get_error_code($parser))); - $this->_raiseSoapFault($err, htmlspecialchars($xml)); - } - xml_parser_free($parser); - } - } - - /** - * Returns an array of responses. - * - * After parsing a SOAP message, use this to get the response. - * - * @return array - */ - function getResponse() - { - if (!empty($this->root_struct[0])) { - return $this->_buildResponse($this->root_struct[0]); - } else { - return $this->_raiseSoapFault('Cannot build response'); - } - } - - /** - * Returns an array of header responses. - * - * After parsing a SOAP message, use this to get the response. - * - * @return array - */ - function getHeaders() - { - if (!empty($this->header_struct[0])) { - return $this->_buildResponse($this->header_struct[0]); - } else { - // We don't fault if there are no headers; that can be handled by - // the application if necessary. - return null; - } - } - - /** - * Recurses to build a multi dimensional array. - * - * @see _buildResponse() - */ - function _domulti($d, &$ar, &$r, &$v, $ad = 0) - { - if ($d) { - $this->_domulti($d - 1, $ar, $r[$ar[$ad]], $v, $ad + 1); - } else { - $r = $v; - } - } - - /** - * Loops through the message, building response structures. - * - * @param integer $pos Position. - * - * @return SOAP_Value - */ - function _buildResponse($pos) - { - $response = null; - - if (isset($this->message[$pos]['children'])) { - $children = explode('|', $this->message[$pos]['children']); - foreach ($children as $c => $child_pos) { - if ($this->message[$child_pos]['type'] != null) { - $response[] = $this->_buildResponse($child_pos); - } - } - if (isset($this->message[$pos]['arraySize'])) { - $ardepth = count($this->message[$pos]['arraySize']); - if ($ardepth > 1) { - $ar = array_pad(array(), $ardepth, 0); - if (isset($this->message[$pos]['arrayOffset'])) { - for ($i = 0; $i < $ardepth; $i++) { - $ar[$i] += $this->message[$pos]['arrayOffset'][$i]; - } - } - $elc = count($response); - for ($i = 0; $i < $elc; $i++) { - // Recurse to build a multi dimensional array. - $this->_domulti($ardepth, $ar, $newresp, $response[$i]); - - // Increment our array pointers. - $ad = $ardepth - 1; - $ar[$ad]++; - while ($ad > 0 && - $ar[$ad] >= $this->message[$pos]['arraySize'][$ad]) { - $ar[$ad] = 0; - $ad--; - $ar[$ad]++; - } - } - $response = $newresp; - } elseif (isset($this->message[$pos]['arrayOffset']) && - $this->message[$pos]['arrayOffset'][0] > 0) { - // Check for padding. - $pad = $this->message[$pos]['arrayOffset'][0] + count($response) * -1; - $response = array_pad($response, $pad, null); - } - } - } - - // Build attributes. - $attrs = array(); - foreach ($this->message[$pos]['attrs'] as $atn => $atv) { - if (!strstr($atn, 'xmlns') && !strpos($atn, ':')) { - $attrs[$atn] = $atv; - } - } - - // Add current node's value. - $nqn = new QName($this->message[$pos]['name'], - $this->message[$pos]['namespace']); - $tqn = new QName($this->message[$pos]['type'], - $this->message[$pos]['type_namespace']); - if ($response) { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), $response, - $attrs); - if (isset($this->message[$pos]['arrayType'])) { - $response->arrayType = $this->message[$pos]['arrayType']; - } - } else { - // Check if value is an empty array - if ($tqn->name == 'Array') { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), array(), - $attrs); - //if ($pos == 4) var_dump($this->message[$pos], $response); - } else { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), - $this->message[$pos]['cdata'], - $attrs); - } - } - - // Handle header attribute that we need. - if (array_key_exists('actor', $this->message[$pos])) { - $response->actor = $this->message[$pos]['actor']; - } - if (array_key_exists('mustUnderstand', $this->message[$pos])) { - $response->mustunderstand = $this->message[$pos]['mustUnderstand']; - } - - return $response; - } - - /** - * Start element handler used with the XML parser. - */ - function _startElement($parser, $name, $attrs) - { - // Position in a total number of elements, starting from 0. - // Update class level position. - $pos = $this->position++; - - // And set mine. - $this->message[$pos] = array( - 'type' => '', - 'type_namespace' => '', - 'cdata' => '', - 'pos' => $pos, - 'id' => ''); - - // Parent/child/depth determinations. - - // depth = How many levels removed from root? - // Set mine as current global depth and increment global depth value. - $this->message[$pos]['depth'] = $this->depth++; - - // Else add self as child to whoever the current parent is. - if ($pos != 0) { - if (isset($this->message[$this->parent]['children'])) { - $this->message[$this->parent]['children'] .= '|' . $pos; - } else { - $this->message[$this->parent]['children'] = $pos; - } - } - - // Set my parent. - $this->message[$pos]['parent'] = $this->parent; - - // Set self as current value for this depth. - $this->depth_array[$this->depth] = $pos; - // Set self as current parent. - $this->parent = $pos; - $qname = new QName($name); - // Set status. - if (strcasecmp('envelope', $qname->name) == 0) { - $this->status = 'envelope'; - } elseif (strcasecmp('header', $qname->name) == 0) { - $this->status = 'header'; - $this->header_struct_name[] = $this->curent_root_struct_name = $qname->name; - $this->header_struct[] = $this->curent_root_struct = $pos; - $this->message[$pos]['type'] = 'Struct'; - } elseif (strcasecmp('body', $qname->name) == 0) { - $this->status = 'body'; - $this->bodyDepth = $this->depth; - - // Set method - } elseif ($this->status == 'body') { - // Is this element allowed to be a root? - // TODO: this needs to be optimized, we loop through $attrs twice - // now. - $can_root = $this->depth == $this->bodyDepth + 1; - if ($can_root) { - foreach ($attrs as $key => $value) { - if (stristr($key, ':root') && !$value) { - $can_root = false; - } - } - } - - if ($can_root) { - $this->status = 'method'; - $this->root_struct_name[] = $this->curent_root_struct_name = $qname->name; - $this->root_struct[] = $this->curent_root_struct = $pos; - $this->message[$pos]['type'] = 'Struct'; - } - } - - // Set my status. - $this->message[$pos]['status'] = $this->status; - - // Set name. - $this->message[$pos]['name'] = htmlspecialchars($qname->name); - - // Set attributes. - $this->message[$pos]['attrs'] = $attrs; - - // Loop through attributes, logging ns and type declarations. - foreach ($attrs as $key => $value) { - // If ns declarations, add to class level array of valid - // namespaces. - $kqn = new QName($key); - if ($kqn->ns == 'xmlns') { - $prefix = $kqn->name; - - if (in_array($value, $this->_XMLSchema)) { - $this->_setSchemaVersion($value); - } - - $this->_namespaces[$value] = $prefix; - - // Set method namespace. - } elseif ($key == 'xmlns') { - $qname->ns = $this->_getNamespacePrefix($value); - $qname->namespace = $value; - } elseif ($kqn->name == 'actor') { - $this->message[$pos]['actor'] = $value; - } elseif ($kqn->name == 'mustUnderstand') { - $this->message[$pos]['mustUnderstand'] = $value; - - // If it's a type declaration, set type. - } elseif ($kqn->name == 'type') { - $vqn = new QName($value); - $this->message[$pos]['type'] = $vqn->name; - $this->message[$pos]['type_namespace'] = $this->_getNamespaceForPrefix($vqn->ns); - - // Should do something here with the namespace of specified - // type? - - } elseif ($kqn->name == 'arrayType') { - $vqn = new QName($value); - $this->message[$pos]['type'] = 'Array'; - if (isset($vqn->arraySize)) { - $this->message[$pos]['arraySize'] = $vqn->arraySize; - } - $this->message[$pos]['arrayType'] = $vqn->name; - - } elseif ($kqn->name == 'offset') { - $this->message[$pos]['arrayOffset'] = preg_split('[,]', substr($value, 1, strlen($value) - 2)); - - } elseif ($kqn->name == 'id') { - // Save id to reference array. - $this->references[$value] = $pos; - $this->message[$pos]['id'] = $value; - - } elseif ($kqn->name == 'href') { - if ($value[0] == '#') { - $ref = substr($value, 1); - if (isset($this->references[$ref])) { - // cdata, type, inval. - $ref_pos = $this->references[$ref]; - $this->message[$pos]['children'] = &$this->message[$ref_pos]['children']; - $this->message[$pos]['cdata'] = &$this->message[$ref_pos]['cdata']; - $this->message[$pos]['type'] = &$this->message[$ref_pos]['type']; - $this->message[$pos]['arraySize'] = &$this->message[$ref_pos]['arraySize']; - $this->message[$pos]['arrayType'] = &$this->message[$ref_pos]['arrayType']; - } else { - // Reverse reference, store in 'need reference'. - if (!isset($this->need_references[$ref])) { - $this->need_references[$ref] = array(); - } - $this->need_references[$ref][] = $pos; - } - } elseif (isset($this->attachments[$value])) { - $this->message[$pos]['cdata'] = $this->attachments[$value]; - } - } - } - // See if namespace is defined in tag. - if (isset($attrs['xmlns:' . $qname->ns])) { - $namespace = $attrs['xmlns:' . $qname->ns]; - } elseif ($qname->ns && !$qname->namespace) { - $namespace = $this->_getNamespaceForPrefix($qname->ns); - } else { - // Get namespace. - $namespace = $qname->namespace ? $qname->namespace : $this->default_namespace; - } - $this->message[$pos]['namespace'] = $namespace; - $this->default_namespace = $namespace; - } - - /** - * End element handler used with the XML parser. - */ - function _endElement($parser, $name) - { - // Position of current element is equal to the last value left in - // depth_array for my depth. - $pos = $this->depth_array[$this->depth]; - - // Bring depth down a notch. - $this->depth--; - $qname = new QName($name); - - // Get type if not explicitly declared in an xsi:type attribute. - // TODO: check on integrating WSDL validation here. - if ($this->message[$pos]['type'] == '') { - if (isset($this->message[$pos]['children'])) { - /* this is slow, need to look at some faster method - $children = explode('|', $this->message[$pos]['children']); - if (count($children) > 2 && - $this->message[$children[1]]['name'] == $this->message[$children[2]]['name']) { - $this->message[$pos]['type'] = 'Array'; - } else { - $this->message[$pos]['type'] = 'Struct'; - }*/ - $this->message[$pos]['type'] = 'Struct'; - } else { - $parent = $this->message[$pos]['parent']; - if ($this->message[$parent]['type'] == 'Array' && - isset($this->message[$parent]['arrayType'])) { - $this->message[$pos]['type'] = $this->message[$parent]['arrayType']; - } else { - $this->message[$pos]['type'] = 'string'; - } - } - } - - // If tag we are currently closing is the method wrapper. - if ($pos == $this->curent_root_struct) { - $this->status = 'body'; - } elseif ($qname->name == 'Body' || $qname->name == 'Header') { - $this->status = 'envelope'; - } - - // Set parent back to my parent. - $this->parent = $this->message[$pos]['parent']; - - // Handle any reverse references now. - $idref = $this->message[$pos]['id']; - - if ($idref != '' && isset($this->need_references[$idref])) { - foreach ($this->need_references[$idref] as $ref_pos) { - // XXX is this stuff there already? - $this->message[$ref_pos]['children'] = &$this->message[$pos]['children']; - $this->message[$ref_pos]['cdata'] = &$this->message[$pos]['cdata']; - $this->message[$ref_pos]['type'] = &$this->message[$pos]['type']; - $this->message[$ref_pos]['arraySize'] = &$this->message[$pos]['arraySize']; - $this->message[$ref_pos]['arrayType'] = &$this->message[$pos]['arrayType']; - } - } - } - - /** - * Element content handler used with the XML parser. - */ - function _characterData($parser, $data) - { - $pos = $this->depth_array[$this->depth]; - if (isset($this->message[$pos]['cdata'])) { - $this->message[$pos]['cdata'] .= $data; - } else { - $this->message[$pos]['cdata'] = $data; - } - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Server.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Server.php deleted file mode 100755 index 62f55089cebdb23a185397a24a5a0c626ee55c63..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Server.php +++ /dev/null @@ -1,824 +0,0 @@ -<?php -/** - * This file contains the code for the SOAP server. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Parser.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Value.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php'; - -/** - * SOAP Server Class - * - * Originaly based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Server extends SOAP_Base -{ - /** - * - * @var array - */ - var $dispatch_map = array(); // create empty dispatch map - var $dispatch_objects = array(); - var $soapobject = null; - var $call_methodname = null; - var $callHandler = null; - var $callValidation = true; - - /** - * A list of headers that are going to be sent back to the client. - * - * @var array - */ - var $headers = array(); - - /** - * - * @var string - */ - var $request = ''; - - /** - * - * @var string XML-Encoding - */ - var $xml_encoding = SOAP_DEFAULT_ENCODING; - var $response_encoding = 'UTF-8'; - - var $result = 'successful'; // for logging interop results to db - - var $endpoint = ''; // the uri to ME! - - var $service = ''; //soapaction header - var $method_namespace = null; - - /** - * Options. - * - * @var array - */ - var $_options = array('use' => 'encoded', - 'style' => 'rpc', - 'parameters' => 0, - 'http_status_success' => '200 OK', - 'http_status_fault' => '500 SOAP Fault'); - - public function __construct($options = null) - { - ini_set('track_errors', 1); - $SOAP_Base = new SOAP_Base('Server'); - //parent::SOAP_Base('Server'); - - if (is_array($options)) { - if (isset($options['use'])) { - $this->_options['use'] = $options['use']; - } - if (isset($options['style'])) { - $this->_options['style'] = $options['style']; - } - if (isset($options['parameters'])) { - $this->_options['parameters'] = $options['parameters']; - } - } - // assume we encode with section 5 - $this->_section5 = true; - if ($this->_options['use'] == 'literal') { - $this->_section5 = false; - } - } - - /** - * Error handler for errors that happen in proxied methods. - * - * To always return a valid SOAP response even on errors that don't happen - * in this code, the errors are catched, transformed to a SOAP fault and - * immediately sent to the client. - */ - function _errorHandler($errno, $errmsg, $filename, $linenum) - { - /* The error handler should ignore '0' errors, eg. hidden by @ - see - * the set_error_handler manual page. (thanks to Alan Knowles). */ - if (!$errno || !error_reporting() || $errno == E_NOTICE || - (defined('E_STRICT') && $errno == constant('E_STRICT'))) { - return false; - } - - $this->fault = new SOAP_Fault($errmsg, 'Server', 'PHP', "Errno: $errno\nFilename: $filename\nLineno: $linenum\n"); - - $this->_sendResponse(); - exit; - } - - function _getContentEncoding($content_type) - { - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - $this->xml_encoding = 'UTF-8'; - if (strpos($content_type, '=')) { - $enc = strtoupper(str_replace('"', '', substr(strstr($content_type, '='), 1))); - if (!in_array($enc, $this->_encodings)) { - return false; - } - $this->xml_encoding = $enc; - } - - return true; - } - - - /** - * Parses the request and posts or returns the response. - * - * @param string $data The SOAP request data. - * @param string $endpoint The service endpoint. Determined automatically - * if left empty. - * @param boolean $test - * @param boolean $return Whether to return the SOAP response data - * instead of sending it to the client. - */ - function service($data, $endpoint = '', $test = false, $return = false) - { - $response = null; - $attachments = array(); - $useEncoding = 'DIME'; - - /* Figure out our endpoint. */ - $this->endpoint = $endpoint; - if (!$test && !$this->endpoint) { - /* We'll try to build our endpoint. */ - $this->endpoint = 'http://' . $_SERVER['SERVER_NAME']; - if (isset($_SERVER['SERVER_PORT'])) { - $this->endpoint .= ':' . $_SERVER['SERVER_PORT']; - } - $this->endpoint .= $_SERVER['SCRIPT_NAME']; - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (isset($_SERVER['CONTENT_TYPE'])) { - if (strcasecmp($_SERVER['CONTENT_TYPE'], 'application/dime') == 0) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - $useEncoding = 'DIME'; - } elseif (stristr($_SERVER['CONTENT_TYPE'], 'multipart/related')) { - /* This is a mime message, let's decode it. */ - $data = 'Content-Type: ' . - stripslashes($_SERVER['CONTENT_TYPE']) . - "\r\n\r\n" . $data; - $this->_decodeMimeMessage($data, $this->headers, $attachments); - $useEncoding = 'Mime'; - } - if (!isset($this->headers['content-type'])) { - $this->headers['content-type'] = stripslashes($_SERVER['CONTENT_TYPE']); - } - if (!$this->fault && - !$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* Found encoding we don't understand; return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - } - } - - /* If this is not a POST with Content-Type text/xml, try to return a - * WSDL file. */ - if (!$this->fault && !$test && - ((isset($_SERVER['REQUEST_METHOD']) && - $_SERVER['REQUEST_METHOD'] != 'POST') || - (isset($this->headers['content-type']) && - strncmp($this->headers['content-type'], 'text/xml', 8) != 0))) { - /* This is not possibly a valid SOAP request, try to return a WSDL - * file. */ - $got = isset($this->headers['content-type']) ? $this->headers['content-type'] : 'Nothing!'; - $this->_raiseSoapFault('Invalid SOAP request, must be POST with content-type: text/xml, got: ' . $got, '', '', 'Server'); - } - - if (!$this->fault) { - /* $response is a SOAP_Msg object. */ - $soap_msg = $this->parseRequest($data, $attachments); - - /* Handle Mime or DIME encoding. */ - /* TODO: DIME decoding should move to the transport, do it here - * for now and for ease of getting it done. */ - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($soap_msg); - } else { - // default is dime - $soap_msg = $this->_makeDIMEMessage($soap_msg); - $this->headers['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - } - - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - $this->headers = $soap_msg['headers']; - } - } else { - $response = $soap_msg; - } - } - - if ($return) { - if ($this->fault) { - $response = $this->fault->message(); - } - return $response; - } - - $this->_sendResponse($response); - } - - /** - * Sends the final HTTP response to the client, including the HTTP header - * and the HTTP body. - * - * If an error happened, it returns a SOAP fault instead of the response - * body. - * - * @param string $response The response body. - */ - function _sendResponse($response = '') - { - /* Make distinction between the different SAPIs, running PHP as CGI or - * as a module. */ - if (stristr(php_sapi_name(), 'cgi') === 0) { - $hdrs_type = 'Status:'; - } else { - $hdrs_type = 'HTTP/1.1'; - } - - if ($this->fault) { - $hdrs = $hdrs_type . ' ' . $this->_options['http_status_fault'] . "\r\n"; - $response = $this->fault->message($this->response_encoding); - } else { - $hdrs = $hdrs_type . ' ' . $this->_options['http_status_success'] . "\r\n"; - } - header($hdrs); - - $this->headers['Server'] = SOAP_LIBRARY_NAME; - if (!isset($this->headers['Content-Type'])) { - $this->headers['Content-Type'] = 'text/xml; charset=' . - $this->response_encoding; - } - $this->headers['Content-Length'] = strlen($response); - - foreach ($this->headers as $k => $v) { - header("$k: $v"); - $hdrs .= "$k: $v\r\n"; - } - - $this->response = $hdrs . "\r\n" . $response; - print $response; - } - - function &callMethod($methodname, &$args) - { - if ($this->callHandler) { - $ret = @call_user_func_array($this->callHandler, array($methodname, $args)); - return $ret; - } - - set_error_handler(array($this, '_errorHandler')); - - if ($args) { - /* Call method with parameters. */ - if (isset($this->soapobject) && is_object($this->soapobject)) { - $ret = call_user_func_array(array(&$this->soapobject, $methodname), $args); - } else { - $ret = call_user_func_array($methodname, $args); - } - } else { - /* Call method withour parameters. */ - if (is_object($this->soapobject)) { - $ret = call_user_func(array(&$this->soapobject, $methodname)); - } else { - $ret = call_user_func($methodname); - } - } - - restore_error_handler(); - - return $ret; - } - - /** - * Creates SOAP_Value objects with return values from method. - * Uses method signature to determine type. - * - * @param mixed $method_response The result(s). - * @param array|string $type The type(s) of the return value(s). - * @param string $return_name The name of the return value. - * @param string $namespace The namespace of the return value. - * - * @return array List of SOAP_Value objects. - */ - function buildResult(&$method_response, &$return_type, - $return_name = 'return', $namespace = '') - { - if (is_a($method_response, 'SOAP_Value')) { - $return_val = array($method_response); - } else { - if (is_array($return_type) && is_array($method_response)) { - $i = 0; - - foreach ($return_type as $key => $type) { - if (is_numeric($key)) { - $key = 'item'; - } - if (is_a($method_response[$i], 'SOAP_Value')) { - $return_val[] =& $method_response[$i++]; - } else { - $qn = new QName($key, $namespace); - $return_val[] = new SOAP_Value($qn->fqn(), $type, $method_response[$i++]); - } - } - } else { - if (is_array($return_type)) { - $keys = array_keys($return_type); - if (!is_numeric($keys[0])) { - $return_name = $keys[0]; - } - $values = array_values($return_type); - $return_type = $values[0]; - } - $qn = new QName($return_name, $namespace); - $return_val = array(new SOAP_Value($qn->fqn(), $return_type, $method_response)); - } - } - return $return_val; - } - - function parseRequest($data = '', $attachments = null) - { - /* Parse response, get SOAP_Parser object. */ - $parser = new SOAP_Parser($data, $this->xml_encoding, $attachments); - - if ($parser->fault) { - /* Fault occurred during message parsing. */ - $this->fault = $parser->fault; - return null; - } - if (!count($parser->root_struct_name)) { - /* No method specified. */ - $this->_raiseSoapFault('No method specified in request.'); - return null; - } - - /* Handle message headers. */ - $request_headers = $parser->getHeaders(); - $header_results = array(); - - if ($request_headers) { - if (!is_a($request_headers, 'SOAP_Value')) { - $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_headers, '', '', 'Server'); - return null; - } - if ($request_headers->value) { - /* Handle headers now. */ - foreach ($request_headers->value as $header_val) { - $f_exists = $this->validateMethod($header_val->name, $header_val->namespace); - - /* TODO: this does not take into account message routing - * yet. */ - $myactor = !$header_val->actor || - $header_val->actor == 'http://schemas.xmlsoap.org/soap/actor/next' || - $header_val->actor == $this->endpoint; - - if (!$f_exists && $header_val->mustunderstand && $myactor) { - $this->_raiseSoapFault('I don\'t understand header ' . $header_val->name, '', '', 'MustUnderstand'); - return null; - } - - /* We only handle the header if it's for us. */ - $isok = $f_exists && $myactor; - - if ($isok) { - /* Call our header now! */ - $header_method = $header_val->name; - $header_data = array($this->_decode($header_val)); - /* If there are parameters to pass. */ - $hr =& $this->callMethod($header_method, $header_data); - if (PEAR::isError($hr)) { - $this->_raiseSoapFault($hr); - return null; - } - $results = $this->buildResult($hr, $this->return_type, $header_method, $header_val->namespace); - $header_results[] = $results[0]; - } - } - } - } - - /* Handle the method call. */ - /* Evaluate message, getting back a SOAP_Value object. */ - $this->call_methodname = $this->methodname = $parser->root_struct_name[0]; - - /* Figure out the method namespace. */ - $this->method_namespace = $parser->message[$parser->root_struct[0]]['namespace']; - - if ($this->_wsdl) { - $this->_setSchemaVersion($this->_wsdl->xsd); - $dataHandler = $this->_wsdl->getDataHandler($this->methodname, $this->method_namespace); - if ($dataHandler) - $this->call_methodname = $this->methodname = $dataHandler; - - $this->_portName = $this->_wsdl->getPortName($this->methodname); - if (PEAR::isError($this->_portName)) { - $this->_raiseSoapFault($this->_portName); - return null; - } - $opData = $this->_wsdl->getOperationData($this->_portName, $this->methodname); - if (PEAR::isError($opData)) { - $this->_raiseSoapFault($opData); - return null; - } - $this->_options['style'] = $opData['style']; - $this->_options['use'] = $opData['output']['use']; - $this->_options['parameters'] = $opData['parameters']; - } - - /* Does method exist? */ - if (!$this->methodname || - !$this->validateMethod($this->methodname, $this->method_namespace)) { - $this->_raiseSoapFault('method "' . $this->method_namespace . $this->methodname . '" not defined in service', '', '', 'Server'); - return null; - } - - if (!$request_val = $parser->getResponse()) { - return null; - } - if (!is_a($request_val, 'SOAP_Value')) { - $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_val, '', '', 'Server'); - return null; - } - - /* Verify that SOAP_Value objects in request match the methods - * signature. */ - if (!$this->verifyMethod($request_val)) { - /* verifyMethod() creates the fault. */ - return null; - } - - /* Need to set special error detection inside the value class to - * differentiate between no params passed, and an error decoding. */ - $request_data = $this->__decodeRequest($request_val); - if (PEAR::isError($request_data)) { - $this->_raiseSoapFault($request_data); - return null; - } - $method_response =& $this->callMethod($this->call_methodname, $request_data); - if (PEAR::isError($method_response)) { - $this->_raiseSoapFault($method_response); - return null; - } - - if ($this->_options['parameters'] || - !$method_response || - $this->_options['style'] == 'rpc') { - /* Get the method result. */ - if (is_null($method_response)) { - $return_val = null; - } else { - $return_val = $this->buildResult($method_response, $this->return_type); - } - - $qn = new QName($this->methodname . 'Response', $this->method_namespace); - $methodValue = new SOAP_Value($qn->fqn(), 'Struct', $return_val); - } else { - $methodValue =& $method_response; - } - return $this->makeEnvelope($methodValue, $header_results, $this->response_encoding); - } - - function &__decodeRequest($request, $shift = false) - { - if (!$request) { - $decoded = null; - return $decoded; - } - - /* Check for valid response. */ - if (PEAR::isError($request)) { - $fault = &$this->_raiseSoapFault($request); - return $fault; - } else if (!is_a($request, 'SOAP_Value')) { - $fault = &$this->_raiseSoapFault('Invalid data in server::__decodeRequest'); - return $fault; - } - - /* Decode to native php datatype. */ - $requestArray = $this->_decode($request); - /* Fault? */ - if (PEAR::isError($requestArray)) { - $fault = &$this->_raiseSoapFault($requestArray); - return $fault; - } - if (is_object($requestArray) && - get_class($requestArray) == 'stdClass') { - $requestArray = get_object_vars($requestArray); - } elseif ($this->_options['style'] == 'document') { - $requestArray = array($requestArray); - } - if (is_array($requestArray)) { - if (isset($requestArray['faultcode']) || - isset($requestArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) { - $faultcode = $faultstring = $faultdetail = $faultactor = ''; - foreach ($requestArray as $k => $v) { - if (stristr($k, 'faultcode')) { - $faultcode = $v; - } - if (stristr($k, 'faultstring')) { - $faultstring = $v; - } - if (stristr($k, 'detail')) { - $faultdetail = $v; - } - if (stristr($k, 'faultactor')) { - $faultactor = $v; - } - } - $fault = &$this->_raiseSoapFault($faultstring, $faultdetail, $faultactor, $faultcode); - return $fault; - } - /* Return array of return values. */ - if ($shift && count($requestArray) == 1) { - $decoded = array_shift($requestArray); - return $decoded; - } - return $requestArray; - } - return $requestArray; - } - - function verifyMethod($request) - { - if (!$this->callValidation) { - return true; - } - - $params = $request->value; - - /* Get the dispatch map if one exists. */ - $map = null; - if (array_key_exists($this->methodname, $this->dispatch_map)) { - $map = $this->dispatch_map[$this->methodname]; - } elseif (isset($this->soapobject)) { - if (method_exists($this->soapobject, '__dispatch')) { - $map = $this->soapobject->__dispatch($this->methodname); - } elseif (method_exists($this->soapobject, $this->methodname)) { - /* No map, all public functions are SOAP functions. */ - return true; - } - } - if (!$map) { - $this->_raiseSoapFault('SOAP request specified an unhandled method "' . $this->methodname . '"', '', '', 'Client'); - return false; - } - - /* If we aliased the SOAP method name to a PHP function, change - * call_methodname so we do the right thing. */ - if (array_key_exists('alias', $map) && !empty($map['alias'])) { - $this->call_methodname = $map['alias']; - } - - /* If there are input parameters required. */ - if ($map['in']) { - $this->input_value = count($map['in']); - $this->return_type = false; - if (is_array($map['out'])) { - $this->return_type = count($map['out']) > 1 - ? $map['out'] - : array_shift($map['out']); - } - if (is_array($params)) { - /* Validate the number of parameters. */ - if (count($params) == count($map['in'])) { - /* Make array of param types. */ - foreach ($params as $param) { - $p[] = strtolower($param->type); - } - $sig_t = array_values($map['in']); - /* Validate each param's type. */ - for ($i = 0; $i < count($p); $i++) { - /* If SOAP types do not match, it's still fine if the - * mapped php types match this allows using plain PHP - * variables to work (i.e. stuff like Decimal would - * fail otherwise). We consider this only error if the - * types exist in our type maps, and they differ. */ - if (strcasecmp($sig_t[$i], $p[$i]) != 0 && - isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]]) && - strcasecmp($this->_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]], $this->_typemap[SOAP_XML_SCHEMA_VERSION][$p[$i]]) != 0) { - - $param = $params[$i]; - $this->_raiseSoapFault("SOAP request contained mismatching parameters of name $param->name had type [{$p[$i]}], which did not match signature's type: [{$sig_t[$i]}], matched? " . (strcasecmp($sig_t[$i], $p[$i])), '', '', 'Client'); - return false; - } - } - return true; - } else { - /* Wrong number of params. */ - $this->_raiseSoapFault('SOAP request contained incorrect number of parameters. method "' . $this->methodname . '" required ' . count($map['in']) . ' and request provided ' . count($params), '', '', 'Client'); - return false; - } - } else { - /* No params. */ - $this->_raiseSoapFault('SOAP request contained incorrect number of parameters. method "' . $this->methodname . '" requires ' . count($map['in']) . ' parameters, and request provided none.', '', '', 'Client'); - return false; - } - } - - /* We'll try it anyway. */ - return true; - } - - function validateMethod($methodname, $namespace = null) - { - unset($this->soapobject); - - if (!$this->callValidation) { - return true; - } - - /* No SOAP access to private functions. */ - if ($methodname[0] == '_') { - return false; - } - - /* if it's in our function list, ok */ - if (array_key_exists($methodname, $this->dispatch_map) && - (!$namespace || - !array_key_exists('namespace', $this->dispatch_map[$methodname]) || - $namespace == $this->dispatch_map[$methodname]['namespace'])) { - if (array_key_exists('namespace', $this->dispatch_map[$methodname])) - $this->method_namespace = $this->dispatch_map[$methodname]['namespace']; - return true; - } - - /* if it's in an object, it's ok */ - if (isset($this->dispatch_objects[$namespace])) { - $c = count($this->dispatch_objects[$namespace]); - for ($i = 0; $i < $c; $i++) { - $obj =& $this->dispatch_objects[$namespace][$i]; - /* If we have a dispatch map, and the function is not in the - * dispatch map, then it is not callable! */ - if (method_exists($obj, '__dispatch')) { - if ($obj->__dispatch($methodname)) { - $this->method_namespace = $namespace; - $this->soapobject =& $obj; - return true; - } - } elseif (method_exists($obj, $methodname)) { - $this->method_namespace = $namespace; - $this->soapobject =& $obj; - return true; - } - } - } - - return false; - } - - function addObjectMap(&$obj, $namespace = null, $service_name = 'Default', - $service_desc = '') - { - if (!$namespace) { - if (isset($obj->namespace)) { - // XXX a bit of backwards compatibility - $namespace = $obj->namespace; - } else { - $this->_raiseSoapFault('No namespace provided for class!', '', '', 'Server'); - return false; - } - } - if (!isset($this->dispatch_objects[$namespace])) { - $this->dispatch_objects[$namespace] = array(); - } - $this->dispatch_objects[$namespace][] =& $obj; - - // Create internal WSDL structures for object - - // XXX Because some internal workings of PEAR::SOAP decide whether to - // do certain things by the presence or absence of _wsdl, we should - // only create a _wsdl structure if we know we can fill it; if - // __dispatch_map or __typedef for the object is missing, we should - // avoid creating it. Later, when we are using PHP 5 introspection, we - // will be able to make the data for all objects without any extra - // information from the developers, and this condition should be - // dropped. - - // XXX Known issue: if imported WSDL (bindWSDL) or another WSDL source - // is used to add _wsdl structure information, then addObjectWSDL is - // used, there is a high possibility of _wsdl data corruption; - // therefore you should avoid using __dispatch_map/__typedef - // definitions AND other WSDL data sources in the same service. We - // exclude classes that don't have __typedefs to allow external WSDL - // files to be used with classes with no internal type definitions - // (the types are defined in the WSDL file). When addObjectWSDL is - // refactored to not cause corruption, this restriction can be - // relaxed. - - // In summary, if you add an object with both a dispatch map and type - // definitions, then previous WSDL file operation and type definitions - // will be overwritten. - if (isset($obj->__dispatch_map) && isset($obj->__typedef)) { - $this->addObjectWSDL($obj, $namespace, $service_name, $service_desc); - } - - return true; - } - - /** - * Adds a method to the dispatch map. - */ - function addToMap($methodname, $in, $out, $namespace = null, $alias = null) - { - if (!$this->callHandler && !function_exists($methodname)) { - $this->_raiseSoapFault('Error mapping function', '', '', 'Server'); - return false; - } - - $this->dispatch_map[$methodname]['in'] = $in; - $this->dispatch_map[$methodname]['out'] = $out; - $this->dispatch_map[$methodname]['alias'] = $alias; - if ($namespace) { - $this->dispatch_map[$methodname]['namespace'] = $namespace; - } - - return true; - } - - function setCallHandler($callHandler, $validation = true) - { - $this->callHandler = $callHandler; - $this->callValidation = $validation; - } - - /** - * @deprecated use bindWSDL from now on - */ - function bind($wsdl_url) - { - $this->bindWSDL($wsdl_url); - } - - /** - * @param string a url to a WSDL resource - * @return void - */ - function bindWSDL($wsdl_url) - { - /* Instantiate WSDL class. */ - $this->_wsdl = new SOAP_WSDL($wsdl_url); - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - - /** - * @return void - */ - function addObjectWSDL($wsdl_obj, $targetNamespace, $service_name, - $service_desc = '') - { - if (!isset($this->_wsdl)) { - $this->_wsdl = new SOAP_WSDL; - } - - $this->_wsdl->parseObject($wsdl_obj, $targetNamespace, $service_name, $service_desc); - - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email.php deleted file mode 100755 index 68cf28f81afdf6bebccf9269e10ffd5abe23e2c3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email.php +++ /dev/null @@ -1,199 +0,0 @@ -<?php -/** - * This file contains the code for the email SOAP server. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Server */ -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Server.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Client.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; -require_once 'Mail/mimeDecode.php'; - -/** - * SOAP Server Class that implements an email SOAP server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * parse an email message and execute SOAP calls. This class DOES NOT pop the - * message; the message, complete with headers, must be passed in as a - * parameter to the service function call. - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - */ -class SOAP_Server_Email extends SOAP_Server { - - var $headers = array(); - - function SOAP_Server_Email($send_response = true) - { - parent::SOAP_Server(); - $this->send_response = $send_response; - } - - /** - * Removes HTTP headers from response. - * - * TODO: use PEAR email classes - * - * @return boolean - * @access private - */ - function _parseEmail(&$data) - { - if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $data, $match)) { - - if (preg_match_all('/^(.*?):\s+(.*)$/m', $match[1], $matches)) { - $hc = count($matches[0]); - for ($i = 0; $i < $hc; $i++) { - $this->headers[strtolower($matches[1][$i])] = trim($matches[2][$i]); - } - } - - if (!stristr($this->headers['content-type'], 'text/xml')) { - $this->_raiseSoapFault('Invalid Content Type', '', '', 'Client'); - return false; - } - - if (strcasecmp($this->headers['content-transfer-encoding'], 'base64')==0) { - /* Unfold lines. */ - $enctext = preg_replace("/[\r|\n]/", '', $match[2]); - $data = base64_decode($enctext); - } else { - $data = $match[2]; - } - - /* If no content, return false. */ - return strlen($this->request) > 0; - } - - $this->_raiseSoapFault('Invalid Email Format', '', '', 'Client'); - - return false; - } - - function client(&$data) - { - $attachments = array(); - - /* If neither matches, we'll just try it anyway. */ - if (stristr($data, 'Content-Type: application/dime')) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - } elseif (stristr($data, 'MIME-Version:')) { - /* This is a mime message, let's decode it. */ - $this->_decodeMimeMessage($data, $this->headers, $attachments); - } else { - /* The old fallback, but decodeMimeMessage handles things fine. */ - $this->_parseEmail($data); - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (!$this->soapfault && - !$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* An encoding we don't understand, return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - } - - if ($this->soapfault) { - return $this->soapfault->getFault(); - } - - $client = new SOAP_Client(null); - - return $client->parseResponse($data, $this->xml_encoding, $this->attachments); - } - - function service(&$data, $endpoint = '', $send_response = true, - $dump = false) - { - $this->endpoint = $endpoint; - $attachments = array(); - $headers = array(); - - /* If neither matches, we'll just try it anyway. */ - if (stristr($data, 'Content-Type: application/dime')) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - $useEncoding = 'DIME'; - } elseif (stristr($data, 'MIME-Version:')) { - /* This is a mime message, let's decode it. */ - $this->_decodeMimeMessage($data, $this->headers, $attachments); - $useEncoding = 'Mime'; - } else { - /* The old fallback, but decodeMimeMessage handles things fine. */ - $this->_parseEmail($data); - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (!$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* An encoding we don't understand, return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - $response = $this->getFaultMessage(); - } - - if ($this->soapfault) { - $response = $this->soapfault->message(); - } else { - $soap_msg = $this->parseRequest($data,$attachments); - - /* Handle Mime or DIME encoding. */ - /* TODO: DIME Encoding should move to the transport, do it here - * for now and for ease of getting it done. */ - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($soap_msg); - } else { - /* Default is DIME. */ - $soap_msg = $this->_makeDIMEMessage($soap_msg); - $soap_msg['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->raiseSoapFault($soap_msg); - } - } - - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - $headers = $soap_msg['headers']; - } - } else { - $response = $soap_msg; - } - } - - if ($this->send_response) { - if ($dump) { - print $response; - } else { - $from = array_key_exists('reply-to', $this->headers) ? $this->headers['reply-to'] : $this->headers['from']; - - $soap_transport =& SOAP_Transport::getTransport('mailto:' . $from, $this->response_encoding); - $from = $this->endpoint ? $this->endpoint : $this->headers['to']; - $headers['In-Reply-To'] = $this->headers['message-id']; - $options = array('from' => $from, 'subject' => $this->headers['subject'], 'headers' => $headers); - $soap_transport->send($response, $options); - } - } - } -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email_Gateway.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email_Gateway.php deleted file mode 100755 index edb4fa036466526ff468adaa9cce9be5614f1232..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email_Gateway.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** - * This file contains the code for the email-HTTP SOAP gateway server. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Server_Email */ -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Server/Email.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; - -/** - * SOAP Server Class that implements an email SOAP server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * parse an email message and execute soap calls. This class DOES NOT pop the - * message; the message, complete with headers, must be passed in as a - * parameter to the service function call. - * - * This class calls a provided HTTP SOAP server, forwarding the email request, - * then sending the HTTP response out as an email. - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - */ -class SOAP_Server_Email_Gateway extends SOAP_Server_Email { - - var $gateway = null; - var $dump = false; - - function SOAP_Server_Email_Gateway($gateway = '', $send_response = true, - $dump = false) - { - parent::SOAP_Server(); - $this->send_response = $send_response; - $this->gateway = $gateway; - $this->dump = $dump; - } - - function service(&$data, $gateway = '', $endpoint = '', - $send_response = true, $dump = false) - { - $this->endpoint = $endpoint; - $response = ''; - $useEncoding = 'Mime'; - $options = array(); - if (!$gateway) { - $gateway = $this->gateway; - } - - /* We have a full set of headers, need to find the first blank - * line. */ - $this->_parseEmail($data); - if ($this->fault) { - $response = $this->fault->message(); - } - if ($this->headers['content-type'] == 'application/dime') - $useEncoding = 'DIME'; - - /* Call the HTTP Server. */ - if (!$response) { - $soap_transport =& SOAP_Transport::getTransport($gateway, $this->xml_encoding); - if ($soap_transport->fault) { - $response = $soap_transport->fault->message(); - } - } - - /* Send the message. */ - if (!$response) { - $options['soapaction'] = $this->headers['soapaction']; - $options['headers']['Content-Type'] = $this->headers['content-type']; - - $response = $soap_transport->send($data, $options); - if (isset($this->headers['mime-version'])) - $options['headers']['MIME-Version'] = $this->headers['mime-version']; - - if ($soap_transport->fault) { - $response = $soap_transport->fault->message(); - } else { - foreach ($soap_transport->transport->attachments as $cid => $body) { - $this->attachments[] = array('body' => $body, 'cid' => $cid, 'encoding' => 'base64'); - } - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($response); - $options['headers']['MIME-Version'] = '1.0'; - } else { - /* Default is DIME. */ - $soap_msg = $this->_makeDIMEMessage($response); - $options['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - if (isset($options['headers'])) { - $options['headers'] = array_merge($options['headers'], $soap_msg['headers']); - } else { - $options['headers'] = $soap_msg['headers']; - } - } - } - } - } - } - - if ($this->send_response) { - if ($this->dump || $dump) { - print $response; - } else { - $from = array_key_exists('reply-to', $this->headers) ? $this->headers['reply-to'] : $this->headers['from']; - - $soap_transport =& SOAP_Transport::getTransport('mailto:' . $from, $this->response_encoding); - $from = $this->endpoint ? $this->endpoint : $this->headers['to']; - $headers = array('In-Reply-To' => $this->headers['message-id']); - $options = array('from' => $from, 'subject'=> $this->headers['subject'], 'headers' => $headers); - $soap_transport->send($response, $options); - } - } - } -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/TCP.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Server/TCP.php deleted file mode 100755 index ac858c0f48e5103691802268b02be50045cfbfd8..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Server/TCP.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * This file contains the code for the TCP SOAP server. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Server.php'; - -/** - * SOAP Server Class that implements a TCP SOAP Server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * accept socket connections and execute SOAP calls. - * - * TODO: - * use Net_Socket - * implement some security scheme - * implement support for attachments - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - */ -class SOAP_Server_TCP extends SOAP_Server { - - var $headers = array(); - var $localaddr; - var $port; - var $listen; - var $reuse; - - function SOAP_Server_TCP($localaddr = '127.0.0.1', $port = 10000, - $listen = 5, $reuse = true) - { - parent::SOAP_Server(); - $this->localaddr = $localaddr; - $this->port = $port; - $this->listen = $listen; - $this->reuse = $reuse; - } - - function run() - { - if (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) < 0) { - return $this->_raiseSoapFault('socket_create() failed. Reason: ' . socket_strerror($sock)); - } - if ($this->reuse && - !@socket_setopt($sock, SOL_SOCKET, SO_REUSEADDR, 1)) { - return $this->_raiseSoapFault('socket_setopt() failed. Reason: ' . socket_strerror(socket_last_error($sock))); - } - if (($ret = socket_bind($sock, $this->localaddr, $this->port)) < 0) { - return $this->_raiseSoapFault('socket_bind() failed. Reason: ' . socket_strerror($ret)); - } - if (($ret = socket_listen($sock, $this->listen)) < 0) { - return $this->_raiseSoapFault('socket_listen() failed. Reason: ' . socket_strerror($ret)); - } - - while (true) { - $data = null; - if (($msgsock = socket_accept($sock)) < 0) { - $this->_raiseSoapFault('socket_accept() failed. Reason: ' . socket_strerror($msgsock)); - break; - } - while ($buf = socket_read($msgsock, 8192)) { - if (!$buf = trim($buf)) { - continue; - } - $data .= $buf; - } - - if ($data) { - $response = $this->service($data); - /* Write to the socket. */ - if (!socket_write($msgsock, $response, strlen($response))) { - return $this->_raiseSoapFault('Error sending response data reason ' . socket_strerror()); - } - } - - socket_close ($msgsock); - } - - socket_close ($sock); - } - - function service(&$data) - { - /* TODO: we need to handle attachments somehow. */ - return $this->parseRequest($data, $attachments); - } -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php deleted file mode 100755 index 0bb585ec83c2b729b6d7db57f2e3104b700b1955..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php -/** - * This file contains the code for an abstract transport layer. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> - * @author Shane Caraveo <Shane@Caraveo.com> - * @author Jan Schneider <jan@horde.org> - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; - -/** - * SOAP Transport Layer - * - * This layer can use different protocols dependant on the endpoint url - * provided. - * - * No knowlege of the SOAP protocol is available at this level. - * No knowlege of the transport protocols is available at this level. - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - * @author Jan Schneider <jan@horde.org> - */ -class SOAP_Transport extends SOAP_Base -{ - /** - * Connection endpoint URL. - * - * @var string - */ - var $url = ''; - - /** - * Array containing urlparts. - * - * @see parse_url() - * - * @var mixed - */ - var $urlparts = null; - - /** - * Incoming payload. - * - * @var string - */ - var $incoming_payload = ''; - - /** - * Outgoing payload. - * - * @var string - */ - var $outgoing_payload = ''; - - /** - * Request encoding. - * - * @var string - */ - var $encoding = SOAP_DEFAULT_ENCODING; - - /** - * Response encoding. - * - * We assume UTF-8 if no encoding is set. - * - * @var string - */ - var $result_encoding = 'UTF-8'; - - /** - * Decoded attachments from the reponse. - * - * @var array - */ - var $attachments; - - /** - * Request User-Agent. - * - * @var string - */ - var $_userAgent = SOAP_LIBRARY_NAME; - - /** - * Sends and receives SOAP data. - * - * @access public - * @abstract - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = null) - { - return $this->_raiseSoapFault('SOAP_Transport::send() not implemented.'); - } - - function getTransport($url, $encoding = SOAP_DEFAULT_ENCODING) - { - $urlparts = @parse_url($url); - - if (!$urlparts['scheme']) { - return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url"); - } - - if (strcasecmp($urlparts['scheme'], 'mailto') == 0) { - $transport_type = 'SMTP'; - } elseif (strcasecmp($urlparts['scheme'], 'https') == 0) { - $transport_type = 'HTTP'; - } else { - /* Handle other transport types */ - $transport_type = strtoupper($urlparts['scheme']); - } - $transport_class = "SOAP_Transport_$transport_type"; - if (!class_exists($transport_class)) { - if (!(@include_once('apps/maarch_entreprise/tools/PEAR/SOAP/Transport/' . basename($transport_type) . '.php'))) { - return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}"); - } - } - if (!class_exists($transport_class)) { - return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class"); - } - - return new $transport_class($url, $encoding); - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/HTTP.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/HTTP.php deleted file mode 100755 index 0d7292b54cb5806c76a26255f5a0da923ed85fc8..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/HTTP.php +++ /dev/null @@ -1,624 +0,0 @@ -<?php -/** - * This file contains the code for a HTTP transport layer. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> - * @author Jan Schneider <jan@horde.org> - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * HTTP Transport class - * - * @package SOAP - * @category Web Services - */ - -/** - * Needed Classes - */ -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; - -/** - * HTTP Transport for SOAP - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - * @author Jan Schneider <jan@horde.org> - */ -class SOAP_Transport_HTTP extends SOAP_Transport -{ - /** - * Basic Auth string. - * - * @var array - */ - var $headers = array(); - - /** - * Cookies. - * - * @var array - */ - var $cookies; - - /** - * Connection timeout in seconds. 0 = none. - * - * @var integer - */ - var $timeout = 4; - - /** - * HTTP-Response Content-Type. - */ - var $result_content_type; - - var $result_headers = array(); - - var $result_cookies = array(); - - /** - * SOAP_Transport_HTTP Constructor - * - * @access public - * - * @param string $url HTTP url to SOAP endpoint. - * @param string $encoding Encoding to use. - */ - function SOAP_Transport_HTTP($url, $encoding = SOAP_DEFAULT_ENCODING) - { - parent::SOAP_Base('HTTP'); - $this->urlparts = @parse_url($url); - $this->url = $url; - $this->encoding = $encoding; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - - if (!$this->_validateUrl()) { - return $this->fault; - } - - if (isset($options['timeout'])) { - $this->timeout = (int)$options['timeout']; - } - - if (strcasecmp($this->urlparts['scheme'], 'HTTP') == 0) { - return $this->_sendHTTP($msg, $options); - } elseif (strcasecmp($this->urlparts['scheme'], 'HTTPS') == 0) { - return $this->_sendHTTPS($msg, $options); - } - - return $this->_raiseSoapFault('Invalid url scheme ' . $this->url); - } - - /** - * Sets data for HTTP authentication, creates authorization header. - * - * @param string $username Username. - * @param string $password Response data, minus HTTP headers. - * - * @access public - */ - function setCredentials($username, $password) - { - $this->headers['Authorization'] = 'Basic ' . base64_encode($username . ':' . $password); - } - - /** - * Adds a cookie. - * - * @access public - * @param string $name Cookie name. - * @param mixed $value Cookie value. - */ - function addCookie($name, $value) - { - $this->cookies[$name] = $value; - } - - /** - * Generates the correct headers for the cookies. - * - * @access private - * - * @param array $options Cookie options. If 'nocookies' is set and true - * the cookies from the last response are added - * automatically. 'cookies' is name-value-hash with - * a list of cookies to add. - * - * @return string The cookie header value. - */ - function _generateCookieHeader($options) - { - $this->cookies = array(); - - if (empty($options['nocookies']) && - isset($this->result_cookies)) { - // Add the cookies we got from the last request. - foreach ($this->result_cookies as $cookie) { - if ($cookie['domain'] == $this->urlparts['host']) { - $this->cookies[$cookie['name']] = $cookie['value']; - } - } - } - - // Add cookies the user wants to set. - if (isset($options['cookies'])) { - foreach ($options['cookies'] as $cookie) { - if ($cookie['domain'] == $this->urlparts['host']) { - $this->cookies[$cookie['name']] = $cookie['value']; - } - } - } - - $cookies = ''; - foreach ($this->cookies as $name => $value) { - if (!empty($cookies)) { - $cookies .= '; '; - } - $cookies .= urlencode($name) . '=' . urlencode($value); - } - - return $cookies; - } - - /** - * Validate url data passed to constructor. - * - * @access private - * @return boolean - */ - function _validateUrl() - { - if (!is_array($this->urlparts) ) { - $this->_raiseSoapFault('Unable to parse URL ' . $this->url); - return false; - } - if (!isset($this->urlparts['host'])) { - $this->_raiseSoapFault('No host in URL ' . $this->url); - return false; - } - if (!isset($this->urlparts['port'])) { - if (strcasecmp($this->urlparts['scheme'], 'HTTP') == 0) { - $this->urlparts['port'] = 80; - } elseif (strcasecmp($this->urlparts['scheme'], 'HTTPS') == 0) { - $this->urlparts['port'] = 443; - } - - } - if (isset($this->urlparts['user'])) { - $this->setCredentials(urldecode($this->urlparts['user']), - urldecode($this->urlparts['pass'])); - } - if (!isset($this->urlparts['path']) || !$this->urlparts['path']) { - $this->urlparts['path'] = '/'; - } - - return true; - } - - /** - * Finds out what the encoding is. - * Sets the object property accordingly. - * - * @access private - * @param array $headers Headers. - */ - function _parseEncoding($headers) - { - $h = stristr($headers, 'Content-Type'); - preg_match_all('/^Content-Type:\s*(.*)$/im', $h, $ct, PREG_SET_ORDER); - $n = count($ct); - $ct = $ct[$n - 1]; - - // Strip the string of \r. - $this->result_content_type = str_replace("\r", '', $ct[1]); - - if (preg_match('/(.*?)(?:;\s?charset=)(.*)/i', - $this->result_content_type, - $m)) { - $this->result_content_type = $m[1]; - if (count($m) > 2) { - $enc = strtoupper(str_replace('"', '', $m[2])); - if (in_array($enc, $this->_encodings)) { - $this->result_encoding = $enc; - } - } - } - - // Deal with broken servers that don't set content type on faults. - if (!$this->result_content_type) { - $this->result_content_type = 'text/xml'; - } - } - - /** - * Parses the headers. - * - * @param array $headers The headers. - */ - function _parseHeaders($headers) - { - /* Largely borrowed from HTTP_Request. */ - $this->result_headers = array(); - $headers = preg_split("[\r?\n]", $headers); - foreach ($headers as $value) { - if (strpos($value,':') === false) { - $this->result_headers[0] = $value; - continue; - } - list($name, $value) = preg_split('[:]', $value); - $headername = strtolower($name); - $headervalue = trim($value); - $this->result_headers[$headername] = $headervalue; - - if ($headername == 'set-cookie') { - // Parse a SetCookie header to fill _cookies array. - $cookie = array('expires' => null, - 'domain' => $this->urlparts['host'], - 'path' => null, - 'secure' => false); - - if (!strpos($headervalue, ';')) { - // Only a name=value pair. - list($cookie['name'], $cookie['value']) = array_map('trim', explode('=', $headervalue)); - $cookie['name'] = urldecode($cookie['name']); - $cookie['value'] = urldecode($cookie['value']); - - } else { - // Some optional parameters are supplied. - $elements = explode(';', $headervalue); - list($cookie['name'], $cookie['value']) = array_map('trim', explode('=', $elements[0])); - $cookie['name'] = urldecode($cookie['name']); - $cookie['value'] = urldecode($cookie['value']); - - for ($i = 1; $i < count($elements);$i++) { - list($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName OR 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->result_cookies[] = $cookie; - } - } - } - - /** - * Removes HTTP headers from response. - * - * @return boolean - * @access private - */ - function _parseResponse() - { - if (!preg_match("/^(.*?)\r?\n\r?\n(.*)/s", - $this->incoming_payload, - $match)) { - $this->_raiseSoapFault('Invalid HTTP Response'); - return false; - } - - $this->response = $match[2]; - // Find the response error, some servers response with 500 for - // SOAP faults. - $this->_parseHeaders($match[1]); - - list(, $code, $msg) = sscanf($this->result_headers[0], '%s %s %s'); - unset($this->result_headers[0]); - - switch($code) { - case 100: // Continue - $this->incoming_payload = $match[2]; - return $this->_parseResponse(); - case 200: - case 202: - $this->incoming_payload = trim($match[2]); - if (!strlen($this->incoming_payload)) { - /* Valid one-way message response. */ - return true; - } - break; - case 400: - $this->_raiseSoapFault("HTTP Response $code Bad Request"); - return false; - case 401: - $this->_raiseSoapFault("HTTP Response $code Authentication Failed"); - return false; - case 403: - $this->_raiseSoapFault("HTTP Response $code Forbidden"); - return false; - case 404: - $this->_raiseSoapFault("HTTP Response $code Not Found"); - return false; - case 407: - $this->_raiseSoapFault("HTTP Response $code Proxy Authentication Required"); - return false; - case 408: - $this->_raiseSoapFault("HTTP Response $code Request Timeout"); - return false; - case 410: - $this->_raiseSoapFault("HTTP Response $code Gone"); - return false; - default: - if ($code >= 400 && $code < 500) { - $this->_raiseSoapFault("HTTP Response $code Not Found, Server message: $msg"); - return false; - } - break; - } - - $this->_parseEncoding($match[1]); - - if ($this->result_content_type == 'application/dime') { - // XXX quick hack insertion of DIME - if (PEAR::isError($this->_decodeDIMEMessage($this->response, $this->headers, $this->attachments))) { - // _decodeDIMEMessage already raised $this->fault - return false; - } - $this->result_content_type = $this->headers['content-type']; - } elseif (stristr($this->result_content_type, 'multipart/related')) { - $this->response = $this->incoming_payload; - if (PEAR::isError($this->_decodeMimeMessage($this->response, $this->headers, $this->attachments))) { - // _decodeMimeMessage already raised $this->fault - return false; - } - } elseif ($this->result_content_type != 'text/xml') { - $this->_raiseSoapFault($this->response); - return false; - } - - // if no content, return false - return strlen($this->response) > 0; - } - - /** - * Creates an HTTP request, including headers, for the outgoing request. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Outgoing payload. - */ - function _getRequest($msg, $options) - { - $this->headers = array(); - - $action = isset($options['soapaction']) ? $options['soapaction'] : ''; - $fullpath = $this->urlparts['path']; - if (isset($this->urlparts['query'])) { - $fullpath .= '?' . $this->urlparts['query']; - } - if (isset($this->urlparts['fragment'])) { - $fullpath .= '#' . $this->urlparts['fragment']; - } - - if (isset($options['proxy_host'])) { - $fullpath = 'http://' . $this->urlparts['host'] . ':' . - $this->urlparts['port'] . $fullpath; - } - - if (isset($options['proxy_user'])) { - $this->headers['Proxy-Authorization'] = 'Basic ' . - base64_encode($options['proxy_user'] . ':' . - $options['proxy_pass']); - } - - if (isset($options['user'])) { - $this->setCredentials($options['user'], $options['pass']); - } - - $this->headers['User-Agent'] = $this->_userAgent; - $this->headers['Host'] = $this->urlparts['host']; - $this->headers['Content-Type'] = "text/xml; charset=$this->encoding"; - $this->headers['Content-Length'] = strlen($msg); - $this->headers['SOAPAction'] = '"' . $action . '"'; - $this->headers['Connection'] = 'close'; - - if (isset($options['headers'])) { - $this->headers = array_merge($this->headers, $options['headers']); - } - - $cookies = $this->_generateCookieHeader($options); - if ($cookies) { - $this->headers['Cookie'] = $cookies; - } - - $headers = ''; - foreach ($this->headers as $k => $v) { - $headers .= "$k: $v\r\n"; - } - $this->outgoing_payload = "POST $fullpath HTTP/1.0\r\n" . $headers . - "\r\n" . $msg; - - return $this->outgoing_payload; - } - - /** - * Sends the outgoing HTTP request and reads and parses the response. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Response data without HTTP headers. - */ - function _sendHTTP($msg, $options) - { - $this->incoming_payload = ''; - $this->_getRequest($msg, $options); - $host = $this->urlparts['host']; - $port = $this->urlparts['port']; - if (isset($options['proxy_host'])) { - $host = $options['proxy_host']; - $port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080; - } - // Send. - if ($this->timeout > 0) { - $fp = @fsockopen($host, $port, $this->errno, $this->errmsg, $this->timeout); - } else { - $fp = @fsockopen($host, $port, $this->errno, $this->errmsg); - } - if (!$fp) { - return $this->_raiseSoapFault("Connect Error to $host:$port"); - } - if ($this->timeout > 0) { - // some builds of PHP do not support this, silence the warning - @socket_set_timeout($fp, $this->timeout); - } - if (!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { - return $this->_raiseSoapFault("Error POSTing Data to $host"); - } - - // get reponse - // XXX time consumer - do { - $data = fread($fp, 4096); - $_tmp_status = socket_get_status($fp); - if ($_tmp_status['timed_out']) { - return $this->_raiseSoapFault("Timed out read from $host"); - } else { - $this->incoming_payload .= $data; - } - } while (!$_tmp_status['eof']); - - fclose($fp); - - if (!$this->_parseResponse()) { - return $this->fault; - } - return $this->response; - } - - /** - * Sends the outgoing HTTPS request and reads and parses the response. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Response data without HTTP headers. - */ - function _sendHTTPS($msg, $options) - { - /* Check if the required curl extension is installed. */ - if (!extension_loaded('curl')) { - return $this->_raiseSoapFault('CURL Extension is required for HTTPS'); - } - - $ch = curl_init(); - - if (isset($options['proxy_host'])) { - $port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080; - curl_setopt($ch, CURLOPT_PROXY, - $options['proxy_host'] . ':' . $port); - } - if (isset($options['proxy_user'])) { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, - $options['proxy_user'] . ':' . $options['proxy_pass']); - } - - if (isset($options['user'])) { - curl_setopt($ch, CURLOPT_USERPWD, - $options['user'] . ':' . $options['pass']); - } - - $headers = array(); - $action = isset($options['soapaction']) ? $options['soapaction'] : ''; - $headers['Content-Type'] = "text/xml; charset=$this->encoding"; - $headers['SOAPAction'] = '"' . $action . '"'; - if (isset($options['headers'])) { - $headers = array_merge($headers, $options['headers']); - } - foreach ($headers as $header => $value) { - $headers[$header] = $header . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_USERAGENT, $this->_userAgent); - - if ($this->timeout) { - curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); - } - - curl_setopt($ch, CURLOPT_POSTFIELDS, $msg); - curl_setopt($ch, CURLOPT_URL, $this->url); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_FAILONERROR, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 1); - if (defined('CURLOPT_HTTP_VERSION')) { - curl_setopt($ch, CURLOPT_HTTP_VERSION, 1); - } - if (!ini_get('safe_mode') && !ini_get('open_basedir')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - } - $cookies = $this->_generateCookieHeader($options); - if ($cookies) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - - if (isset($options['curl'])) { - foreach ($options['curl'] as $key => $val) { - curl_setopt($ch, $key, $val); - } - } - - // Save the outgoing XML. This doesn't quite match _sendHTTP as CURL - // generates the headers, but having the XML is usually the most - // important part for tracing/debugging. - $this->outgoing_payload = $msg; - - $this->incoming_payload = curl_exec($ch); - if (!$this->incoming_payload) { - $m = 'curl_exec error ' . curl_errno($ch) . ' ' . curl_error($ch); - curl_close($ch); - return $this->_raiseSoapFault($m); - } - curl_close($ch); - - if (!$this->_parseResponse()) { - return $this->fault; - } - - return $this->response; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/SMTP.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/SMTP.php deleted file mode 100755 index 9056d9e9e76b78075923d802a2942a952484cfa3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/SMTP.php +++ /dev/null @@ -1,206 +0,0 @@ -<?php -/** - * This file contains the code for an SMTP transport layer. - * - * This code is still a rough and untested draft. - * TODO: - * switch to pear mail stuff - * smtp authentication - * smtp ssl support - * ability to define smtp options (encoding, from, etc.) - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> - * @author Jan Schneider <jan@horde.org> - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; -require_once 'Mail/smtp.php'; - -/** - * SMTP Transport for SOAP - * - * Implements SOAP-SMTP as defined at - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * @todo use PEAR smtp and Mime classes - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> - * @author Jan Schneider <jan@horde.org> - */ -class SOAP_Transport_SMTP extends SOAP_Transport -{ - var $credentials = ''; - var $timeout = 4; // connect timeout - var $host = '127.0.0.1'; - var $port = 25; - var $auth = null; - - /** - * SOAP_Transport_SMTP Constructor - * - * @param string $url mailto: address. - * - * @access public - */ - function SOAP_Transport_SMTP($url, $encoding = 'US-ASCII') - { - parent::SOAP_Base('SMTP'); - $this->encoding = $encoding; - $this->urlparts = @parse_url($url); - $this->url = $url; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - $this->incoming_payload = ''; - $this->outgoing_payload = $msg; - if (!$this->_validateUrl()) { - return $this->fault; - } - if (!$options || !isset($options['from'])) { - return $this->_raiseSoapFault('No From: address to send message with'); - } - - if (isset($options['host'])) $this->host = $options['host']; - if (isset($options['port'])) $this->port = $options['port']; - if (isset($options['auth'])) $this->auth = $options['auth']; - if (isset($options['username'])) $this->username = $options['username']; - if (isset($options['password'])) $this->password = $options['password']; - - $headers = array(); - $headers['From'] = $options['from']; - $headers['X-Mailer'] = $this->_userAgent; - $headers['MIME-Version'] = '1.0'; - $headers['Message-ID'] = md5(time()) . '.soap@' . $this->host; - $headers['To'] = $this->urlparts['path']; - if (isset($options['soapaction'])) { - $headers['Soapaction'] = "\"{$options['soapaction']}\""; - } - - if (isset($options['headers'])) - $headers = array_merge($headers, $options['headers']); - - // If the content type is already set, we assume that MIME encoding is - // already done. - if (isset($headers['Content-Type'])) { - $out = $msg; - } else { - // Do a simple inline MIME encoding. - $headers['Content-Disposition'] = 'inline'; - $headers['Content-Type'] = "text/xml; charset=\"$this->encoding\""; - if (isset($options['transfer-encoding'])) { - if (strcasecmp($options['transfer-encoding'], 'quoted-printable') == 0) { - $headers['Content-Transfer-Encoding'] = $options['transfer-encoding']; - $out = $msg; - } elseif (strcasecmp($options['transfer-encoding'],'base64') == 0) { - $headers['Content-Transfer-Encoding'] = 'base64'; - $out = chunk_split(base64_encode($msg), 76, "\n"); - } else { - return $this->_raiseSoapFault("Invalid Transfer Encoding: {$options['transfer-encoding']}"); - } - } else { - // Default to base64. - $headers['Content-Transfer-Encoding'] = 'base64'; - $out = chunk_split(base64_encode($msg)); - } - } - - $headers['Subject'] = isset($options['subject']) ? $options['subject'] : 'SOAP Message'; - - foreach ($headers as $key => $value) { - $header_text .= "$key: $value\n"; - } - $this->outgoing_payload = $header_text . "\r\n" . $this->outgoing_payload; - - $mailer_params = array( - 'host' => $this->host, - 'port' => $this->port, - 'username' => $this->username, - 'password' => $this->password, - 'auth' => $this->auth - ); - $mailer = new Mail_smtp($mailer_params); - $result = $mailer->send($this->urlparts['path'], $headers, $out); - if (!PEAR::isError($result)) { - $val = new SOAP_Value('Message-ID', 'string', $headers['Message-ID']); - } else { - $sval[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::SOAPENVPrefix().':Client'); - $sval[] = new SOAP_Value('faultstring', 'string', "couldn't send SMTP message to {$this->urlparts['path']}"); - $val = new SOAP_Value('Fault', 'Struct', $sval); - } - - $methodValue = new SOAP_Value('Response', 'Struct', array($val)); - - $this->incoming_payload = $this->makeEnvelope($methodValue, - $this->headers, - $this->encoding); - - return $this->incoming_payload; - } - - /** - * Sets data for HTTP authentication, creates Authorization header. - * - * @param string $username Username. - * @param string $password Response data, minus HTTP headers. - * - * @access public - */ - function setCredentials($username, $password) - { - $this->username = $username; - $this->password = $password; - } - - /** - * Validates url data passed to constructor. - * - * @return boolean - * @access private - */ - function _validateUrl() - { - if (!is_array($this->urlparts)) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['scheme']) || - strcasecmp($this->urlparts['scheme'], 'mailto') != 0) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['path'])) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - return true; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TCP.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TCP.php deleted file mode 100755 index 8de51b7daa90116ca973afad80bec0b942cc953d..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TCP.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php -/** - * This file contains the code for a TCP transport layer. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; - -/** - * TCP transport for SOAP. - * - * @todo use Net_Socket; implement some security scheme; implement support - * for attachments - * @access public - * @package SOAP - * @author Jan Schneider <jan@horde.org> - */ -class SOAP_Transport_TCP extends SOAP_Transport -{ - /** - * Socket. - */ - var $socket = null; - - /** - * Constructor. - * - * @param string $url HTTP url to SOAP endpoint. - * - * @access public - */ - function SOAP_Transport_TCP($url, $encoding = SOAP_DEFAULT_ENCODING) - { - parent::SOAP_Base_Object('TCP'); - $this->urlparts = @parse_url($url); - $this->url = $url; - $this->encoding = $encoding; - } - - function _socket_ping() - { - // XXX how do we restart after socket_shutdown? - //if (!$this->socket) { - // Create socket resource. - $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - if ($this->socket < 0) { - return 0; - } - - // Connect. - $result = socket_connect($this->socket, $this->urlparts['host'], - $this->urlparts['port']); - if ($result < 0) { - return 0; - } - //} - return 1; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - $this->incoming_payload = ''; - $this->outgoing_payload = $msg; - if (!$this->_validateUrl()) { - return $this->fault; - } - - // Check for TCP scheme. - if (strcasecmp($this->urlparts['scheme'], 'TCP') == 0) { - // Check connection. - if (!$this->_socket_ping()) { - return $this->_raiseSoapFault('Error connecting to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket))); - } - - // Write to the socket. - if (!@socket_write($this->socket, $this->outgoing_payload, - strlen($this->outgoing_payload))) { - return $this->_raiseSoapFault('Error sending data to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket))); - } - - // Shutdown writing. - if(!socket_shutdown($this->socket, 1)) { - return $this->_raiseSoapFault('Cannot change socket mode to read.'); - } - - // Read everything we can. - while ($buf = @socket_read($this->socket, 1024, PHP_BINARY_READ)) { - $this->incoming_payload .= $buf; - } - - // Return payload or die. - if ($this->incoming_payload) { - return $this->incoming_payload; - } - - return $this->_raiseSoapFault('Error reveiving data from ' . $this->url); - } - - return $this->_raiseSoapFault('Invalid url scheme ' . $this->url); - } - - /** - * Validates the url data passed to the constructor. - * - * @return boolean - * @access private - */ - function _validateUrl() - { - if (!is_array($this->urlparts) ) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['host'])) { - $this->_raiseSoapFault("No host in URL $this->url"); - return false; - } - if (!isset($this->urlparts['path']) || !$this->urlparts['path']) { - $this->urlparts['path'] = '/'; - } - - return true; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TEST.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TEST.php deleted file mode 100755 index 41a680b04bf99e94d2bdd89a837a4c6a4f5bce7e..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Transport/TEST.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * This file contains the code for a local transport layer for testing - * purposes. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Jan Schneider <jan@horde.org> - * @copyright 2008 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Transport.php'; - -/** - * Test transport for SOAP. - * - * @access public - * @package SOAP - * @author Jan Schneider <jan@horde.org> - */ -class SOAP_Transport_TEST extends SOAP_Transport -{ - /** - * Sends and receives SOAP data. - * - * @param string $msg Outgoing SOAP data. - * @param array $options Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->outgoing_payload = $msg; - ob_start(); - $server = clone($options['server']); - $server->service($msg); - $this->incoming_payload = ob_get_contents(); - ob_end_clean(); - return $this->incoming_payload; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/dateTime.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Type/dateTime.php deleted file mode 100755 index 4fcec72f73f202d2d1fa9a91e77d747bcbf2bd15..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/dateTime.php +++ /dev/null @@ -1,243 +0,0 @@ -<?php -/** - * This file contains the code for the SOAP_Type_dateTime class. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * This class converts from and to unix timestamps and ISO 8601 date/time. - * - * @access public - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <shane@php.net> Port to PEAR and more - * @author Jan Schneider <jan@horde.org> Maintenance - */ -class SOAP_Type_dateTime -{ - var $_iso8601 = - '# 1: centuries & years CCYY- - (-?[0-9]{4})- - # 2: months MM- - ([0-9]{2})- - # 3: days DD - ([0-9]{2}) - # 4: separator T - T - # 5: hours hh: - ([0-9]{2}): - # 6: minutes mm: - ([0-9]{2}): - # 7: seconds ss.ss... - ([0-9]{2})(\.[0-9]*)? - # 8: Z to indicate UTC, -+HH:MM:SS.SS... for local zones - (Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?'; - - var $timestamp = -1; - - /** - * Constructor. - * - * @param string|integer $date The timestamp or ISO 8601 formatted - * date and time this object is going to - * represent. - */ - function SOAP_Type_dateTime($date = -1) - { - if ($date == -1) { - $this->timestamp = time(); - } elseif (is_int($date)) { - $this->timestamp = $date; - } else { - $this->timestamp = $this->toUnixtime($date); - } - } - - /** - * Alias of {@link SOAP_Type_dateTime::toUTC}. - */ - function toSOAP($date = NULL) - { - return $this->toUTC($date); - } - - /** - * Converts this object or a timestamp to an ISO 8601 date/time string. - * - * @param integer $timestamp A unix timestamp - * - * @return string An ISO 8601 formatted date/time string. - */ - function toString($timestamp = 0) - { - if (!$timestamp) { - $timestamp = $this->timestamp; - } - if ($timestamp < 0) { - return 0; - } - - //simulate PHP5's P parameter - $zone = date('O', $timestamp); - if (strlen($zone) === 5) { - $zone = substr($zone, 0, 3) . ':' . substr($zone, 3); - } - return date('Y-m-d\TH:i:s', $timestamp) . $zone; - } - - /** - * Splits a date/time into its components. - * - * @param string|integer $datestr A unix timestamp or ISO 8601 date/time - * string. If empty, this object is used. - * - * @return boolean|array An array with the date and time components or - * false on failure. - */ - function _split($datestr) - { - if (!$datestr) { - $datestr = $this->toString(); - } elseif (is_int($datestr)) { - $datestr = $this->toString($datestr); - } - - if (preg_match('/' . $this->_iso8601 . '/x', $datestr, $regs)) { - if (empty($regs[8])) { - $timestamp = strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02d', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6])); - $regs[8] = date('O', $timestamp); - } - if ($regs[8] != 'Z') { - $op = substr($regs[8], 0, 1); - $h = substr($regs[8], 1, 2); - if (strstr($regs[8], ':')) { - $m = substr($regs[8], 4, 2); - } else { - $m = substr($regs[8], 3, 2); - } - if ($op == '+') { - $regs[4] = $regs[4] - $h; - if ($regs[4] < 0) { - $regs[4] += 24; - } - $regs[5] = $regs[5] - $m; - if ($regs[5] < 0) { - $regs[5] += 60; - } - } else { - $regs[4] = $regs[4] + $h; - if ($regs[4] > 23) { - $regs[4] -= 24; - } - $regs[5] = $regs[5] + $m; - if ($regs[5] > 59) { - $regs[5] -= 60; - } - } - } - return $regs; - } - - return false; - } - - /** - * Returns an ISO 8601 formatted UTC date/time string. - * - * @param string|integer $datestr @see SOAP_Type_dateTime::_split - * - * @return string The ISO 8601 formatted UTC date/time string. - */ - function toUTC($datestr = null) - { - $regs = $this->_split($datestr); - - if ($regs) { - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6]); - } - - return ''; - } - - /** - * Returns a unix timestamp. - * - * @param string|integer $datestr @see SOAP_Type_dateTime::_split - * - * @return integer The unix timestamp. - */ - function toUnixtime($datestr = null) - { - $regs = $this->_split($datestr); - if ($regs) { - return strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02dZ', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6])); - } - return -1; - } - - /** - * Compares two dates or this object with a second date. - * - * @param string|integer $date1 A unix timestamp or ISO 8601 date/time - * string. - * @param string|integer $date2 A unix timestamp or ISO 8601 date/time - * string. If empty, this object is used. - * - * @return integer The difference between the first and the second date. - */ - function compare($date1, $date2 = null) - { - if (is_null($date2)) { - $date2 = $date1; - $date1 = $this->timestamp; - } - if (!is_int($date1)) { - $date1 = $this->toUnixtime($date1); - } - if (!is_int($date2)) { - $date2 = $this->toUnixtime($date2); - } - - if ($date1 != -1 && $date2 != -1) { - return $date1 - $date2; - } - - return -1; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/duration.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Type/duration.php deleted file mode 100755 index f7d7925dbaa5591a6de8fa2685759e4c23a188d4..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/duration.php +++ /dev/null @@ -1,194 +0,0 @@ -<?php -/** - * This file contains the code for the SOAP_Type_duration class. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * This is only an aproximation of duration, more work still to do. See the - * schema url for more info on duration. - * - * http://www.w3.org/TR/xmlschema-2/ - * - * [Definition:] duration represents a duration of time. The value space of - * duration is a six-dimensional space where the coordinates designate the - * Gregorian year, month, day, hour, minute, and second components - * defined in 5.5.3.2 of [ISO 8601], respectively. These components are - * ordered in their significance by their order of appearance i.e. as year, - * month, day, hour, minute, and second. - * - * 3.2.6.1 Lexical representation - * The lexical representation for duration is the [ISO 8601] extended - * format PnYn MnDTnH nMnS, where nY represents the number of - * years, nM the number of months, nD the number of days, 'T' is the - * date/time separator, nH the number of hours, nM the number of - * minutes and nS the number of seconds. The number of seconds - * can include decimal digits to arbitrary precision. - * - * The values of the Year, Month, Day, Hour and Minutes components - * are not restricted but allow an arbitrary integer. Similarly, the - * value of the Seconds component allows an arbitrary decimal. - * Thus, the lexical representation of duration does not follow the - * alternative format of 5.5.3.2.1 of [ISO 8601]. - * - * An optional preceding minus sign ('-') is allowed, to indicate a - * negative duration. If the sign is omitted a positive duration is - * indicated. See also ISO 8601 Date and Time Formats (D). - * - * For example, to indicate a duration of 1 year, 2 months, 3 days, - * 10 hours, and 30 minutes, one would write: P1Y2M3DT10H30M. - * One could also indicate a duration of minus 120 days as: -P120D. - * - * Reduced precision and truncated representations of this format - * are allowed provided they conform to the following: - * - * If the number of years, months, days, hours, minutes, or seconds - * in any expression equals zero, the number and its corresponding - * designator *may* be omitted. However, at least one number and - * its designator *must* be present. - * The seconds part *may* have a decimal fraction. - * The designator 'T' shall be absent if all of the time items are absent. - * The designator 'P' must always be present. - * For example, P1347Y, P1347M and P1Y2MT2H are all allowed; P0Y1347M - * and P0Y1347M0D are allowed. P-1347M is not allowed although -P1347M - * is allowed. P1Y2MT is not allowed. - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Port to PEAR and more - * @author Jan Schneider <jan@horde.org> Maintenance - * @todo Figure out best aproximation for year and month conversion to - * seconds - */ -class SOAP_Type_duration -{ - // format PnYnMnDTnHnMnS - function unix_to_duration($seconds) - { - return SOAP_Type_duration::getduration($seconds); - } - - function mod($a, $b, &$d, &$r) - { - $d = floor($a / $b); - $r = $a % $b; - } - - function getduration($seconds) - { - $neg = ''; - if ($seconds < 0) { - $neg = '-'; - $seconds = $seconds * -1; - } - - $_mi = 60; - $_h = $_mi * 60; - $_d = $_h * 24; - // XXX how do we properly handle month and year values? - $_m = $_d * 30; - $_y = $_d * 365; - - SOAP_Type_duration::mod($seconds, $_y, $y, $seconds); - SOAP_Type_duration::mod($seconds, $_m, $m, $seconds); - SOAP_Type_duration::mod($seconds, $_d, $d, $seconds); - SOAP_Type_duration::mod($seconds, $_h, $h, $seconds); - SOAP_Type_duration::mod($seconds, $_mi, $mi, $s); - - $duration = $neg.'P'; - if ($y) $duration .= $y.'Y'; - if ($m) $duration .= $m.'M'; - if ($d) $duration .= $d.'D'; - if ($h || $mi || $s) $duration .='T'; - if ($h) $duration .= $h.'H'; - if ($mi) $duration .= $mi.'M'; - if ($s) $duration .= $s.'S'; - if ($duration == 'P' || $duration == '-P') $duration = 'PT0S'; - - return $duration; - } - - function mkduration($n, $Y, $Mo, $D, $H, $Mi, $S) - { - $_mi = 60; - $_h = $_mi * 60; - $_d = $_h * 24; - // XXX how do we properly handle month and year values? - $_m = $_d * 30; - $_y = $_d * 365; - - $sec = $Y * $_y + $Mo * $_m + $D * $_d + $H * $_h + $Mi * $_mi + $S; - if ($n == '-') $sec = $sec * -1; - - return $sec; - } - - function duration_to_unix($duration) - { - if (ereg('(-)?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?T?([0-9]+H)?([0-9]+M)?([0-9]+S)?', $duration, $regs)) { - return SOAP_Type_duration::mkduration($regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6], $regs[7]); - } - return false; - } - - function is_duration($duration) - { - return ereg('(-)?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?T?([0-9]+H)?([0-9]+M)?([0-9]+S)?', $duration, $regs); - } - - function _test($time) - { - if (SOAP_Type_duration::is_duration($time)) { - $t = SOAP_Type_duration::duration_to_unix($time); - echo "Duration: $time is ".$t." seconds\n"; - } else { - $t = SOAP_Type_duration::unix_to_duration($time); - echo "Seconds: $time is ".$t." duration\n"; - } - return $t; - } - - function add($d1, $d2) - { - $s1 = SOAP_Type_duration::duration_to_unix($d1); - $s2 = SOAP_Type_duration::duration_to_unix($d2); - return SOAP_Type_duration::unix_to_duration($s1 + $s2); - } - - function subtract($d1, $d2) - { - $s1 = SOAP_Type_duration::duration_to_unix($d1); - $s2 = SOAP_Type_duration::duration_to_unix($d2); - return SOAP_Type_duration::unix_to_duration($s1 - $s2); - } - -} - -/* Tests. */ -$t = SOAP_Type_duration::_test('P1Y2M3DT10H30M'); -SOAP_Type_duration::_test($t); -$t = SOAP_Type_duration::_test('-P120D'); -SOAP_Type_duration::_test($t); - -/* Duration since 1970. */ -$t = SOAP_Type_duration::_test(time()); -SOAP_Type_duration::_test($t); - -echo 'Add should be PT0S: ' . SOAP_Type_duration::add('-P120D','P4M') . "\n"; -echo 'Subtract should be PT0S: ' . SOAP_Type_duration::subtract('P120D','P4M') . "\n"; diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/hexBinary.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Type/hexBinary.php deleted file mode 100755 index e6bbdf43da8e93c547aa4ca6f82774210e0858ed..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Type/hexBinary.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * This class provides methods to detect and convert binary data from an to - * hexadecimal strings. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ -class SOAP_Type_hexBinary { - - function to_bin($value) - { - return pack('H' . strlen($value), $value); - } - - function to_hex($value) - { - return bin2hex($value); - } - - function is_hexbin($value) - { - // First see if there are any invalid chars. - if (!strlen($value) || preg_match('/[^A-Fa-f0-9]/', $value)) { - return false; - } - - return strcasecmp($value, SOAP_Type_hexBinary::to_hex(SOAP_Type_hexBinary::to_bin($value))) == 0; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/Value.php b/apps/maarch_entreprise/tools/PEAR/SOAP/Value.php deleted file mode 100755 index 743f62581141a86bf26ef271df53e3d5b13ec581..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/Value.php +++ /dev/null @@ -1,288 +0,0 @@ -<?php -/** - * This file contains the code for converting values between SOAP and PHP. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; - -/** - * SOAP::Value - * - * This class converts values between PHP and SOAP. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Value -{ - /** - * The actual value. - * - * @var mixed - */ - var $value = null; - - /** - * QName instance representing the value name. - * - * @var QName - */ - var $nqn; - - /** - * The value name, without namespace information. - * - * @var string - */ - var $name = ''; - - /** - * The namespace of the value name. - * - * @var string - */ - var $namespace = ''; - - /** - * QName instance representing the value type. - * - * @var QName - */ - var $tqn; - - /** - * The value type, without namespace information. - * - * @var string - */ - var $type = ''; - - /** - * The namespace of the value type. - * - * @var string - */ - var $type_namespace = ''; - - /** - * The type of the array elements, if this value is an array. - * - * @var string - */ - var $arrayType = ''; - - /** - * A hash of additional attributes. - * - * @see SOAP_Value() - * @var array - */ - var $attributes = array(); - - /** - * List of encoding and serialization options. - * - * @see SOAP_Value() - * @var array - */ - var $options = array(); - - /** - * Constructor. - * - * @param string $name Name of the SOAP value {namespace}name. - * @param mixed $type SOAP value {namespace}type. Determined - * automatically if not set. - * @param mixed $value Value to set. - * @param array $attributes A has of additional XML attributes to be - * added to the serialized value. - * @param array $options A list of encoding and serialization options: - * - 'attachment': array with information about - * the attachment - * - 'soap_encoding': defines encoding for SOAP - * message part of a MIME encoded SOAP request - * (default: base64) - * - 'keep_arrays_flat': use the tag name - * multiple times for each element when - * passing in an array in literal mode - * - 'no_type_prefix': supress adding of the - * namespace prefix - */ - public function __construct($name = '', $type = false, $value = null, - $attributes = array(), $options = array()) - { - $this->nqn = new QName($name); - $this->name = $this->nqn->name; - $this->namespace = $this->nqn->namespace; - if ($type) { - $this->tqn = new QName($type); - $this->type = $this->tqn->name; - $this->type_namespace = $this->tqn->namespace; - } - $this->value = $value; - $this->attributes = $attributes; - $this->options = $options; - } - - /** - * Serializes this value. - * - * @param SOAP_Base $serializer A SOAP_Base instance or subclass to - * serialize with. - * - * @return string XML representation of $this. - */ - function serialize(&$serializer) - { - return $serializer->_serializeValue($this->value, - $this->nqn, - $this->tqn, - $this->options, - $this->attributes, - $this->arrayType); - } - -} - -/** - * This class converts values between PHP and SOAP. It is a simple wrapper - * around SOAP_Value, adding support for SOAP actor and mustunderstand - * parameters. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_Header extends SOAP_Value -{ - /** - * Constructor - * - * @param string $name Name of the SOAP value {namespace}name. - * @param mixed $type SOAP value {namespace}type. Determined - * automatically if not set. - * @param mixed $value Value to set - * @param integer $mustunderstand Zero or one. - * @param mixed $attributes Attributes. - */ - public function __construct($name = '', $type, $value, $mustunderstand = 0, - $attributes = array()) - { - if (!is_array($attributes)) { - $actor = $attributes; - $attributes = array(); - } - - parent::SOAP_Value($name, $type, $value, $attributes); - - if (isset($actor)) { - $this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'] = $actor; - } elseif (!isset($this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'])) { - $this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; - } - $this->attributes[SOAP_BASE::SOAPENVPrefix().':mustUnderstand'] = (int)$mustunderstand; - } - -} - -/** - * This class handles MIME attachements per W3C's Note on Soap Attachements at - * http://www.w3.org/TR/SOAP-attachments - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - */ -class SOAP_Attachment extends SOAP_Value -{ - /** - * Constructor. - * - * @param string $name Name of the SOAP value <value_name> - * @param string $type The attachment's MIME type. - * @param string $filename The attachment's file name. Ignored if $file - * is provide. - * @param string $file The attachment data. - * @param array $attributes Attributes. - */ - public function __construct($name = '', $type = 'application/octet-stream', - $filename, $file = null, $attributes = null) - { - parent::SOAP_Value($name, null, null); - - $filedata = $file === null ? $this->_file2str($filename) : $file; - $filename = basename($filename); - if (PEAR::isError($filedata)) { - $this->options['attachment'] = $filedata; - return; - } - - $cid = md5(uniqid(time())); - - $this->attributes = $attributes; - $this->attributes['href'] = 'cid:' . $cid; - - $this->options['attachment'] = array('body' => $filedata, - 'disposition' => $filename, - 'content_type' => $type, - 'encoding' => 'base64', - 'cid' => $cid); - } - - /** - * Returns the contents of the given file name as string. - * - * @access private - * - * @param string $file_name The file location. - * - * @return string The file data or a PEAR_Error. - */ - function _file2str($file_name) - { - if (!is_readable($file_name)) { - return PEAR::raiseError('File is not readable: ' . $file_name); - } - - if (function_exists('file_get_contents')) { - return file_get_contents($file_name); - } - - if (!$fd = fopen($file_name, 'rb')) { - return PEAR::raiseError('Could not open ' . $file_name); - } - $cont = fread($fd, filesize($file_name)); - fclose($fd); - - return $cont; - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php b/apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php deleted file mode 100755 index ae77b96d2a156d142a79984f27d7c94c324ef8a3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php +++ /dev/null @@ -1,2306 +0,0 @@ -<?php -/** - * This file contains the code for dealing with WSDL access and services. - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 2.02 of the PHP license, - * that is bundled with this package in the file LICENSE, and is available at - * through the world-wide-web at http://www.php.net/license/2_02.txt. If you - * did not receive a copy of the PHP license and are unable to obtain it - * through the world-wide-web, please send a note to license@php.net so we can - * mail you a copy immediately. - * - * @category Web Services - * @package SOAP - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more - * @author Chuck Hagenbuch <chuck@horde.org> Maintenance - * @author Jan Schneider <jan@horde.org> Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Base.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Fault.php'; -require_once 'apps/maarch_entreprise/tools/PEAR/HTTP/Request.php'; - -define('WSDL_CACHE_MAX_AGE', 43200); - -/** - * This class parses WSDL files, and can be used by SOAP::Client to properly - * register soap values for services. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @todo - * - refactor namespace handling ($namespace/$ns) - * - implement IDL type syntax declaration so we can generate WSDL - * - * @access public - * @package SOAP - * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates - * @author Dietrich Ayala <dietrich@ganx4.com> Original Author - */ -class SOAP_WSDL extends SOAP_Base -{ - var $tns = null; - var $definition = array(); - var $namespaces = array(); - var $ns = array(); - var $xsd = SOAP_XML_SCHEMA_VERSION; - var $complexTypes = array(); - var $elements = array(); - var $messages = array(); - var $portTypes = array(); - var $bindings = array(); - var $imports = array(); - var $services = array(); - var $service = ''; - - /** - * URL to WSDL file. - * - * @var string - */ - var $uri; - - /** - * Parse documentation in the WSDL? - * - * @var boolean - */ - var $docs; - - /** - * Proxy parameters. - * - * @var array - */ - var $proxy; - - /** - * Enable tracing in the generated proxy class? - * - * @var boolean - */ - var $trace = false; - - /** - * Use WSDL cache? - * - * @var boolean - */ - var $cacheUse; - - /** - * WSDL cache directory. - * - * @var string - */ - var $cacheDir; - - /** - * Cache maximum lifetime (in seconds). - * - * @var integer - */ - var $cacheMaxAge; - - /** - * Class to use for WSDL parsing. Can be overridden for special cases, - * subclasses, etc. - * - * @var string - */ - var $wsdlParserClass = 'SOAP_WSDL_Parser'; - - /** - * Reserved PHP keywords. - * - * @link http://www.php.net/manual/en/reserved.php - * - * @var array - */ - var $_reserved = array('abstract', 'and', 'array', 'as', 'break', 'case', - 'catch', 'cfunction', 'class', 'clone', 'const', - 'continue', 'declare', 'default', 'die', 'do', - 'echo', 'else', 'elseif', 'empty', 'enddeclare', - 'endfor', 'endforeach', 'endif', 'endswitch', - 'endwhile', 'eval', 'exception', 'exit', 'extends', - 'final', 'for', 'foreach', 'function', 'global', - 'if', 'implements', 'include', 'include_once', - 'interface', 'isset', 'list', 'new', 'old_function', - 'or', 'php_user_filter', 'print', 'private', - 'protected', 'public', 'require', 'require_once', - 'return', 'static', 'switch', 'this', 'throw', - 'try', 'unset', 'use', 'var', 'while', 'xor'); - - /** - * Regular expressions for invalid PHP labels. - * - * @link http://www.php.net/manual/en/language.variables.php. - * - * @var string - */ - var $_invalid = array('/^[^a-zA-Z_\x7f-\xff]/', '/[^a-zA-Z0-9_\x7f-\xff]/'); - - /** - * SOAP_WSDL constructor. - * - * @param string $wsdl_uri URL to WSDL file. - * @param array $proxy Options for HTTP_Request class - * @see HTTP_Request. - * @param boolean|string $cacheUse Use WSDL caching? The cache directory - * if a string. - * @param integer $cacheMaxAge Cache maximum lifetime (in seconds). - * @param boolean $docs Parse documentation in the WSDL? - * - * @access public - */ - public function __construct( - $wsdl_uri = false, - $proxy = array(), - $cacheUse = false, - $cacheMaxAge = WSDL_CACHE_MAX_AGE, - $docs = false) - { - $SOAP_Base = new SOAP_Base('WSDL'); - //parent::SOAP_Base('WSDL'); - $this->uri = $wsdl_uri; - $this->proxy = $proxy; - $this->cacheUse = !empty($cacheUse); - $this->cacheMaxAge = $cacheMaxAge; - $this->docs = $docs; - if (is_string($cacheUse)) { - $this->cacheDir = $cacheUse; - } - - if ($wsdl_uri) { - if (!PEAR::isError($this->parseURL($wsdl_uri))) { - reset($this->services); - $this->service = key($this->services); - } - } - } - - /** - * @deprecated Use setService(). - */ - function set_service($service) - { - $this->setService($service); - } - - /** - * Sets the service currently to be used. - * - * @param string $service An (existing) service name. - */ - function setService($service) - { - if (array_key_exists($service, $this->services)) { - $this->service = $service; - } - } - - /** - * Fills the WSDL array tree with data from a WSDL file. - * - * @param string $wsdl_uri URL to WSDL file. - */ - function parseURL($wsdl_uri) - { - $parser = new SOAP_WSDL_Parser($wsdl_uri, $this, $this->docs); - - if ($parser->fault) { - $this->_raiseSoapFault($parser->fault); - } - } - - /** - * Fills the WSDL array tree with data from one or more PHP class objects. - * - * @param mixed $wsdl_obj An object or array of objects to add to - * the internal WSDL tree. - * @param string $targetNamespace The target namespace of schema types - * etc. - * @param string $service_name Name of the WSDL service. - * @param string $service_desc Optional description of the WSDL - * service. - */ - function parseObject($wsdl_obj, $targetNamespace, $service_name, - $service_desc = '') - { - $parser = new SOAP_WSDL_ObjectParser($wsdl_obj, $this, - $targetNamespace, $service_name, - $service_desc); - - if ($parser->fault) { - $this->_raiseSoapFault($parser->fault); - } - } - - function getEndpoint($portName) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - return (isset($this->services[$this->service]['ports'][$portName]['address']['location'])) - ? $this->services[$this->service]['ports'][$portName]['address']['location'] - : $this->_raiseSoapFault("No endpoint for port for $portName", $this->uri); - } - - function _getPortName($operation, $service) - { - if (isset($this->services[$service]['ports'])) { - $ports = $this->services[$service]['ports']; - foreach ($ports as $port => $portAttrs) { - $type = $ports[$port]['type']; - if ($type == 'soap' && - isset($this->bindings[$portAttrs['binding']]['operations'][$operation])) { - return $port; - } - } - } - return null; - } - - /** - * Finds the name of the first port that contains an operation of name - * $operation. Always returns a SOAP portName. - */ - function getPortName($operation, $service = null) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!$service) { - $service = $this->service; - } - if (isset($this->services[$service]['ports'])) { - if ($portName = $this->_getPortName($operation, $service)) { - return $portName; - } - } - // Try any service in the WSDL. - foreach ($this->services as $serviceName => $service) { - if (isset($this->services[$serviceName]['ports'])) { - if ($portName = $this->_getPortName($operation, $serviceName)) { - $this->service = $serviceName; - return $portName; - } - } - } - return $this->_raiseSoapFault("No operation $operation in WSDL.", $this->uri); - } - - function getOperationData($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!isset($this->services[$this->service]['ports'][$portName]['binding']) || - !($binding = $this->services[$this->service]['ports'][$portName]['binding'])) { - return $this->_raiseSoapFault("No binding for port $portName in WSDL.", $this->uri); - } - - // Get operation data from binding. - if (is_array($this->bindings[$binding]['operations'][$operation])) { - $opData = $this->bindings[$binding]['operations'][$operation]; - } - // Get operation data from porttype. - $portType = $this->bindings[$binding]['type']; - if (!$portType) { - return $this->_raiseSoapFault("No port type for binding $binding in WSDL.", $this->uri); - } - if (is_array($type = $this->portTypes[$portType][$operation])) { - if (isset($type['parameterOrder'])) { - $opData['parameterOrder'] = $type['parameterOrder']; - } - $opData['input'] = array_merge($opData['input'], $type['input']); - $opData['output'] = array_merge($opData['output'], $type['output']); - } - if (!$opData) - return $this->_raiseSoapFault("No operation $operation for port $portName in WSDL.", $this->uri); - $opData['parameters'] = false; - if (isset($this->bindings[$binding]['operations'][$operation]['input']['namespace'])) - $opData['namespace'] = $this->bindings[$binding]['operations'][$operation]['input']['namespace']; - // Message data from messages. - $inputMsg = $opData['input']['message']; - if (is_array($this->messages[$inputMsg])) { - foreach ($this->messages[$inputMsg] as $pname => $pattrs) { - if ($opData['style'] == 'document' && - $opData['input']['use'] == 'literal' && - $pname == 'parameters') { - $opData['parameters'] = true; - $opData['namespace'] = $this->namespaces[$pattrs['namespace']]; - $el = $this->elements[$pattrs['namespace']][$pattrs['type']]; - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $opData['input']['parts'][$elname] = $elattrs; - } - } - } else { - $opData['input']['parts'][$pname] = $pattrs; - } - } - } - $outputMsg = $opData['output']['message']; - if (is_array($this->messages[$outputMsg])) { - foreach ($this->messages[$outputMsg] as $pname => $pattrs) { - if ($opData['style'] == 'document' && - $opData['output']['use'] == 'literal' && - $pname == 'parameters') { - - $el = $this->elements[$pattrs['namespace']][$pattrs['type']]; - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $opData['output']['parts'][$elname] = $elattrs; - } - } - } else { - $opData['output']['parts'][$pname] = $pattrs; - } - } - } - return $opData; - } - - function matchMethod(&$operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - // Overloading lowercases function names :( - foreach ($this->services[$this->service]['ports'] as $portAttrs) { - foreach (array_keys($this->bindings[$portAttrs['binding']]['operations']) as $op) { - if (strcasecmp($op, $operation) == 0) { - $operation = $op; - } - } - } - } - - /** - * Given a datatype, what function handles the processing? - * - * This is used for doc/literal requests where we receive a datatype, and - * we need to pass it to a method in out server class. - * - * @param string $datatype - * @param string $namespace - * @return string - * @access public - */ - function getDataHandler($datatype, $namespace) - { - // See if we have an element by this name. - if (isset($this->namespaces[$namespace])) { - $namespace = $this->namespaces[$namespace]; - } - - if (!isset($this->ns[$namespace])) { - return null; - } - - $nsp = $this->ns[$namespace]; - //if (!isset($this->elements[$nsp])) - // $nsp = $this->namespaces[$nsp]; - if (!isset($this->elements[$nsp][$datatype])) { - return null; - } - - $checkmessages = array(); - // Find what messages use this datatype. - foreach ($this->messages as $messagename => $message) { - foreach ($message as $part) { - if ($part['type'] == $datatype) { - $checkmessages[] = $messagename; - break; - } - } - } - // Find the operation that uses this message. - foreach($this->portTypes as $porttype) { - foreach ($porttype as $opname => $opinfo) { - foreach ($checkmessages as $messagename) { - if ($opinfo['input']['message'] == $messagename) { - return $opname; - } - } - } - } - - return null; - } - - function getSoapAction($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!empty($this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['soapAction'])) { - return $this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['soapAction']; - } - - return false; - } - - function getNamespace($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!empty($this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['input']['namespace'])) { - return $this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['input']['namespace']; - } - - return false; - } - - function getNamespaceAttributeName($namespace) - { - /* If it doesn't exist at first, flip the array and check again. */ - if (empty($this->ns[$namespace])) { - $this->ns = array_flip($this->namespaces); - } - - /* If it doesn't exist now, add it. */ - if (empty($this->ns[$namespace])) { - return $this->addNamespace($namespace); - } - - return $this->ns[$namespace]; - } - - function addNamespace($namespace) - { - if (!empty($this->ns[$namespace])) { - return $this->ns[$namespace]; - } - - $n = count($this->ns); - $attr = 'ns' . $n; - $this->namespaces['ns' . $n] = $namespace; - $this->ns[$namespace] = $attr; - - return $attr; - } - - function _validateString($string) - { - return preg_match('/^[\w_:#\/]+$/', $string); - } - - function _addArg(&$args, &$argarray, $argname) - { - if ($args) { - $args .= ', '; - } - $args .= '$' . $argname; - if (!$this->_validateString($argname)) { - return; - } - if ($argarray) { - $argarray .= ', '; - } - $argarray .= "'$argname' => $" . $argname; - } - - function _elementArg(&$args, &$argarray, &$_argtype, $_argname) - { - $comments = ''; - $el = $this->elements[$_argtype['namespace']][$_argtype['type']]; - $tns = isset($this->ns[$el['namespace']]) - ? $this->ns[$el['namespace']] - : $_argtype['namespace']; - - if (!empty($el['complex']) || - (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]))) { - // The element is a complex type. - $comments .= " // {$_argtype['type']} is a ComplexType, refer to the WSDL for more info.\n"; - $attrname = "{$_argtype['type']}_attr"; - if (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]['attribute'])) { - $comments .= " // {$_argtype['type']} may require attributes, refer to the WSDL for more info.\n"; - } - $comments .= " \${$attrname}['xmlns'] = '{$this->namespaces[$_argtype['namespace']]}';\n"; - $comments .= " \${$_argtype['type']} = new SOAP_Value('{$_argtype['type']}', false, \${$_argtype['type']}, \$$attrname);\n"; - $this->_addArg($args, $argarray, $_argtype['type']); - if (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]['attribute'])) { - if ($args) { - $args .= ', '; - } - $args .= '$' . $attrname; - } - } elseif (isset($el['elements'])) { - foreach ($el['elements'] as $ename => $element) { - $comments .= " \$$ename = new SOAP_Value('{{$this->namespaces[$element['namespace']]}}$ename', '" . - (isset($element['type']) ? $element['type'] : false) . - "', \$$ename);\n"; - $this->_addArg($args, $argarray, $ename); - } - } else { - $comments .= " \$$_argname = new SOAP_Value('{{$this->namespaces[$tns]}}$_argname', '{$el['type']}', \$$_argname);\n"; - $this->_addArg($args, $argarray, $_argname); - } - - return $comments; - } - - function _complexTypeArg(&$args, &$argarray, &$_argtype, $_argname) - { - $comments = ''; - if (isset($this->complexTypes[$_argtype['namespace']][$_argtype['type']])) { - $comments = " // $_argname is a ComplexType {$_argtype['type']},\n" . - " // refer to wsdl for more info\n"; - if (isset($this->complexTypes[$_argtype['namespace']][$_argtype['type']]['attribute'])) { - $comments .= " // $_argname may require attributes, refer to wsdl for more info\n"; - } - $wrapname = '{' . $this->namespaces[$_argtype['namespace']].'}' . $_argtype['type']; - $comments .= " \$$_argname = new SOAP_Value('$_argname', '$wrapname', \$$_argname);\n"; - } - - $this->_addArg($args, $argarray, $_argname); - - return $comments; - } - - /** - * Generates stub code from the WSDL that can be saved to a file or eval'd - * into existence. - */ - function generateProxyCode($port = '', $classname = '') - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - $multiport = count($this->services[$this->service]['ports']) > 1; - if (!$port) { - reset($this->services[$this->service]['ports']); - $port = current($this->services[$this->service]['ports']); - } - // XXX currently do not support HTTP ports - if ($port['type'] != 'soap') { - return null; - } - - // XXX currentPort is BAD - $clienturl = $port['address']['location']; - if (!$classname) { - if ($multiport || $port) { - $classname = 'WebService_' . $this->service . '_' . $port['name']; - } else { - $classname = 'WebService_' . $this->service; - } - $classname = $this->_sanitize($classname); - } - - if (!$this->_validateString($classname)) { - return null; - } - - if (is_array($this->proxy) && count($this->proxy)) { - $class = "class $classname extends SOAP_Client\n{\n" . - //" function $classname(\$path = '$clienturl')\n {\n" . - " public function __construct(\$path = '$clienturl')\n {\n" . - " \$this->SOAP_Client(\$path, 0, 0,\n" . - ' array('; - - foreach ($this->proxy as $key => $val) { - if (is_array($val)) { - $class .= "'$key' => array("; - foreach ($val as $key2 => $val2) { - $class .= "'$key2' => '$val2', "; - } - $class .= ')'; - } else { - $class .= "'$key' => '$val', "; - } - } - $class .= "));\n }\n"; - $class = str_replace(', ))', '))', $class); - } else { - $class = "class $classname extends SOAP_Client\n{\n" . - " function $classname(\$path = '$clienturl')\n {\n" . - " \$this->SOAP_Client(\$path, 0);\n" . - " }\n"; - } - - // Get the binding, from that get the port type. - $primaryBinding = $port['binding']; - $primaryBinding = preg_replace("/^(.*:)/", '', $primaryBinding); - $portType = $this->bindings[$primaryBinding]['type']; - $portType = preg_replace("/^(.*:)/", '', $portType); - $style = $this->bindings[$primaryBinding]['style']; - - // XXX currentPortType is BAD - foreach ($this->portTypes[$portType] as $opname => $operation) { - $binding = $this->bindings[$primaryBinding]['operations'][$opname]; - if (isset($binding['soapAction'])) { - $soapaction = $binding['soapAction']; - } else { - $soapaction = null; - } - if (isset($binding['style'])) { - $opstyle = $binding['style']; - } else { - $opstyle = $style; - } - $use = $binding['input']['use']; - if ($use == 'encoded') { - $namespace = $binding['input']['namespace']; - } else { - $bindingType = $this->bindings[$primaryBinding]['type']; - $ns = $this->portTypes[$bindingType][$opname]['input']['namespace']; - $namespace = $this->namespaces[$ns]; - } - - $args = ''; - $argarray = ''; - $comments = ''; - $wrappers = ''; - foreach ($operation['input'] as $argname => $argtype) { - if ($argname == 'message') { - foreach ($this->messages[$argtype] as $_argname => $_argtype) { - $_argname = $this->_sanitize($_argname); - if ($opstyle == 'document' && $use == 'literal' && - $_argtype['name'] == 'parameters') { - // The type or element refered to is used for - // parameters. - $elattrs = null; - $el = $this->elements[$_argtype['namespace']][$_argtype['type']]; - - if ($el['complex']) { - $namespace = $this->namespaces[$_argtype['namespace']]; - // XXX need to wrap the parameters in a - // SOAP_Value. - } - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $elname = $this->_sanitize($elname); - // Is the element a complex type? - if (isset($this->complexTypes[$elattrs['namespace']][$elname])) { - $comments .= $this->_complexTypeArg($args, $argarray, $_argtype, $_argname); - } else { - $this->_addArg($args, $argarray, $elname); - } - } - } - if ($el['complex'] && $argarray) { - $wrapname = '{' . $this->namespaces[$_argtype['namespace']].'}' . $el['name']; - $comments .= " \${$el['name']} = new SOAP_Value('$wrapname', false, \$v = array($argarray));\n"; - $argarray = "'{$el['name']}' => \${$el['name']}"; - } - } else { - if (isset($_argtype['element'])) { - // Element argument. - $comments .= $this->_elementArg($args, $argarray, $_argtype, $_argtype['type']); - } else { - // Complex type argument. - $comments .= $this->_complexTypeArg($args, $argarray, $_argtype, $_argname); - } - } - } - } - } - - // Validate entries. - - // Operation names are function names, so try to make sure it's - // legal. This could potentially cause collisions, but let's try - // to make everything callable and see how many problems that - // causes. - $opname_php = $this->_sanitize($opname); - if (!$this->_validateString($opname_php)) { - return null; - } - - if ($argarray) { - $argarray = "array($argarray)"; - } else { - $argarray = 'null'; - } - - $class .= " function &$opname_php($args)\n {\n$comments$wrappers" . - " \$result = \$this->call('$opname',\n" . - " \$v = $argarray,\n" . - " array('namespace' => '$namespace',\n" . - " 'soapaction' => '$soapaction',\n" . - " 'style' => '$opstyle',\n" . - " 'use' => '$use'" . - ($this->trace ? ",\n 'trace' => true" : '') . "));\n" . - " return \$result;\n" . - " }\n"; - } - - $class .= "}\n"; - - return $class; - } - - function generateAllProxies() - { - $proxycode = ''; - foreach (array_keys($this->services[$this->service]['ports']) as $key) { - $port =& $this->services[$this->service]['ports'][$key]; - $proxycode .= $this->generateProxyCode($port); - } - return $proxycode; - } - - function &getProxy($port = '', $name = '') - { - if ($this->_isfault()) { - $fault =& $this->_getfault(); - return $fault; - } - - $multiport = count($this->services[$this->service]['ports']) > 1; - - if (!$port) { - reset($this->services[$this->service]['ports']); - $port = current($this->services[$this->service]['ports']); - } - - if ($multiport || $port) { - $classname = 'WebService_' . $this->service . '_' . $port['name']; - } else { - $classname = 'WebService_' . $this->service; - } - - if ($name) { - $classname = $name . '_' . $classname; - } - - $classname = $this->_sanitize($classname); - if (!class_exists($classname)) { - $proxy = $this->generateProxyCode($port, $classname); - //var_dump($proxy);exit; - require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Client.php'; - eval($proxy); - } - $proxy = new $classname; - - return $proxy; - } - - /** - * Sanitizes a SOAP value, method or class name so that it can be used as - * a valid PHP identifier. Invalid characters are converted into - * underscores and reserved words are prefixed with an underscore. - * - * @param string $name The identifier to sanitize. - * - * @return string The sanitized identifier. - */ - function _sanitize($name) - { - $name = preg_replace($this->_invalid, '_', $name); - if (in_array($name, $this->_reserved)) { - $name = '_' . $name; - } - return $name; - } - - function &_getComplexTypeForElement($name, $namespace) - { - $t = null; - if (isset($this->ns[$namespace]) && - isset($this->elements[$this->ns[$namespace]][$name]['type'])) { - - $type = $this->elements[$this->ns[$namespace]][$name]['type']; - $ns = $this->elements[$this->ns[$namespace]][$name]['namespace']; - - if (isset($this->complexTypes[$ns][$type])) { - $t = $this->complexTypes[$ns][$type]; - } - } - return $t; - } - - function getComplexTypeNameForElement($name, $namespace) - { - $t = $this->_getComplexTypeForElement($name, $namespace); - if ($t) { - return $t['name']; - } - return null; - } - - function getComplexTypeChildType($ns, $name, $child_ns, $child_name) - { - // Is the type an element? - $t = $this->_getComplexTypeForElement($name, $ns); - if ($t) { - // No, get it from complex types directly. - if (isset($t['elements'][$child_name]['type'])) - return $t['elements'][$child_name]['type']; - } elseif (isset($this->ns[$ns]) && - isset($this->elements[$this->ns[$ns]][$name]['complex']) && - $this->elements[$this->ns[$ns]][$name]['complex']) { - // Type is not an element but complex. - return $this->elements[$this->ns[$ns]][$name]['elements'][$child_name]['type']; - } - return null; - } - - /** - * @param QName $name A parameter name. - * @param QName $type A parameter type. - * - * @return array A list of [type, array element type, array element - * namespace, array length]. - */ - function getSchemaType($type, $name) - { - // see if it's a complex type so we can deal properly with - // SOAPENC:arrayType. - if ($name && $type) { - // XXX TODO: - // look up the name in the wsdl and validate the type. - foreach ($this->complexTypes as $types) { - if (isset($types[$type->name])) { - if (isset($types[$type->name]['type'])) { - list($arraytype_ns, $arraytype, $array_depth) = isset($types[$type->name]['arrayType']) - ? $this->_getDeepestArrayType($types[$type->name]['namespace'], $types[$type->name]['arrayType']) - : array($this->namespaces[$types[$type->name]['namespace']], null, 0); - return array($types[$type->name]['type'], $arraytype, $arraytype_ns, $array_depth); - } - if (isset($types[$type->name]['arrayType'])) { - list($arraytype_ns, $arraytype, $array_depth) = - $this->_getDeepestArrayType($types[$type->name]['namespace'], $types[$type->name]['arrayType']); - return array('Array', $arraytype, $arraytype_ns, $array_depth); - } - if (!empty($types[$type->name]['elements'][$name->name])) { - $type->name = $types[$type->name]['elements']['type']; - return array($type->name, null, $this->namespaces[$types[$type->name]['namespace']], null); - } - break; - } - } - } - if ($type && $type->namespace) { - $arrayType = null; - // XXX TODO: - // this code currently handles only one way of encoding array - // types in wsdl need to do a generalized function to figure out - // complex types - $p = $this->ns[$type->namespace]; - if ($p && !empty($this->complexTypes[$p][$type->name])) { - if ($arrayType = $this->complexTypes[$p][$type->name]['arrayType']) { - $type->name = 'Array'; - } elseif ($this->complexTypes[$p][$type->name]['order'] == 'sequence' && - array_key_exists('elements', $this->complexTypes[$p][$type->name])) { - reset($this->complexTypes[$p][$type->name]['elements']); - // assume an array - if (count($this->complexTypes[$p][$type->name]['elements']) == 1) { - $arg = current($this->complexTypes[$p][$type->name]['elements']); - $arrayType = $arg['type']; - $type->name = 'Array'; - } else { - foreach ($this->complexTypes[$p][$type->name]['elements'] as $element) { - if ($element['name'] == $type->name) { - $arrayType = $element['type']; - $type->name = $element['type']; - } - } - } - } else { - $type->name = 'Struct'; - } - return array($type->name, $arrayType, $type->namespace, null); - } - } - return array(null, null, null, null); - } - - /** - * Recurse through the WSDL structure looking for the innermost array type - * of multi-dimensional arrays. - * - * Takes a namespace prefix and a type, which can be in the form 'type' or - * 'type[]', and returns the full namespace URI, the type of the most - * deeply nested array type found, and the number of levels of nesting. - * - * @access private - * @return mixed array or nothing - */ - function _getDeepestArrayType($nsPrefix, $arrayType) - { - static $trail = array(); - - $arrayType = ereg_replace('\[\]$', '', $arrayType); - - // Protect against circular references XXX We really need to remove - // trail from this altogether (it's very inefficient and in the wrong - // place!) and put circular reference checking in when the WSDL info - // is generated in the first place - if (array_search($nsPrefix . ':' . $arrayType, $trail)) { - return array(null, null, -count($trail)); - } - - if (array_key_exists($nsPrefix, $this->complexTypes) && - array_key_exists($arrayType, $this->complexTypes[$nsPrefix]) && - array_key_exists('arrayType', $this->complexTypes[$nsPrefix][$arrayType])) { - $trail[] = $nsPrefix . ':' . $arrayType; - $result = $this->_getDeepestArrayType($this->complexTypes[$nsPrefix][$arrayType]['namespace'], - $this->complexTypes[$nsPrefix][$arrayType]['arrayType']); - return array($result[0], $result[1], $result[2] + 1); - } - return array($this->namespaces[$nsPrefix], $arrayType, 0); - } - -} - -class SOAP_WSDL_Cache extends SOAP_Base -{ - /** - * Use WSDL cache? - * - * @var boolean - */ - var $_cacheUse; - - /** - * WSDL cache directory. - * - * @var string - */ - var $_cacheDir; - - /** - * Cache maximum lifetime (in seconds) - * - * @var integer - */ - var $_cacheMaxAge; - - /** - * Constructor. - * - * @param boolean $cashUse Use caching? - * @param integer $cacheMaxAge Cache maximum lifetime (in seconds) - */ - public function __construct( - $cacheUse = false, - $cacheMaxAge = WSDL_CACHE_MAX_AGE, - $cacheDir = null) - { - //parent::SOAP_Base('WSDLCACHE'); - $SOAP_Base = new SOAP_Base('WSDLCACHE'); - $this->_cacheUse = $cacheUse; - $this->_cacheDir = $cacheDir; - $this->_cacheMaxAge = $cacheMaxAge; - } - - /** - * Returns the path to the cache and creates it, if it doesn't exist. - * - * @private - * - * @return string The directory to use for the cache. - */ - function _cacheDir() - { - if (!empty($this->_cacheDir)) { - $dir = $this->_cacheDir; - } else { - $dir = getenv('WSDLCACHE'); - if (empty($dir)) { - $dir = './wsdlcache'; - } - } - @mkdir($dir, 0700); - return $dir; - } - - /** - * Retrieves a file from cache if it exists, otherwise retreive from net, - * add to cache, and return from cache. - * - * @param string URL to WSDL - * @param array proxy parameters - * @param int expected MD5 of WSDL URL - * @access public - * @return string data - */ - function get($wsdl_fname, $proxy_params = array(), $cache = 0) - { - $cachename = $md5_wsdl = $file_data = ''; - if ($this->_cacheUse) { - // Try to retrieve WSDL from cache - $cachename = $this->_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; - if (file_exists($cachename) && - $file_data = file_get_contents($cachename)) { - $md5_wsdl = md5($file_data); - if ($cache) { - if ($cache != $md5_wsdl) { - return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname); - } - } else { - $fi = stat($cachename); - $cache_mtime = $fi[8]; - if ($cache_mtime + $this->_cacheMaxAge < time()) { - // Expired, refetch. - $md5_wsdl = ''; - } - } - } - } - - // Not cached or not using cache. Retrieve WSDL from URL - if (!$md5_wsdl) { - // Is it a local file? - if (strpos($wsdl_fname, 'file://') === 0) { - $wsdl_fname = substr($wsdl_fname, 7); - if (!file_exists($wsdl_fname)) { - return $this->_raiseSoapFault('Unable to read local WSDL file', $wsdl_fname); - } - $file_data = file_get_contents($wsdl_fname); - } elseif (!preg_match('|^https?://|', $wsdl_fname)) { - return $this->_raiseSoapFault('Unknown schema of WSDL URL', $wsdl_fname); - } else { - $uri = explode('?', $wsdl_fname); - $rq = new HTTP_Request($uri[0], $proxy_params); - // the user agent HTTP_Request uses fouls things up - if (isset($uri[1])) { - $rq->addRawQueryString($uri[1]); - } - - if (isset($proxy_params['proxy_host']) && - isset($proxy_params['proxy_port']) && - isset($proxy_params['proxy_user']) && - isset($proxy_params['proxy_pass'])) { - $rq->setProxy($proxy_params['proxy_host'], - $proxy_params['proxy_port'], - $proxy_params['proxy_user'], - $proxy_params['proxy_pass']); - } elseif (isset($proxy_params['proxy_host']) && - isset($proxy_params['proxy_port'])) { - $rq->setProxy($proxy_params['proxy_host'], - $proxy_params['proxy_port']); - } - - $result = $rq->sendRequest(); - if (PEAR::isError($result)) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname); - } - $file_data = $rq->getResponseBody(); - if (!$file_data) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname); - } - } - - $md5_wsdl = md5($file_data); - - if ($this->_cacheUse) { - $fp = fopen($cachename, "wb"); - fwrite($fp, $file_data); - fclose($fp); - } - } - - if ($this->_cacheUse && $cache && $cache != $md5_wsdl) { - return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname); - } - - return $file_data; - } - -} - -class SOAP_WSDL_Parser extends SOAP_Base -{ - - /** - * Define internal arrays of bindings, ports, operations, - * messages, etc. - */ - var $currentMessage; - var $currentOperation; - var $currentPortType; - var $currentBinding; - var $currentPort; - - /** - * Parser vars. - */ - var $cache; - - var $tns = null; - var $soapns = array('soap'); - var $uri = ''; - var $wsdl = null; - - var $status = ''; - var $element_stack = array(); - var $parentElement = ''; - - var $schema = ''; - var $schemaStatus = ''; - var $schema_stack = array(); - var $currentComplexType; - var $schema_element_stack = array(); - var $currentElement; - - /** - * Constructor. - */ - public function __construct($uri, &$wsdl, $docs = false) - { - //parent::SOAP_Base('WSDLPARSER'); - $SOAP_Base = new SOAP_Base('WSDLPARSER'); - $this->cache = new SOAP_WSDL_Cache($wsdl->cacheUse, - $wsdl->cacheMaxAge, - $wsdl->cacheDir); - $this->uri = $uri; - $this->wsdl = &$wsdl; - $this->docs = $docs; - $this->parse($uri); - } - - function parse($uri) - { - // Check whether content has been read. - $fd = $this->cache->get($uri, $this->wsdl->proxy); - if (PEAR::isError($fd)) { - return $this->_raiseSoapFault($fd); - } - - // Create an XML parser. - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($parser, $this); - xml_set_element_handler($parser, 'startElement', 'endElement'); - if ($this->docs) { - xml_set_character_data_handler($parser, 'characterData'); - } - - if (!xml_parse($parser, $fd, true)) { - $detail = sprintf('XML error on line %d: %s', - xml_get_current_line_number($parser), - xml_error_string(xml_get_error_code($parser))); - return $this->_raiseSoapFault("Unable to parse WSDL file $uri\n$detail"); - } - xml_parser_free($parser); - return true; - } - - /** - * start-element handler - */ - function startElement($parser, $name, $attrs) - { - // Get element prefix. - $qname = new QName($name); - if ($qname->ns) { - $ns = $qname->ns; - if ($ns && ((!$this->tns && strcasecmp($qname->name, 'definitions') == 0) || $ns == $this->tns)) { - $name = $qname->name; - } - } - $this->currentTag = $qname->name; - $this->parentElement = ''; - $stack_size = count($this->element_stack); - if ($stack_size) { - $this->parentElement = $this->element_stack[$stack_size - 1]; - } - $this->element_stack[] = $this->currentTag; - - // Find status, register data. - switch ($this->status) { - case 'types': - // sect 2.2 wsdl:types - // children: xsd:schema - $parent_tag = ''; - $stack_size = count($this->schema_stack); - if ($stack_size) { - $parent_tag = $this->schema_stack[$stack_size - 1]; - } - - switch ($qname->name) { - case 'schema': - // No parent should be in the stack. - if (!$parent_tag || $parent_tag == 'types') { - if (array_key_exists('targetNamespace', $attrs)) { - $this->schema = $this->wsdl->getNamespaceAttributeName($attrs['targetNamespace']); - } else { - $this->schema = $this->wsdl->getNamespaceAttributeName($this->wsdl->tns); - } - $this->wsdl->complexTypes[$this->schema] = array(); - $this->wsdl->elements[$this->schema] = array(); - } - break; - - case 'complexType': - if ($parent_tag == 'schema') { - $this->currentComplexType = $attrs['name']; - if (!isset($attrs['namespace'])) { - $attrs['namespace'] = $this->schema; - } - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType] = $attrs; - if (array_key_exists('base', $attrs)) { - $qn = new QName($attrs['base']); - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = $qn->name; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $qn->ns; - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - $this->schemaStatus = 'complexType'; - } else { - $this->wsdl->elements[$this->schema][$this->currentElement]['complex'] = true; - } - break; - - case 'element': - if (isset($attrs['type'])) { - $qn = new QName($attrs['type']); - $attrs['type'] = $qn->name; - if ($qn->ns && array_key_exists($qn->ns, $this->wsdl->namespaces)) { - $attrs['namespace'] = $qn->ns; - } - } - - $parentElement = ''; - $stack_size = count($this->schema_element_stack); - if ($stack_size > 0) { - $parentElement = $this->schema_element_stack[$stack_size - 1]; - } - - if (isset($attrs['ref'])) { - $qn = new QName($attrs['ref']); - $this->currentElement = $qn->name; - } else { - $this->currentElement = $attrs['name']; - } - $this->schema_element_stack[] = $this->currentElement; - if (!isset($attrs['namespace'])) { - $attrs['namespace'] = $this->schema; - } - - if ($parent_tag == 'schema') { - $this->wsdl->elements[$this->schema][$this->currentElement] = $attrs; - $this->wsdl->elements[$this->schema][$this->currentElement]['complex'] = false; - $this->schemaStatus = 'element'; - } elseif ($this->currentComplexType) { - // we're inside a complexType - if ((isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order']) && - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] == 'sequence') - && $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] == 'Array') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['arrayType'] = isset($attrs['type']) ? $attrs['type'] : null; - } - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements'][$this->currentElement] = $attrs; - } else { - $this->wsdl->elements[$this->schema][$parentElement]['elements'][$this->currentElement] = $attrs; - } - break; - - case 'complexContent': - case 'simpleContent': - break; - - case 'extension': - case 'restriction': - if ($this->schemaStatus == 'complexType') { - if (!empty($attrs['base'])) { - $qn = new QName($attrs['base']); - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = $qn->name; - - // Types that extend from other types aren't - // *of* those types. Reflect this by denoting - // which type they extend. I'm leaving the - // 'type' setting here since I'm not sure what - // removing it might break at the moment. - if ($qname->name == 'extension') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['extends'] = $qn->name; - } - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - } - break; - - case 'sequence': - if ($this->schemaStatus == 'complexType') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - } - } - break; - - case 'all': - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - break; - - case 'choice': - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - } - - case 'attribute': - if ($this->schemaStatus == 'complexType') { - if (isset($attrs['name'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['attribute'][$attrs['name']] = $attrs; - } else { - if (isset($attrs['ref'])) { - $q = new QName($attrs['ref']); - foreach ($attrs as $k => $v) { - if ($k != 'ref' && strstr($k, $q->name)) { - $vq = new QName($v); - if ($q->name == 'arrayType') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name. $vq->arrayInfo; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $vq->ns; - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name; - } - } - } - } - } - } - break; - } - - $this->schema_stack[] = $qname->name; - break; - - case 'message': - // sect 2.3 wsdl:message child wsdl:part - switch ($qname->name) { - case 'part': - $qn = null; - if (isset($attrs['type'])) { - $qn = new QName($attrs['type']); - } elseif (isset($attrs['element'])) { - $qn = new QName($attrs['element']); - } - if ($qn) { - $attrs['type'] = $qn->name; - $attrs['namespace'] = $qn->ns; - } - $this->wsdl->messages[$this->currentMessage][$attrs['name']] = $attrs; - // error in wsdl - - case 'documentation': - break; - - default: - break; - } - break; - - case 'portType': - // sect 2.4 - switch ($qname->name) { - case 'operation': - // attributes: name - // children: wsdl:input wsdl:output wsdl:fault - $this->currentOperation = $attrs['name']; - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation] = $attrs; - break; - - case 'input': - case 'output': - case 'fault': - // wsdl:input wsdl:output wsdl:fault - // attributes: name message parameterOrder(optional) - if ($this->currentOperation) { - if (isset($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name])) { - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = array_merge($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name], $attrs); - } else { - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = $attrs; - } - if (array_key_exists('message', $attrs)) { - $qn = new QName($attrs['message']); - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['message'] = $qn->name; - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['namespace'] = $qn->ns; - } - } - break; - - case 'documentation': - break; - - default: - break; - } - break; - - case 'binding': - $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL; - switch ($ns) { - case SCHEMA_SOAP: - case SCHEMA_SOAP12: - // this deals with wsdl section 3 soap binding - switch ($qname->name) { - case 'binding': - // sect 3.3 - // soap:binding, attributes: transport(required), style(optional, default = document) - // if style is missing, it is assumed to be 'document' - if (!isset($attrs['style'])) { - $attrs['style'] = 'document'; - } - $this->wsdl->bindings[$this->currentBinding] = array_merge($this->wsdl->bindings[$this->currentBinding], $attrs); - break; - - case 'operation': - // sect 3.4 - // soap:operation, attributes: soapAction(required), style(optional, default = soap:binding:style) - if (!isset($attrs['style'])) { - $attrs['style'] = $this->wsdl->bindings[$this->currentBinding]['style']; - } - if (isset($this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation])) { - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation] = array_merge($this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation], $attrs); - } else { - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation] = $attrs; - } - break; - - case 'body': - // sect 3.5 - // soap:body attributes: - // part - optional. listed parts must appear in body, missing means all parts appear in body - // use - required. encoded|literal - // encodingStyle - optional. space seperated list of encodings (uri's) - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus] = $attrs; - break; - - case 'fault': - // sect 3.6 - // soap:fault attributes: name use encodingStyle namespace - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus] = $attrs; - break; - - case 'header': - // sect 3.7 - // soap:header attributes: message part use encodingStyle namespace - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; - break; - - case 'headerfault': - // sect 3.7 - // soap:header attributes: message part use encodingStyle namespace - $header = count($this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'])-1; - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'][$header]['fault'] = $attrs; - break; - - case 'documentation': - break; - - default: - // error! not a valid element inside binding - break; - } - break; - - case SCHEMA_WSDL: - // XXX verify correct namespace - // for now, default is the 'wsdl' namespace - // other possible namespaces include smtp, http, etc. for alternate bindings - switch ($qname->name) { - case 'operation': - // sect 2.5 - // wsdl:operation attributes: name - $this->currentOperation = $attrs['name']; - break; - - case 'output': - case 'input': - case 'fault': - // sect 2.5 - // wsdl:input attributes: name - $this->opStatus = $qname->name; - break; - - case 'documentation': - break; - - default: - break; - } - break; - - case SCHEMA_WSDL_HTTP: - switch ($qname->name) { - case 'binding': - // sect 4.4 - // http:binding attributes: verb - // parent: wsdl:binding - $this->wsdl->bindings[$this->currentBinding] = array_merge($this->wsdl->bindings[$this->currentBinding], $attrs); - break; - - case 'operation': - // sect 4.5 - // http:operation attributes: location - // parent: wsdl:operation - $this->wsdl->bindings[$this->currentBinding]['operations'] - [$this->currentOperation] = $attrs; - break; - - case 'urlEncoded': - // sect 4.6 - // http:urlEncoded attributes: location - // parent: wsdl:input wsdl:output etc. - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->opStatus] - [$this->currentOperation]['uri'] = 'urlEncoded'; - break; - - case 'urlReplacement': - // sect 4.7 - // http:urlReplacement attributes: location - // parent: wsdl:input wsdl:output etc. - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->opStatus] - [$this->currentOperation]['uri'] = 'urlReplacement'; - break; - - case 'documentation': - break; - - default: - // error - break; - } - - case SCHEMA_MIME: - // sect 5 - // all mime parts are children of wsdl:input, wsdl:output, etc. - // unsuported as of yet - switch ($qname->name) { - case 'content': - // sect 5.3 mime:content - // <mime:content part="nmtoken"? type="string"?/> - // part attribute only required if content is child of multipart related, - // it contains the name of the part - // type attribute contains the mime type - case 'multipartRelated': - // sect 5.4 mime:multipartRelated - case 'part': - case 'mimeXml': - // sect 5.6 mime:mimeXml - // <mime:mimeXml part="nmtoken"?/> - // - case 'documentation': - break; - - default: - // error - break; - } - - case SCHEMA_DIME: - // DIME is defined in: - // http://gotdotnet.com/team/xml_wsspecs/dime/WSDL-Extension-for-DIME.htm - // all DIME parts are children of wsdl:input, wsdl:output, etc. - // unsuported as of yet - switch ($qname->name) { - case 'message': - // sect 4.1 dime:message - // appears in binding section - $this->wsdl->bindings[$this->currentBinding]['dime'] = $attrs; - break; - - default: - break; - } - - default: - break; - } - break; - - case 'service': - $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL; - - switch ($qname->name) { - case 'port': - // sect 2.6 wsdl:port attributes: name binding - $this->currentPort = $attrs['name']; - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort] = $attrs; - // XXX hack to deal with binding namespaces - $qn = new QName($attrs['binding']); - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['binding'] = $qn->name; - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['namespace'] = $qn->ns; - break; - - case 'address': - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['address'] = $attrs; - // what TYPE of port is it? SOAP or HTTP? - $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL; - switch ($ns) { - case SCHEMA_WSDL_HTTP: - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='http'; - break; - - case SCHEMA_SOAP: - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='soap'; - break; - - default: - // Shouldn't happen, we'll assume SOAP. - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='soap'; - } - - break; - - case 'documentation': - break; - - default: - break; - } - } - - // Top level elements found under wsdl:definitions. - switch ($qname->name) { - case 'import': - // sect 2.1.1 wsdl:import attributes: namespace location - if ((isset($attrs['location']) || isset($attrs['schemaLocation'])) && - !isset($this->wsdl->imports[$attrs['namespace']])) { - $uri = isset($attrs['location']) ? $attrs['location'] : $attrs['schemaLocation']; - $location = @parse_url($uri); - if (!isset($location['scheme'])) { - $base = @parse_url($this->uri); - $uri = $this->mergeUrl($base, $uri); - } - - $this->wsdl->imports[$attrs['namespace']] = $attrs; - $import_parser_class = get_class($this); - $import_parser = new $import_parser_class($uri, $this->wsdl, $this->docs); - if ($import_parser->fault) { - unset($this->wsdl->imports[$attrs['namespace']]); - return false; - } - $this->currentImport = $attrs['namespace']; - } - // Continue on to the 'types' case - lack of break; is - // intentional. - - case 'types': - // sect 2.2 wsdl:types - $this->status = 'types'; - break; - - case 'schema': - // We can hit this at the top level if we've been asked to - // import an XSD file. - if (!empty($attrs['targetNamespace'])) { - $this->schema = $this->wsdl->getNamespaceAttributeName($attrs['targetNamespace']); - } else { - $this->schema = $this->wsdl->getNamespaceAttributeName($this->wsdl->tns); - } - $this->wsdl->complexTypes[$this->schema] = array(); - $this->wsdl->elements[$this->schema] = array(); - $this->schema_stack[] = $qname->name; - $this->status = 'types'; - break; - - case 'message': - // sect 2.3 wsdl:message attributes: name children:wsdl:part - $this->status = 'message'; - if (isset($attrs['name'])) { - $this->currentMessage = $attrs['name']; - $this->wsdl->messages[$this->currentMessage] = array(); - } - break; - - case 'portType': - // sect 2.4 wsdl:portType - // attributes: name - // children: wsdl:operation - $this->status = 'portType'; - $this->currentPortType = $attrs['name']; - $this->wsdl->portTypes[$this->currentPortType] = array(); - break; - - case 'binding': - // sect 2.5 wsdl:binding attributes: name type - // children: wsdl:operation soap:binding http:binding - if ($qname->ns && $qname->ns != $this->tns) { - break; - } - $this->status = 'binding'; - $this->currentBinding = $attrs['name']; - $qn = new QName($attrs['type']); - $this->wsdl->bindings[$this->currentBinding]['type'] = $qn->name; - $this->wsdl->bindings[$this->currentBinding]['namespace'] = $qn->ns; - break; - - case 'service': - // sect 2.7 wsdl:service attributes: name children: ports - $this->currentService = $attrs['name']; - $this->wsdl->services[$this->currentService]['ports'] = array(); - $this->status = 'service'; - break; - - case 'definitions': - // sec 2.1 wsdl:definitions - // attributes: name targetNamespace xmlns:* - // children: wsdl:import wsdl:types wsdl:message wsdl:portType wsdl:binding wsdl:service - $this->wsdl->definition = $attrs; - foreach ($attrs as $key => $value) { - if (strstr($key, 'xmlns:') !== false) { - $qn = new QName($key); - // XXX need to refactor ns handling. - $this->wsdl->namespaces[$qn->name] = $value; - $this->wsdl->ns[$value] = $qn->name; - if ($key == 'targetNamespace' || - strcasecmp($value,SOAP_SCHEMA) == 0) { - $this->soapns[] = $qn->name; - } else { - if (in_array($value, $this->_XMLSchema)) { - $this->wsdl->xsd = $value; - } - } - } - } - if (isset($ns) && $ns) { - $namespace = 'xmlns:' . $ns; - if (!$this->wsdl->definition[$namespace]) { - return $this->_raiseSoapFault("parse error, no namespace for $namespace", $this->uri); - } - $this->tns = $ns; - } - break; - } - } - - /** - * end-element handler. - */ - function endElement($parser, $name) - { - $stacksize = count($this->element_stack); - if ($stacksize) { - if ($this->element_stack[$stacksize - 1] == 'definitions') { - $this->status = ''; - } - array_pop($this->element_stack); - } - - if (stristr($name, 'schema')) { - array_pop($this->schema_stack); - $this->schema = ''; - } - - if ($this->schema) { - array_pop($this->schema_stack); - if (count($this->schema_stack) <= 1) { - /* Correct the type for sequences with multiple - * elements. */ - if (isset($this->currentComplexType) && isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type']) - && $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] == 'Array' - && array_key_exists('elements', $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]) - && count($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements']) > 1) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - } - if (stristr($name, 'complexType')) { - $this->currentComplexType = ''; - if (count($this->schema_element_stack)) { - $this->currentElement = array_pop($this->schema_element_stack); - } else { - $this->currentElement = ''; - } - } elseif (stristr($name, 'element')) { - if (count($this->schema_element_stack)) { - $this->currentElement = array_pop($this->schema_element_stack); - } else { - $this->currentElement = ''; - } - } - } - } - - /** - * Element content handler. - */ - function characterData($parser, $data) - { - // Store the documentation in the WSDL file. - if ($this->currentTag == 'documentation') { - $data = trim(preg_replace('/\s+/', ' ', $data)); - if (!strlen($data)) { - return; - } - - switch ($this->status) { - case 'service': - $ptr =& $this->wsdl->services[$this->currentService]; - break; - - case 'portType': - $ptr =& $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation]; - break; - - case 'binding': - $ptr =& $this->wsdl->bindings[$this->currentBinding]; - break; - - case 'message': - $ptr =& $this->wsdl->messages[$this->currentMessage]; - break; - - case 'operation': - break; - - case 'types': - if (isset($this->currentComplexType) && - isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType])) { - if ($this->currentElement) { - $ptr =& $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements'][$this->currentElement]; - } else { - $ptr =& $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]; - } - } - break; - } - - if (isset($ptr)) { - if (!isset($ptr['documentation'])) { - $ptr['documentation'] = ''; - } else { - $ptr['documentation'] .= ' '; - } - $ptr['documentation'] .= $data; - } - } - } - - /** - * $parsed is an array returned by parse_url(). - * - * @access private - */ - function mergeUrl($parsed, $path) - { - if (!is_array($parsed)) { - return false; - } - - $uri = ''; - if (!empty($parsed['scheme'])) { - $sep = (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'); - $uri = $parsed['scheme'] . $sep; - } - - if (isset($parsed['pass'])) { - $uri .= "$parsed[user]:$parsed[pass]@"; - } elseif (isset($parsed['user'])) { - $uri .= "$parsed[user]@"; - } - - if (isset($parsed['host'])) { - $uri .= $parsed['host']; - } - if (isset($parsed['port'])) { - $uri .= ":$parsed[port]"; - } - if ($path[0] != '/' && isset($parsed['path'])) { - if ($parsed['path'][strlen($parsed['path']) - 1] != '/') { - $path = dirname($parsed['path']) . '/' . $path; - } else { - $path = $parsed['path'] . $path; - } - $path = $this->_normalize($path); - } - $sep = $path[0] == '/' ? '' : '/'; - $uri .= $sep . $path; - - return $uri; - } - - function _normalize($path_str) - { - $pwd = ''; - $strArr = preg_split('/(\/)/', $path_str, -1, PREG_SPLIT_NO_EMPTY); - $pwdArr = ''; - $j = 0; - for ($i = 0; $i < count($strArr); $i++) { - if ($strArr[$i] != ' ..') { - if ($strArr[$i] != ' .') { - $pwdArr[$j] = $strArr[$i]; - $j++; - } - } else { - array_pop($pwdArr); - $j--; - } - } - $pStr = implode('/', $pwdArr); - $pwd = (strlen($pStr) > 0) ? ('/' . $pStr) : '/'; - return $pwd; - } - -} - -/** - * Parses the types and methods used in web service objects into the internal - * data structures used by SOAP_WSDL. - * - * Assumes the SOAP_WSDL class is unpopulated to start with. - * - * @author Chris Coe <info@intelligentstreaming.com> - */ -class SOAP_WSDL_ObjectParser extends SOAP_Base -{ - /** - * Target namespace for the WSDL document will have the following - * prefix. - */ - var $tnsPrefix = 'tns'; - - /** - * Reference to the SOAP_WSDL object to populate. - */ - var $wsdl = null; - - /** - * Constructor. - * - * @param object|array $objects Reference to the object or array of - * objects to parse. - * @param SOAP_WSDL $wsdl Reference to the SOAP_WSDL object to - * populate. - * @param string $targetNamespace The target namespace of schema types - * etc. - * @param string $service_name Name of the WSDL <service>. - * @param string $service_desc Optional description of the WSDL - * <service>. - */ - public function __construct($objects, &$wsdl, $targetNamespace, - $service_name, $service_desc = '') - { - //echo '<br/>------------juste avant----------<br/>'; - $SOAP_Base = new SOAP_Base('WSDLOBJECTPARSER'); - //parent::SOAP_Base('WSDLOBJECTPARSER'); - - $this->wsdl = &$wsdl; - - // Set up the SOAP_WSDL object - $this->_initialise($service_name); - - // Parse each web service object - $wsdl_ref = is_array($objects) ? $objects : array($objects); - - foreach ($wsdl_ref as $ref_item) { - if (!is_object($ref_item)) { - $this->_raiseSoapFault('Invalid web service object passed to object parser'); - continue; - } - - if (!$this->_parse($ref_item, $targetNamespace, $service_name)) { - break; - } - } - - // Build bindings from abstract data. - if ($this->fault == null) { - $this->_generateBindingsAndServices($targetNamespace, $service_name, $service_desc); - } - } - - /** - * Initialise the SOAP_WSDL tree (destructive). - * - * If the object has already been initialised, the only effect - * will be to change the tns namespace to the new service name. - * - * @param $service_name Name of the WSDL <service> - * @access private - */ - function _initialise($service_name) - { - //echo $service_name;exit; - $this->_resetNamespaces(); - // Set up the basic namespaces that all WSDL definitions use. - $this->wsdl->namespaces['wsdl'] = SCHEMA_WSDL; // WSDL language - $this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings - $this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace - //echo '<br/>--------avant erreur-----------<br/>namespace : ' . $this->_namespaces . ' service_name : ' . $service_name;exit; - $this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema - $this->wsdl->namespaces[SOAP_BASE::SOAPENCPrefix()] = array_search(SOAP_BASE::SOAPENCPrefix(), $this->_namespaces); // SOAP types - - // XXX Refactor $namespace/$ns for Shane :-) - unset($this->wsdl->ns['urn:' . $service_name]); - $this->wsdl->ns += array_flip($this->wsdl->namespaces); - - // Imports are not implemented in WSDL generation from classes. - // *** <wsdl:import> *** - } - - /** - * Parser - takes a single object to add to tree (non-destructive). - * - * @access private - * - * @param object $object Reference to the object to parse. - * @param string $schemaNamespace - * @param string $service_name Name of the WSDL <service>. - */ - function _parse($object, $schemaNamespace, $service_name) - { - // Create namespace prefix for the schema - list($schPrefix,) = $this->_getTypeNs('{' . $schemaNamespace . '}'); - - // Parse all the types defined by the object in whatever - // schema language we are using (currently __typedef arrays) - // *** <wsdl:types> *** - foreach ($object->__typedef as $typeName => $typeValue) { - // Get/create namespace definition - list($nsPrefix, $typeName) = $this->_getTypeNs($typeName); - - // Create type definition - $this->wsdl->complexTypes[$schPrefix][$typeName] = array('name' => $typeName); - $thisType =& $this->wsdl->complexTypes[$schPrefix][$typeName]; - - // According to Dmitri's documentation, __typedef comes in two - // flavors: - // Array = array(array("item" => "value")) - // Struct = array("item1" => "value1", "item2" => "value2", ...) - if (is_array($typeValue)) { - if (is_array(current($typeValue)) && count($typeValue) == 1 - && count(current($typeValue)) == 1) { - // It's an array - $thisType['type'] = 'Array'; - $nsType = current(current($typeValue)); - list($nsPrefix, $typeName) = $this->_getTypeNs($nsType); - $thisType['namespace'] = $nsPrefix; - $thisType['arrayType'] = $typeName . '[]'; - } elseif (!is_array(current($typeValue))) { - // It's a struct - $thisType['type'] = 'Struct'; - $thisType['order'] = 'all'; - $thisType['namespace'] = $nsPrefix; - $thisType['elements'] = array(); - - foreach ($typeValue as $elementName => $elementType) { - list($nsPrefix, $typeName) = $this->_getTypeNs($elementType); - $thisType['elements'][$elementName]['name'] = $elementName; - $thisType['elements'][$elementName]['type'] = $typeName; - $thisType['elements'][$elementName]['namespace'] = $nsPrefix; - } - } else { - // It's erroneous - return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object)); - } - } else { - // It's erroneous - return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object)); - } - } - - // Create an empty element array with the target namespace - // prefix, to match the results of WSDL parsing. - $this->wsdl->elements[$schPrefix] = array(); - - // Populate tree with message information - // *** <wsdl:message> *** - foreach ($object->__dispatch_map as $operationName => $messages) { - // We need at least 'in' and 'out' parameters. - if (!isset($messages['in']) || !isset($messages['out'])) { - return $this->_raiseSoapFault('The dispatch map for the method "' . $operationName . '" is missing an "in" or "out" definition.', 'urn:' . get_class($object)); - } - foreach ($messages as $messageType => $messageParts) { - unset($thisMessage); - - switch ($messageType) { - case 'in': - $this->wsdl->messages[$operationName . 'Request'] = array(); - $thisMessage =& $this->wsdl->messages[$operationName . 'Request']; - break; - - case 'out': - $this->wsdl->messages[$operationName . 'Response'] = array(); - $thisMessage =& $this->wsdl->messages[$operationName . 'Response']; - break; - - case 'alias': - // Do nothing - break; - - default: - // Error condition - break; - } - - if (isset($thisMessage)) { - foreach ($messageParts as $partName => $partType) { - list ($nsPrefix, $typeName) = $this->_getTypeNs($partType); - - $thisMessage[$partName] = array( - 'name' => $partName, - 'type' => $typeName, - 'namespace' => $nsPrefix - ); - } - } - } - } - - // Populate tree with portType information - // XXX Current implementation only supports one portType that - // encompasses all of the operations available. - // *** <wsdl:portType> *** - if (!isset($this->wsdl->portTypes[$service_name . 'Port'])) { - $this->wsdl->portTypes[$service_name . 'Port'] = array(); - } - $thisPortType =& $this->wsdl->portTypes[$service_name . 'Port']; - - foreach ($object->__dispatch_map as $operationName => $messages) { - $thisPortType[$operationName] = array('name' => $operationName); - - foreach ($messages as $messageType => $messageParts) { - switch ($messageType) { - case 'in': - $thisPortType[$operationName]['input'] = array( - 'message' => $operationName . 'Request', - 'namespace' => $this->tnsPrefix); - break; - - case 'out': - $thisPortType[$operationName]['output'] = array( - 'message' => $operationName . 'Response', - 'namespace' => $this->tnsPrefix); - break; - } - } - } - - return true; - } - - /** - * Takes all the abstract WSDL data and builds concrete bindings and - * services (destructive). - * - * @access private - * @todo Current implementation discards $service_desc. - * - * @param string $schemaNamespace Namespace for types etc. - * @param string $service_name Name of the WSDL <service>. - * @param string $service_desc Optional description of the WSDL - * <service>. - */ - function _generateBindingsAndServices($schemaNamespace, $service_name, - $service_desc = '') - { - // Populate tree with bindings information - // XXX Current implementation only supports one binding that - // matches the single portType and all of its operations. - // XXX Is this the correct use of $schemaNamespace here? - // *** <wsdl:binding> *** - $this->wsdl->bindings[$service_name . 'Binding'] = array( - 'type' => $service_name . 'Port', - 'namespace' => $this->tnsPrefix, - 'style' => 'rpc', - 'transport' => SCHEMA_SOAP_HTTP, - 'operations' => array()); - $thisBinding =& $this->wsdl->bindings[$service_name . 'Binding']; - - foreach ($this->wsdl->portTypes[$service_name . 'Port'] as $operationName => $operationData) { - $thisBinding['operations'][$operationName] = array( - 'soapAction' => $schemaNamespace . '#' . $operationName, - 'style' => $thisBinding['style']); - - foreach (array('input', 'output') as $messageType) - if (isset($operationData[$messageType])) { - $thisBinding['operations'][$operationName][$messageType] = array( - 'use' => 'encoded', - 'namespace' => $schemaNamespace, - 'encodingStyle' => SOAP_SCHEMA_ENCODING); - } - } - - // Populate tree with service information - // XXX Current implementation supports one service which groups - // all of the ports together, one port per binding - // *** <wsdl:service> *** - - $this->wsdl->services[$service_name . 'Service'] = array('ports' => array()); - $thisService =& $this->wsdl->services[$service_name . 'Service']['ports']; - $https = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || - getenv('SSL_PROTOCOL_VERSION'); - - foreach ($this->wsdl->bindings as $bindingName => $bindingData) { - $thisService[$bindingData['type']] = array( - 'name' => $bindingData['type'], - 'binding' => $bindingName, - 'namespace' => $this->tnsPrefix, - 'address' => array('location' => - ($https ? 'https://' : 'http://') . - $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . - (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), - 'type' => 'soap'); - } - - // Set service - $this->wsdl->set_service($service_name . 'Service'); - $this->wsdl->uri = $this->wsdl->namespaces[$this->tnsPrefix]; - - // Create WSDL definition - // *** <wsdl:definitions> *** - - $this->wsdl->definition = array( - 'name' => $service_name, - 'targetNamespace' => $this->wsdl->namespaces[$this->tnsPrefix], - 'xmlns' => SCHEMA_WSDL); - - foreach ($this->wsdl->namespaces as $nsPrefix => $namespace) { - $this->wsdl->definition['xmlns:' . $nsPrefix] = $namespace; - } - } - - /** - * This function is adapted from Dmitri V's implementation of - * DISCO/WSDL generation. It separates namespace from type name in - * a __typedef key and creates a new namespace entry in the WSDL - * structure if the namespace has not been used before. The - * namespace prefix and type name are returned. If no namespace is - * specified, xsd is assumed. - * - * We will not need this function anymore once __typedef is - * eliminated. - */ - function _getTypeNs($type) - { - preg_match_all('/\{(.*)\}/sm', $type, $m); - if (!empty($m[1][0])) { - if (!isset($this->wsdl->ns[$m[1][0]])) { - $ns_pref = 'ns' . count($this->wsdl->namespaces); - $this->wsdl->ns[$m[1][0]] = $ns_pref; - $this->wsdl->namespaces[$ns_pref] = $m[1][0]; - } - $typens = $this->wsdl->ns[$m[1][0]]; - $type = str_replace($m[0][0], '', $type); - } else { - $typens = 'xsd'; - } - - return array($typens, $type); - } - -} diff --git a/apps/maarch_entreprise/tools/PEAR/SOAP/tools/genproxy.php b/apps/maarch_entreprise/tools/PEAR/SOAP/tools/genproxy.php deleted file mode 100755 index 078804b2b763ad9dfd8059548daae76939a998dc..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/PEAR/SOAP/tools/genproxy.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -error_reporting(E_ALL); -require_once 'apps/maarch_entreprise/tools/PEAR/SOAP/WSDL.php'; - -/** - * genproxy - * - * a command line tool for generating SOAP proxies from WSDL files - * - * genproxy.php http://site/foo.wsdl > foo.php - * - */ - -function do_wsdl($uri) { - $wsdl = new SOAP_WSDL($uri); - print $wsdl->generateAllProxies(); -} -echo "<?php\n\nrequire_once 'apps/maarch_entreprise/tools/PEAR/SOAP/Client.php';\n\n"; -do_wsdl($_SERVER['argv'][1]); -echo "\n?>"; -?> \ No newline at end of file diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/.eslintrc b/apps/maarch_entreprise/tools/fingerprintjs2/.eslintrc deleted file mode 100755 index 6a5a94f7b6468a26e76634b58ed8051dace3a1ee..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "amd": true - }, - "globals": { - "swfobject": true, - "ActiveXObject": true - }, - "rules": { - "no-fallthrough": false, - "yoda": false, - "no-shadow": false, - "no-new": false, - "no-extend-native": false - }, - -} diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/.npmignore b/apps/maarch_entreprise/tools/fingerprintjs2/.npmignore deleted file mode 100755 index 5ffc10fab66464e455217ffc22703999767bc868..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules/ -.idea/ -fingerprintjs2.iml -*.log \ No newline at end of file diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/.travis.yml b/apps/maarch_entreprise/tools/fingerprintjs2/.travis.yml deleted file mode 100755 index 0cfd861bbc92f1300284a04c8088366a9163a9b8..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -script: "specs/phantomjs.runner.sh specs/spec_runner.html" diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/CONTRIBUTING.md b/apps/maarch_entreprise/tools/fingerprintjs2/CONTRIBUTING.md deleted file mode 100755 index 556dc7587e1699499389557e9a9aaa2b18bc9ab2..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/CONTRIBUTING.md +++ /dev/null @@ -1,41 +0,0 @@ -Contributing to FingerprintJS2 -============================== - -# IF YOU WANT TO ASK A QUESTION - USE GITTER.IM OR STACKOVERFLOW.COM with fingerprintjs2 tag - -PLEASE :) - -ISSUES WITH QUESTIONS IN THEM WILL BE CLOSED W/OUT EXPLANATION! - -## Found a bug? - -Please submit an issue. -Include in the issue: - -* List of components you received in the `get` call (make sure values are not truncated) -* If FP is different every time you call the library, include 2 versions of components -* Include your OS version -* Include steps to reproduce -* Include library call code (I need all options you used when calling the library function) - -## Want to add a feature / contribute? -* Make sure the issue/suggestion does not exist by searching existing issues -* Fork the project and make the required changes in it (don't forget to add specs) -* PRs w/out specs will not be accepted -* Run `gulp` to catch stylistic errors and produce the minified version. -* Run specs by opening the `specs/spec_runner.html` or typing `npm test` (requires phantomjs for console running). -* Make a PR. -* Make sure you only make one commit per feature you want to add -* Make sure your commit message is descriptive and tells what you changed (`Updated the library` - that's a bad commit message) - -If your code changes the list of fingerprinting sources, please update -the README. - -If you're unsure about the feature you want to add, submit an issue with -a `question` tag. - -## Want to ask? -* Please read FAQ first -* If you have not found the answer you were looking for - use gitter.im to ask your question (link is in the readme) - -Happy Coding! diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/FAQ.md b/apps/maarch_entreprise/tools/fingerprintjs2/FAQ.md deleted file mode 100755 index 520c16930124bcafccd057334527b67bf45d84a8..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/FAQ.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Can I use this library to uniquely identify users? -##### No, you cannot. This library is built to be able to associate string identifiers with devices. Since there are a lot of identical devices, you will get a lot of identical identifiers. - -#### OK, I get it, I cannot _uniquely_ identify users, but can I identify users at all? -##### No, you cannot. This library is strictly for non-deterministic device identification. - - -#### How good is your library? Can you guarantee that different devices will have different identifiers? -##### This library is not good. It has an error margin of 10-20% - -#### Can you improve the library to be 100% accurate for device identification? -##### I don't think it is possible now and don't think it will be possible in the future. - -#### Can you improve the library to be more accurate (since you cannot make it 100% accurate)? -##### I can, but it takes a lot of time. I need a lot of devices, enviroments and more importantly - time. Since this is my hobby project, I spend very little time on it. - -#### How can I build a complete identification solution? -##### You should either use commercial services, such as https://augur.io, or develop such service yourself. If you don't know how to do it, please use StackOverflow. - -#### The fingerprint is changing frequently for me, is library broken? -##### Well, most likely not. You may have different user agents (because of the browser ugprades), or different screen resolutions. You can disable corresponding options (please see README and Wiki for details). V2 will have a callback/extension system which will allow to use UserAgent parsers and cut off the frequently changing parts of user agents (such as verion numbers). If you're sure it is a bug, please submit an issue and don't forget to attach the relevant info about which component, participating in fingerprint building, changes for your from call to call. This will greatly help me fix the issue diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/ISSUE_TEMPLATE.md b/apps/maarch_entreprise/tools/fingerprintjs2/ISSUE_TEMPLATE.md deleted file mode 100755 index 1b32225073557bfbaf1c310a55e5ac5b42c5d74e..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,14 +0,0 @@ -# Before submitting an issue please read: - -### https://github.com/Valve/fingerprintjs2/blob/master/FAQ.md - -### https://github.com/Valve/fingerprintjs2/blob/master/CONTRIBUTING.md - -If your issue is about fingerprint changing fast/being inconsistent, please search for already closed issues about it, you may find your answer there. - -This can be probably because of your browser upgrade (User agent string changing), different screen resolution on various devices (fixable by disabling screen_resolution option). - -If you want to submit a bug, please let me know which browser/os you're using and which fingerprinting component is broken and/or different for you on multiple library calls. - - -If you want to ask a question - please use gitter.im (badge is in the readme) and ping me with @valve handle, I'll gladly answer specific questions about the library. diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/README.md b/apps/maarch_entreprise/tools/fingerprintjs2/README.md deleted file mode 100755 index 4430f717699695ee82a5d1ea91bf0071463837fe..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/README.md +++ /dev/null @@ -1,196 +0,0 @@ -# Fingerprintjs2 -[](https://travis-ci.org/Valve/fingerprintjs2) -[](https://gitter.im/Valve/fingerprintjs2) - -Original fingerprintjs library was developed in 2012, it's now impossible to evolve it -without breaking backwards compatibilty, so this project will be where -all the new development happens. - -This project will use significantly more sources for fingerprinting, all -of them will be configurable, that is it should be possible to -cherry-pick only the options you need or just enable them all. - -I'm also paying special attention to IE plugins, popular in China, such -as QQ, Baidu and others. - -This project will not be backwards compatible with original -fingerprintjs. - -This project uses `semver`. - -### Installation - -#### CDN: -``` -//cdn.jsdelivr.net/fingerprintjs2/<VERSION>/fingerprint2.min.js -``` -or - -``` -https://cdnjs.com/libraries/fingerprintjs2 -``` - -#### Bower - -``` -bower install fingerprintjs2 -``` - -#### NPM - -``` -npm install fingerprintjs2 -``` - - -### Usage - -```js -new Fingerprint2().get(function(result, components){ - console.log(result); //a hash, representing your device fingerprint - console.log(components); // an array of FP components -}); -``` - -#### You can pass an object with options (all of which are optional): - -```js -var options = {swfPath: '/assets/FontList.swf', excludeUserAgent: true}; -new Fingerprint2(options).get(function(result){ - console.log(result); -}); -``` - -Full list of options will be in the -(https://github.com/Valve/fingerprintjs2/wiki/List-of-options) wiki -page. - -Flash font enumeration is disabled by default. JS code is used by -default to get the list of available fonts. - -The reason for this is that Flash will not work in incognito mode. - -However, you can make the library to use Flash when detecting the fonts -with: - -```js -excludeJsFonts: true -``` -option. - -To use Flash font enumeration, make sure you have swfobject available. -If you don't, the library will skip the Flash part entirely. - -#### `detectScreenOrientation` option is `true` by default - -To ensure consistent fingerprints when users rotate their mobile -devices. - - -##### All fingerprinting sources are enabled by default, i.e. you don't need to explicitly configure the library to include them. - -```js -new Fingerprint2().get(function(result, components){ - // this will use all available fingerprinting sources - console.log(result); - // components is an array of all fingerprinting components used - console.log(components); -}); -``` - -#### `userDefinedFonts` option - -While hundreds of the most popular fonts are included in the extended font list, you may wish to increase the entropy of the font fingerprint by specifying the `userDefinedFonts` option as an array of font names. - -``` -new Fingerprint2({ - userDefinedFonts: ["Nimbus Mono", "Junicode", "Presto"] -}).get(function(result, components){} - console.log(result); -); -``` - -#### View the fingerprint locally - -You can view your browser fingerprint locally by starting a webserver and viewing the `index.html` page. -Loading `index.html` from the filesystem won't work due to Flash's ExternalInterface security restrictions. - -To start a web server you can try using one of the following: - -* Ruby 1.9.2+ - - `ruby -run -e httpd . -p 8080` - -* Python 2.x - - `python -m SimpleHTTPServer 8080` - -* Python 3.x - - `python -m http.server 8080` - -* PHP 5.4+ - - `php -S 0.0.0.0:8080` - - -### List of fingerprinting sources - -1. UserAgent -2. Language -3. Color Depth -4. Screen Resolution -5. Timezone -6. Has session storage or not -7. Has local storage or not -8. Has indexed DB -9. Has IE specific 'AddBehavior' -10. Has open DB -11. CPU class -12. Platform -13. DoNotTrack or not -14. Full list of installed fonts (maintaining their order, which increases the entropy), implemented with Flash. -15. A list of installed fonts, detected with JS/CSS (side-channel technique) - can detect up to 500 installed fonts without flash -16. Canvas fingerprinting -17. WebGL fingerprinting -18. Plugins (IE included) -19. Is AdBlock installed or not -20. Has the user tampered with its languages <sup>[1](https://github.com/Valve/fingerprintjs2/wiki/Browser-tampering)</sup> -21. Has the user tampered with its screen resolution <sup>[1](https://github.com/Valve/fingerprintjs2/wiki/Browser-tampering)</sup> -22. Has the user tampered with its OS <sup>[1](https://github.com/Valve/fingerprintjs2/wiki/Browser-tampering)</sup> -23. Has the user tampered with its browser <sup>[1](https://github.com/Valve/fingerprintjs2/wiki/Browser-tampering)</sup> -24. Touch screen detection and capabilities -25. Pixel Ratio -26. System's total number of logical processors available to the user agent. - - -By default, JS font detection will only detect up to 65 installed fonts. If you want to improve the font detection, -you can pass `extendedJsFonts: true` option. This will increase the number of detectable fonts to ~500. - -On my machine (MBP 2013 Core i5) + Chrome 46 the default FP process takes about 80-100ms. If you use `extendedJsFonts` option this time will increase up to 160-200ms. -This option can incur even more overhead on mobile Firefox browsers, which is much slower in font detection, so use it with caution on mobile devices. - -### Many more fingerprinting sources will be implemented, such as -(in no particular order) - -* Multi-monitor detection, -* Internal HashTable implementation detection -* WebRTC fingerprinting -* Math constants -* Accessibility fingerprinting -* Camera information -* DRM support -* Accelerometer support -* Virtual keyboards -* List of supported gestures (for touch-enabled devices) -* Pixel density -* Video and audio codecs availability -* Audio stack fingerprinting - -#### To recompile the `FontList.swf` file: - -* Download [Adobe Flex SDK](http://www.adobe.com/devnet/flex/flex-sdk-download.html) -* Unzip it, add the `bin/` directory to your `$PATH` (mxmlc binary should be in path) -* Run `make` - -#### License: MIT or Apache, whichever you prefer. diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/bower.json b/apps/maarch_entreprise/tools/fingerprintjs2/bower.json deleted file mode 100755 index fb233abfb83c61515e96a582ae38a8c47b1dcaa8..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/bower.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "fingerprintjs2", - "description": "Modern & flexible browser fingerprinting library", - "main": "fingerprint2.js", - "moduleType": [ - "es6" - ], - "keywords": [ - "browser", - "fingerprint", - "fingerprinting", - "security", - "privacy" - ], - "authors": [ - "Valentin Vasilev" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "spec" - ] -} diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/dist/fingerprint2.min.js b/apps/maarch_entreprise/tools/fingerprintjs2/dist/fingerprint2.min.js deleted file mode 100755 index 54b948c0c611c31e6a585d8589ab5e3332f5caae..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/dist/fingerprint2.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e,t,i){"use strict";"function"==typeof define&&define.amd?define(i):"undefined"!=typeof module&&module.exports?module.exports=i():t.exports?t.exports=i():t[e]=i()}("Fingerprint2",this,function(){"use strict";Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var i;if(null==this)throw new TypeError("'this' is null or undefined");var a=Object(this),r=a.length>>>0;if(0===r)return-1;var n=+t||0;if(Math.abs(n)===1/0&&(n=0),n>=r)return-1;for(i=Math.max(n>=0?n:r-Math.abs(n),0);i<r;){if(i in a&&a[i]===e)return i;i++}return-1});var e=function(t){if(!(this instanceof e))return new e(t);var i={swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",detectScreenOrientation:!0,sortPluginsFor:[/palemoon/i],userDefinedFonts:[]};this.options=this.extend(t,i),this.nativeForEach=Array.prototype.forEach,this.nativeMap=Array.prototype.map};return e.prototype={extend:function(e,t){if(null==e)return t;for(var i in e)null!=e[i]&&t[i]!==e[i]&&(t[i]=e[i]);return t},log:function(e){window.console&&console.log(e)},get:function(e){var t=[];t=this.userAgentKey(t),t=this.languageKey(t),t=this.colorDepthKey(t),t=this.pixelRatioKey(t),t=this.hardwareConcurrencyKey(t),t=this.screenResolutionKey(t),t=this.availableScreenResolutionKey(t),t=this.timezoneOffsetKey(t),t=this.sessionStorageKey(t),t=this.localStorageKey(t),t=this.indexedDbKey(t),t=this.addBehaviorKey(t),t=this.openDatabaseKey(t),t=this.cpuClassKey(t),t=this.platformKey(t),t=this.doNotTrackKey(t),t=this.pluginsKey(t),t=this.canvasKey(t),t=this.webglKey(t),t=this.adBlockKey(t),t=this.hasLiedLanguagesKey(t),t=this.hasLiedResolutionKey(t),t=this.hasLiedOsKey(t),t=this.hasLiedBrowserKey(t),t=this.touchSupportKey(t);var i=this;this.fontsKey(t,function(t){var a=[];i.each(t,function(e){var t=e.value;"undefined"!=typeof e.value.join&&(t=e.value.join(";")),a.push(t)});var r=i.x64hash128(a.join("~~~"),31);return e(r,t)})},userAgentKey:function(e){return this.options.excludeUserAgent||e.push({key:"user_agent",value:this.getUserAgent()}),e},getUserAgent:function(){return navigator.userAgent},languageKey:function(e){return this.options.excludeLanguage||e.push({key:"language",value:navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||""}),e},colorDepthKey:function(e){return this.options.excludeColorDepth||e.push({key:"color_depth",value:screen.colorDepth||-1}),e},pixelRatioKey:function(e){return this.options.excludePixelRatio||e.push({key:"pixel_ratio",value:this.getPixelRatio()}),e},getPixelRatio:function(){return window.devicePixelRatio||""},screenResolutionKey:function(e){return this.options.excludeScreenResolution?e:this.getScreenResolution(e)},getScreenResolution:function(e){var t;return t=this.options.detectScreenOrientation&&screen.height>screen.width?[screen.height,screen.width]:[screen.width,screen.height],"undefined"!=typeof t&&e.push({key:"resolution",value:t}),e},availableScreenResolutionKey:function(e){return this.options.excludeAvailableScreenResolution?e:this.getAvailableScreenResolution(e)},getAvailableScreenResolution:function(e){var t;return screen.availWidth&&screen.availHeight&&(t=this.options.detectScreenOrientation?screen.availHeight>screen.availWidth?[screen.availHeight,screen.availWidth]:[screen.availWidth,screen.availHeight]:[screen.availHeight,screen.availWidth]),"undefined"!=typeof t&&e.push({key:"available_resolution",value:t}),e},timezoneOffsetKey:function(e){return this.options.excludeTimezoneOffset||e.push({key:"timezone_offset",value:(new Date).getTimezoneOffset()}),e},sessionStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasSessionStorage()&&e.push({key:"session_storage",value:1}),e},localStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasLocalStorage()&&e.push({key:"local_storage",value:1}),e},indexedDbKey:function(e){return!this.options.excludeIndexedDB&&this.hasIndexedDB()&&e.push({key:"indexed_db",value:1}),e},addBehaviorKey:function(e){return document.body&&!this.options.excludeAddBehavior&&document.body.addBehavior&&e.push({key:"add_behavior",value:1}),e},openDatabaseKey:function(e){return!this.options.excludeOpenDatabase&&window.openDatabase&&e.push({key:"open_database",value:1}),e},cpuClassKey:function(e){return this.options.excludeCpuClass||e.push({key:"cpu_class",value:this.getNavigatorCpuClass()}),e},platformKey:function(e){return this.options.excludePlatform||e.push({key:"navigator_platform",value:this.getNavigatorPlatform()}),e},doNotTrackKey:function(e){return this.options.excludeDoNotTrack||e.push({key:"do_not_track",value:this.getDoNotTrack()}),e},canvasKey:function(e){return!this.options.excludeCanvas&&this.isCanvasSupported()&&e.push({key:"canvas",value:this.getCanvasFp()}),e},webglKey:function(e){return this.options.excludeWebGL?e:this.isWebGlSupported()?(e.push({key:"webgl",value:this.getWebglFp()}),e):e},adBlockKey:function(e){return this.options.excludeAdBlock||e.push({key:"adblock",value:this.getAdBlock()}),e},hasLiedLanguagesKey:function(e){return this.options.excludeHasLiedLanguages||e.push({key:"has_lied_languages",value:this.getHasLiedLanguages()}),e},hasLiedResolutionKey:function(e){return this.options.excludeHasLiedResolution||e.push({key:"has_lied_resolution",value:this.getHasLiedResolution()}),e},hasLiedOsKey:function(e){return this.options.excludeHasLiedOs||e.push({key:"has_lied_os",value:this.getHasLiedOs()}),e},hasLiedBrowserKey:function(e){return this.options.excludeHasLiedBrowser||e.push({key:"has_lied_browser",value:this.getHasLiedBrowser()}),e},fontsKey:function(e,t){return this.options.excludeJsFonts?this.flashFontsKey(e,t):this.jsFontsKey(e,t)},flashFontsKey:function(e,t){return this.options.excludeFlashFonts?t(e):this.hasSwfObjectLoaded()&&this.hasMinFlashInstalled()?"undefined"==typeof this.options.swfPath?t(e):void this.loadSwfAndDetectFonts(function(i){e.push({key:"swf_fonts",value:i.join(";")}),t(e)}):t(e)},jsFontsKey:function(e,t){var i=this;return setTimeout(function(){var a=["monospace","sans-serif","serif"],r=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Garamond","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"],n=["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"];i.options.extendedJsFonts&&(r=r.concat(n)),r=r.concat(i.options.userDefinedFonts);var o="mmmmmmmmmmlli",s="72px",l=document.getElementsByTagName("body")[0],h=document.createElement("div"),u=document.createElement("div"),d={},c={},g=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize=s,e.style.lineHeight="normal",e.innerHTML=o,e},p=function(e,t){var i=g();return i.style.fontFamily="'"+e+"',"+t,i},f=function(){for(var e=[],t=0,i=a.length;t<i;t++){var r=g();r.style.fontFamily=a[t],h.appendChild(r),e.push(r)}return e},m=function(){for(var e={},t=0,i=r.length;t<i;t++){for(var n=[],o=0,s=a.length;o<s;o++){var l=p(r[t],a[o]);u.appendChild(l),n.push(l)}e[r[t]]=n}return e},T=function(e){for(var t=!1,i=0;i<a.length;i++)if(t=e[i].offsetWidth!==d[a[i]]||e[i].offsetHeight!==c[a[i]])return t;return t},S=f();l.appendChild(h);for(var x=0,v=a.length;x<v;x++)d[a[x]]=S[x].offsetWidth,c[a[x]]=S[x].offsetHeight;var M=m();l.appendChild(u);for(var E=[],A=0,y=r.length;A<y;A++)T(M[r[A]])&&E.push(r[A]);l.removeChild(u),l.removeChild(h),e.push({key:"js_fonts",value:E}),t(e)},1)},pluginsKey:function(e){return this.options.excludePlugins||(this.isIE()?this.options.excludeIEPlugins||e.push({key:"ie_plugins",value:this.getIEPlugins()}):e.push({key:"regular_plugins",value:this.getRegularPlugins()})),e},getRegularPlugins:function(){for(var e=[],t=0,i=navigator.plugins.length;t<i;t++)e.push(navigator.plugins[t]);return this.pluginsShouldBeSorted()&&(e=e.sort(function(e,t){return e.name>t.name?1:e.name<t.name?-1:0})),this.map(e,function(e){var t=this.map(e,function(e){return[e.type,e.suffixes].join("~")}).join(",");return[e.name,e.description,t].join("::")},this)},getIEPlugins:function(){var e=[];if(Object.getOwnPropertyDescriptor&&Object.getOwnPropertyDescriptor(window,"ActiveXObject")||"ActiveXObject"in window){var t=["AcroPDF.PDF","Adodb.Stream","AgControl.AgControl","DevalVRXCtrl.DevalVRXCtrl.1","MacromediaFlashPaper.MacromediaFlashPaper","Msxml2.DOMDocument","Msxml2.XMLHTTP","PDF.PdfCtrl","QuickTime.QuickTime","QuickTimeCheckObject.QuickTimeCheck.1","RealPlayer","RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)","RealVideo.RealVideo(tm) ActiveX Control (32-bit)","Scripting.Dictionary","SWCtl.SWCtl","Shell.UIHelper","ShockwaveFlash.ShockwaveFlash","Skype.Detection","TDCCtl.TDCCtl","WMPlayer.OCX","rmocx.RealPlayer G2 Control","rmocx.RealPlayer G2 Control.1"];e=this.map(t,function(e){try{return new ActiveXObject(e),e}catch(t){return null}})}return navigator.plugins&&(e=e.concat(this.getRegularPlugins())),e},pluginsShouldBeSorted:function(){for(var e=!1,t=0,i=this.options.sortPluginsFor.length;t<i;t++){var a=this.options.sortPluginsFor[t];if(navigator.userAgent.match(a)){e=!0;break}}return e},touchSupportKey:function(e){return this.options.excludeTouchSupport||e.push({key:"touch_support",value:this.getTouchSupport()}),e},hardwareConcurrencyKey:function(e){return this.options.excludeHardwareConcurrency||e.push({key:"hardware_concurrency",value:this.getHardwareConcurrency()}),e},hasSessionStorage:function(){try{return!!window.sessionStorage}catch(e){return!0}},hasLocalStorage:function(){try{return!!window.localStorage}catch(e){return!0}},hasIndexedDB:function(){try{return!!window.indexedDB}catch(e){return!0}},getHardwareConcurrency:function(){return navigator.hardwareConcurrency?navigator.hardwareConcurrency:"unknown"},getNavigatorCpuClass:function(){return navigator.cpuClass?navigator.cpuClass:"unknown"},getNavigatorPlatform:function(){return navigator.platform?navigator.platform:"unknown"},getDoNotTrack:function(){return navigator.doNotTrack?navigator.doNotTrack:navigator.msDoNotTrack?navigator.msDoNotTrack:window.doNotTrack?window.doNotTrack:"unknown"},getTouchSupport:function(){var e=0,t=!1;"undefined"!=typeof navigator.maxTouchPoints?e=navigator.maxTouchPoints:"undefined"!=typeof navigator.msMaxTouchPoints&&(e=navigator.msMaxTouchPoints);try{document.createEvent("TouchEvent"),t=!0}catch(i){}var a="ontouchstart"in window;return[e,t,a]},getCanvasFp:function(){var e=[],t=document.createElement("canvas");t.width=2e3,t.height=200,t.style.display="inline";var i=t.getContext("2d");return i.rect(0,0,10,10),i.rect(2,2,6,6),e.push("canvas winding:"+(i.isPointInPath(5,5,"evenodd")===!1?"yes":"no")),i.textBaseline="alphabetic",i.fillStyle="#f60",i.fillRect(125,1,62,20),i.fillStyle="#069",this.options.dontUseFakeFontInCanvas?i.font="11pt Arial":i.font="11pt no-real-font-123",i.fillText("Cwm fjordbank glyphs vext quiz, \ud83d\ude03",2,15),i.fillStyle="rgba(102, 204, 0, 0.2)",i.font="18pt Arial",i.fillText("Cwm fjordbank glyphs vext quiz, \ud83d\ude03",4,45),i.globalCompositeOperation="multiply",i.fillStyle="rgb(255,0,255)",i.beginPath(),i.arc(50,50,50,0,2*Math.PI,!0),i.closePath(),i.fill(),i.fillStyle="rgb(0,255,255)",i.beginPath(),i.arc(100,50,50,0,2*Math.PI,!0),i.closePath(),i.fill(),i.fillStyle="rgb(255,255,0)",i.beginPath(),i.arc(75,100,50,0,2*Math.PI,!0),i.closePath(),i.fill(),i.fillStyle="rgb(255,0,255)",i.arc(75,75,75,0,2*Math.PI,!0),i.arc(75,75,25,0,2*Math.PI,!0),i.fill("evenodd"),e.push("canvas fp:"+t.toDataURL()),e.join("~")},getWebglFp:function(){var e,t=function(t){return e.clearColor(0,0,0,1),e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),"["+t[0]+", "+t[1]+"]"},i=function(e){var t,i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic");return i?(t=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT),0===t&&(t=2),t):null};if(e=this.getWebglCanvas(),!e)return null;var a=[],r="attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}",n="precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}",o=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,o);var s=new Float32Array([-.2,-.9,0,.4,-.26,0,0,.732134444,0]);e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),o.itemSize=3,o.numItems=3;var l=e.createProgram(),h=e.createShader(e.VERTEX_SHADER);e.shaderSource(h,r),e.compileShader(h);var u=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(u,n),e.compileShader(u),e.attachShader(l,h),e.attachShader(l,u),e.linkProgram(l),e.useProgram(l),l.vertexPosAttrib=e.getAttribLocation(l,"attrVertex"),l.offsetUniform=e.getUniformLocation(l,"uniformOffset"),e.enableVertexAttribArray(l.vertexPosArray),e.vertexAttribPointer(l.vertexPosAttrib,o.itemSize,e.FLOAT,!1,0,0),e.uniform2f(l.offsetUniform,1,1),e.drawArrays(e.TRIANGLE_STRIP,0,o.numItems),null!=e.canvas&&a.push(e.canvas.toDataURL()),a.push("extensions:"+e.getSupportedExtensions().join(";")),a.push("webgl aliased line width range:"+t(e.getParameter(e.ALIASED_LINE_WIDTH_RANGE))),a.push("webgl aliased point size range:"+t(e.getParameter(e.ALIASED_POINT_SIZE_RANGE))),a.push("webgl alpha bits:"+e.getParameter(e.ALPHA_BITS)),a.push("webgl antialiasing:"+(e.getContextAttributes().antialias?"yes":"no")),a.push("webgl blue bits:"+e.getParameter(e.BLUE_BITS)),a.push("webgl depth bits:"+e.getParameter(e.DEPTH_BITS)),a.push("webgl green bits:"+e.getParameter(e.GREEN_BITS)),a.push("webgl max anisotropy:"+i(e)),a.push("webgl max combined texture image units:"+e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS)),a.push("webgl max cube map texture size:"+e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE)),a.push("webgl max fragment uniform vectors:"+e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)),a.push("webgl max render buffer size:"+e.getParameter(e.MAX_RENDERBUFFER_SIZE)),a.push("webgl max texture image units:"+e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)),a.push("webgl max texture size:"+e.getParameter(e.MAX_TEXTURE_SIZE)),a.push("webgl max varying vectors:"+e.getParameter(e.MAX_VARYING_VECTORS)),a.push("webgl max vertex attribs:"+e.getParameter(e.MAX_VERTEX_ATTRIBS)),a.push("webgl max vertex texture image units:"+e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)),a.push("webgl max vertex uniform vectors:"+e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)),a.push("webgl max viewport dims:"+t(e.getParameter(e.MAX_VIEWPORT_DIMS))),a.push("webgl red bits:"+e.getParameter(e.RED_BITS)),a.push("webgl renderer:"+e.getParameter(e.RENDERER)),a.push("webgl shading language version:"+e.getParameter(e.SHADING_LANGUAGE_VERSION)),a.push("webgl stencil bits:"+e.getParameter(e.STENCIL_BITS)),a.push("webgl vendor:"+e.getParameter(e.VENDOR)),a.push("webgl version:"+e.getParameter(e.VERSION));try{var d=e.getExtension("WEBGL_debug_renderer_info");d&&(a.push("webgl unmasked vendor:"+e.getParameter(d.UNMASKED_VENDOR_WEBGL)),a.push("webgl unmasked renderer:"+e.getParameter(d.UNMASKED_RENDERER_WEBGL)))}catch(c){}return e.getShaderPrecisionFormat?(a.push("webgl vertex shader high float precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision),a.push("webgl vertex shader high float precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).rangeMin),a.push("webgl vertex shader high float precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).rangeMax),a.push("webgl vertex shader medium float precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision),a.push("webgl vertex shader medium float precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).rangeMin),a.push("webgl vertex shader medium float precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).rangeMax),a.push("webgl vertex shader low float precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_FLOAT).precision),a.push("webgl vertex shader low float precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_FLOAT).rangeMin),a.push("webgl vertex shader low float precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_FLOAT).rangeMax),a.push("webgl fragment shader high float precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision),a.push("webgl fragment shader high float precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).rangeMin),a.push("webgl fragment shader high float precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).rangeMax),a.push("webgl fragment shader medium float precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision),a.push("webgl fragment shader medium float precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).rangeMin),a.push("webgl fragment shader medium float precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).rangeMax),a.push("webgl fragment shader low float precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_FLOAT).precision),a.push("webgl fragment shader low float precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_FLOAT).rangeMin),a.push("webgl fragment shader low float precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_FLOAT).rangeMax),a.push("webgl vertex shader high int precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_INT).precision),a.push("webgl vertex shader high int precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_INT).rangeMin),a.push("webgl vertex shader high int precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_INT).rangeMax),a.push("webgl vertex shader medium int precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_INT).precision),a.push("webgl vertex shader medium int precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_INT).rangeMin),a.push("webgl vertex shader medium int precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_INT).rangeMax),a.push("webgl vertex shader low int precision:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_INT).precision),a.push("webgl vertex shader low int precision rangeMin:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_INT).rangeMin),a.push("webgl vertex shader low int precision rangeMax:"+e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.LOW_INT).rangeMax),a.push("webgl fragment shader high int precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_INT).precision),a.push("webgl fragment shader high int precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_INT).rangeMin),a.push("webgl fragment shader high int precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_INT).rangeMax),a.push("webgl fragment shader medium int precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_INT).precision),a.push("webgl fragment shader medium int precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_INT).rangeMin),a.push("webgl fragment shader medium int precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_INT).rangeMax),a.push("webgl fragment shader low int precision:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_INT).precision),a.push("webgl fragment shader low int precision rangeMin:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_INT).rangeMin),a.push("webgl fragment shader low int precision rangeMax:"+e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.LOW_INT).rangeMax),a.join("~")):a.join("~")},getAdBlock:function(){var e=document.createElement("div");e.innerHTML=" ",e.className="adsbox";var t=!1;try{document.body.appendChild(e),t=0===document.getElementsByClassName("adsbox")[0].offsetHeight,document.body.removeChild(e)}catch(i){t=!1}return t},getHasLiedLanguages:function(){if("undefined"!=typeof navigator.languages)try{var e=navigator.languages[0].substr(0,2);if(e!==navigator.language.substr(0,2))return!0}catch(t){return!0}return!1},getHasLiedResolution:function(){return screen.width<screen.availWidth||screen.height<screen.availHeight},getHasLiedOs:function(){var e,t=navigator.userAgent.toLowerCase(),i=navigator.oscpu,a=navigator.platform.toLowerCase();e=t.indexOf("windows phone")>=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other";var r;if(r="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,r&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if("undefined"!=typeof i){if(i=i.toLowerCase(),i.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(i.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(i.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if(0===i.indexOf("win")&&0===i.indexOf("linux")&&i.indexOf("mac")>=0&&"other"!==e)return!0}return a.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((a.indexOf("linux")>=0||a.indexOf("android")>=0||a.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((a.indexOf("mac")>=0||a.indexOf("ipad")>=0||a.indexOf("ipod")>=0||a.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||(0===a.indexOf("win")&&0===a.indexOf("linux")&&a.indexOf("mac")>=0&&"other"!==e||"undefined"==typeof navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},getHasLiedBrowser:function(){var e,t=navigator.userAgent.toLowerCase(),i=navigator.productSub;if(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other",("Chrome"===e||"Safari"===e||"Opera"===e)&&"20030107"!==i)return!0;var a=eval.toString().length;if(37===a&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===a&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===a&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;var r;try{throw"a"}catch(n){try{n.toSource(),r=!0}catch(o){r=!1}}return!(!r||"Firefox"===e||"Other"===e)},isCanvasSupported:function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},isWebGlSupported:function(){if(!this.isCanvasSupported())return!1;var e,t=document.createElement("canvas");try{e=t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(i){e=!1}return!!window.WebGLRenderingContext&&!!e},isIE:function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},hasSwfObjectLoaded:function(){return"undefined"!=typeof window.swfobject},hasMinFlashInstalled:function(){return swfobject.hasFlashPlayerVersion("9.0.0")},addFlashDivNode:function(){var e=document.createElement("div");e.setAttribute("id",this.options.swfContainerId),document.body.appendChild(e)},loadSwfAndDetectFonts:function(e){var t="___fp_swf_loaded";window[t]=function(t){e(t)};var i=this.options.swfContainerId;this.addFlashDivNode();var a={onReady:t},r={allowScriptAccess:"always",menu:"false"};swfobject.embedSWF(this.options.swfPath,i,"1","1","9.0.0",!1,a,r,{})},getWebglCanvas:function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(i){}return t||(t=null),t},each:function(e,t,i){if(null!==e)if(this.nativeForEach&&e.forEach===this.nativeForEach)e.forEach(t,i);else if(e.length===+e.length){for(var a=0,r=e.length;a<r;a++)if(t.call(i,e[a],a,e)==={})return}else for(var n in e)if(e.hasOwnProperty(n)&&t.call(i,e[n],n,e)==={})return},map:function(e,t,i){var a=[];return null==e?a:this.nativeMap&&e.map===this.nativeMap?e.map(t,i):(this.each(e,function(e,r,n){a[a.length]=t.call(i,e,r,n)}),a)},x64Add:function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var i=[0,0,0,0];return i[3]+=e[3]+t[3],i[2]+=i[3]>>>16,i[3]&=65535,i[2]+=e[2]+t[2],i[1]+=i[2]>>>16,i[2]&=65535,i[1]+=e[1]+t[1],i[0]+=i[1]>>>16,i[1]&=65535,i[0]+=e[0]+t[0],i[0]&=65535,[i[0]<<16|i[1],i[2]<<16|i[3]]},x64Multiply:function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var i=[0,0,0,0];return i[3]+=e[3]*t[3],i[2]+=i[3]>>>16,i[3]&=65535,i[2]+=e[2]*t[3],i[1]+=i[2]>>>16,i[2]&=65535,i[2]+=e[3]*t[2],i[1]+=i[2]>>>16,i[2]&=65535,i[1]+=e[1]*t[3],i[0]+=i[1]>>>16,i[1]&=65535,i[1]+=e[2]*t[2],i[0]+=i[1]>>>16,i[1]&=65535,i[1]+=e[3]*t[1],i[0]+=i[1]>>>16,i[1]&=65535,i[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],i[0]&=65535,[i[0]<<16|i[1],i[2]<<16|i[3]]},x64Rotl:function(e,t){return t%=64,32===t?[e[1],e[0]]:t<32?[e[0]<<t|e[1]>>>32-t,e[1]<<t|e[0]>>>32-t]:(t-=32,[e[1]<<t|e[0]>>>32-t,e[0]<<t|e[1]>>>32-t])},x64LeftShift:function(e,t){return t%=64,0===t?e:t<32?[e[0]<<t|e[1]>>>32-t,e[1]<<t]:[e[1]<<t-32,0]},x64Xor:function(e,t){return[e[0]^t[0],e[1]^t[1]]},x64Fmix:function(e){return e=this.x64Xor(e,[0,e[0]>>>1]),e=this.x64Multiply(e,[4283543511,3981806797]),e=this.x64Xor(e,[0,e[0]>>>1]),e=this.x64Multiply(e,[3301882366,444984403]),e=this.x64Xor(e,[0,e[0]>>>1]); -},x64hash128:function(e,t){e=e||"",t=t||0;for(var i=e.length%16,a=e.length-i,r=[0,t],n=[0,t],o=[0,0],s=[0,0],l=[2277735313,289559509],h=[1291169091,658871167],u=0;u<a;u+=16)o=[255&e.charCodeAt(u+4)|(255&e.charCodeAt(u+5))<<8|(255&e.charCodeAt(u+6))<<16|(255&e.charCodeAt(u+7))<<24,255&e.charCodeAt(u)|(255&e.charCodeAt(u+1))<<8|(255&e.charCodeAt(u+2))<<16|(255&e.charCodeAt(u+3))<<24],s=[255&e.charCodeAt(u+12)|(255&e.charCodeAt(u+13))<<8|(255&e.charCodeAt(u+14))<<16|(255&e.charCodeAt(u+15))<<24,255&e.charCodeAt(u+8)|(255&e.charCodeAt(u+9))<<8|(255&e.charCodeAt(u+10))<<16|(255&e.charCodeAt(u+11))<<24],o=this.x64Multiply(o,l),o=this.x64Rotl(o,31),o=this.x64Multiply(o,h),r=this.x64Xor(r,o),r=this.x64Rotl(r,27),r=this.x64Add(r,n),r=this.x64Add(this.x64Multiply(r,[0,5]),[0,1390208809]),s=this.x64Multiply(s,h),s=this.x64Rotl(s,33),s=this.x64Multiply(s,l),n=this.x64Xor(n,s),n=this.x64Rotl(n,31),n=this.x64Add(n,r),n=this.x64Add(this.x64Multiply(n,[0,5]),[0,944331445]);switch(o=[0,0],s=[0,0],i){case 15:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+14)],48));case 14:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+13)],40));case 13:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+12)],32));case 12:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+11)],24));case 11:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+10)],16));case 10:s=this.x64Xor(s,this.x64LeftShift([0,e.charCodeAt(u+9)],8));case 9:s=this.x64Xor(s,[0,e.charCodeAt(u+8)]),s=this.x64Multiply(s,h),s=this.x64Rotl(s,33),s=this.x64Multiply(s,l),n=this.x64Xor(n,s);case 8:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+7)],56));case 7:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+6)],48));case 6:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+5)],40));case 5:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+4)],32));case 4:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+3)],24));case 3:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+2)],16));case 2:o=this.x64Xor(o,this.x64LeftShift([0,e.charCodeAt(u+1)],8));case 1:o=this.x64Xor(o,[0,e.charCodeAt(u)]),o=this.x64Multiply(o,l),o=this.x64Rotl(o,31),o=this.x64Multiply(o,h),r=this.x64Xor(r,o)}return r=this.x64Xor(r,[0,e.length]),n=this.x64Xor(n,[0,e.length]),r=this.x64Add(r,n),n=this.x64Add(n,r),r=this.x64Fmix(r),n=this.x64Fmix(n),r=this.x64Add(r,n),n=this.x64Add(n,r),("00000000"+(r[0]>>>0).toString(16)).slice(-8)+("00000000"+(r[1]>>>0).toString(16)).slice(-8)+("00000000"+(n[0]>>>0).toString(16)).slice(-8)+("00000000"+(n[1]>>>0).toString(16)).slice(-8)}},e.VERSION="1.5.0",e}); \ No newline at end of file diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/fingerprint2.js b/apps/maarch_entreprise/tools/fingerprintjs2/fingerprint2.js deleted file mode 100755 index 79befe953e87a0864adb80d6381f4384ea5fc1e1..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/fingerprint2.js +++ /dev/null @@ -1,1332 +0,0 @@ -/* -* Fingerprintjs2 1.5.0 - Modern & flexible browser fingerprint library v2 -* https://github.com/Valve/fingerprintjs2 -* Copyright (c) 2015 Valentin Vasilyev (valentin.vasilyev@outlook.com) -* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL VALENTIN VASILYEV BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function (name, context, definition) { - "use strict"; - if (typeof define === "function" && define.amd) { define(definition); } - else if (typeof module !== "undefined" && module.exports) { module.exports = definition(); } - else if (context.exports) { context.exports = definition(); } - else { context[name] = definition(); } -})("Fingerprint2", this, function() { - "use strict"; - // This will only be polyfilled for IE8 and older - // Taken from Mozilla MDC - if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function(searchElement, fromIndex) { - var k; - if (this == null) { - throw new TypeError("'this' is null or undefined"); - } - var O = Object(this); - var len = O.length >>> 0; - if (len === 0) { - return -1; - } - var n = +fromIndex || 0; - if (Math.abs(n) === Infinity) { - n = 0; - } - if (n >= len) { - return -1; - } - k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); - while (k < len) { - if (k in O && O[k] === searchElement) { - return k; - } - k++; - } - return -1; - }; - } - var Fingerprint2 = function(options) { - - if (!(this instanceof Fingerprint2)) { - return new Fingerprint2(options); - } - - var defaultOptions = { - swfContainerId: "fingerprintjs2", - swfPath: "flash/compiled/FontList.swf", - detectScreenOrientation: true, - sortPluginsFor: [/palemoon/i], - userDefinedFonts: [] - }; - this.options = this.extend(options, defaultOptions); - this.nativeForEach = Array.prototype.forEach; - this.nativeMap = Array.prototype.map; - }; - Fingerprint2.prototype = { - extend: function(source, target) { - if (source == null) { return target; } - for (var k in source) { - if(source[k] != null && target[k] !== source[k]) { - target[k] = source[k]; - } - } - return target; - }, - log: function(msg){ - if(window.console){ - console.log(msg); - } - }, - get: function(done){ - var keys = []; - keys = this.userAgentKey(keys); - keys = this.languageKey(keys); - keys = this.colorDepthKey(keys); - keys = this.pixelRatioKey(keys); - keys = this.hardwareConcurrencyKey(keys); - keys = this.screenResolutionKey(keys); - keys = this.availableScreenResolutionKey(keys); - keys = this.timezoneOffsetKey(keys); - keys = this.sessionStorageKey(keys); - keys = this.localStorageKey(keys); - keys = this.indexedDbKey(keys); - keys = this.addBehaviorKey(keys); - keys = this.openDatabaseKey(keys); - keys = this.cpuClassKey(keys); - keys = this.platformKey(keys); - keys = this.doNotTrackKey(keys); - keys = this.pluginsKey(keys); - keys = this.canvasKey(keys); - keys = this.webglKey(keys); - keys = this.adBlockKey(keys); - keys = this.hasLiedLanguagesKey(keys); - keys = this.hasLiedResolutionKey(keys); - keys = this.hasLiedOsKey(keys); - keys = this.hasLiedBrowserKey(keys); - keys = this.touchSupportKey(keys); - var that = this; - this.fontsKey(keys, function(newKeys){ - var values = []; - that.each(newKeys, function(pair) { - var value = pair.value; - if (typeof pair.value.join !== "undefined") { - value = pair.value.join(";"); - } - values.push(value); - }); - var murmur = that.x64hash128(values.join("~~~"), 31); - return done(murmur, newKeys); - }); - }, - userAgentKey: function(keys) { - if(!this.options.excludeUserAgent) { - keys.push({key: "user_agent", value: this.getUserAgent()}); - } - return keys; - }, - // for tests - getUserAgent: function(){ - return navigator.userAgent; - }, - languageKey: function(keys) { - if(!this.options.excludeLanguage) { - // IE 9,10 on Windows 10 does not have the `navigator.language` property any longer - keys.push({ key: "language", value: navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || "" }); - } - return keys; - }, - colorDepthKey: function(keys) { - if(!this.options.excludeColorDepth) { - keys.push({key: "color_depth", value: screen.colorDepth || -1}); - } - return keys; - }, - pixelRatioKey: function(keys) { - if(!this.options.excludePixelRatio) { - keys.push({key: "pixel_ratio", value: this.getPixelRatio()}); - } - return keys; - }, - getPixelRatio: function() { - return window.devicePixelRatio || ""; - }, - screenResolutionKey: function(keys) { - if(!this.options.excludeScreenResolution) { - return this.getScreenResolution(keys); - } - return keys; - }, - getScreenResolution: function(keys) { - var resolution; - if(this.options.detectScreenOrientation) { - resolution = (screen.height > screen.width) ? [screen.height, screen.width] : [screen.width, screen.height]; - } else { - resolution = [screen.width, screen.height]; - } - if(typeof resolution !== "undefined") { // headless browsers - keys.push({key: "resolution", value: resolution}); - } - return keys; - }, - availableScreenResolutionKey: function(keys) { - if (!this.options.excludeAvailableScreenResolution) { - return this.getAvailableScreenResolution(keys); - } - return keys; - }, - getAvailableScreenResolution: function(keys) { - var available; - if(screen.availWidth && screen.availHeight) { - if(this.options.detectScreenOrientation) { - available = (screen.availHeight > screen.availWidth) ? [screen.availHeight, screen.availWidth] : [screen.availWidth, screen.availHeight]; - } else { - available = [screen.availHeight, screen.availWidth]; - } - } - if(typeof available !== "undefined") { // headless browsers - keys.push({key: "available_resolution", value: available}); - } - return keys; - }, - timezoneOffsetKey: function(keys) { - if(!this.options.excludeTimezoneOffset) { - keys.push({key: "timezone_offset", value: new Date().getTimezoneOffset()}); - } - return keys; - }, - sessionStorageKey: function(keys) { - if(!this.options.excludeSessionStorage && this.hasSessionStorage()) { - keys.push({key: "session_storage", value: 1}); - } - return keys; - }, - localStorageKey: function(keys) { - if(!this.options.excludeSessionStorage && this.hasLocalStorage()) { - keys.push({key: "local_storage", value: 1}); - } - return keys; - }, - indexedDbKey: function(keys) { - if(!this.options.excludeIndexedDB && this.hasIndexedDB()) { - keys.push({key: "indexed_db", value: 1}); - } - return keys; - }, - addBehaviorKey: function(keys) { - //body might not be defined at this point or removed programmatically - if(document.body && !this.options.excludeAddBehavior && document.body.addBehavior) { - keys.push({key: "add_behavior", value: 1}); - } - return keys; - }, - openDatabaseKey: function(keys) { - if(!this.options.excludeOpenDatabase && window.openDatabase) { - keys.push({key: "open_database", value: 1}); - } - return keys; - }, - cpuClassKey: function(keys) { - if(!this.options.excludeCpuClass) { - keys.push({key: "cpu_class", value: this.getNavigatorCpuClass()}); - } - return keys; - }, - platformKey: function(keys) { - if(!this.options.excludePlatform) { - keys.push({key: "navigator_platform", value: this.getNavigatorPlatform()}); - } - return keys; - }, - doNotTrackKey: function(keys) { - if(!this.options.excludeDoNotTrack) { - keys.push({key: "do_not_track", value: this.getDoNotTrack()}); - } - return keys; - }, - canvasKey: function(keys) { - if(!this.options.excludeCanvas && this.isCanvasSupported()) { - keys.push({key: "canvas", value: this.getCanvasFp()}); - } - return keys; - }, - webglKey: function(keys) { - if(this.options.excludeWebGL) { - if(typeof NODEBUG === "undefined"){ - this.log("Skipping WebGL fingerprinting per excludeWebGL configuration option"); - } - return keys; - } - if(!this.isWebGlSupported()) { - if(typeof NODEBUG === "undefined"){ - this.log("Skipping WebGL fingerprinting because it is not supported in this browser"); - } - return keys; - } - keys.push({key: "webgl", value: this.getWebglFp()}); - return keys; - }, - adBlockKey: function(keys){ - if(!this.options.excludeAdBlock) { - keys.push({key: "adblock", value: this.getAdBlock()}); - } - return keys; - }, - hasLiedLanguagesKey: function(keys){ - if(!this.options.excludeHasLiedLanguages){ - keys.push({key: "has_lied_languages", value: this.getHasLiedLanguages()}); - } - return keys; - }, - hasLiedResolutionKey: function(keys){ - if(!this.options.excludeHasLiedResolution){ - keys.push({key: "has_lied_resolution", value: this.getHasLiedResolution()}); - } - return keys; - }, - hasLiedOsKey: function(keys){ - if(!this.options.excludeHasLiedOs){ - keys.push({key: "has_lied_os", value: this.getHasLiedOs()}); - } - return keys; - }, - hasLiedBrowserKey: function(keys){ - if(!this.options.excludeHasLiedBrowser){ - keys.push({key: "has_lied_browser", value: this.getHasLiedBrowser()}); - } - return keys; - }, - fontsKey: function(keys, done) { - if (this.options.excludeJsFonts) { - return this.flashFontsKey(keys, done); - } - return this.jsFontsKey(keys, done); - }, - // flash fonts (will increase fingerprinting time 20X to ~ 130-150ms) - flashFontsKey: function(keys, done) { - if(this.options.excludeFlashFonts) { - if(typeof NODEBUG === "undefined"){ - this.log("Skipping flash fonts detection per excludeFlashFonts configuration option"); - } - return done(keys); - } - // we do flash if swfobject is loaded - if(!this.hasSwfObjectLoaded()){ - if(typeof NODEBUG === "undefined"){ - this.log("Swfobject is not detected, Flash fonts enumeration is skipped"); - } - return done(keys); - } - if(!this.hasMinFlashInstalled()){ - if(typeof NODEBUG === "undefined"){ - this.log("Flash is not installed, skipping Flash fonts enumeration"); - } - return done(keys); - } - if(typeof this.options.swfPath === "undefined"){ - if(typeof NODEBUG === "undefined"){ - this.log("To use Flash fonts detection, you must pass a valid swfPath option, skipping Flash fonts enumeration"); - } - return done(keys); - } - this.loadSwfAndDetectFonts(function(fonts){ - keys.push({key: "swf_fonts", value: fonts.join(";")}); - done(keys); - }); - }, - // kudos to http://www.lalit.org/lab/javascript-css-font-detect/ - jsFontsKey: function(keys, done) { - var that = this; - // doing js fonts detection in a pseudo-async fashion - return setTimeout(function(){ - - // a font will be compared against all the three default fonts. - // and if it doesn't match all 3 then that font is not available. - var baseFonts = ["monospace", "sans-serif", "serif"]; - - var fontList = [ - "Andale Mono", "Arial", "Arial Black", "Arial Hebrew", "Arial MT", "Arial Narrow", "Arial Rounded MT Bold", "Arial Unicode MS", - "Bitstream Vera Sans Mono", "Book Antiqua", "Bookman Old Style", - "Calibri", "Cambria", "Cambria Math", "Century", "Century Gothic", "Century Schoolbook", "Comic Sans", "Comic Sans MS", "Consolas", "Courier", "Courier New", - "Garamond", "Geneva", "Georgia", - "Helvetica", "Helvetica Neue", - "Impact", - "Lucida Bright", "Lucida Calligraphy", "Lucida Console", "Lucida Fax", "LUCIDA GRANDE", "Lucida Handwriting", "Lucida Sans", "Lucida Sans Typewriter", "Lucida Sans Unicode", - "Microsoft Sans Serif", "Monaco", "Monotype Corsiva", "MS Gothic", "MS Outlook", "MS PGothic", "MS Reference Sans Serif", "MS Sans Serif", "MS Serif", "MYRIAD", "MYRIAD PRO", - "Palatino", "Palatino Linotype", - "Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", - "Tahoma", "Times", "Times New Roman", "Times New Roman PS", "Trebuchet MS", - "Verdana", "Wingdings", "Wingdings 2", "Wingdings 3" - ]; - var extendedFontList = [ - "Abadi MT Condensed Light", "Academy Engraved LET", "ADOBE CASLON PRO", "Adobe Garamond", "ADOBE GARAMOND PRO", "Agency FB", "Aharoni", "Albertus Extra Bold", "Albertus Medium", "Algerian", "Amazone BT", "American Typewriter", - "American Typewriter Condensed", "AmerType Md BT", "Andalus", "Angsana New", "AngsanaUPC", "Antique Olive", "Aparajita", "Apple Chancery", "Apple Color Emoji", "Apple SD Gothic Neo", "Arabic Typesetting", "ARCHER", - "ARNO PRO", "Arrus BT", "Aurora Cn BT", "AvantGarde Bk BT", "AvantGarde Md BT", "AVENIR", "Ayuthaya", "Bandy", "Bangla Sangam MN", "Bank Gothic", "BankGothic Md BT", "Baskerville", - "Baskerville Old Face", "Batang", "BatangChe", "Bauer Bodoni", "Bauhaus 93", "Bazooka", "Bell MT", "Bembo", "Benguiat Bk BT", "Berlin Sans FB", "Berlin Sans FB Demi", "Bernard MT Condensed", "BernhardFashion BT", "BernhardMod BT", "Big Caslon", "BinnerD", - "Blackadder ITC", "BlairMdITC TT", "Bodoni 72", "Bodoni 72 Oldstyle", "Bodoni 72 Smallcaps", "Bodoni MT", "Bodoni MT Black", "Bodoni MT Condensed", "Bodoni MT Poster Compressed", - "Bookshelf Symbol 7", "Boulder", "Bradley Hand", "Bradley Hand ITC", "Bremen Bd BT", "Britannic Bold", "Broadway", "Browallia New", "BrowalliaUPC", "Brush Script MT", "Californian FB", "Calisto MT", "Calligrapher", "Candara", - "CaslonOpnface BT", "Castellar", "Centaur", "Cezanne", "CG Omega", "CG Times", "Chalkboard", "Chalkboard SE", "Chalkduster", "Charlesworth", "Charter Bd BT", "Charter BT", "Chaucer", - "ChelthmITC Bk BT", "Chiller", "Clarendon", "Clarendon Condensed", "CloisterBlack BT", "Cochin", "Colonna MT", "Constantia", "Cooper Black", "Copperplate", "Copperplate Gothic", "Copperplate Gothic Bold", - "Copperplate Gothic Light", "CopperplGoth Bd BT", "Corbel", "Cordia New", "CordiaUPC", "Cornerstone", "Coronet", "Cuckoo", "Curlz MT", "DaunPenh", "Dauphin", "David", "DB LCD Temp", "DELICIOUS", "Denmark", - "DFKai-SB", "Didot", "DilleniaUPC", "DIN", "DokChampa", "Dotum", "DotumChe", "Ebrima", "Edwardian Script ITC", "Elephant", "English 111 Vivace BT", "Engravers MT", "EngraversGothic BT", "Eras Bold ITC", "Eras Demi ITC", "Eras Light ITC", "Eras Medium ITC", - "EucrosiaUPC", "Euphemia", "Euphemia UCAS", "EUROSTILE", "Exotc350 Bd BT", "FangSong", "Felix Titling", "Fixedsys", "FONTIN", "Footlight MT Light", "Forte", - "FrankRuehl", "Fransiscan", "Freefrm721 Blk BT", "FreesiaUPC", "Freestyle Script", "French Script MT", "FrnkGothITC Bk BT", "Fruitger", "FRUTIGER", - "Futura", "Futura Bk BT", "Futura Lt BT", "Futura Md BT", "Futura ZBlk BT", "FuturaBlack BT", "Gabriola", "Galliard BT", "Gautami", "Geeza Pro", "Geometr231 BT", "Geometr231 Hv BT", "Geometr231 Lt BT", "GeoSlab 703 Lt BT", - "GeoSlab 703 XBd BT", "Gigi", "Gill Sans", "Gill Sans MT", "Gill Sans MT Condensed", "Gill Sans MT Ext Condensed Bold", "Gill Sans Ultra Bold", "Gill Sans Ultra Bold Condensed", "Gisha", "Gloucester MT Extra Condensed", "GOTHAM", "GOTHAM BOLD", - "Goudy Old Style", "Goudy Stout", "GoudyHandtooled BT", "GoudyOLSt BT", "Gujarati Sangam MN", "Gulim", "GulimChe", "Gungsuh", "GungsuhChe", "Gurmukhi MN", "Haettenschweiler", "Harlow Solid Italic", "Harrington", "Heather", "Heiti SC", "Heiti TC", "HELV", - "Herald", "High Tower Text", "Hiragino Kaku Gothic ProN", "Hiragino Mincho ProN", "Hoefler Text", "Humanst 521 Cn BT", "Humanst521 BT", "Humanst521 Lt BT", "Imprint MT Shadow", "Incised901 Bd BT", "Incised901 BT", - "Incised901 Lt BT", "INCONSOLATA", "Informal Roman", "Informal011 BT", "INTERSTATE", "IrisUPC", "Iskoola Pota", "JasmineUPC", "Jazz LET", "Jenson", "Jester", "Jokerman", "Juice ITC", "Kabel Bk BT", "Kabel Ult BT", "Kailasa", "KaiTi", "Kalinga", "Kannada Sangam MN", - "Kartika", "Kaufmann Bd BT", "Kaufmann BT", "Khmer UI", "KodchiangUPC", "Kokila", "Korinna BT", "Kristen ITC", "Krungthep", "Kunstler Script", "Lao UI", "Latha", "Leelawadee", "Letter Gothic", "Levenim MT", "LilyUPC", "Lithograph", "Lithograph Light", "Long Island", - "Lydian BT", "Magneto", "Maiandra GD", "Malayalam Sangam MN", "Malgun Gothic", - "Mangal", "Marigold", "Marion", "Marker Felt", "Market", "Marlett", "Matisse ITC", "Matura MT Script Capitals", "Meiryo", "Meiryo UI", "Microsoft Himalaya", "Microsoft JhengHei", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", - "Microsoft Uighur", "Microsoft YaHei", "Microsoft Yi Baiti", "MingLiU", "MingLiU_HKSCS", "MingLiU_HKSCS-ExtB", "MingLiU-ExtB", "Minion", "Minion Pro", "Miriam", "Miriam Fixed", "Mistral", "Modern", "Modern No. 20", "Mona Lisa Solid ITC TT", "Mongolian Baiti", - "MONO", "MoolBoran", "Mrs Eaves", "MS LineDraw", "MS Mincho", "MS PMincho", "MS Reference Specialty", "MS UI Gothic", "MT Extra", "MUSEO", "MV Boli", - "Nadeem", "Narkisim", "NEVIS", "News Gothic", "News GothicMT", "NewsGoth BT", "Niagara Engraved", "Niagara Solid", "Noteworthy", "NSimSun", "Nyala", "OCR A Extended", "Old Century", "Old English Text MT", "Onyx", "Onyx BT", "OPTIMA", "Oriya Sangam MN", - "OSAKA", "OzHandicraft BT", "Palace Script MT", "Papyrus", "Parchment", "Party LET", "Pegasus", "Perpetua", "Perpetua Titling MT", "PetitaBold", "Pickwick", "Plantagenet Cherokee", "Playbill", "PMingLiU", "PMingLiU-ExtB", - "Poor Richard", "Poster", "PosterBodoni BT", "PRINCETOWN LET", "Pristina", "PTBarnum BT", "Pythagoras", "Raavi", "Rage Italic", "Ravie", "Ribbon131 Bd BT", "Rockwell", "Rockwell Condensed", "Rockwell Extra Bold", "Rod", "Roman", "Sakkal Majalla", - "Santa Fe LET", "Savoye LET", "Sceptre", "Script", "Script MT Bold", "SCRIPTINA", "Serifa", "Serifa BT", "Serifa Th BT", "ShelleyVolante BT", "Sherwood", - "Shonar Bangla", "Showcard Gothic", "Shruti", "Signboard", "SILKSCREEN", "SimHei", "Simplified Arabic", "Simplified Arabic Fixed", "SimSun", "SimSun-ExtB", "Sinhala Sangam MN", "Sketch Rockwell", "Skia", "Small Fonts", "Snap ITC", "Snell Roundhand", "Socket", - "Souvenir Lt BT", "Staccato222 BT", "Steamer", "Stencil", "Storybook", "Styllo", "Subway", "Swis721 BlkEx BT", "Swiss911 XCm BT", "Sylfaen", "Synchro LET", "System", "Tamil Sangam MN", "Technical", "Teletype", "Telugu Sangam MN", "Tempus Sans ITC", - "Terminal", "Thonburi", "Traditional Arabic", "Trajan", "TRAJAN PRO", "Tristan", "Tubular", "Tunga", "Tw Cen MT", "Tw Cen MT Condensed", "Tw Cen MT Condensed Extra Bold", - "TypoUpright BT", "Unicorn", "Univers", "Univers CE 55 Medium", "Univers Condensed", "Utsaah", "Vagabond", "Vani", "Vijaya", "Viner Hand ITC", "VisualUI", "Vivaldi", "Vladimir Script", "Vrinda", "Westminster", "WHITNEY", "Wide Latin", - "ZapfEllipt BT", "ZapfHumnst BT", "ZapfHumnst Dm BT", "Zapfino", "Zurich BlkEx BT", "Zurich Ex BT", "ZWAdobeF"]; - - if(that.options.extendedJsFonts) { - fontList = fontList.concat(extendedFontList); - } - - fontList = fontList.concat(that.options.userDefinedFonts); - - //we use m or w because these two characters take up the maximum width. - // And we use a LLi so that the same matching fonts can get separated - var testString = "mmmmmmmmmmlli"; - - //we test using 72px font size, we may use any size. I guess larger the better. - var testSize = "72px"; - - var h = document.getElementsByTagName("body")[0]; - - // div to load spans for the base fonts - var baseFontsDiv = document.createElement("div"); - - // div to load spans for the fonts to detect - var fontsDiv = document.createElement("div"); - - var defaultWidth = {}; - var defaultHeight = {}; - - // creates a span where the fonts will be loaded - var createSpan = function() { - var s = document.createElement("span"); - /* - * We need this css as in some weird browser this - * span elements shows up for a microSec which creates a - * bad user experience - */ - s.style.position = "absolute"; - s.style.left = "-9999px"; - s.style.fontSize = testSize; - s.style.lineHeight = "normal"; - s.innerHTML = testString; - return s; - }; - - // creates a span and load the font to detect and a base font for fallback - var createSpanWithFonts = function(fontToDetect, baseFont) { - var s = createSpan(); - s.style.fontFamily = "'" + fontToDetect + "'," + baseFont; - return s; - }; - - // creates spans for the base fonts and adds them to baseFontsDiv - var initializeBaseFontsSpans = function() { - var spans = []; - for (var index = 0, length = baseFonts.length; index < length; index++) { - var s = createSpan(); - s.style.fontFamily = baseFonts[index]; - baseFontsDiv.appendChild(s); - spans.push(s); - } - return spans; - }; - - // creates spans for the fonts to detect and adds them to fontsDiv - var initializeFontsSpans = function() { - var spans = {}; - for(var i = 0, l = fontList.length; i < l; i++) { - var fontSpans = []; - for(var j = 0, numDefaultFonts = baseFonts.length; j < numDefaultFonts; j++) { - var s = createSpanWithFonts(fontList[i], baseFonts[j]); - fontsDiv.appendChild(s); - fontSpans.push(s); - } - spans[fontList[i]] = fontSpans; // Stores {fontName : [spans for that font]} - } - return spans; - }; - - // checks if a font is available - var isFontAvailable = function(fontSpans) { - var detected = false; - for(var i = 0; i < baseFonts.length; i++) { - detected = (fontSpans[i].offsetWidth !== defaultWidth[baseFonts[i]] || fontSpans[i].offsetHeight !== defaultHeight[baseFonts[i]]); - if(detected) { - return detected; - } - } - return detected; - }; - - // create spans for base fonts - var baseFontsSpans = initializeBaseFontsSpans(); - - // add the spans to the DOM - h.appendChild(baseFontsDiv); - - // get the default width for the three base fonts - for (var index = 0, length = baseFonts.length; index < length; index++) { - defaultWidth[baseFonts[index]] = baseFontsSpans[index].offsetWidth; // width for the default font - defaultHeight[baseFonts[index]] = baseFontsSpans[index].offsetHeight; // height for the default font - } - - // create spans for fonts to detect - var fontsSpans = initializeFontsSpans(); - - // add all the spans to the DOM - h.appendChild(fontsDiv); - - // check available fonts - var available = []; - for(var i = 0, l = fontList.length; i < l; i++) { - if(isFontAvailable(fontsSpans[fontList[i]])) { - available.push(fontList[i]); - } - } - - // remove spans from DOM - h.removeChild(fontsDiv); - h.removeChild(baseFontsDiv); - - keys.push({key: "js_fonts", value: available}); - done(keys); - }, 1); - }, - pluginsKey: function(keys) { - if(!this.options.excludePlugins){ - if(this.isIE()){ - if(!this.options.excludeIEPlugins) { - keys.push({key: "ie_plugins", value: this.getIEPlugins()}); - } - } else { - keys.push({key: "regular_plugins", value: this.getRegularPlugins()}); - } - } - return keys; - }, - getRegularPlugins: function () { - var plugins = []; - for(var i = 0, l = navigator.plugins.length; i < l; i++) { - plugins.push(navigator.plugins[i]); - } - // sorting plugins only for those user agents, that we know randomize the plugins - // every time we try to enumerate them - if(this.pluginsShouldBeSorted()) { - plugins = plugins.sort(function(a, b) { - if(a.name > b.name){ return 1; } - if(a.name < b.name){ return -1; } - return 0; - }); - } - return this.map(plugins, function (p) { - var mimeTypes = this.map(p, function(mt){ - return [mt.type, mt.suffixes].join("~"); - }).join(","); - return [p.name, p.description, mimeTypes].join("::"); - }, this); - }, - getIEPlugins: function () { - var result = []; - if((Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(window, "ActiveXObject")) || ("ActiveXObject" in window)) { - var names = [ - "AcroPDF.PDF", // Adobe PDF reader 7+ - "Adodb.Stream", - "AgControl.AgControl", // Silverlight - "DevalVRXCtrl.DevalVRXCtrl.1", - "MacromediaFlashPaper.MacromediaFlashPaper", - "Msxml2.DOMDocument", - "Msxml2.XMLHTTP", - "PDF.PdfCtrl", // Adobe PDF reader 6 and earlier, brrr - "QuickTime.QuickTime", // QuickTime - "QuickTimeCheckObject.QuickTimeCheck.1", - "RealPlayer", - "RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)", - "RealVideo.RealVideo(tm) ActiveX Control (32-bit)", - "Scripting.Dictionary", - "SWCtl.SWCtl", // ShockWave player - "Shell.UIHelper", - "ShockwaveFlash.ShockwaveFlash", //flash plugin - "Skype.Detection", - "TDCCtl.TDCCtl", - "WMPlayer.OCX", // Windows media player - "rmocx.RealPlayer G2 Control", - "rmocx.RealPlayer G2 Control.1" - ]; - // starting to detect plugins in IE - result = this.map(names, function(name) { - try { - new ActiveXObject(name); // eslint-disable-no-new - return name; - } catch(e) { - return null; - } - }); - } - if(navigator.plugins) { - result = result.concat(this.getRegularPlugins()); - } - return result; - }, - pluginsShouldBeSorted: function () { - var should = false; - for(var i = 0, l = this.options.sortPluginsFor.length; i < l; i++) { - var re = this.options.sortPluginsFor[i]; - if(navigator.userAgent.match(re)) { - should = true; - break; - } - } - return should; - }, - touchSupportKey: function (keys) { - if(!this.options.excludeTouchSupport){ - keys.push({key: "touch_support", value: this.getTouchSupport()}); - } - return keys; - }, - hardwareConcurrencyKey: function(keys){ - if(!this.options.excludeHardwareConcurrency){ - keys.push({key: "hardware_concurrency", value: this.getHardwareConcurrency()}); - } - return keys; - }, - hasSessionStorage: function () { - try { - return !!window.sessionStorage; - } catch(e) { - return true; // SecurityError when referencing it means it exists - } - }, - // https://bugzilla.mozilla.org/show_bug.cgi?id=781447 - hasLocalStorage: function () { - try { - return !!window.localStorage; - } catch(e) { - return true; // SecurityError when referencing it means it exists - } - }, - hasIndexedDB: function (){ - try { - return !!window.indexedDB; - } catch(e) { - return true; // SecurityError when referencing it means it exists - } - }, - getHardwareConcurrency: function(){ - if(navigator.hardwareConcurrency){ - return navigator.hardwareConcurrency; - } - return "unknown"; - }, - getNavigatorCpuClass: function () { - if(navigator.cpuClass){ - return navigator.cpuClass; - } else { - return "unknown"; - } - }, - getNavigatorPlatform: function () { - if(navigator.platform) { - return navigator.platform; - } else { - return "unknown"; - } - }, - getDoNotTrack: function () { - if(navigator.doNotTrack) { - return navigator.doNotTrack; - } else if (navigator.msDoNotTrack) { - return navigator.msDoNotTrack; - } else if (window.doNotTrack) { - return window.doNotTrack; - } else { - return "unknown"; - } - }, - // This is a crude and primitive touch screen detection. - // It's not possible to currently reliably detect the availability of a touch screen - // with a JS, without actually subscribing to a touch event. - // http://www.stucox.com/blog/you-cant-detect-a-touchscreen/ - // https://github.com/Modernizr/Modernizr/issues/548 - // method returns an array of 3 values: - // maxTouchPoints, the success or failure of creating a TouchEvent, - // and the availability of the 'ontouchstart' property - getTouchSupport: function () { - var maxTouchPoints = 0; - var touchEvent = false; - if(typeof navigator.maxTouchPoints !== "undefined") { - maxTouchPoints = navigator.maxTouchPoints; - } else if (typeof navigator.msMaxTouchPoints !== "undefined") { - maxTouchPoints = navigator.msMaxTouchPoints; - } - try { - document.createEvent("TouchEvent"); - touchEvent = true; - } catch(_) { /* squelch */ } - var touchStart = "ontouchstart" in window; - return [maxTouchPoints, touchEvent, touchStart]; - }, - // https://www.browserleaks.com/canvas#how-does-it-work - getCanvasFp: function() { - var result = []; - // Very simple now, need to make it more complex (geo shapes etc) - var canvas = document.createElement("canvas"); - canvas.width = 2000; - canvas.height = 200; - canvas.style.display = "inline"; - var ctx = canvas.getContext("2d"); - // detect browser support of canvas winding - // http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/ - // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js - ctx.rect(0, 0, 10, 10); - ctx.rect(2, 2, 6, 6); - result.push("canvas winding:" + ((ctx.isPointInPath(5, 5, "evenodd") === false) ? "yes" : "no")); - - ctx.textBaseline = "alphabetic"; - ctx.fillStyle = "#f60"; - ctx.fillRect(125, 1, 62, 20); - ctx.fillStyle = "#069"; - // https://github.com/Valve/fingerprintjs2/issues/66 - if(this.options.dontUseFakeFontInCanvas) { - ctx.font = "11pt Arial"; - } else { - ctx.font = "11pt no-real-font-123"; - } - ctx.fillText("Cwm fjordbank glyphs vext quiz, \ud83d\ude03", 2, 15); - ctx.fillStyle = "rgba(102, 204, 0, 0.2)"; - ctx.font = "18pt Arial"; - ctx.fillText("Cwm fjordbank glyphs vext quiz, \ud83d\ude03", 4, 45); - - // canvas blending - // http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/ - // http://jsfiddle.net/NDYV8/16/ - ctx.globalCompositeOperation = "multiply"; - ctx.fillStyle = "rgb(255,0,255)"; - ctx.beginPath(); - ctx.arc(50, 50, 50, 0, Math.PI * 2, true); - ctx.closePath(); - ctx.fill(); - ctx.fillStyle = "rgb(0,255,255)"; - ctx.beginPath(); - ctx.arc(100, 50, 50, 0, Math.PI * 2, true); - ctx.closePath(); - ctx.fill(); - ctx.fillStyle = "rgb(255,255,0)"; - ctx.beginPath(); - ctx.arc(75, 100, 50, 0, Math.PI * 2, true); - ctx.closePath(); - ctx.fill(); - ctx.fillStyle = "rgb(255,0,255)"; - // canvas winding - // http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/ - // http://jsfiddle.net/NDYV8/19/ - ctx.arc(75, 75, 75, 0, Math.PI * 2, true); - ctx.arc(75, 75, 25, 0, Math.PI * 2, true); - ctx.fill("evenodd"); - - result.push("canvas fp:" + canvas.toDataURL()); - return result.join("~"); - }, - - getWebglFp: function() { - var gl; - var fa2s = function(fa) { - gl.clearColor(0.0, 0.0, 0.0, 1.0); - gl.enable(gl.DEPTH_TEST); - gl.depthFunc(gl.LEQUAL); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - return "[" + fa[0] + ", " + fa[1] + "]"; - }; - var maxAnisotropy = function(gl) { - var anisotropy, ext = gl.getExtension("EXT_texture_filter_anisotropic") || gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || gl.getExtension("MOZ_EXT_texture_filter_anisotropic"); - return ext ? (anisotropy = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT), 0 === anisotropy && (anisotropy = 2), anisotropy) : null; - }; - gl = this.getWebglCanvas(); - if(!gl) { return null; } - // WebGL fingerprinting is a combination of techniques, found in MaxMind antifraud script & Augur fingerprinting. - // First it draws a gradient object with shaders and convers the image to the Base64 string. - // Then it enumerates all WebGL extensions & capabilities and appends them to the Base64 string, resulting in a huge WebGL string, potentially very unique on each device - // Since iOS supports webgl starting from version 8.1 and 8.1 runs on several graphics chips, the results may be different across ios devices, but we need to verify it. - var result = []; - var vShaderTemplate = "attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}"; - var fShaderTemplate = "precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}"; - var vertexPosBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer); - var vertices = new Float32Array([-.2, -.9, 0, .4, -.26, 0, 0, .732134444, 0]); - gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); - vertexPosBuffer.itemSize = 3; - vertexPosBuffer.numItems = 3; - var program = gl.createProgram(), vshader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(vshader, vShaderTemplate); - gl.compileShader(vshader); - var fshader = gl.createShader(gl.FRAGMENT_SHADER); - gl.shaderSource(fshader, fShaderTemplate); - gl.compileShader(fshader); - gl.attachShader(program, vshader); - gl.attachShader(program, fshader); - gl.linkProgram(program); - gl.useProgram(program); - program.vertexPosAttrib = gl.getAttribLocation(program, "attrVertex"); - program.offsetUniform = gl.getUniformLocation(program, "uniformOffset"); - gl.enableVertexAttribArray(program.vertexPosArray); - gl.vertexAttribPointer(program.vertexPosAttrib, vertexPosBuffer.itemSize, gl.FLOAT, !1, 0, 0); - gl.uniform2f(program.offsetUniform, 1, 1); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexPosBuffer.numItems); - if (gl.canvas != null) { result.push(gl.canvas.toDataURL()); } - result.push("extensions:" + gl.getSupportedExtensions().join(";")); - result.push("webgl aliased line width range:" + fa2s(gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE))); - result.push("webgl aliased point size range:" + fa2s(gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE))); - result.push("webgl alpha bits:" + gl.getParameter(gl.ALPHA_BITS)); - result.push("webgl antialiasing:" + (gl.getContextAttributes().antialias ? "yes" : "no")); - result.push("webgl blue bits:" + gl.getParameter(gl.BLUE_BITS)); - result.push("webgl depth bits:" + gl.getParameter(gl.DEPTH_BITS)); - result.push("webgl green bits:" + gl.getParameter(gl.GREEN_BITS)); - result.push("webgl max anisotropy:" + maxAnisotropy(gl)); - result.push("webgl max combined texture image units:" + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)); - result.push("webgl max cube map texture size:" + gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)); - result.push("webgl max fragment uniform vectors:" + gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS)); - result.push("webgl max render buffer size:" + gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)); - result.push("webgl max texture image units:" + gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)); - result.push("webgl max texture size:" + gl.getParameter(gl.MAX_TEXTURE_SIZE)); - result.push("webgl max varying vectors:" + gl.getParameter(gl.MAX_VARYING_VECTORS)); - result.push("webgl max vertex attribs:" + gl.getParameter(gl.MAX_VERTEX_ATTRIBS)); - result.push("webgl max vertex texture image units:" + gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)); - result.push("webgl max vertex uniform vectors:" + gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS)); - result.push("webgl max viewport dims:" + fa2s(gl.getParameter(gl.MAX_VIEWPORT_DIMS))); - result.push("webgl red bits:" + gl.getParameter(gl.RED_BITS)); - result.push("webgl renderer:" + gl.getParameter(gl.RENDERER)); - result.push("webgl shading language version:" + gl.getParameter(gl.SHADING_LANGUAGE_VERSION)); - result.push("webgl stencil bits:" + gl.getParameter(gl.STENCIL_BITS)); - result.push("webgl vendor:" + gl.getParameter(gl.VENDOR)); - result.push("webgl version:" + gl.getParameter(gl.VERSION)); - - try { - // Add the unmasked vendor and unmasked renderer if the debug_renderer_info extension is available - var extensionDebugRendererInfo = gl.getExtension("WEBGL_debug_renderer_info"); - if (!extensionDebugRendererInfo) { - if (typeof NODEBUG === "undefined") { - this.log("WebGL fingerprinting is incomplete, because your browser does not have the extension WEBGL_debug_renderer_info"); - } - } else { - result.push("webgl unmasked vendor:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL)); - result.push("webgl unmasked renderer:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL)); - } - } catch(e) { /* squelch */ } - - if (!gl.getShaderPrecisionFormat) { - if (typeof NODEBUG === "undefined") { - this.log("WebGL fingerprinting is incomplete, because your browser does not support getShaderPrecisionFormat"); - } - return result.join("~"); - } - - result.push("webgl vertex shader high float precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision); - result.push("webgl vertex shader high float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).rangeMin); - result.push("webgl vertex shader high float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).rangeMax); - result.push("webgl vertex shader medium float precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision); - result.push("webgl vertex shader medium float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).rangeMin); - result.push("webgl vertex shader medium float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).rangeMax); - result.push("webgl vertex shader low float precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT ).precision); - result.push("webgl vertex shader low float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT ).rangeMin); - result.push("webgl vertex shader low float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT ).rangeMax); - result.push("webgl fragment shader high float precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision); - result.push("webgl fragment shader high float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).rangeMin); - result.push("webgl fragment shader high float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).rangeMax); - result.push("webgl fragment shader medium float precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision); - result.push("webgl fragment shader medium float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).rangeMin); - result.push("webgl fragment shader medium float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).rangeMax); - result.push("webgl fragment shader low float precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT ).precision); - result.push("webgl fragment shader low float precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT ).rangeMin); - result.push("webgl fragment shader low float precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT ).rangeMax); - result.push("webgl vertex shader high int precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT ).precision); - result.push("webgl vertex shader high int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT ).rangeMin); - result.push("webgl vertex shader high int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT ).rangeMax); - result.push("webgl vertex shader medium int precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT ).precision); - result.push("webgl vertex shader medium int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT ).rangeMin); - result.push("webgl vertex shader medium int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT ).rangeMax); - result.push("webgl vertex shader low int precision:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT ).precision); - result.push("webgl vertex shader low int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT ).rangeMin); - result.push("webgl vertex shader low int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT ).rangeMax); - result.push("webgl fragment shader high int precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT ).precision); - result.push("webgl fragment shader high int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT ).rangeMin); - result.push("webgl fragment shader high int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT ).rangeMax); - result.push("webgl fragment shader medium int precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_INT ).precision); - result.push("webgl fragment shader medium int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_INT ).rangeMin); - result.push("webgl fragment shader medium int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_INT ).rangeMax); - result.push("webgl fragment shader low int precision:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT ).precision); - result.push("webgl fragment shader low int precision rangeMin:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT ).rangeMin); - result.push("webgl fragment shader low int precision rangeMax:" + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT ).rangeMax); - return result.join("~"); - }, - getAdBlock: function(){ - var ads = document.createElement("div"); - ads.innerHTML = " "; - ads.className = "adsbox"; - var result = false; - try { - // body may not exist, that's why we need try/catch - document.body.appendChild(ads); - result = document.getElementsByClassName("adsbox")[0].offsetHeight === 0; - document.body.removeChild(ads); - } catch (e) { - result = false; - } - return result; - }, - getHasLiedLanguages: function(){ - //We check if navigator.language is equal to the first language of navigator.languages - if(typeof navigator.languages !== "undefined"){ - try { - var firstLanguages = navigator.languages[0].substr(0, 2); - if(firstLanguages !== navigator.language.substr(0, 2)){ - return true; - } - } catch(err) { - return true; - } - } - return false; - }, - getHasLiedResolution: function(){ - if(screen.width < screen.availWidth){ - return true; - } - if(screen.height < screen.availHeight){ - return true; - } - return false; - }, - getHasLiedOs: function(){ - var userAgent = navigator.userAgent.toLowerCase(); - var oscpu = navigator.oscpu; - var platform = navigator.platform.toLowerCase(); - var os; - //We extract the OS from the user agent (respect the order of the if else if statement) - if(userAgent.indexOf("windows phone") >= 0){ - os = "Windows Phone"; - } else if(userAgent.indexOf("win") >= 0){ - os = "Windows"; - } else if(userAgent.indexOf("android") >= 0){ - os = "Android"; - } else if(userAgent.indexOf("linux") >= 0){ - os = "Linux"; - } else if(userAgent.indexOf("iphone") >= 0 || userAgent.indexOf("ipad") >= 0 ){ - os = "iOS"; - } else if(userAgent.indexOf("mac") >= 0){ - os = "Mac"; - } else{ - os = "Other"; - } - // We detect if the person uses a mobile device - var mobileDevice; - if (("ontouchstart" in window) || - (navigator.maxTouchPoints > 0) || - (navigator.msMaxTouchPoints > 0)) { - mobileDevice = true; - } else{ - mobileDevice = false; - } - - if(mobileDevice && os !== "Windows Phone" && os !== "Android" && os !== "iOS" && os !== "Other"){ - return true; - } - - // We compare oscpu with the OS extracted from the UA - if(typeof oscpu !== "undefined"){ - oscpu = oscpu.toLowerCase(); - if(oscpu.indexOf("win") >= 0 && os !== "Windows" && os !== "Windows Phone"){ - return true; - } else if(oscpu.indexOf("linux") >= 0 && os !== "Linux" && os !== "Android"){ - return true; - } else if(oscpu.indexOf("mac") >= 0 && os !== "Mac" && os !== "iOS"){ - return true; - } else if(oscpu.indexOf("win") === 0 && oscpu.indexOf("linux") === 0 && oscpu.indexOf("mac") >= 0 && os !== "other"){ - return true; - } - } - - //We compare platform with the OS extracted from the UA - if(platform.indexOf("win") >= 0 && os !== "Windows" && os !== "Windows Phone"){ - return true; - } else if((platform.indexOf("linux") >= 0 || platform.indexOf("android") >= 0 || platform.indexOf("pike") >= 0) && os !== "Linux" && os !== "Android"){ - return true; - } else if((platform.indexOf("mac") >= 0 || platform.indexOf("ipad") >= 0 || platform.indexOf("ipod") >= 0 || platform.indexOf("iphone") >= 0) && os !== "Mac" && os !== "iOS"){ - return true; - } else if(platform.indexOf("win") === 0 && platform.indexOf("linux") === 0 && platform.indexOf("mac") >= 0 && os !== "other"){ - return true; - } - - if(typeof navigator.plugins === "undefined" && os !== "Windows" && os !== "Windows Phone"){ - //We are are in the case where the person uses ie, therefore we can infer that it's windows - return true; - } - - return false; - }, - getHasLiedBrowser: function () { - var userAgent = navigator.userAgent.toLowerCase(); - var productSub = navigator.productSub; - - //we extract the browser from the user agent (respect the order of the tests) - var browser; - if(userAgent.indexOf("firefox") >= 0){ - browser = "Firefox"; - } else if(userAgent.indexOf("opera") >= 0 || userAgent.indexOf("opr") >= 0){ - browser = "Opera"; - } else if(userAgent.indexOf("chrome") >= 0){ - browser = "Chrome"; - } else if(userAgent.indexOf("safari") >= 0){ - browser = "Safari"; - } else if(userAgent.indexOf("trident") >= 0){ - browser = "Internet Explorer"; - } else{ - browser = "Other"; - } - - if((browser === "Chrome" || browser === "Safari" || browser === "Opera") && productSub !== "20030107"){ - return true; - } - - var tempRes = eval.toString().length; - if(tempRes === 37 && browser !== "Safari" && browser !== "Firefox" && browser !== "Other"){ - return true; - } else if(tempRes === 39 && browser !== "Internet Explorer" && browser !== "Other"){ - return true; - } else if(tempRes === 33 && browser !== "Chrome" && browser !== "Opera" && browser !== "Other"){ - return true; - } - - //We create an error to see how it is handled - var errFirefox; - try { - throw "a"; - } catch(err){ - try{ - err.toSource(); - errFirefox = true; - } catch(errOfErr){ - errFirefox = false; - } - } - if(errFirefox && browser !== "Firefox" && browser !== "Other"){ - return true; - } - return false; - }, - isCanvasSupported: function () { - var elem = document.createElement("canvas"); - return !!(elem.getContext && elem.getContext("2d")); - }, - isWebGlSupported: function() { - // code taken from Modernizr - if (!this.isCanvasSupported()) { - return false; - } - - var canvas = document.createElement("canvas"), - glContext; - - try { - glContext = canvas.getContext && (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")); - } catch(e) { - glContext = false; - } - - return !!window.WebGLRenderingContext && !!glContext; - }, - isIE: function () { - if(navigator.appName === "Microsoft Internet Explorer") { - return true; - } else if(navigator.appName === "Netscape" && /Trident/.test(navigator.userAgent)) { // IE 11 - return true; - } - return false; - }, - hasSwfObjectLoaded: function(){ - return typeof window.swfobject !== "undefined"; - }, - hasMinFlashInstalled: function () { - return swfobject.hasFlashPlayerVersion("9.0.0"); - }, - addFlashDivNode: function() { - var node = document.createElement("div"); - node.setAttribute("id", this.options.swfContainerId); - document.body.appendChild(node); - }, - loadSwfAndDetectFonts: function(done) { - var hiddenCallback = "___fp_swf_loaded"; - window[hiddenCallback] = function(fonts) { - done(fonts); - }; - var id = this.options.swfContainerId; - this.addFlashDivNode(); - var flashvars = { onReady: hiddenCallback}; - var flashparams = { allowScriptAccess: "always", menu: "false" }; - swfobject.embedSWF(this.options.swfPath, id, "1", "1", "9.0.0", false, flashvars, flashparams, {}); - }, - getWebglCanvas: function() { - var canvas = document.createElement("canvas"); - var gl = null; - try { - gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); - } catch(e) { /* squelch */ } - if (!gl) { gl = null; } - return gl; - }, - each: function (obj, iterator, context) { - if (obj === null) { - return; - } - if (this.nativeForEach && obj.forEach === this.nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (iterator.call(context, obj[i], i, obj) === {}) { return; } - } - } else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - if (iterator.call(context, obj[key], key, obj) === {}) { return; } - } - } - } - }, - - map: function(obj, iterator, context) { - var results = []; - // Not using strict equality so that this acts as a - // shortcut to checking for `null` and `undefined`. - if (obj == null) { return results; } - if (this.nativeMap && obj.map === this.nativeMap) { return obj.map(iterator, context); } - this.each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - return results; - }, - - /// MurmurHash3 related functions - - // - // Given two 64bit ints (as an array of two 32bit ints) returns the two - // added together as a 64bit int (as an array of two 32bit ints). - // - x64Add: function(m, n) { - m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; - n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; - var o = [0, 0, 0, 0]; - o[3] += m[3] + n[3]; - o[2] += o[3] >>> 16; - o[3] &= 0xffff; - o[2] += m[2] + n[2]; - o[1] += o[2] >>> 16; - o[2] &= 0xffff; - o[1] += m[1] + n[1]; - o[0] += o[1] >>> 16; - o[1] &= 0xffff; - o[0] += m[0] + n[0]; - o[0] &= 0xffff; - return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; - }, - - // - // Given two 64bit ints (as an array of two 32bit ints) returns the two - // multiplied together as a 64bit int (as an array of two 32bit ints). - // - x64Multiply: function(m, n) { - m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; - n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; - var o = [0, 0, 0, 0]; - o[3] += m[3] * n[3]; - o[2] += o[3] >>> 16; - o[3] &= 0xffff; - o[2] += m[2] * n[3]; - o[1] += o[2] >>> 16; - o[2] &= 0xffff; - o[2] += m[3] * n[2]; - o[1] += o[2] >>> 16; - o[2] &= 0xffff; - o[1] += m[1] * n[3]; - o[0] += o[1] >>> 16; - o[1] &= 0xffff; - o[1] += m[2] * n[2]; - o[0] += o[1] >>> 16; - o[1] &= 0xffff; - o[1] += m[3] * n[1]; - o[0] += o[1] >>> 16; - o[1] &= 0xffff; - o[0] += (m[0] * n[3]) + (m[1] * n[2]) + (m[2] * n[1]) + (m[3] * n[0]); - o[0] &= 0xffff; - return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; - }, - // - // Given a 64bit int (as an array of two 32bit ints) and an int - // representing a number of bit positions, returns the 64bit int (as an - // array of two 32bit ints) rotated left by that number of positions. - // - x64Rotl: function(m, n) { - n %= 64; - if (n === 32) { - return [m[1], m[0]]; - } - else if (n < 32) { - return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))]; - } - else { - n -= 32; - return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))]; - } - }, - // - // Given a 64bit int (as an array of two 32bit ints) and an int - // representing a number of bit positions, returns the 64bit int (as an - // array of two 32bit ints) shifted left by that number of positions. - // - x64LeftShift: function(m, n) { - n %= 64; - if (n === 0) { - return m; - } - else if (n < 32) { - return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n]; - } - else { - return [m[1] << (n - 32), 0]; - } - }, - // - // Given two 64bit ints (as an array of two 32bit ints) returns the two - // xored together as a 64bit int (as an array of two 32bit ints). - // - x64Xor: function(m, n) { - return [m[0] ^ n[0], m[1] ^ n[1]]; - }, - // - // Given a block, returns murmurHash3's final x64 mix of that block. - // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the - // only place where we need to right shift 64bit ints.) - // - x64Fmix: function(h) { - h = this.x64Xor(h, [0, h[0] >>> 1]); - h = this.x64Multiply(h, [0xff51afd7, 0xed558ccd]); - h = this.x64Xor(h, [0, h[0] >>> 1]); - h = this.x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]); - h = this.x64Xor(h, [0, h[0] >>> 1]); - return h; - }, - - // - // Given a string and an optional seed as an int, returns a 128 bit - // hash using the x64 flavor of MurmurHash3, as an unsigned hex. - // - x64hash128: function (key, seed) { - key = key || ""; - seed = seed || 0; - var remainder = key.length % 16; - var bytes = key.length - remainder; - var h1 = [0, seed]; - var h2 = [0, seed]; - var k1 = [0, 0]; - var k2 = [0, 0]; - var c1 = [0x87c37b91, 0x114253d5]; - var c2 = [0x4cf5ad43, 0x2745937f]; - for (var i = 0; i < bytes; i = i + 16) { - k1 = [((key.charCodeAt(i + 4) & 0xff)) | ((key.charCodeAt(i + 5) & 0xff) << 8) | ((key.charCodeAt(i + 6) & 0xff) << 16) | ((key.charCodeAt(i + 7) & 0xff) << 24), ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24)]; - k2 = [((key.charCodeAt(i + 12) & 0xff)) | ((key.charCodeAt(i + 13) & 0xff) << 8) | ((key.charCodeAt(i + 14) & 0xff) << 16) | ((key.charCodeAt(i + 15) & 0xff) << 24), ((key.charCodeAt(i + 8) & 0xff)) | ((key.charCodeAt(i + 9) & 0xff) << 8) | ((key.charCodeAt(i + 10) & 0xff) << 16) | ((key.charCodeAt(i + 11) & 0xff) << 24)]; - k1 = this.x64Multiply(k1, c1); - k1 = this.x64Rotl(k1, 31); - k1 = this.x64Multiply(k1, c2); - h1 = this.x64Xor(h1, k1); - h1 = this.x64Rotl(h1, 27); - h1 = this.x64Add(h1, h2); - h1 = this.x64Add(this.x64Multiply(h1, [0, 5]), [0, 0x52dce729]); - k2 = this.x64Multiply(k2, c2); - k2 = this.x64Rotl(k2, 33); - k2 = this.x64Multiply(k2, c1); - h2 = this.x64Xor(h2, k2); - h2 = this.x64Rotl(h2, 31); - h2 = this.x64Add(h2, h1); - h2 = this.x64Add(this.x64Multiply(h2, [0, 5]), [0, 0x38495ab5]); - } - k1 = [0, 0]; - k2 = [0, 0]; - switch(remainder) { - case 15: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 14)], 48)); - case 14: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 13)], 40)); - case 13: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 12)], 32)); - case 12: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 11)], 24)); - case 11: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 10)], 16)); - case 10: - k2 = this.x64Xor(k2, this.x64LeftShift([0, key.charCodeAt(i + 9)], 8)); - case 9: - k2 = this.x64Xor(k2, [0, key.charCodeAt(i + 8)]); - k2 = this.x64Multiply(k2, c2); - k2 = this.x64Rotl(k2, 33); - k2 = this.x64Multiply(k2, c1); - h2 = this.x64Xor(h2, k2); - case 8: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 7)], 56)); - case 7: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 6)], 48)); - case 6: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 5)], 40)); - case 5: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 4)], 32)); - case 4: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 3)], 24)); - case 3: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 2)], 16)); - case 2: - k1 = this.x64Xor(k1, this.x64LeftShift([0, key.charCodeAt(i + 1)], 8)); - case 1: - k1 = this.x64Xor(k1, [0, key.charCodeAt(i)]); - k1 = this.x64Multiply(k1, c1); - k1 = this.x64Rotl(k1, 31); - k1 = this.x64Multiply(k1, c2); - h1 = this.x64Xor(h1, k1); - } - h1 = this.x64Xor(h1, [0, key.length]); - h2 = this.x64Xor(h2, [0, key.length]); - h1 = this.x64Add(h1, h2); - h2 = this.x64Add(h2, h1); - h1 = this.x64Fmix(h1); - h2 = this.x64Fmix(h2); - h1 = this.x64Add(h1, h2); - h2 = this.x64Add(h2, h1); - return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8); - } - }; - Fingerprint2.VERSION = "1.5.0"; - return Fingerprint2; -}); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/flash/FontList.as b/apps/maarch_entreprise/tools/fingerprintjs2/flash/FontList.as deleted file mode 100755 index 030ab3ceeddb83f90534b3e2a74472db84c44620..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/flash/FontList.as +++ /dev/null @@ -1,31 +0,0 @@ -package { - import flash.display.Sprite; - import flash.display.LoaderInfo; - import flash.text.Font; - import flash.external.ExternalInterface; - - public class FontList extends Sprite { - - public function FontList() { - var params:Object = loadParams(); - loadExternalInterface(params); - } - - private function loadParams():Object { - return LoaderInfo(this.root.loaderInfo).parameters; - } - - private function loadExternalInterface(params:Object):void { - ExternalInterface.call(params.onReady, fonts()); - } - - private function fonts():Array { - var fontNames:Array = []; - for each (var font:Font in Font.enumerateFonts(true) ) - { - fontNames.push(font.fontName); - } - return fontNames; - } - } -} diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/flash/Makefile b/apps/maarch_entreprise/tools/fingerprintjs2/flash/Makefile deleted file mode 100755 index cb6e1cc33a39a03b027089c4e0bf71b7dd69324f..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/flash/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: FontList.swf - -FontList.swf: clean - mxmlc -static-link-runtime-shared-libraries FontList.as - -clean: - rm -f FontList.swf diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/flash/compiled/FontList.swf b/apps/maarch_entreprise/tools/fingerprintjs2/flash/compiled/FontList.swf deleted file mode 100755 index a7481e86bc1b7ad444dc16428782eacad7b54fbd..0000000000000000000000000000000000000000 Binary files a/apps/maarch_entreprise/tools/fingerprintjs2/flash/compiled/FontList.swf and /dev/null differ diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/gulpfile.js b/apps/maarch_entreprise/tools/fingerprintjs2/gulpfile.js deleted file mode 100755 index 0bf891334681104fbb836125beb63df6aa1be580..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/gulpfile.js +++ /dev/null @@ -1,32 +0,0 @@ -var gulp = require("gulp"), - eslint = require("gulp-eslint"), - rename = require("gulp-rename"), - uglify = require("gulp-uglify"); - -gulp.task("lint", function() { - return gulp - .src("fingerprint2.js") - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failOnError()); -}); - -gulp.task("minify", function() { - return gulp - .src("fingerprint2.js") - .pipe(rename({suffix: ".min"})) - .pipe(uglify({ - compress: { - global_defs: { - NODEBUG: true - } - }, - output: { - ascii_only: true - } - })) - .pipe(gulp.dest("dist/")); -}); - - -gulp.task("default", ["lint", "minify"], function() {}); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/index.html b/apps/maarch_entreprise/tools/fingerprintjs2/index.html deleted file mode 100755 index 8227b933df87fe2291a89a138c6c95effbacdcb0..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/index.html +++ /dev/null @@ -1,107 +0,0 @@ -<!doctype html> -<html> -<head> - <title>Fingerprintjs2 test</title> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-42202458-2', 'auto'); - ga('send', 'pageview'); - </script> - <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> - <style> - body{ - font-family: sans-serif; - max-width: 48em; - margin: auto; - padding: 0 5%; - background: #222; - color: #fff; - } - - h1 { - margin: 2em 0 0; - } - - p { - font-size: 1.2em - } - - button { - border: none; - color: #fff; - font-size: 1.2em; - background: #27e; - padding: 0.5em 0.75em 0.6em; - border-radius: 3px; - box-shadow: 0 3px 0 #05c; - outline: none; - } - - button:active { - transform: translateY(3px); - box-shadow: none; - } - - strong { - display: block; - letter-spacing: 1px; - word-wrap: break-word; - } - - @media (min-width: 32em) { - h1 { - font-size: 4em; - } - - strong { - font-size: 1.5em; - } - } - </style> -</head> -<body> - <div id="container"></div> - - - <h1>Fingerprintjs2</h1> - - <p>Your browser fingerprint: <strong id="fp"></strong></p> - <p><code id="time"/></p> - <p><span id="details"/></p> - <button type="button" id="btn">Get my fingerprint</button> - - <a href="https://github.com/Valve/fingerprintjs2"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a> - - <script src="fingerprint2.js"></script> - <script> - $("#btn").on("click", function () { - var d1 = new Date(); - var fp = new Fingerprint2(); - fp.get(function(result, components) { - var d2 = new Date(); - var timeString = "Time took to calculate the fingerprint: " + (d2 - d1) + "ms"; - var details = "<strong>Detailed information: </strong><br />"; - if(typeof window.console !== "undefined") { - console.log(timeString); - console.log(result); - for (var index in components) { - var obj = components[index]; - var value = obj.value; - var line = obj.key + " = " + value.toString().substr(0, 100); - console.log(line); - details += line + "<br />"; - } - } - $("#details").html(details); - $("#fp").text(result); - $("#time").text(timeString); - }); - }); - </script> -</body> -</html> diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/package.json b/apps/maarch_entreprise/tools/fingerprintjs2/package.json deleted file mode 100755 index d020a9c7f64c2dd6271ab929b8726d15ebc0d8e4..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/package.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "fingerprintjs2", - "scope": null, - "escapedName": "fingerprintjs2", - "name": "fingerprintjs2", - "rawSpec": "", - "spec": "latest", - "type": "tag" - }, - "C:\\xampp\\htdocs\\test\\infos_device" - ] - ], - "_from": "fingerprintjs2@latest", - "_id": "fingerprintjs2@1.5.0", - "_inCache": true, - "_location": "/fingerprintjs2", - "_nodeVersion": "4.7.3", - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/fingerprintjs2-1.5.0.tgz_1486570585044_0.8709120729472488" - }, - "_npmUser": { - "name": "valve", - "email": "valentin.vasilyev@outlook.com" - }, - "_npmVersion": "2.15.11", - "_phantomChildren": {}, - "_requested": { - "raw": "fingerprintjs2", - "scope": null, - "escapedName": "fingerprintjs2", - "name": "fingerprintjs2", - "rawSpec": "", - "spec": "latest", - "type": "tag" - }, - "_requiredBy": [ - "#USER" - ], - "_resolved": "https://registry.npmjs.org/fingerprintjs2/-/fingerprintjs2-1.5.0.tgz", - "_shasum": "f61bc48d0f913ad3fc867919d9cec25e8150f397", - "_shrinkwrap": null, - "_spec": "fingerprintjs2", - "_where": "C:\\xampp\\htdocs\\test\\infos_device", - "author": { - "name": "Valentin Vasilyev" - }, - "bugs": { - "url": "https://github.com/Valve/fingerprintjs2/issues" - }, - "dependencies": {}, - "description": "Modern & flexible browser fingerprinting library", - "devDependencies": { - "eslint": "^0.14.1", - "gulp": "^3.8.11", - "gulp-eslint": "^0.4.2", - "gulp-rename": "^1.2.2", - "gulp-uglify": "^1.1.0" - }, - "directories": {}, - "dist": { - "shasum": "f61bc48d0f913ad3fc867919d9cec25e8150f397", - "tarball": "https://registry.npmjs.org/fingerprintjs2/-/fingerprintjs2-1.5.0.tgz" - }, - "gitHead": "ec8e3deceac3db562c61589a25a5c5bf33ed05a7", - "homepage": "https://github.com/Valve/fingerprintjs2", - "keywords": [ - "browser", - "identification", - "fingerprint", - "fingerprinting", - "privacy" - ], - "license": "MIT", - "main": "dist/fingerprint2.min.js", - "maintainers": [ - { - "name": "valve", - "email": "valentin.vasilyev@outlook.com" - } - ], - "name": "fingerprintjs2", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/Valve/fingerprintjs2.git" - }, - "scripts": { - "test": "specs/phantomjs.runner.sh specs/spec_runner.html" - }, - "version": "1.5.0" -} diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/boot.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/boot.js deleted file mode 100755 index 04ed64c1c0a992aee76d089c08fb58690965ae34..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/boot.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. - - If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. - - The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. - - [jasmine-gem]: http://github.com/pivotal/jasmine-gem - */ - -(function() { - - /** - * ## Require & Instantiate - * - * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. - */ - window.jasmine = jasmineRequire.core(jasmineRequire); - - /** - * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. - */ - jasmineRequire.html(jasmine); - - /** - * Create the Jasmine environment. This is used to run all specs in a project. - */ - var env = jasmine.getEnv(); - - /** - * ## The Global Interface - * - * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. - */ - var jasmineInterface = jasmineRequire.interface(jasmine, env); - - /** - * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. - */ - extend(window, jasmineInterface); - - /** - * ## Runner Parameters - * - * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. - */ - - var queryString = new jasmine.QueryString({ - getWindowLocation: function() { return window.location; } - }); - - var catchingExceptions = queryString.getParam("catch"); - env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); - - var throwingExpectationFailures = queryString.getParam("throwFailures"); - env.throwOnExpectationFailure(throwingExpectationFailures); - - /** - * ## Reporters - * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). - */ - var htmlReporter = new jasmine.HtmlReporter({ - env: env, - onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); }, - onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); }, - addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); }, - getContainer: function() { return document.body; }, - createElement: function() { return document.createElement.apply(document, arguments); }, - createTextNode: function() { return document.createTextNode.apply(document, arguments); }, - timer: new jasmine.Timer() - }); - - /** - * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. - */ - env.addReporter(jasmineInterface.jsApiReporter); - env.addReporter(htmlReporter); - - /** - * Filter which specs will be run by matching the start of the full name against the `spec` query param. - */ - var specFilter = new jasmine.HtmlSpecFilter({ - filterString: function() { return queryString.getParam("spec"); } - }); - - env.specFilter = function(spec) { - return specFilter.matches(spec.getFullName()); - }; - - /** - * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. - */ - window.setTimeout = window.setTimeout; - window.setInterval = window.setInterval; - window.clearTimeout = window.clearTimeout; - window.clearInterval = window.clearInterval; - - /** - * ## Execution - * - * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. - */ - var currentWindowOnload = window.onload; - - window.onload = function() { - if (currentWindowOnload) { - currentWindowOnload(); - } - htmlReporter.initialize(); - env.execute(); - }; - - /** - * Helper function for readability above. - */ - function extend(destination, source) { - for (var property in source) destination[property] = source[property]; - return destination; - } - -}()); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-html.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-html.js deleted file mode 100755 index 259f45ce26d00d85768673cdfaee00aae5b9a2a3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-html.js +++ /dev/null @@ -1,446 +0,0 @@ -/* -Copyright (c) 2008-2015 Pivotal Labs - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -jasmineRequire.html = function(j$) { - j$.ResultsNode = jasmineRequire.ResultsNode(); - j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); - j$.QueryString = jasmineRequire.QueryString(); - j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); -}; - -jasmineRequire.HtmlReporter = function(j$) { - - var noopTimer = { - start: function() {}, - elapsed: function() { return 0; } - }; - - function HtmlReporter(options) { - var env = options.env || {}, - getContainer = options.getContainer, - createElement = options.createElement, - createTextNode = options.createTextNode, - onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {}, - onThrowExpectationsClick = options.onThrowExpectationsClick || function() {}, - addToExistingQueryString = options.addToExistingQueryString || defaultQueryString, - timer = options.timer || noopTimer, - results = [], - specsExecuted = 0, - failureCount = 0, - pendingSpecCount = 0, - htmlReporterMain, - symbols, - failedSuites = []; - - this.initialize = function() { - clearPrior(); - htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'}, - createDom('div', {className: 'banner'}, - createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}), - createDom('span', {className: 'version'}, j$.version) - ), - createDom('ul', {className: 'symbol-summary'}), - createDom('div', {className: 'alert'}), - createDom('div', {className: 'results'}, - createDom('div', {className: 'failures'}) - ) - ); - getContainer().appendChild(htmlReporterMain); - - symbols = find('.symbol-summary'); - }; - - var totalSpecsDefined; - this.jasmineStarted = function(options) { - totalSpecsDefined = options.totalSpecsDefined || 0; - timer.start(); - }; - - var summary = createDom('div', {className: 'summary'}); - - var topResults = new j$.ResultsNode({}, '', null), - currentParent = topResults; - - this.suiteStarted = function(result) { - currentParent.addChild(result, 'suite'); - currentParent = currentParent.last(); - }; - - this.suiteDone = function(result) { - if (result.status == 'failed') { - failedSuites.push(result); - } - - if (currentParent == topResults) { - return; - } - - currentParent = currentParent.parent; - }; - - this.specStarted = function(result) { - currentParent.addChild(result, 'spec'); - }; - - var failures = []; - this.specDone = function(result) { - if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') { - console.error('Spec \'' + result.fullName + '\' has no expectations.'); - } - - if (result.status != 'disabled') { - specsExecuted++; - } - - symbols.appendChild(createDom('li', { - className: noExpectations(result) ? 'empty' : result.status, - id: 'spec_' + result.id, - title: result.fullName - } - )); - - if (result.status == 'failed') { - failureCount++; - - var failure = - createDom('div', {className: 'spec-detail failed'}, - createDom('div', {className: 'description'}, - createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName) - ), - createDom('div', {className: 'messages'}) - ); - var messages = failure.childNodes[1]; - - for (var i = 0; i < result.failedExpectations.length; i++) { - var expectation = result.failedExpectations[i]; - messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message)); - messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack)); - } - - failures.push(failure); - } - - if (result.status == 'pending') { - pendingSpecCount++; - } - }; - - this.jasmineDone = function() { - var banner = find('.banner'); - var alert = find('.alert'); - alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's')); - - banner.appendChild( - createDom('div', { className: 'run-options' }, - createDom('span', { className: 'trigger' }, 'Options'), - createDom('div', { className: 'payload' }, - createDom('div', { className: 'exceptions' }, - createDom('input', { - className: 'raise', - id: 'raise-exceptions', - type: 'checkbox' - }), - createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')), - createDom('div', { className: 'throw-failures' }, - createDom('input', { - className: 'throw', - id: 'throw-failures', - type: 'checkbox' - }), - createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure')) - ) - )); - - var raiseCheckbox = find('#raise-exceptions'); - - raiseCheckbox.checked = !env.catchingExceptions(); - raiseCheckbox.onclick = onRaiseExceptionsClick; - - var throwCheckbox = find('#throw-failures'); - throwCheckbox.checked = env.throwingExpectationFailures(); - throwCheckbox.onclick = onThrowExpectationsClick; - - var optionsMenu = find('.run-options'), - optionsTrigger = optionsMenu.querySelector('.trigger'), - optionsPayload = optionsMenu.querySelector('.payload'), - isOpen = /\bopen\b/; - - optionsTrigger.onclick = function() { - if (isOpen.test(optionsPayload.className)) { - optionsPayload.className = optionsPayload.className.replace(isOpen, ''); - } else { - optionsPayload.className += ' open'; - } - }; - - if (specsExecuted < totalSpecsDefined) { - var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all'; - alert.appendChild( - createDom('span', {className: 'bar skipped'}, - createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage) - ) - ); - } - var statusBarMessage = ''; - var statusBarClassName = 'bar '; - - if (totalSpecsDefined > 0) { - statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount); - if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); } - statusBarClassName += (failureCount > 0) ? 'failed' : 'passed'; - } else { - statusBarClassName += 'skipped'; - statusBarMessage += 'No specs found'; - } - - alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage)); - - for(i = 0; i < failedSuites.length; i++) { - var failedSuite = failedSuites[i]; - for(var j = 0; j < failedSuite.failedExpectations.length; j++) { - var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message; - var errorBarClassName = 'bar errored'; - alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage)); - } - } - - var results = find('.results'); - results.appendChild(summary); - - summaryList(topResults, summary); - - function summaryList(resultsTree, domParent) { - var specListNode; - for (var i = 0; i < resultsTree.children.length; i++) { - var resultNode = resultsTree.children[i]; - if (resultNode.type == 'suite') { - var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id}, - createDom('li', {className: 'suite-detail'}, - createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description) - ) - ); - - summaryList(resultNode, suiteListNode); - domParent.appendChild(suiteListNode); - } - if (resultNode.type == 'spec') { - if (domParent.getAttribute('class') != 'specs') { - specListNode = createDom('ul', {className: 'specs'}); - domParent.appendChild(specListNode); - } - var specDescription = resultNode.result.description; - if(noExpectations(resultNode.result)) { - specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription; - } - if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') { - specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason; - } - specListNode.appendChild( - createDom('li', { - className: resultNode.result.status, - id: 'spec-' + resultNode.result.id - }, - createDom('a', {href: specHref(resultNode.result)}, specDescription) - ) - ); - } - } - } - - if (failures.length) { - alert.appendChild( - createDom('span', {className: 'menu bar spec-list'}, - createDom('span', {}, 'Spec List | '), - createDom('a', {className: 'failures-menu', href: '#'}, 'Failures'))); - alert.appendChild( - createDom('span', {className: 'menu bar failure-list'}, - createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'), - createDom('span', {}, ' | Failures '))); - - find('.failures-menu').onclick = function() { - setMenuModeTo('failure-list'); - }; - find('.spec-list-menu').onclick = function() { - setMenuModeTo('spec-list'); - }; - - setMenuModeTo('failure-list'); - - var failureNode = find('.failures'); - for (var i = 0; i < failures.length; i++) { - failureNode.appendChild(failures[i]); - } - } - }; - - return this; - - function find(selector) { - return getContainer().querySelector('.jasmine_html-reporter ' + selector); - } - - function clearPrior() { - // return the reporter - var oldReporter = find(''); - - if(oldReporter) { - getContainer().removeChild(oldReporter); - } - } - - function createDom(type, attrs, childrenVarArgs) { - var el = createElement(type); - - for (var i = 2; i < arguments.length; i++) { - var child = arguments[i]; - - if (typeof child === 'string') { - el.appendChild(createTextNode(child)); - } else { - if (child) { - el.appendChild(child); - } - } - } - - for (var attr in attrs) { - if (attr == 'className') { - el[attr] = attrs[attr]; - } else { - el.setAttribute(attr, attrs[attr]); - } - } - - return el; - } - - function pluralize(singular, count) { - var word = (count == 1 ? singular : singular + 's'); - - return '' + count + ' ' + word; - } - - function specHref(result) { - return addToExistingQueryString('spec', result.fullName); - } - - function defaultQueryString(key, value) { - return '?' + key + '=' + value; - } - - function setMenuModeTo(mode) { - htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode); - } - - function noExpectations(result) { - return (result.failedExpectations.length + result.passedExpectations.length) === 0 && - result.status === 'passed'; - } - } - - return HtmlReporter; -}; - -jasmineRequire.HtmlSpecFilter = function() { - function HtmlSpecFilter(options) { - var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); - var filterPattern = new RegExp(filterString); - - this.matches = function(specName) { - return filterPattern.test(specName); - }; - } - - return HtmlSpecFilter; -}; - -jasmineRequire.ResultsNode = function() { - function ResultsNode(result, type, parent) { - this.result = result; - this.type = type; - this.parent = parent; - - this.children = []; - - this.addChild = function(result, type) { - this.children.push(new ResultsNode(result, type, this)); - }; - - this.last = function() { - return this.children[this.children.length - 1]; - }; - } - - return ResultsNode; -}; - -jasmineRequire.QueryString = function() { - function QueryString(options) { - - this.navigateWithNewParam = function(key, value) { - options.getWindowLocation().search = this.fullStringWithNewParam(key, value); - }; - - this.fullStringWithNewParam = function(key, value) { - var paramMap = queryStringToParamMap(); - paramMap[key] = value; - return toQueryString(paramMap); - }; - - this.getParam = function(key) { - return queryStringToParamMap()[key]; - }; - - return this; - - function toQueryString(paramMap) { - var qStrPairs = []; - for (var prop in paramMap) { - qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])); - } - return '?' + qStrPairs.join('&'); - } - - function queryStringToParamMap() { - var paramStr = options.getWindowLocation().search.substring(1), - params = [], - paramMap = {}; - - if (paramStr.length > 0) { - params = paramStr.split('&'); - for (var i = 0; i < params.length; i++) { - var p = params[i].split('='); - var value = decodeURIComponent(p[1]); - if (value === 'true' || value === 'false') { - value = JSON.parse(value); - } - paramMap[decodeURIComponent(p[0])] = value; - } - } - - return paramMap; - } - - } - - return QueryString; -}; diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-matchers.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-matchers.js deleted file mode 100755 index fff2033f09330fa66791a6e296e0fe18a883308a..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine-matchers.js +++ /dev/null @@ -1,1757 +0,0 @@ -(function e(t, n, r) { - function s(o, u) { - if (!n[o]) { - if (!t[o]) { - var a = typeof require == 'function' && require; - if (!u && a) { - return a(o, !0); - } - if (i) { - return i(o, !0); - } - var f = new Error('Cannot find module \'' + o + '\''); - throw f.code = 'MODULE_NOT_FOUND', f - } - var l = n[o] = { - exports: {} - }; - t[o][0].call(l.exports, function(e) { - var n = t[o][1][e]; - return s(n ? n : e); - }, l, l.exports, e, t, n, r); - } - return n[o].exports; - } - var i = typeof require == 'function' && require; - for (var o = 0; o < r.length; o++) { - s(r[o]); - } - return s; -})({ - 1: [function(require, module, exports) { - 'use strict'; - - /* - * Copyright © Jamie Mason, @fold_left, - * https://github.com/JamieMason - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var factory = require('./lib/factory'); - - var matchers = { - toBeAfter: require('./toBeAfter'), - toBeArray: require('./toBeArray'), - toBeArrayOfBooleans: require('./toBeArrayOfBooleans'), - toBeArrayOfNumbers: require('./toBeArrayOfNumbers'), - toBeArrayOfObjects: require('./toBeArrayOfObjects'), - toBeArrayOfSize: require('./toBeArrayOfSize'), - toBeArrayOfStrings: require('./toBeArrayOfStrings'), - toBeBefore: require('./toBeBefore'), - toBeBoolean: require('./toBeBoolean'), - toBeCalculable: require('./toBeCalculable'), - toBeDate: require('./toBeDate'), - toBeEmptyArray: require('./toBeEmptyArray'), - toBeEmptyObject: require('./toBeEmptyObject'), - toBeEmptyString: require('./toBeEmptyString'), - toBeEvenNumber: require('./toBeEvenNumber'), - toBeFalse: require('./toBeFalse'), - toBeFunction: require('./toBeFunction'), - toBeHtmlString: require('./toBeHtmlString'), - toBeIso8601: require('./toBeIso8601'), - toBeJsonString: require('./toBeJsonString'), - toBeLongerThan: require('./toBeLongerThan'), - toBeNonEmptyArray: require('./toBeNonEmptyArray'), - toBeNonEmptyObject: require('./toBeNonEmptyObject'), - toBeNonEmptyString: require('./toBeNonEmptyString'), - toBeNumber: require('./toBeNumber'), - toBeObject: require('./toBeObject'), - toBeOddNumber: require('./toBeOddNumber'), - toBeSameLengthAs: require('./toBeSameLengthAs'), - toBeShorterThan: require('./toBeShorterThan'), - toBeString: require('./toBeString'), - toBeTrue: require('./toBeTrue'), - toBeWhitespace: require('./toBeWhitespace'), - toBeWholeNumber: require('./toBeWholeNumber'), - toBeWithinRange: require('./toBeWithinRange'), - toEndWith: require('./toEndWith'), - toImplement: require('./toImplement'), - toStartWith: require('./toStartWith'), - toThrowAnyError: require('./toThrowAnyError'), - toThrowErrorOfType: require('./toThrowErrorOfType'), - toHaveArray: require('./toHaveArray'), - toHaveArrayOfBooleans: require('./toHaveArrayOfBooleans'), - toHaveArrayOfNumbers: require('./toHaveArrayOfNumbers'), - toHaveArrayOfObjects: require('./toHaveArrayOfObjects'), - toHaveArrayOfSize: require('./toHaveArrayOfSize'), - toHaveArrayOfStrings: require('./toHaveArrayOfStrings'), - toHaveBoolean: require('./toHaveBoolean'), - toHaveCalculable: require('./toHaveCalculable'), - toHaveDate: require('./toHaveDate'), - toHaveDateAfter: require('./toHaveDateAfter'), - toHaveDateBefore: require('./toHaveDateBefore'), - toHaveEmptyArray: require('./toHaveEmptyArray'), - toHaveEmptyObject: require('./toHaveEmptyObject'), - toHaveEmptyString: require('./toHaveEmptyString'), - toHaveEvenNumber: require('./toHaveEvenNumber'), - toHaveFalse: require('./toHaveFalse'), - toHaveHtmlString: require('./toHaveHtmlString'), - toHaveIso8601: require('./toHaveIso8601'), - toHaveJsonString: require('./toHaveJsonString'), - toHaveMember: require('./toHaveMember'), - toHaveMethod: require('./toHaveMethod'), - toHaveNonEmptyArray: require('./toHaveNonEmptyArray'), - toHaveNonEmptyObject: require('./toHaveNonEmptyObject'), - toHaveNonEmptyString: require('./toHaveNonEmptyString'), - toHaveNumber: require('./toHaveNumber'), - toHaveNumberWithinRange: require('./toHaveNumberWithinRange'), - toHaveObject: require('./toHaveObject'), - toHaveOddNumber: require('./toHaveOddNumber'), - toHaveString: require('./toHaveString'), - toHaveStringLongerThan: require('./toHaveStringLongerThan'), - toHaveStringSameLengthAs: require('./toHaveStringSameLengthAs'), - toHaveStringShorterThan: require('./toHaveStringShorterThan'), - toHaveTrue: require('./toHaveTrue'), - toHaveWhitespaceString: require('./toHaveWhitespaceString'), - toHaveWholeNumber: require('./toHaveWholeNumber') - }; - - for (var matcherName in matchers) { - factory(matcherName, matchers[matcherName]); - } - - module.exports = matchers; - - }, { - './lib/factory': 3, - './toBeAfter': 10, - './toBeArray': 11, - './toBeArrayOfBooleans': 12, - './toBeArrayOfNumbers': 13, - './toBeArrayOfObjects': 14, - './toBeArrayOfSize': 15, - './toBeArrayOfStrings': 16, - './toBeBefore': 17, - './toBeBoolean': 18, - './toBeCalculable': 19, - './toBeDate': 20, - './toBeEmptyArray': 21, - './toBeEmptyObject': 22, - './toBeEmptyString': 23, - './toBeEvenNumber': 24, - './toBeFalse': 25, - './toBeFunction': 26, - './toBeHtmlString': 27, - './toBeIso8601': 28, - './toBeJsonString': 29, - './toBeLongerThan': 30, - './toBeNonEmptyArray': 31, - './toBeNonEmptyObject': 32, - './toBeNonEmptyString': 33, - './toBeNumber': 34, - './toBeObject': 35, - './toBeOddNumber': 36, - './toBeSameLengthAs': 37, - './toBeShorterThan': 38, - './toBeString': 39, - './toBeTrue': 40, - './toBeWhitespace': 41, - './toBeWholeNumber': 42, - './toBeWithinRange': 43, - './toEndWith': 44, - './toHaveArray': 45, - './toHaveArrayOfBooleans': 46, - './toHaveArrayOfNumbers': 47, - './toHaveArrayOfObjects': 48, - './toHaveArrayOfSize': 49, - './toHaveArrayOfStrings': 50, - './toHaveBoolean': 51, - './toHaveCalculable': 52, - './toHaveDate': 53, - './toHaveDateAfter': 54, - './toHaveDateBefore': 55, - './toHaveEmptyArray': 56, - './toHaveEmptyObject': 57, - './toHaveEmptyString': 58, - './toHaveEvenNumber': 59, - './toHaveFalse': 60, - './toHaveHtmlString': 61, - './toHaveIso8601': 62, - './toHaveJsonString': 63, - './toHaveMember': 64, - './toHaveMethod': 65, - './toHaveNonEmptyArray': 66, - './toHaveNonEmptyObject': 67, - './toHaveNonEmptyString': 68, - './toHaveNumber': 69, - './toHaveNumberWithinRange': 70, - './toHaveObject': 71, - './toHaveOddNumber': 72, - './toHaveString': 73, - './toHaveStringLongerThan': 74, - './toHaveStringSameLengthAs': 75, - './toHaveStringShorterThan': 76, - './toHaveTrue': 77, - './toHaveWhitespaceString': 78, - './toHaveWholeNumber': 79, - './toImplement': 80, - './toStartWith': 81, - './toThrowAnyError': 82, - './toThrowErrorOfType': 83 - }], - 2: [function(require, module, exports) { - 'use strict'; - - module.exports = every; - - function every(array, truthTest) { - for (var i = 0, len = array.length; i < len; i++) { - if (!truthTest(array[i])) { - return false; - } - } - return true; - } - - }, {}], - 3: [function(require, module, exports) { - 'use strict'; - - var adapters = typeof jasmine.addMatchers === 'function' ? - require('./jasmine-v2') : - require('./jasmine-v1'); - - module.exports = function(name, matcher) { - var adapter = adapters[matcher.length]; - return adapter(name, matcher); - }; - - }, { - './jasmine-v1': 4, - './jasmine-v2': 5 - }], - 4: [function(require, module, exports) { - 'use strict'; - - module.exports = { - 1: createFactory(forActual), - 2: createFactory(forActualAndExpected), - 3: createFactory(forActualAndTwoExpected), - 4: createFactory(forKeyAndActualAndTwoExpected) - }; - - function createFactory(adapter) { - return function jasmineV1MatcherFactory(name, matcher) { - var matcherByName = new JasmineV1Matcher(name, adapter, matcher); - beforeEach(function() { - this.addMatchers(matcherByName); - }); - return matcherByName; - }; - } - - function JasmineV1Matcher(name, adapter, matcher) { - this[name] = adapter(name, matcher); - } - - function forActual(name, matcher) { - return function(optionalMessage) { - return matcher(this.actual, optionalMessage); - }; - } - - function forActualAndExpected(name, matcher) { - return function(expected, optionalMessage) { - return matcher(expected, this.actual, optionalMessage); - }; - } - - function forActualAndTwoExpected(name, matcher) { - return function(expected1, expected2, optionalMessage) { - return matcher(expected1, expected2, this.actual, optionalMessage); - }; - } - - function forKeyAndActualAndTwoExpected(name, matcher) { - return function(key, expected1, expected2, optionalMessage) { - return matcher(key, expected1, expected2, this.actual, optionalMessage); - }; - } - - }, {}], - 5: [function(require, module, exports) { - 'use strict'; - - var matcherFactory = require('./matcherFactory'); - var memberMatcherFactory = require('./memberMatcherFactory'); - - module.exports = { - 1: createFactory(getAdapter(1)), - 2: createFactory(getAdapter(2)), - 3: createFactory(getAdapter(3)), - 4: createFactory(getAdapter(4)) - }; - - function createFactory(adapter) { - return function jasmineV2MatcherFactory(name, matcher) { - var matcherByName = new JasmineV2Matcher(name, adapter, matcher); - beforeEach(function() { - jasmine.addMatchers(matcherByName); - }); - return matcherByName; - }; - } - - function JasmineV2Matcher(name, adapter, matcher) { - this[name] = adapter(name, matcher); - } - - function getAdapter(argsCount) { - return function adapter(name, matcher) { - var factory = isMemberMatcher(name) ? memberMatcherFactory : matcherFactory; - return factory[argsCount](name, matcher); - }; - } - - function isMemberMatcher(name) { - return name.search(/^toHave/) !== -1; - } - - }, { - './matcherFactory': 6, - './memberMatcherFactory': 7 - }], - 6: [function(require, module, exports) { - 'use strict'; - - module.exports = { - 1: forActual, - 2: forActualAndExpected, - 3: forActualAndTwoExpected - }; - - function forActual(name, matcher) { - return function(util) { - return { - compare: function(actual, optionalMessage) { - var passes = matcher(actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, optionalMessage) : - util.buildFailureMessage(name, passes, actual) - ) - }; - } - }; - }; - } - - function forActualAndExpected(name, matcher) { - return function(util) { - return { - compare: function(actual, expected, optionalMessage) { - var passes = matcher(expected, actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, expected, optionalMessage) : - util.buildFailureMessage(name, passes, actual, expected) - ) - }; - } - }; - }; - } - - function forActualAndTwoExpected(name, matcher) { - return function(util) { - return { - compare: function(actual, expected1, expected2, optionalMessage) { - var passes = matcher(expected1, expected2, actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, expected1, expected2, optionalMessage) : - util.buildFailureMessage(name, passes, actual, expected1, expected2) - ) - }; - } - }; - }; - } - - }, {}], - 7: [function(require, module, exports) { - 'use strict'; - - module.exports = { - 2: forKeyAndActual, - 3: forKeyAndActualAndExpected, - 4: forKeyAndActualAndTwoExpected - }; - - function forKeyAndActual(name, matcher) { - return function(util) { - return { - compare: function(actual, key, optionalMessage) { - var passes = matcher(key, actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, optionalMessage) : - util.buildFailureMessage(name, passes, actual) - ) - }; - } - }; - }; - } - - function forKeyAndActualAndExpected(name, matcher) { - return function(util) { - return { - compare: function(actual, key, expected, optionalMessage) { - var passes = matcher(key, expected, actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, expected, optionalMessage) : - util.buildFailureMessage(name, passes, actual, expected) - ) - }; - } - }; - }; - } - - function forKeyAndActualAndTwoExpected(name, matcher) { - return function(util) { - return { - compare: function(actual, key, expected1, expected2, optionalMessage) { - var passes = matcher(key, expected1, expected2, actual); - return { - pass: passes, - message: ( - optionalMessage ? - util.buildFailureMessage(name, passes, actual, expected1, expected2, optionalMessage) : - util.buildFailureMessage(name, passes, actual, expected1, expected2) - ) - }; - } - }; - }; - } - - }, {}], - 8: [function(require, module, exports) { - 'use strict'; - - module.exports = is; - - function is(value, type) { - return Object.prototype.toString.call(value) === '[object ' + type + ']'; - } - - }, {}], - 9: [function(require, module, exports) { - 'use strict'; - - module.exports = keys; - - function keys(object) { - var list = []; - for (var key in object) { - if (object.hasOwnProperty(key)) { - list.push(key); - } - } - return list; - } - - }, {}], - 10: [function(require, module, exports) { - 'use strict'; - - var toBeBefore = require('./toBeBefore'); - - module.exports = toBeAfter; - - function toBeAfter(otherDate, actual) { - return toBeBefore(actual, otherDate); - } - - }, { - './toBeBefore': 17 - }], - 11: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeArray; - - function toBeArray(actual) { - return is(actual, 'Array'); - } - - }, { - './lib/is': 8 - }], - 12: [function(require, module, exports) { - 'use strict'; - - var every = require('./lib/every'); - var toBeArray = require('./toBeArray'); - var toBeBoolean = require('./toBeBoolean'); - - module.exports = toBeArrayOfBooleans; - - function toBeArrayOfBooleans(actual) { - return toBeArray(actual) && - every(actual, toBeBoolean); - } - - }, { - './lib/every': 2, - './toBeArray': 11, - './toBeBoolean': 18 - }], - 13: [function(require, module, exports) { - 'use strict'; - - var every = require('./lib/every'); - var toBeArray = require('./toBeArray'); - var toBeNumber = require('./toBeNumber'); - - module.exports = toBeArrayOfBooleans; - - function toBeArrayOfBooleans(actual) { - return toBeArray(actual) && - every(actual, toBeNumber); - } - - }, { - './lib/every': 2, - './toBeArray': 11, - './toBeNumber': 34 - }], - 14: [function(require, module, exports) { - 'use strict'; - - var every = require('./lib/every'); - var toBeArray = require('./toBeArray'); - var toBeObject = require('./toBeObject'); - - module.exports = toBeArrayOfBooleans; - - function toBeArrayOfBooleans(actual) { - return toBeArray(actual) && - every(actual, toBeObject); - } - - }, { - './lib/every': 2, - './toBeArray': 11, - './toBeObject': 35 - }], - 15: [function(require, module, exports) { - 'use strict'; - - var toBeArray = require('./toBeArray'); - - module.exports = toBeArrayOfSize; - - function toBeArrayOfSize(size, actual) { - return toBeArray(actual) && - actual.length === size; - } - - }, { - './toBeArray': 11 - }], - 16: [function(require, module, exports) { - 'use strict'; - - var every = require('./lib/every'); - var toBeArray = require('./toBeArray'); - var toBeString = require('./toBeString'); - - module.exports = toBeArrayOfStrings; - - function toBeArrayOfStrings(actual) { - return toBeArray(actual) && - every(actual, toBeString); - } - - }, { - './lib/every': 2, - './toBeArray': 11, - './toBeString': 39 - }], - 17: [function(require, module, exports) { - 'use strict'; - - var toBeDate = require('./toBeDate'); - - module.exports = toBeBefore; - - function toBeBefore(otherDate, actual) { - return toBeDate(actual) && - toBeDate(otherDate) && - actual.getTime() < otherDate.getTime(); - } - - }, { - './toBeDate': 20 - }], - 18: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeBoolean; - - function toBeBoolean(actual) { - return is(actual, 'Boolean'); - } - - }, { - './lib/is': 8 - }], - 19: [function(require, module, exports) { - 'use strict'; - - module.exports = toBeCalculable; - - // Assert subject can be used in Mathemetic - // calculations despite not being a Number, - // for example `"1" * "2" === 2` whereas - // `"wut?" * 2 === NaN`. - function toBeCalculable(actual) { - return !isNaN(actual * 2); - } - - }, {}], - 20: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeDate; - - function toBeDate(actual) { - return is(actual, 'Date'); - } - - }, { - './lib/is': 8 - }], - 21: [function(require, module, exports) { - 'use strict'; - - var toBeArrayOfSize = require('./toBeArrayOfSize'); - - module.exports = toBeEmptyArray; - - function toBeEmptyArray(actual) { - return toBeArrayOfSize(0, actual); - } - - }, { - './toBeArrayOfSize': 15 - }], - 22: [function(require, module, exports) { - 'use strict'; - - var keys = require('./lib/keys'); - var is = require('./lib/is'); - - module.exports = toBeEmptyObject; - - function toBeEmptyObject(actual) { - return is(actual, 'Object') && - keys(actual).length === 0; - } - - }, { - './lib/is': 8, - './lib/keys': 9 - }], - 23: [function(require, module, exports) { - 'use strict'; - - module.exports = toBeEmptyString; - - function toBeEmptyString(actual) { - return actual === ''; - } - - }, {}], - 24: [function(require, module, exports) { - 'use strict'; - - var toBeNumber = require('./toBeNumber'); - - module.exports = toBeEvenNumber; - - function toBeEvenNumber(actual) { - return toBeNumber(actual) && - actual % 2 === 0; - } - - }, { - './toBeNumber': 34 - }], - 25: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeFalse; - - function toBeFalse(actual) { - return actual === false || - is(actual, 'Boolean') && - !actual.valueOf(); - } - - }, { - './lib/is': 8 - }], - 26: [function(require, module, exports) { - 'use strict'; - - module.exports = toBeFunction; - - function toBeFunction(actual) { - return typeof actual === 'function'; - } - - }, {}], - 27: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeHtmlString; - - function toBeHtmlString(actual) { - // < start with opening tag "<" - // ( start group 1 - // "[^"]*" allow string in "double quotes" - // | OR - // '[^']*' allow string in "single quotes" - // | OR - // [^'">] cant contains one single quotes, double quotes and ">" - // ) end group 1 - // * 0 or more - // > end with closing tag ">" - return toBeString(actual) && - actual.search(/<("[^"]*"|'[^']*'|[^'">])*>/) !== -1; - } - - }, { - './toBeString': 39 - }], - 28: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeIso8601; - - function toBeIso8601(actual) { - - if (!toBeString(actual)) { - return false; - } - - if ( - isIso8601(actual, [ - // 2013-07-08 - 4, '-', 2, '-', 2 - ]) || isIso8601(actual, [ - // 2013-07-08T07:29 - 4, '-', 2, '-', 2, 'T', 2, ':', 2 - ]) || isIso8601(actual, [ - // 2013-07-08T07:29:15 - 4, '-', 2, '-', 2, 'T', 2, ':', 2, ':', 2 - ]) || isIso8601(actual, [ - // 2013-07-08T07:29:15.863 - 4, '-', 2, '-', 2, 'T', 2, ':', 2, ':', 2, '.', 3 - ]) || isIso8601(actual, [ - // 2013-07-08T07:29:15.863Z - 4, '-', 2, '-', 2, 'T', 2, ':', 2, ':', 2, '.', 3, 'Z' - ]) - ) { - return new Date(actual).toString() !== 'Invalid Date'; - } - - return false; - - } - - function isIso8601(string, pattern) { - var returnValue = string.search( - new RegExp('^' + pattern.map(function(term) { - if (term === '-') { - return '\\-'; - } else if (typeof term === 'string') { - return term; - } else { - return '([0-9]{' + term + '})'; - } - }).join('') + '$') - ) !== -1; - return returnValue; - } - - }, { - './toBeString': 39 - }], - 29: [function(require, module, exports) { - 'use strict'; - - module.exports = toBeJsonString; - - function toBeJsonString(actual) { - var isParseable; - var json; - try { - json = JSON.parse(actual); - } catch (e) { - isParseable = false; - } - return isParseable !== false && - json !== null; - } - - }, {}], - 30: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeLongerThan; - - function toBeLongerThan(otherString, actual) { - return toBeString(actual) && - toBeString(otherString) && - actual.length > otherString.length; - } - - }, { - './toBeString': 39 - }], - 31: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeNonEmptyArray; - - function toBeNonEmptyArray(actual) { - return is(actual, 'Array') && - actual.length > 0; - } - - }, { - './lib/is': 8 - }], - 32: [function(require, module, exports) { - 'use strict'; - - var keys = require('./lib/keys'); - var is = require('./lib/is'); - - module.exports = toBeNonEmptyObject; - - function toBeNonEmptyObject(actual) { - return is(actual, 'Object') && - keys(actual).length > 0; - } - - }, { - './lib/is': 8, - './lib/keys': 9 - }], - 33: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeNonEmptyString; - - function toBeNonEmptyString(actual) { - return toBeString(actual) && - actual.length > 0; - } - - }, { - './toBeString': 39 - }], - 34: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeNumber; - - function toBeNumber(actual) { - return !isNaN(parseFloat(actual)) && - !is(actual, 'String'); - } - - }, { - './lib/is': 8 - }], - 35: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeObject; - - function toBeObject(actual) { - return is(actual, 'Object'); - } - - }, { - './lib/is': 8 - }], - 36: [function(require, module, exports) { - 'use strict'; - - var toBeNumber = require('./toBeNumber'); - - module.exports = toBeOddNumber; - - function toBeOddNumber(actual) { - return toBeNumber(actual) && - actual % 2 !== 0; - } - - }, { - './toBeNumber': 34 - }], - 37: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeSameLengthAs; - - function toBeSameLengthAs(otherString, actual) { - return toBeString(actual) && - toBeString(otherString) && - actual.length === otherString.length; - } - - }, { - './toBeString': 39 - }], - 38: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeShorterThan; - - function toBeShorterThan(otherString, actual) { - return toBeString(actual) && - toBeString(otherString) && - actual.length < otherString.length; - } - - }, { - './toBeString': 39 - }], - 39: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeString; - - function toBeString(actual) { - return is(actual, 'String'); - } - - }, { - './lib/is': 8 - }], - 40: [function(require, module, exports) { - 'use strict'; - - var is = require('./lib/is'); - - module.exports = toBeTrue; - - function toBeTrue(actual) { - return actual === true || - is(actual, 'Boolean') && - actual.valueOf(); - } - - }, { - './lib/is': 8 - }], - 41: [function(require, module, exports) { - 'use strict'; - - var toBeString = require('./toBeString'); - - module.exports = toBeWhitespace; - - function toBeWhitespace(actual) { - return toBeString(actual) && - actual.search(/\S/) === -1; - } - - }, { - './toBeString': 39 - }], - 42: [function(require, module, exports) { - 'use strict'; - - var toBeNumber = require('./toBeNumber'); - - module.exports = toBeWholeNumber; - - function toBeWholeNumber(actual) { - return toBeNumber(actual) && ( - actual === 0 || actual % 1 === 0 - ); - } - - }, { - './toBeNumber': 34 - }], - 43: [function(require, module, exports) { - 'use strict'; - - var toBeNumber = require('./toBeNumber'); - - module.exports = toBeWithinRange; - - function toBeWithinRange(floor, ceiling, actual) { - return toBeNumber(actual) && - actual >= floor && - actual <= ceiling; - } - - }, { - './toBeNumber': 34 - }], - 44: [function(require, module, exports) { - 'use strict'; - - var toBeNonEmptyString = require('./toBeNonEmptyString'); - - module.exports = toEndWith; - - function toEndWith(subString, actual) { - if (!toBeNonEmptyString(actual) || !toBeNonEmptyString(subString)) { - return false; - } - return actual.slice(actual.length - subString.length, actual.length) === subString; - } - - }, { - './toBeNonEmptyString': 33 - }], - 45: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArray = require('./toBeArray'); - - module.exports = toHaveArray; - - function toHaveArray(key, actual) { - return toBeObject(actual) && - toBeArray(actual[key]); - } - - }, { - './toBeArray': 11, - './toBeObject': 35 - }], - 46: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArrayOfBooleans = require('./toBeArrayOfBooleans'); - - module.exports = toHaveArrayOfBooleans; - - function toHaveArrayOfBooleans(key, actual) { - return toBeObject(actual) && - toBeArrayOfBooleans(actual[key]); - } - - }, { - './toBeArrayOfBooleans': 12, - './toBeObject': 35 - }], - 47: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArrayOfNumbers = require('./toBeArrayOfNumbers'); - - module.exports = toHaveArrayOfNumbers; - - function toHaveArrayOfNumbers(key, actual) { - return toBeObject(actual) && - toBeArrayOfNumbers(actual[key]); - } - - }, { - './toBeArrayOfNumbers': 13, - './toBeObject': 35 - }], - 48: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArrayOfObjects = require('./toBeArrayOfObjects'); - - module.exports = toHaveArrayOfObjects; - - function toHaveArrayOfObjects(key, actual) { - return toBeObject(actual) && - toBeArrayOfObjects(actual[key]); - } - - }, { - './toBeArrayOfObjects': 14, - './toBeObject': 35 - }], - 49: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArrayOfSize = require('./toBeArrayOfSize'); - - module.exports = toHaveArrayOfSize; - - function toHaveArrayOfSize(key, size, actual) { - return toBeObject(actual) && - toBeArrayOfSize(size, actual[key]); - } - - }, { - './toBeArrayOfSize': 15, - './toBeObject': 35 - }], - 50: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeArrayOfStrings = require('./toBeArrayOfStrings'); - - module.exports = toHaveArrayOfStrings; - - function toHaveArrayOfStrings(key, actual) { - return toBeObject(actual) && - toBeArrayOfStrings(actual[key]); - } - - }, { - './toBeArrayOfStrings': 16, - './toBeObject': 35 - }], - 51: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeBoolean = require('./toBeBoolean'); - - module.exports = toHaveBoolean; - - function toHaveBoolean(key, actual) { - return toBeObject(actual) && - toBeBoolean(actual[key]); - } - - }, { - './toBeBoolean': 18, - './toBeObject': 35 - }], - 52: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeCalculable = require('./toBeCalculable'); - - module.exports = toHaveCalculable; - - function toHaveCalculable(key, actual) { - return toBeObject(actual) && - toBeCalculable(actual[key]); - } - - }, { - './toBeCalculable': 19, - './toBeObject': 35 - }], - 53: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeDate = require('./toBeDate'); - - module.exports = toHaveDate; - - function toHaveDate(key, actual) { - return toBeObject(actual) && - toBeDate(actual[key]); - } - - }, { - './toBeDate': 20, - './toBeObject': 35 - }], - 54: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeAfter = require('./toBeAfter'); - - module.exports = toHaveDateAfter; - - function toHaveDateAfter(key, date, actual) { - return toBeObject(actual) && - toBeAfter(date, actual[key]); - } - - }, { - './toBeAfter': 10, - './toBeObject': 35 - }], - 55: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeBefore = require('./toBeBefore'); - - module.exports = toHaveDateBefore; - - function toHaveDateBefore(key, date, actual) { - return toBeObject(actual) && - toBeBefore(date, actual[key]); - } - - }, { - './toBeBefore': 17, - './toBeObject': 35 - }], - 56: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeEmptyArray = require('./toBeEmptyArray'); - - module.exports = toHaveEmptyArray; - - function toHaveEmptyArray(key, actual) { - return toBeObject(actual) && - toBeEmptyArray(actual[key]); - } - - }, { - './toBeEmptyArray': 21, - './toBeObject': 35 - }], - 57: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeEmptyObject = require('./toBeEmptyObject'); - - module.exports = toHaveEmptyObject; - - function toHaveEmptyObject(key, actual) { - return toBeObject(actual) && - toBeEmptyObject(actual[key]); - } - - }, { - './toBeEmptyObject': 22, - './toBeObject': 35 - }], - 58: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeEmptyString = require('./toBeEmptyString'); - - module.exports = toHaveEmptyString; - - function toHaveEmptyString(key, actual) { - return toBeObject(actual) && - toBeEmptyString(actual[key]); - } - - }, { - './toBeEmptyString': 23, - './toBeObject': 35 - }], - 59: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeEvenNumber = require('./toBeEvenNumber'); - - module.exports = toHaveEvenNumber; - - function toHaveEvenNumber(key, actual) { - return toBeObject(actual) && - toBeEvenNumber(actual[key]); - } - - }, { - './toBeEvenNumber': 24, - './toBeObject': 35 - }], - 60: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeFalse = require('./toBeFalse'); - - module.exports = toHaveFalse; - - function toHaveFalse(key, actual) { - return toBeObject(actual) && - toBeFalse(actual[key]); - } - - }, { - './toBeFalse': 25, - './toBeObject': 35 - }], - 61: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeHtmlString = require('./toBeHtmlString'); - - module.exports = toHaveHtmlString; - - function toHaveHtmlString(key, actual) { - return toBeObject(actual) && - toBeHtmlString(actual[key]); - } - - }, { - './toBeHtmlString': 27, - './toBeObject': 35 - }], - 62: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeIso8601 = require('./toBeIso8601'); - - module.exports = toHaveIso8601; - - function toHaveIso8601(key, actual) { - return toBeObject(actual) && - toBeIso8601(actual[key]); - } - - }, { - './toBeIso8601': 28, - './toBeObject': 35 - }], - 63: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeJsonString = require('./toBeJsonString'); - - module.exports = toHaveJsonString; - - function toHaveJsonString(key, actual) { - return toBeObject(actual) && - toBeJsonString(actual[key]); - } - - }, { - './toBeJsonString': 29, - './toBeObject': 35 - }], - 64: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeString = require('./toBeString'); - - module.exports = toHaveMember; - - function toHaveMember(key, actual) { - return toBeString(key) && - toBeObject(actual) && - key in actual; - } - - }, { - './toBeObject': 35, - './toBeString': 39 - }], - 65: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeFunction = require('./toBeFunction'); - - module.exports = toHaveMethod; - - function toHaveMethod(key, actual) { - return toBeObject(actual) && - toBeFunction(actual[key]); - } - - }, { - './toBeFunction': 26, - './toBeObject': 35 - }], - 66: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeNonEmptyArray = require('./toBeNonEmptyArray'); - - module.exports = toHaveNonEmptyArray; - - function toHaveNonEmptyArray(key, actual) { - return toBeObject(actual) && - toBeNonEmptyArray(actual[key]); - } - - }, { - './toBeNonEmptyArray': 31, - './toBeObject': 35 - }], - 67: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeNonEmptyObject = require('./toBeNonEmptyObject'); - - module.exports = toHaveNonEmptyObject; - - function toHaveNonEmptyObject(key, actual) { - return toBeObject(actual) && - toBeNonEmptyObject(actual[key]); - } - - }, { - './toBeNonEmptyObject': 32, - './toBeObject': 35 - }], - 68: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeNonEmptyString = require('./toBeNonEmptyString'); - - module.exports = toHaveNonEmptyString; - - function toHaveNonEmptyString(key, actual) { - return toBeObject(actual) && - toBeNonEmptyString(actual[key]); - } - - }, { - './toBeNonEmptyString': 33, - './toBeObject': 35 - }], - 69: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeNumber = require('./toBeNumber'); - - module.exports = toHaveNumber; - - function toHaveNumber(key, actual) { - return toBeObject(actual) && - toBeNumber(actual[key]); - } - - }, { - './toBeNumber': 34, - './toBeObject': 35 - }], - 70: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeWithinRange = require('./toBeWithinRange'); - - module.exports = toHaveNumberWithinRange; - - function toHaveNumberWithinRange(key, floor, ceiling, actual) { - return toBeObject(actual) && - toBeWithinRange(floor, ceiling, actual[key]); - } - - }, { - './toBeObject': 35, - './toBeWithinRange': 43 - }], - 71: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - - module.exports = toHaveObject; - - function toHaveObject(key, actual) { - return toBeObject(actual) && - toBeObject(actual[key]); - } - - }, { - './toBeObject': 35 - }], - 72: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeOddNumber = require('./toBeOddNumber'); - - module.exports = toHaveOddNumber; - - function toHaveOddNumber(key, actual) { - return toBeObject(actual) && - toBeOddNumber(actual[key]); - } - - }, { - './toBeObject': 35, - './toBeOddNumber': 36 - }], - 73: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeString = require('./toBeString'); - - module.exports = toHaveString; - - function toHaveString(key, actual) { - return toBeObject(actual) && - toBeString(actual[key]); - } - - }, { - './toBeObject': 35, - './toBeString': 39 - }], - 74: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeLongerThan = require('./toBeLongerThan'); - - module.exports = toHaveStringLongerThan; - - function toHaveStringLongerThan(key, other, actual) { - return toBeObject(actual) && - toBeLongerThan(other, actual[key]); - } - - }, { - './toBeLongerThan': 30, - './toBeObject': 35 - }], - 75: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeSameLengthAs = require('./toBeSameLengthAs'); - - module.exports = toHaveStringSameLengthAs; - - function toHaveStringSameLengthAs(key, other, actual) { - return toBeObject(actual) && - toBeSameLengthAs(other, actual[key]); - } - - }, { - './toBeObject': 35, - './toBeSameLengthAs': 37 - }], - 76: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeShorterThan = require('./toBeShorterThan'); - - module.exports = toHaveStringShorterThan; - - function toHaveStringShorterThan(key, other, actual) { - return toBeObject(actual) && - toBeShorterThan(other, actual[key]); - } - - }, { - './toBeObject': 35, - './toBeShorterThan': 38 - }], - 77: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeTrue = require('./toBeTrue'); - - module.exports = toHaveTrue; - - function toHaveTrue(key, actual) { - return toBeObject(actual) && - toBeTrue(actual[key]); - } - - }, { - './toBeObject': 35, - './toBeTrue': 40 - }], - 78: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeWhitespace = require('./toBeWhitespace'); - - module.exports = toHaveWhitespaceString; - - function toHaveWhitespaceString(key, actual) { - return toBeObject(actual) && - toBeWhitespace(actual[key]); - } - - }, { - './toBeObject': 35, - './toBeWhitespace': 41 - }], - 79: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - var toBeWholeNumber = require('./toBeWholeNumber'); - - module.exports = toHaveWholeNumber; - - function toHaveWholeNumber(key, actual) { - return toBeObject(actual) && - toBeWholeNumber(actual[key]); - } - - }, { - './toBeObject': 35, - './toBeWholeNumber': 42 - }], - 80: [function(require, module, exports) { - 'use strict'; - - var toBeObject = require('./toBeObject'); - - module.exports = toImplement; - - function toImplement(api, actual) { - return toBeObject(api) && - toBeObject(actual) && - featuresAll(api, actual); - } - - function featuresAll(api, actual) { - for (var key in api) { - if (api.hasOwnProperty(key) && - key in actual === false) { - return false; - } - } - return true; - } - - }, { - './toBeObject': 35 - }], - 81: [function(require, module, exports) { - 'use strict'; - - var toBeNonEmptyString = require('./toBeNonEmptyString'); - - module.exports = toStartWith; - - function toStartWith(subString, actual) { - if (!toBeNonEmptyString(actual) || !toBeNonEmptyString(subString)) { - return false; - } - return actual.slice(0, subString.length) === subString; - } - - }, { - './toBeNonEmptyString': 33 - }], - 82: [function(require, module, exports) { - 'use strict'; - - module.exports = toThrowAnyError; - - function toThrowAnyError(actual) { - var threwError = false; - try { - actual(); - } catch (e) { - threwError = true; - } - return threwError; - } - - }, {}], - 83: [function(require, module, exports) { - 'use strict'; - - module.exports = toThrowErrorOfType; - - function toThrowErrorOfType(type, actual) { - var threwErrorOfType = false; - try { - actual(); - } catch (e) { - threwErrorOfType = (e.name === type); - } - return threwErrorOfType; - } - - }, {}] -}, {}, [1]); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.css b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.css deleted file mode 100755 index f9f4ae901eeef2836c575ed01e24c475353b0ef2..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.css +++ /dev/null @@ -1,58 +0,0 @@ -body { overflow-y: scroll; } - -.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; } -.jasmine_html-reporter a { text-decoration: none; } -.jasmine_html-reporter a:hover { text-decoration: underline; } -.jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; } -.jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; } -.jasmine_html-reporter .banner { position: relative; } -.jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4KIQoSKQYKIQICIQISMQoSKQYKLQIOLQoOJQYGLQIOKQIOMQoGKQYOLQYGKQIOLQoGJQYOJQIOKQYGJQIOKQoGKQIGLQIKLQ4KKQoGLQYKJQIGKQYKJQIGKQIKJQoGKQYKLQIGKQYKLQIOJQoKKQoOJQYKKQIOJQoKKQoOKQIOLQoKKQYOLQYKJQIOKQoKKQYKKQoKJQYOKQYKLQIOKQoKLQYOKQYKLQIOJQoGKQYKJQYGJQoGKQYKLQoGLQYGKQoGJQYKKQYGJQIKKQoGJQYKLQIKKQYGLQYKKQYGKQYGKQYKJQYOKQoKJQYOKQYKLQYOLQYOKQYKLQYOKQoKKQYKKQYOKQYOJQYKKQYKLQYKKQIKKQoKKQYKKQYKKQoKJQIKKQYKLQYKKQYKKQIKKQYKKQYKKQYKKQIKKQYKJQYGLQYGKQYKKQYKKQYGKQIKKQYGKQYOJQoKKQYOLQYKKQYOKQoKKQYKKQoKKQYKKQYKJQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKJQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKmIDpEAAAA0XRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAiIyQlJycoKissLS4wMTQ1Njc4OTo7PDw+P0BCQ0RISUpLTE1OUFNUVVdYWFlaW15fYGFiY2ZnaGlqa2xtb3BxcnN0dnh5ent8fX5/gIGChIWIioyNjo+QkZOUlZaYmZqbnJ2eoKGio6WmqKmsra6vsLGztre4ubq7vL2+wMHDxMjJysvNzs/Q0dLU1tfY2dvc3t/g4eLj5ebn6Onq6+zt7u/w8vP09fb3+Pn6+/z9/vkVQXAAAAMaSURBVHhe5dXxV1N1GMfxz2ABbDgIAm5VDJOyVDIJLUMaVpBWUZUaGbmqoGpZRSiGiRWp6KoZ5AB0ZY50RImZQIlahKkMYXv/R90dBvET/rJfOr3Ouc8v99zPec59zvf56j+vYKlViSf7250X4Mr3O29Tgq08BdGB4DhcekEJ5YkQKFsgWZdtj9JpV+I8xPjLFqkrsEIqO8PHSpis36jWazcqjEsfJjkvRssVU37SdIOu4XCf5vEJPsnwJpnRNU9JmxhMk8l1gehIrq7hTFjzOD+Vf88629qKMJVNltInFeRexRQyJlNeqd1iGDlSzrIUIyXbyFfm3RYprcQRe7lqtWyGYbfc6dT0R2vmdOOkX3u55C1rP37ftiH+tDby4r/RBT0w8TyEkr+epB9XgPDmSYYWbrhCuFYaIyw3fDQAXTnSkh+ANofiHmWf9l+FY1I90FdQTetstO00o23novzVsJ7uB3/C5TkbjRwZ5JerwV4iRWq9HFbFMaK/d0TYqayRiQPuIxxS3Bu8JWU90/60tKi7vkhaznez0a/TbVOKj5CaOZh6fWG6/Lyv9B/ZLR1gw/S/fpbeVD3MCW1li6SvWDOn65tr99/uvWtBS0XDm4s1t+sOHpG0kpBKx/l77wOSnxLpcx6TXmXLTPQOKYOf9Q1dfr8/SJ2mFdCvl1Yl93DiHUZvXeLJbGSzYu5gVJ2slbSakOR8dxCq5adQ2oFLqsE9Ex3L4qQO0eOPeU5x56bypXp4onSEb5OkICX6lDat55TeoztNKQcJaakrz9KCb95oD69IKq+yKW4XPjknaS52V0TZqE2cTtXjcHSCRmUO88e+85hj3EP74i9p8pylw7lxgMDyyl6OV7ZejnjNMfatu87LxRbH0IS35gt2a4ZjmGpVBdKK3Wr6INk8jWWSGqbA55CKgjBRC6E9w78ydTg3ABS3AFV1QN0Y4Aa2pgEjWnQURj9L0ayK6R2ysEqxHUKzYnLvvyU+i9KM2JHJzE4vyZOyDcOwOsySajeLPc8sNvPJkFlyJd20wpqAzZeAfZ3oWybxd+P/3j+SG3uSBdf2VQAAAABJRU5ErkJggg==') no-repeat; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICB3aWR0aD0iNjgxLjk2MjUyIgogICBoZWlnaHQ9IjE4Ny41IgogICBpZD0ic3ZnMiIKICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhOCI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczYiPjxjbGlwUGF0aAogICAgICAgaWQ9ImNsaXBQYXRoMTgiPjxwYXRoCiAgICAgICAgIGQ9Ik0gMCwxNTAwIDAsMCBsIDU0NTUuNzQsMCAwLDE1MDAgTCAwLDE1MDAgeiIKICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgaWQ9InBhdGgyMCIgLz48L2NsaXBQYXRoPjwvZGVmcz48ZwogICAgIHRyYW5zZm9ybT0ibWF0cml4KDEuMjUsMCwwLC0xLjI1LDAsMTg3LjUpIgogICAgIGlkPSJnMTAiPjxnCiAgICAgICB0cmFuc2Zvcm09InNjYWxlKDAuMSwwLjEpIgogICAgICAgaWQ9ImcxMiI+PGcKICAgICAgICAgaWQ9ImcxNCI+PGcKICAgICAgICAgICBjbGlwLXBhdGg9InVybCgjY2xpcFBhdGgxOCkiCiAgICAgICAgICAgaWQ9ImcxNiI+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMTU0NCw1OTkuNDM0IGMgMC45MiwtNDAuMzUyIDI1LjY4LC04MS42MDIgNzEuNTMsLTgxLjYwMiAyNy41MSwwIDQ3LjY4LDEyLjgzMiA2MS40NCwzNS43NTQgMTIuODMsMjIuOTMgMTIuODMsNTYuODUyIDEyLjgzLDgyLjUyNyBsIDAsMzI5LjE4NCAtNzEuNTIsMCAwLDEwNC41NDMgMjY2LjgzLDAgMCwtMTA0LjU0MyAtNzAuNiwwIDAsLTM0NC43NyBjIDAsLTU4LjY5MSAtMy42OCwtMTA0LjUzMSAtNDQuOTMsLTE1Mi4yMTggLTM2LjY4LC00Mi4xOCAtOTYuMjgsLTY2LjAyIC0xNTMuMTQsLTY2LjAyIC0xMTcuMzcsMCAtMjA3LjI0LDc3Ljk0MSAtMjAyLjY0LDE5Ny4xNDUgbCAxMzAuMiwwIgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMjIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDIzMDEuNCw2NjIuNjk1IGMgMCw4MC43MDMgLTY2Ljk0LDE0NS44MTMgLTE0Ny42MywxNDUuODEzIC04My40NCwwIC0xNDcuNjMsLTY4Ljc4MSAtMTQ3LjYzLC0xNTEuMzAxIDAsLTc5Ljc4NSA2Ni45NCwtMTQ1LjgwMSAxNDUuOCwtMTQ1LjgwMSA4NC4zNSwwIDE0OS40Niw2Ny44NTIgMTQ5LjQ2LDE1MS4yODkgeiBtIC0xLjgzLC0xODEuNTQ3IGMgLTM1Ljc3LC01NC4wOTcgLTkzLjUzLC03OC44NTkgLTE1Ny43MiwtNzguODU5IC0xNDAuMywwIC0yNTEuMjQsMTE2LjQ0OSAtMjUxLjI0LDI1NC45MTggMCwxNDIuMTI5IDExMy43LDI2MC40MSAyNTYuNzQsMjYwLjQxIDYzLjI3LDAgMTE4LjI5LC0yOS4zMzYgMTUyLjIyLC04Mi41MjMgbCAwLDY5LjY4NyAxNzUuMTQsMCAwLC0xMDQuNTI3IC02MS40NCwwIDAsLTI4MC41OTggNjEuNDQsMCAwLC0xMDQuNTI3IC0xNzUuMTQsMCAwLDY2LjAxOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDI0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSAyNjIyLjMzLDU1Ny4yNTggYyAzLjY3LC00NC4wMTYgMzMuMDEsLTczLjM0OCA3OC44NiwtNzMuMzQ4IDMzLjkzLDAgNjYuOTMsMjMuODI0IDY2LjkzLDYwLjUwNCAwLDQ4LjYwNiAtNDUuODQsNTYuODU2IC04My40NCw2Ni45NDEgLTg1LjI4LDIyLjAwNCAtMTc4LjgxLDQ4LjYwNiAtMTc4LjgxLDE1NS44NzkgMCw5My41MzYgNzguODYsMTQ3LjYzMyAxNjUuOTgsMTQ3LjYzMyA0NCwwIDgzLjQzLC05LjE3NiAxMTAuOTQsLTQ0LjAwOCBsIDAsMzMuOTIyIDgyLjUzLDAgMCwtMTMyLjk2NSAtMTA4LjIxLDAgYyAtMS44MywzNC44NTYgLTI4LjQyLDU3Ljc3NCAtNjMuMjYsNTcuNzc0IC0zMC4yNiwwIC02Mi4zNSwtMTcuNDIyIC02Mi4zNSwtNTEuMzQ4IDAsLTQ1Ljg0NyA0NC45MywtNTUuOTMgODAuNjksLTY0LjE4IDg4LjAyLC0yMC4xNzUgMTgyLjQ3LC00Ny42OTUgMTgyLjQ3LC0xNTcuNzM0IDAsLTk5LjAyNyAtODMuNDQsLTE1NC4wMzkgLTE3NS4xMywtMTU0LjAzOSAtNDkuNTMsMCAtOTQuNDYsMTUuNTgyIC0xMjYuNTUsNTMuMTggbCAwLC00MC4zNCAtODUuMjcsMCAwLDE0Mi4xMjkgMTE0LjYyLDAiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGgyNiIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMjk4OC4xOCw4MDAuMjU0IC02My4yNiwwIDAsMTA0LjUyNyAxNjUuMDUsMCAwLC03My4zNTUgYyAzMS4xOCw1MS4zNDcgNzguODYsODUuMjc3IDE0MS4yMSw4NS4yNzcgNjcuODUsMCAxMjQuNzEsLTQxLjI1OCAxNTIuMjEsLTEwMi42OTkgMjYuNiw2Mi4zNTEgOTIuNjIsMTAyLjY5OSAxNjAuNDcsMTAyLjY5OSA1My4xOSwwIDEwNS40NiwtMjIgMTQxLjIxLC02Mi4zNTEgMzguNTIsLTQ0LjkzOCAzOC41MiwtOTMuNTMyIDM4LjUyLC0xNDkuNDU3IGwgMCwtMTg1LjIzOSA2My4yNywwIDAsLTEwNC41MjcgLTIzOC40MiwwIDAsMTA0LjUyNyA2My4yOCwwIDAsMTU3LjcxNSBjIDAsMzIuMTAyIDAsNjAuNTI3IC0xNC42Nyw4OC45NTcgLTE4LjM0LDI2LjU4MiAtNDguNjEsNDAuMzQ0IC03OS43Nyw0MC4zNDQgLTMwLjI2LDAgLTYzLjI4LC0xMi44NDQgLTgyLjUzLC0zNi42NzIgLTIyLjkzLC0yOS4zNTUgLTIyLjkzLC01Ni44NjMgLTIyLjkzLC05Mi42MjkgbCAwLC0xNTcuNzE1IDYzLjI3LDAgMCwtMTA0LjUyNyAtMjM4LjQxLDAgMCwxMDQuNTI3IDYzLjI4LDAgMCwxNTAuMzgzIGMgMCwyOS4zNDggMCw2Ni4wMjMgLTE0LjY3LDkxLjY5OSAtMTUuNTksMjkuMzM2IC00Ny42OSw0NC45MzQgLTgwLjcsNDQuOTM0IC0zMS4xOCwwIC01Ny43NywtMTEuMDA4IC03Ny45NCwtMzUuNzc0IC0yNC43NywtMzAuMjUzIC0yNi42LC02Mi4zNDMgLTI2LjYsLTk5Ljk0MSBsIDAsLTE1MS4zMDEgNjMuMjcsMCAwLC0xMDQuNTI3IC0yMzguNCwwIDAsMTA0LjUyNyA2My4yNiwwIDAsMjgwLjU5OCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDI4IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSAzOTk4LjY2LDk1MS41NDcgLTExMS44NywwIDAsMTE4LjI5MyAxMTEuODcsMCAwLC0xMTguMjkzIHogbSAwLC00MzEuODkxIDYzLjI3LDAgMCwtMTA0LjUyNyAtMjM5LjMzLDAgMCwxMDQuNTI3IDY0LjE5LDAgMCwyODAuNTk4IC02My4yNywwIDAsMTA0LjUyNyAxNzUuMTQsMCAwLC0zODUuMTI1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzAiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDQxNTkuMTIsODAwLjI1NCAtNjMuMjcsMCAwLDEwNC41MjcgMTc1LjE0LDAgMCwtNjkuNjg3IGMgMjkuMzUsNTQuMTAxIDg0LjM2LDgwLjY5OSAxNDQuODcsODAuNjk5IDUzLjE5LDAgMTA1LjQ1LC0yMi4wMTYgMTQxLjIyLC02MC41MjcgNDAuMzQsLTQ0LjkzNCA0MS4yNiwtODguMDMyIDQxLjI2LC0xNDMuOTU3IGwgMCwtMTkxLjY1MyA2My4yNywwIDAsLTEwNC41MjcgLTIzOC40LDAgMCwxMDQuNTI3IDYzLjI2LDAgMCwxNTguNjM3IGMgMCwzMC4yNjIgMCw2MS40MzQgLTE5LjI2LDg4LjAzNSAtMjAuMTcsMjYuNTgyIC01My4xOCwzOS40MTQgLTg2LjE5LDM5LjQxNCAtMzMuOTMsMCAtNjguNzcsLTEzLjc1IC04OC45NCwtNDEuMjUgLTIxLjA5LC0yNy41IC0yMS4wOSwtNjkuNjg3IC0yMS4wOSwtMTAyLjcwNyBsIDAsLTE0Mi4xMjkgNjMuMjYsMCAwLC0xMDQuNTI3IC0yMzguNCwwIDAsMTA0LjUyNyA2My4yNywwIDAsMjgwLjU5OCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDMyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA1MDgyLjQ4LDcwMy45NjUgYyAtMTkuMjQsNzAuNjA1IC04MS42LDExNS41NDcgLTE1NC4wNCwxMTUuNTQ3IC02Ni4wNCwwIC0xMjkuMywtNTEuMzQ4IC0xNDMuMDUsLTExNS41NDcgbCAyOTcuMDksMCB6IG0gODUuMjcsLTE0NC44ODMgYyAtMzguNTEsLTkzLjUyMyAtMTI5LjI3LC0xNTYuNzkzIC0yMzEuMDUsLTE1Ni43OTMgLTE0My4wNywwIC0yNTcuNjgsMTExLjg3MSAtMjU3LjY4LDI1NS44MzYgMCwxNDQuODgzIDEwOS4xMiwyNjEuMzI4IDI1NC45MSwyNjEuMzI4IDY3Ljg3LDAgMTM1LjcyLC0zMC4yNTggMTgzLjM5LC03OC44NjMgNDguNjIsLTUxLjM0NCA2OC43OSwtMTEzLjY5NSA2OC43OSwtMTgzLjM4MyBsIC0zLjY3LC0zOS40MzQgLTM5Ni4xMywwIGMgMTQuNjcsLTY3Ljg2MyA3Ny4wMywtMTE3LjM2MyAxNDYuNzIsLTExNy4zNjMgNDguNTksMCA5MC43NiwxOC4zMjggMTE4LjI4LDU4LjY3MiBsIDExNi40NCwwIgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzQiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDY5MC44OTUsODUwLjcwMyA5MC43NSwwIDIyLjU0MywzMS4wMzUgMCwyNDMuMTIyIC0xMzUuODI5LDAgMCwtMjQzLjE0MSAyMi41MzYsLTMxLjAxNiIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDM2IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA2MzIuMzk1LDc0Mi4yNTggMjguMDM5LDg2LjMwNCAtMjIuNTUxLDMxLjA0IC0yMzEuMjIzLDc1LjEyOCAtNDEuOTc2LC0xMjkuMTgzIDIzMS4yNTcsLTc1LjEzNyAzNi40NTQsMTEuODQ4IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoMzgiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDcxNy40NDksNjUzLjEwNSAtNzMuNDEsNTMuMzYgLTM2LjQ4OCwtMTEuODc1IC0xNDIuOTAzLC0xOTYuNjkyIDEwOS44ODMsLTc5LjgyOCAxNDIuOTE4LDE5Ni43MDMgMCwzOC4zMzIiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGg0MCIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gODI4LjUyLDcwNi40NjUgLTczLjQyNiwtNTMuMzQgMC4wMTEsLTM4LjM1OSBMIDg5OC4wMDQsNDE4LjA3IDEwMDcuOSw0OTcuODk4IDg2NC45NzMsNjk0LjYwOSA4MjguNTIsNzA2LjQ2NSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDQyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA4MTIuMDg2LDgyOC41ODYgMjguMDU1LC04Ni4zMiAzNi40ODQsLTExLjgzNiAyMzEuMjI1LDc1LjExNyAtNDEuOTcsMTI5LjE4MyAtMjMxLjIzOSwtNzUuMTQgLTIyLjU1NSwtMzEuMDA0IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNDQiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDczNi4zMDEsMTMzNS44OCBjIC0zMjMuMDQ3LDAgLTU4NS44NzUsLTI2Mi43OCAtNTg1Ljg3NSwtNTg1Ljc4MiAwLC0zMjMuMTE4IDI2Mi44MjgsLTU4NS45NzcgNTg1Ljg3NSwtNTg1Ljk3NyAzMjMuMDE5LDAgNTg1LjgwOSwyNjIuODU5IDU4NS44MDksNTg1Ljk3NyAwLDMyMy4wMDIgLTI2Mi43OSw1ODUuNzgyIC01ODUuODA5LDU4NS43ODIgbCAwLDAgeiBtIDAsLTExOC42MSBjIDI1Ny45NzIsMCA0NjcuMTg5LC0yMDkuMTMgNDY3LjE4OSwtNDY3LjE3MiAwLC0yNTguMTI5IC0yMDkuMjE3LC00NjcuMzQ4IC00NjcuMTg5LC00NjcuMzQ4IC0yNTguMDc0LDAgLTQ2Ny4yNTQsMjA5LjIxOSAtNDY3LjI1NCw0NjcuMzQ4IDAsMjU4LjA0MiAyMDkuMTgsNDY3LjE3MiA0NjcuMjU0LDQ2Ny4xNzIiCiAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgICAgICAgaWQ9InBhdGg0NiIKICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiM4YTQxODI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiIC8+PHBhdGgKICAgICAgICAgICAgIGQ9Im0gMTA5MS4xMyw2MTkuODgzIC0xNzUuNzcxLDU3LjEyMSAxMS42MjksMzUuODA4IDE3NS43NjIsLTU3LjEyMSAtMTEuNjIsLTM1LjgwOCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDQ4IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0iTSA4NjYuOTU3LDkwMi4wNzQgODM2LjUsOTI0LjE5OSA5NDUuMTIxLDEwNzMuNzMgOTc1LjU4NiwxMDUxLjYxIDg2Ni45NTcsOTAyLjA3NCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDUwIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0iTSA2MDcuNDY1LDkwMy40NDUgNDk4Ljg1NSwxMDUyLjk3IDUyOS4zMiwxMDc1LjEgNjM3LjkzLDkyNS41NjYgNjA3LjQ2NSw5MDMuNDQ1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDM4MC42ODgsNjIyLjEyOSAtMTEuNjI2LDM1LjgwMSAxNzUuNzU4LDU3LjA5IDExLjYyMSwtMzUuODAxIC0xNzUuNzUzLC01Ny4wOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDU0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -moz-background-size: 100%; -o-background-size: 100%; -webkit-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; } -.jasmine_html-reporter .banner .version { margin-left: 14px; position: relative; top: 6px; } -.jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; } -.jasmine_html-reporter .version { color: #aaa; } -.jasmine_html-reporter .banner { margin-top: 14px; } -.jasmine_html-reporter .duration { color: #fff; float: right; line-height: 28px; padding-right: 9px; } -.jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; } -.jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; } -.jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; } -.jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; } -.jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; } -.jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; } -.jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; } -.jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; } -.jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; } -.jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; } -.jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; } -.jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; } -.jasmine_html-reporter .run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; } -.jasmine_html-reporter .run-options .trigger { cursor: pointer; padding: 8px 16px; } -.jasmine_html-reporter .run-options .payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; } -.jasmine_html-reporter .run-options .payload.open { display: block; } -.jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } -.jasmine_html-reporter .bar.failed { background-color: #ca3a11; } -.jasmine_html-reporter .bar.passed { background-color: #007069; } -.jasmine_html-reporter .bar.skipped { background-color: #bababa; } -.jasmine_html-reporter .bar.errored { background-color: #ca3a11; } -.jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaa; } -.jasmine_html-reporter .bar.menu a { color: #333; } -.jasmine_html-reporter .bar a { color: white; } -.jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; } -.jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; } -.jasmine_html-reporter .results { margin-top: 14px; } -.jasmine_html-reporter .summary { margin-top: 14px; } -.jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; } -.jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; } -.jasmine_html-reporter .summary li.passed a { color: #007069; } -.jasmine_html-reporter .summary li.failed a { color: #ca3a11; } -.jasmine_html-reporter .summary li.empty a { color: #ba9d37; } -.jasmine_html-reporter .summary li.pending a { color: #ba9d37; } -.jasmine_html-reporter .summary li.disabled a { color: #bababa; } -.jasmine_html-reporter .description + .suite { margin-top: 0; } -.jasmine_html-reporter .suite { margin-top: 14px; } -.jasmine_html-reporter .suite a { color: #333; } -.jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; } -.jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; } -.jasmine_html-reporter .failures .spec-detail .description a { color: white; } -.jasmine_html-reporter .result-message { padding-top: 14px; color: #333; white-space: pre; } -.jasmine_html-reporter .result-message span.result { display: block; } -.jasmine_html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666; border: 1px solid #ddd; background: white; white-space: pre; } diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.js deleted file mode 100755 index 312d591e12d9d59f036d5daba04b1dbd2e6c453a..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine.js +++ /dev/null @@ -1,3298 +0,0 @@ -/* -Copyright (c) 2008-2015 Pivotal Labs - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -var getJasmineRequireObj = (function (jasmineGlobal) { - var jasmineRequire; - - if (typeof module !== 'undefined' && module.exports) { - jasmineGlobal = global; - jasmineRequire = exports; - } else { - if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') { - jasmineGlobal = window; - } - jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {}; - } - - function getJasmineRequire() { - return jasmineRequire; - } - - getJasmineRequire().core = function(jRequire) { - var j$ = {}; - - jRequire.base(j$, jasmineGlobal); - j$.util = jRequire.util(); - j$.errors = jRequire.errors(); - j$.Any = jRequire.Any(j$); - j$.Anything = jRequire.Anything(j$); - j$.CallTracker = jRequire.CallTracker(); - j$.MockDate = jRequire.MockDate(); - j$.Clock = jRequire.Clock(); - j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(); - j$.Env = jRequire.Env(j$); - j$.ExceptionFormatter = jRequire.ExceptionFormatter(); - j$.Expectation = jRequire.Expectation(); - j$.buildExpectationResult = jRequire.buildExpectationResult(); - j$.JsApiReporter = jRequire.JsApiReporter(); - j$.matchersUtil = jRequire.matchersUtil(j$); - j$.ObjectContaining = jRequire.ObjectContaining(j$); - j$.ArrayContaining = jRequire.ArrayContaining(j$); - j$.pp = jRequire.pp(j$); - j$.QueueRunner = jRequire.QueueRunner(j$); - j$.ReportDispatcher = jRequire.ReportDispatcher(); - j$.Spec = jRequire.Spec(j$); - j$.SpyRegistry = jRequire.SpyRegistry(j$); - j$.SpyStrategy = jRequire.SpyStrategy(); - j$.StringMatching = jRequire.StringMatching(j$); - j$.Suite = jRequire.Suite(j$); - j$.Timer = jRequire.Timer(); - j$.TreeProcessor = jRequire.TreeProcessor(); - j$.version = jRequire.version(); - - j$.matchers = jRequire.requireMatchers(jRequire, j$); - - return j$; - }; - - return getJasmineRequire; -})(this); - -getJasmineRequireObj().requireMatchers = function(jRequire, j$) { - var availableMatchers = [ - 'toBe', - 'toBeCloseTo', - 'toBeDefined', - 'toBeFalsy', - 'toBeGreaterThan', - 'toBeLessThan', - 'toBeNaN', - 'toBeNull', - 'toBeTruthy', - 'toBeUndefined', - 'toContain', - 'toEqual', - 'toHaveBeenCalled', - 'toHaveBeenCalledWith', - 'toMatch', - 'toThrow', - 'toThrowError' - ], - matchers = {}; - - for (var i = 0; i < availableMatchers.length; i++) { - var name = availableMatchers[i]; - matchers[name] = jRequire[name](j$); - } - - return matchers; -}; - -getJasmineRequireObj().base = function(j$, jasmineGlobal) { - j$.unimplementedMethod_ = function() { - throw new Error('unimplemented method'); - }; - - j$.MAX_PRETTY_PRINT_DEPTH = 40; - j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100; - j$.DEFAULT_TIMEOUT_INTERVAL = 5000; - - j$.getGlobal = function() { - return jasmineGlobal; - }; - - j$.getEnv = function(options) { - var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options); - //jasmine. singletons in here (setTimeout blah blah). - return env; - }; - - j$.isArray_ = function(value) { - return j$.isA_('Array', value); - }; - - j$.isString_ = function(value) { - return j$.isA_('String', value); - }; - - j$.isNumber_ = function(value) { - return j$.isA_('Number', value); - }; - - j$.isA_ = function(typeName, value) { - return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; - }; - - j$.isDomNode = function(obj) { - return obj.nodeType > 0; - }; - - j$.fnNameFor = function(func) { - return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1]; - }; - - j$.any = function(clazz) { - return new j$.Any(clazz); - }; - - j$.anything = function() { - return new j$.Anything(); - }; - - j$.objectContaining = function(sample) { - return new j$.ObjectContaining(sample); - }; - - j$.stringMatching = function(expected) { - return new j$.StringMatching(expected); - }; - - j$.arrayContaining = function(sample) { - return new j$.ArrayContaining(sample); - }; - - j$.createSpy = function(name, originalFn) { - - var spyStrategy = new j$.SpyStrategy({ - name: name, - fn: originalFn, - getSpy: function() { return spy; } - }), - callTracker = new j$.CallTracker(), - spy = function() { - var callData = { - object: this, - args: Array.prototype.slice.apply(arguments) - }; - - callTracker.track(callData); - var returnValue = spyStrategy.exec.apply(this, arguments); - callData.returnValue = returnValue; - - return returnValue; - }; - - for (var prop in originalFn) { - if (prop === 'and' || prop === 'calls') { - throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon'); - } - - spy[prop] = originalFn[prop]; - } - - spy.and = spyStrategy; - spy.calls = callTracker; - - return spy; - }; - - j$.isSpy = function(putativeSpy) { - if (!putativeSpy) { - return false; - } - return putativeSpy.and instanceof j$.SpyStrategy && - putativeSpy.calls instanceof j$.CallTracker; - }; - - j$.createSpyObj = function(baseName, methodNames) { - if (j$.isArray_(baseName) && j$.util.isUndefined(methodNames)) { - methodNames = baseName; - baseName = 'unknown'; - } - - if (!j$.isArray_(methodNames) || methodNames.length === 0) { - throw 'createSpyObj requires a non-empty array of method names to create spies for'; - } - var obj = {}; - for (var i = 0; i < methodNames.length; i++) { - obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]); - } - return obj; - }; -}; - -getJasmineRequireObj().util = function() { - - var util = {}; - - util.inherit = function(childClass, parentClass) { - var Subclass = function() { - }; - Subclass.prototype = parentClass.prototype; - childClass.prototype = new Subclass(); - }; - - util.htmlEscape = function(str) { - if (!str) { - return str; - } - return str.replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>'); - }; - - util.argsToArray = function(args) { - var arrayOfArgs = []; - for (var i = 0; i < args.length; i++) { - arrayOfArgs.push(args[i]); - } - return arrayOfArgs; - }; - - util.isUndefined = function(obj) { - return obj === void 0; - }; - - util.arrayContains = function(array, search) { - var i = array.length; - while (i--) { - if (array[i] === search) { - return true; - } - } - return false; - }; - - util.clone = function(obj) { - if (Object.prototype.toString.apply(obj) === '[object Array]') { - return obj.slice(); - } - - var cloned = {}; - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - cloned[prop] = obj[prop]; - } - } - - return cloned; - }; - - return util; -}; - -getJasmineRequireObj().Spec = function(j$) { - function Spec(attrs) { - this.expectationFactory = attrs.expectationFactory; - this.resultCallback = attrs.resultCallback || function() {}; - this.id = attrs.id; - this.description = attrs.description || ''; - this.queueableFn = attrs.queueableFn; - this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; }; - this.userContext = attrs.userContext || function() { return {}; }; - this.onStart = attrs.onStart || function() {}; - this.getSpecName = attrs.getSpecName || function() { return ''; }; - this.expectationResultFactory = attrs.expectationResultFactory || function() { }; - this.queueRunnerFactory = attrs.queueRunnerFactory || function() {}; - this.catchingExceptions = attrs.catchingExceptions || function() { return true; }; - this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; - - if (!this.queueableFn.fn) { - this.pend(); - } - - this.result = { - id: this.id, - description: this.description, - fullName: this.getFullName(), - failedExpectations: [], - passedExpectations: [], - pendingReason: '' - }; - } - - Spec.prototype.addExpectationResult = function(passed, data, isError) { - var expectationResult = this.expectationResultFactory(data); - if (passed) { - this.result.passedExpectations.push(expectationResult); - } else { - this.result.failedExpectations.push(expectationResult); - - if (this.throwOnExpectationFailure && !isError) { - throw new j$.errors.ExpectationFailed(); - } - } - }; - - Spec.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Spec.prototype.execute = function(onComplete, enabled) { - var self = this; - - this.onStart(this); - - if (!this.isExecutable() || this.markedPending || enabled === false) { - complete(enabled); - return; - } - - var fns = this.beforeAndAfterFns(); - var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters); - - this.queueRunnerFactory({ - queueableFns: allFns, - onException: function() { self.onException.apply(self, arguments); }, - onComplete: complete, - userContext: this.userContext() - }); - - function complete(enabledAgain) { - self.result.status = self.status(enabledAgain); - self.resultCallback(self.result); - - if (onComplete) { - onComplete(); - } - } - }; - - Spec.prototype.onException = function onException(e) { - if (Spec.isPendingSpecException(e)) { - this.pend(extractCustomPendingMessage(e)); - return; - } - - if (e instanceof j$.errors.ExpectationFailed) { - return; - } - - this.addExpectationResult(false, { - matcherName: '', - passed: false, - expected: '', - actual: '', - error: e - }, true); - }; - - Spec.prototype.disable = function() { - this.disabled = true; - }; - - Spec.prototype.pend = function(message) { - this.markedPending = true; - if (message) { - this.result.pendingReason = message; - } - }; - - Spec.prototype.getResult = function() { - this.result.status = this.status(); - return this.result; - }; - - Spec.prototype.status = function(enabled) { - if (this.disabled || enabled === false) { - return 'disabled'; - } - - if (this.markedPending) { - return 'pending'; - } - - if (this.result.failedExpectations.length > 0) { - return 'failed'; - } else { - return 'passed'; - } - }; - - Spec.prototype.isExecutable = function() { - return !this.disabled; - }; - - Spec.prototype.getFullName = function() { - return this.getSpecName(this); - }; - - var extractCustomPendingMessage = function(e) { - var fullMessage = e.toString(), - boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage), - boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length; - - return fullMessage.substr(boilerplateEnd); - }; - - Spec.pendingSpecExceptionMessage = '=> marked Pending'; - - Spec.isPendingSpecException = function(e) { - return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); - }; - - return Spec; -}; - -if (typeof window == void 0 && typeof exports == 'object') { - exports.Spec = jasmineRequire.Spec; -} - -getJasmineRequireObj().Env = function(j$) { - function Env(options) { - options = options || {}; - - var self = this; - var global = options.global || j$.getGlobal(); - - var totalSpecsDefined = 0; - - var catchExceptions = true; - - var realSetTimeout = j$.getGlobal().setTimeout; - var realClearTimeout = j$.getGlobal().clearTimeout; - this.clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global)); - - var runnableLookupTable = {}; - var runnableResources = {}; - - var currentSpec = null; - var currentlyExecutingSuites = []; - var currentDeclarationSuite = null; - var throwOnExpectationFailure = false; - - var currentSuite = function() { - return currentlyExecutingSuites[currentlyExecutingSuites.length - 1]; - }; - - var currentRunnable = function() { - return currentSpec || currentSuite(); - }; - - var reporter = new j$.ReportDispatcher([ - 'jasmineStarted', - 'jasmineDone', - 'suiteStarted', - 'suiteDone', - 'specStarted', - 'specDone' - ]); - - this.specFilter = function() { - return true; - }; - - this.addCustomEqualityTester = function(tester) { - if(!currentRunnable()) { - throw new Error('Custom Equalities must be added in a before function or a spec'); - } - runnableResources[currentRunnable().id].customEqualityTesters.push(tester); - }; - - this.addMatchers = function(matchersToAdd) { - if(!currentRunnable()) { - throw new Error('Matchers must be added in a before function or a spec'); - } - var customMatchers = runnableResources[currentRunnable().id].customMatchers; - for (var matcherName in matchersToAdd) { - customMatchers[matcherName] = matchersToAdd[matcherName]; - } - }; - - j$.Expectation.addCoreMatchers(j$.matchers); - - var nextSpecId = 0; - var getNextSpecId = function() { - return 'spec' + nextSpecId++; - }; - - var nextSuiteId = 0; - var getNextSuiteId = function() { - return 'suite' + nextSuiteId++; - }; - - var expectationFactory = function(actual, spec) { - return j$.Expectation.Factory({ - util: j$.matchersUtil, - customEqualityTesters: runnableResources[spec.id].customEqualityTesters, - customMatchers: runnableResources[spec.id].customMatchers, - actual: actual, - addExpectationResult: addExpectationResult - }); - - function addExpectationResult(passed, result) { - return spec.addExpectationResult(passed, result); - } - }; - - var defaultResourcesForRunnable = function(id, parentRunnableId) { - var resources = {spies: [], customEqualityTesters: [], customMatchers: {}}; - - if(runnableResources[parentRunnableId]){ - resources.customEqualityTesters = j$.util.clone(runnableResources[parentRunnableId].customEqualityTesters); - resources.customMatchers = j$.util.clone(runnableResources[parentRunnableId].customMatchers); - } - - runnableResources[id] = resources; - }; - - var clearResourcesForRunnable = function(id) { - spyRegistry.clearSpies(); - delete runnableResources[id]; - }; - - var beforeAndAfterFns = function(suite) { - return function() { - var befores = [], - afters = []; - - while(suite) { - befores = befores.concat(suite.beforeFns); - afters = afters.concat(suite.afterFns); - - suite = suite.parentSuite; - } - - return { - befores: befores.reverse(), - afters: afters - }; - }; - }; - - var getSpecName = function(spec, suite) { - return suite.getFullName() + ' ' + spec.description; - }; - - // TODO: we may just be able to pass in the fn instead of wrapping here - var buildExpectationResult = j$.buildExpectationResult, - exceptionFormatter = new j$.ExceptionFormatter(), - expectationResultFactory = function(attrs) { - attrs.messageFormatter = exceptionFormatter.message; - attrs.stackFormatter = exceptionFormatter.stack; - - return buildExpectationResult(attrs); - }; - - // TODO: fix this naming, and here's where the value comes in - this.catchExceptions = function(value) { - catchExceptions = !!value; - return catchExceptions; - }; - - this.catchingExceptions = function() { - return catchExceptions; - }; - - var maximumSpecCallbackDepth = 20; - var currentSpecCallbackDepth = 0; - - function clearStack(fn) { - currentSpecCallbackDepth++; - if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) { - currentSpecCallbackDepth = 0; - realSetTimeout(fn, 0); - } else { - fn(); - } - } - - var catchException = function(e) { - return j$.Spec.isPendingSpecException(e) || catchExceptions; - }; - - this.throwOnExpectationFailure = function(value) { - throwOnExpectationFailure = !!value; - }; - - this.throwingExpectationFailures = function() { - return throwOnExpectationFailure; - }; - - var queueRunnerFactory = function(options) { - options.catchException = catchException; - options.clearStack = options.clearStack || clearStack; - options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; - options.fail = self.fail; - - new j$.QueueRunner(options).execute(); - }; - - var topSuite = new j$.Suite({ - env: this, - id: getNextSuiteId(), - description: 'Jasmine__TopLevel__Suite', - queueRunner: queueRunnerFactory - }); - runnableLookupTable[topSuite.id] = topSuite; - defaultResourcesForRunnable(topSuite.id); - currentDeclarationSuite = topSuite; - - this.topSuite = function() { - return topSuite; - }; - - this.execute = function(runnablesToRun) { - if(!runnablesToRun) { - if (focusedRunnables.length) { - runnablesToRun = focusedRunnables; - } else { - runnablesToRun = [topSuite.id]; - } - } - var processor = new j$.TreeProcessor({ - tree: topSuite, - runnableIds: runnablesToRun, - queueRunnerFactory: queueRunnerFactory, - nodeStart: function(suite) { - currentlyExecutingSuites.push(suite); - defaultResourcesForRunnable(suite.id, suite.parentSuite.id); - reporter.suiteStarted(suite.result); - }, - nodeComplete: function(suite, result) { - if (!suite.disabled) { - clearResourcesForRunnable(suite.id); - } - currentlyExecutingSuites.pop(); - reporter.suiteDone(result); - } - }); - - if(!processor.processTree().valid) { - throw new Error('Invalid order: would cause a beforeAll or afterAll to be run multiple times'); - } - - reporter.jasmineStarted({ - totalSpecsDefined: totalSpecsDefined - }); - - processor.execute(reporter.jasmineDone); - }; - - this.addReporter = function(reporterToAdd) { - reporter.addReporter(reporterToAdd); - }; - - var spyRegistry = new j$.SpyRegistry({currentSpies: function() { - if(!currentRunnable()) { - throw new Error('Spies must be created in a before function or a spec'); - } - return runnableResources[currentRunnable().id].spies; - }}); - - this.spyOn = function() { - return spyRegistry.spyOn.apply(spyRegistry, arguments); - }; - - var suiteFactory = function(description) { - var suite = new j$.Suite({ - env: self, - id: getNextSuiteId(), - description: description, - parentSuite: currentDeclarationSuite, - expectationFactory: expectationFactory, - expectationResultFactory: expectationResultFactory, - throwOnExpectationFailure: throwOnExpectationFailure - }); - - runnableLookupTable[suite.id] = suite; - return suite; - }; - - this.describe = function(description, specDefinitions) { - var suite = suiteFactory(description); - addSpecsToSuite(suite, specDefinitions); - return suite; - }; - - this.xdescribe = function(description, specDefinitions) { - var suite = this.describe(description, specDefinitions); - suite.disable(); - return suite; - }; - - var focusedRunnables = []; - - this.fdescribe = function(description, specDefinitions) { - var suite = suiteFactory(description); - suite.isFocused = true; - - focusedRunnables.push(suite.id); - unfocusAncestor(); - addSpecsToSuite(suite, specDefinitions); - - return suite; - }; - - function addSpecsToSuite(suite, specDefinitions) { - var parentSuite = currentDeclarationSuite; - parentSuite.addChild(suite); - currentDeclarationSuite = suite; - - var declarationError = null; - try { - specDefinitions.call(suite); - } catch (e) { - declarationError = e; - } - - if (declarationError) { - self.it('encountered a declaration exception', function() { - throw declarationError; - }); - } - - currentDeclarationSuite = parentSuite; - } - - function findFocusedAncestor(suite) { - while (suite) { - if (suite.isFocused) { - return suite.id; - } - suite = suite.parentSuite; - } - - return null; - } - - function unfocusAncestor() { - var focusedAncestor = findFocusedAncestor(currentDeclarationSuite); - if (focusedAncestor) { - for (var i = 0; i < focusedRunnables.length; i++) { - if (focusedRunnables[i] === focusedAncestor) { - focusedRunnables.splice(i, 1); - break; - } - } - } - } - - var specFactory = function(description, fn, suite, timeout) { - totalSpecsDefined++; - var spec = new j$.Spec({ - id: getNextSpecId(), - beforeAndAfterFns: beforeAndAfterFns(suite), - expectationFactory: expectationFactory, - resultCallback: specResultCallback, - getSpecName: function(spec) { - return getSpecName(spec, suite); - }, - onStart: specStarted, - description: description, - expectationResultFactory: expectationResultFactory, - queueRunnerFactory: queueRunnerFactory, - userContext: function() { return suite.clonedSharedUserContext(); }, - queueableFn: { - fn: fn, - timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } - }, - throwOnExpectationFailure: throwOnExpectationFailure - }); - - runnableLookupTable[spec.id] = spec; - - if (!self.specFilter(spec)) { - spec.disable(); - } - - return spec; - - function specResultCallback(result) { - clearResourcesForRunnable(spec.id); - currentSpec = null; - reporter.specDone(result); - } - - function specStarted(spec) { - currentSpec = spec; - defaultResourcesForRunnable(spec.id, suite.id); - reporter.specStarted(spec.result); - } - }; - - this.it = function(description, fn, timeout) { - var spec = specFactory(description, fn, currentDeclarationSuite, timeout); - currentDeclarationSuite.addChild(spec); - return spec; - }; - - this.xit = function() { - var spec = this.it.apply(this, arguments); - spec.pend(); - return spec; - }; - - this.fit = function(){ - var spec = this.it.apply(this, arguments); - - focusedRunnables.push(spec.id); - unfocusAncestor(); - return spec; - }; - - this.expect = function(actual) { - if (!currentRunnable()) { - throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out'); - } - - return currentRunnable().expect(actual); - }; - - this.beforeEach = function(beforeEachFunction, timeout) { - currentDeclarationSuite.beforeEach({ - fn: beforeEachFunction, - timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } - }); - }; - - this.beforeAll = function(beforeAllFunction, timeout) { - currentDeclarationSuite.beforeAll({ - fn: beforeAllFunction, - timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } - }); - }; - - this.afterEach = function(afterEachFunction, timeout) { - currentDeclarationSuite.afterEach({ - fn: afterEachFunction, - timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } - }); - }; - - this.afterAll = function(afterAllFunction, timeout) { - currentDeclarationSuite.afterAll({ - fn: afterAllFunction, - timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } - }); - }; - - this.pending = function(message) { - var fullMessage = j$.Spec.pendingSpecExceptionMessage; - if(message) { - fullMessage += message; - } - throw fullMessage; - }; - - this.fail = function(error) { - var message = 'Failed'; - if (error) { - message += ': '; - message += error.message || error; - } - - currentRunnable().addExpectationResult(false, { - matcherName: '', - passed: false, - expected: '', - actual: '', - message: message, - error: error && error.message ? error : null - }); - }; - } - - return Env; -}; - -getJasmineRequireObj().JsApiReporter = function() { - - var noopTimer = { - start: function(){}, - elapsed: function(){ return 0; } - }; - - function JsApiReporter(options) { - var timer = options.timer || noopTimer, - status = 'loaded'; - - this.started = false; - this.finished = false; - - this.jasmineStarted = function() { - this.started = true; - status = 'started'; - timer.start(); - }; - - var executionTime; - - this.jasmineDone = function() { - this.finished = true; - executionTime = timer.elapsed(); - status = 'done'; - }; - - this.status = function() { - return status; - }; - - var suites = [], - suites_hash = {}; - - this.suiteStarted = function(result) { - suites_hash[result.id] = result; - }; - - this.suiteDone = function(result) { - storeSuite(result); - }; - - this.suiteResults = function(index, length) { - return suites.slice(index, index + length); - }; - - function storeSuite(result) { - suites.push(result); - suites_hash[result.id] = result; - } - - this.suites = function() { - return suites_hash; - }; - - var specs = []; - - this.specDone = function(result) { - specs.push(result); - }; - - this.specResults = function(index, length) { - return specs.slice(index, index + length); - }; - - this.specs = function() { - return specs; - }; - - this.executionTime = function() { - return executionTime; - }; - - } - - return JsApiReporter; -}; - -getJasmineRequireObj().CallTracker = function() { - - function CallTracker() { - var calls = []; - - this.track = function(context) { - calls.push(context); - }; - - this.any = function() { - return !!calls.length; - }; - - this.count = function() { - return calls.length; - }; - - this.argsFor = function(index) { - var call = calls[index]; - return call ? call.args : []; - }; - - this.all = function() { - return calls; - }; - - this.allArgs = function() { - var callArgs = []; - for(var i = 0; i < calls.length; i++){ - callArgs.push(calls[i].args); - } - - return callArgs; - }; - - this.first = function() { - return calls[0]; - }; - - this.mostRecent = function() { - return calls[calls.length - 1]; - }; - - this.reset = function() { - calls = []; - }; - } - - return CallTracker; -}; - -getJasmineRequireObj().Clock = function() { - function Clock(global, delayedFunctionSchedulerFactory, mockDate) { - var self = this, - realTimingFunctions = { - setTimeout: global.setTimeout, - clearTimeout: global.clearTimeout, - setInterval: global.setInterval, - clearInterval: global.clearInterval - }, - fakeTimingFunctions = { - setTimeout: setTimeout, - clearTimeout: clearTimeout, - setInterval: setInterval, - clearInterval: clearInterval - }, - installed = false, - delayedFunctionScheduler, - timer; - - - self.install = function() { - if(!originalTimingFunctionsIntact()) { - throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?'); - } - replace(global, fakeTimingFunctions); - timer = fakeTimingFunctions; - delayedFunctionScheduler = delayedFunctionSchedulerFactory(); - installed = true; - - return self; - }; - - self.uninstall = function() { - delayedFunctionScheduler = null; - mockDate.uninstall(); - replace(global, realTimingFunctions); - - timer = realTimingFunctions; - installed = false; - }; - - self.withMock = function(closure) { - this.install(); - try { - closure(); - } finally { - this.uninstall(); - } - }; - - self.mockDate = function(initialDate) { - mockDate.install(initialDate); - }; - - self.setTimeout = function(fn, delay, params) { - if (legacyIE()) { - if (arguments.length > 2) { - throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill'); - } - return timer.setTimeout(fn, delay); - } - return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]); - }; - - self.setInterval = function(fn, delay, params) { - if (legacyIE()) { - if (arguments.length > 2) { - throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill'); - } - return timer.setInterval(fn, delay); - } - return Function.prototype.apply.apply(timer.setInterval, [global, arguments]); - }; - - self.clearTimeout = function(id) { - return Function.prototype.call.apply(timer.clearTimeout, [global, id]); - }; - - self.clearInterval = function(id) { - return Function.prototype.call.apply(timer.clearInterval, [global, id]); - }; - - self.tick = function(millis) { - if (installed) { - mockDate.tick(millis); - delayedFunctionScheduler.tick(millis); - } else { - throw new Error('Mock clock is not installed, use jasmine.clock().install()'); - } - }; - - return self; - - function originalTimingFunctionsIntact() { - return global.setTimeout === realTimingFunctions.setTimeout && - global.clearTimeout === realTimingFunctions.clearTimeout && - global.setInterval === realTimingFunctions.setInterval && - global.clearInterval === realTimingFunctions.clearInterval; - } - - function legacyIE() { - //if these methods are polyfilled, apply will be present - return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply; - } - - function replace(dest, source) { - for (var prop in source) { - dest[prop] = source[prop]; - } - } - - function setTimeout(fn, delay) { - return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2)); - } - - function clearTimeout(id) { - return delayedFunctionScheduler.removeFunctionWithId(id); - } - - function setInterval(fn, interval) { - return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true); - } - - function clearInterval(id) { - return delayedFunctionScheduler.removeFunctionWithId(id); - } - - function argSlice(argsObj, n) { - return Array.prototype.slice.call(argsObj, n); - } - } - - return Clock; -}; - -getJasmineRequireObj().DelayedFunctionScheduler = function() { - function DelayedFunctionScheduler() { - var self = this; - var scheduledLookup = []; - var scheduledFunctions = {}; - var currentTime = 0; - var delayedFnCount = 0; - - self.tick = function(millis) { - millis = millis || 0; - var endTime = currentTime + millis; - - runScheduledFunctions(endTime); - currentTime = endTime; - }; - - self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) { - var f; - if (typeof(funcToCall) === 'string') { - /* jshint evil: true */ - f = function() { return eval(funcToCall); }; - /* jshint evil: false */ - } else { - f = funcToCall; - } - - millis = millis || 0; - timeoutKey = timeoutKey || ++delayedFnCount; - runAtMillis = runAtMillis || (currentTime + millis); - - var funcToSchedule = { - runAtMillis: runAtMillis, - funcToCall: f, - recurring: recurring, - params: params, - timeoutKey: timeoutKey, - millis: millis - }; - - if (runAtMillis in scheduledFunctions) { - scheduledFunctions[runAtMillis].push(funcToSchedule); - } else { - scheduledFunctions[runAtMillis] = [funcToSchedule]; - scheduledLookup.push(runAtMillis); - scheduledLookup.sort(function (a, b) { - return a - b; - }); - } - - return timeoutKey; - }; - - self.removeFunctionWithId = function(timeoutKey) { - for (var runAtMillis in scheduledFunctions) { - var funcs = scheduledFunctions[runAtMillis]; - var i = indexOfFirstToPass(funcs, function (func) { - return func.timeoutKey === timeoutKey; - }); - - if (i > -1) { - if (funcs.length === 1) { - delete scheduledFunctions[runAtMillis]; - deleteFromLookup(runAtMillis); - } else { - funcs.splice(i, 1); - } - - // intervals get rescheduled when executed, so there's never more - // than a single scheduled function with a given timeoutKey - break; - } - } - }; - - return self; - - function indexOfFirstToPass(array, testFn) { - var index = -1; - - for (var i = 0; i < array.length; ++i) { - if (testFn(array[i])) { - index = i; - break; - } - } - - return index; - } - - function deleteFromLookup(key) { - var value = Number(key); - var i = indexOfFirstToPass(scheduledLookup, function (millis) { - return millis === value; - }); - - if (i > -1) { - scheduledLookup.splice(i, 1); - } - } - - function reschedule(scheduledFn) { - self.scheduleFunction(scheduledFn.funcToCall, - scheduledFn.millis, - scheduledFn.params, - true, - scheduledFn.timeoutKey, - scheduledFn.runAtMillis + scheduledFn.millis); - } - - function forEachFunction(funcsToRun, callback) { - for (var i = 0; i < funcsToRun.length; ++i) { - callback(funcsToRun[i]); - } - } - - function runScheduledFunctions(endTime) { - if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) { - return; - } - - do { - currentTime = scheduledLookup.shift(); - - var funcsToRun = scheduledFunctions[currentTime]; - delete scheduledFunctions[currentTime]; - - forEachFunction(funcsToRun, function(funcToRun) { - if (funcToRun.recurring) { - reschedule(funcToRun); - } - }); - - forEachFunction(funcsToRun, function(funcToRun) { - funcToRun.funcToCall.apply(null, funcToRun.params || []); - }); - } while (scheduledLookup.length > 0 && - // checking first if we're out of time prevents setTimeout(0) - // scheduled in a funcToRun from forcing an extra iteration - currentTime !== endTime && - scheduledLookup[0] <= endTime); - } - } - - return DelayedFunctionScheduler; -}; - -getJasmineRequireObj().ExceptionFormatter = function() { - function ExceptionFormatter() { - this.message = function(error) { - var message = ''; - - if (error.name && error.message) { - message += error.name + ': ' + error.message; - } else { - message += error.toString() + ' thrown'; - } - - if (error.fileName || error.sourceURL) { - message += ' in ' + (error.fileName || error.sourceURL); - } - - if (error.line || error.lineNumber) { - message += ' (line ' + (error.line || error.lineNumber) + ')'; - } - - return message; - }; - - this.stack = function(error) { - return error ? error.stack : null; - }; - } - - return ExceptionFormatter; -}; - -getJasmineRequireObj().Expectation = function() { - - function Expectation(options) { - this.util = options.util || { buildFailureMessage: function() {} }; - this.customEqualityTesters = options.customEqualityTesters || []; - this.actual = options.actual; - this.addExpectationResult = options.addExpectationResult || function(){}; - this.isNot = options.isNot; - - var customMatchers = options.customMatchers || {}; - for (var matcherName in customMatchers) { - this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]); - } - } - - Expectation.prototype.wrapCompare = function(name, matcherFactory) { - return function() { - var args = Array.prototype.slice.call(arguments, 0), - expected = args.slice(0), - message = ''; - - args.unshift(this.actual); - - var matcher = matcherFactory(this.util, this.customEqualityTesters), - matcherCompare = matcher.compare; - - function defaultNegativeCompare() { - var result = matcher.compare.apply(null, args); - result.pass = !result.pass; - return result; - } - - if (this.isNot) { - matcherCompare = matcher.negativeCompare || defaultNegativeCompare; - } - - var result = matcherCompare.apply(null, args); - - if (!result.pass) { - if (!result.message) { - args.unshift(this.isNot); - args.unshift(name); - message = this.util.buildFailureMessage.apply(null, args); - } else { - if (Object.prototype.toString.apply(result.message) === '[object Function]') { - message = result.message(); - } else { - message = result.message; - } - } - } - - if (expected.length == 1) { - expected = expected[0]; - } - - // TODO: how many of these params are needed? - this.addExpectationResult( - result.pass, - { - matcherName: name, - passed: result.pass, - message: message, - actual: this.actual, - expected: expected // TODO: this may need to be arrayified/sliced - } - ); - }; - }; - - Expectation.addCoreMatchers = function(matchers) { - var prototype = Expectation.prototype; - for (var matcherName in matchers) { - var matcher = matchers[matcherName]; - prototype[matcherName] = prototype.wrapCompare(matcherName, matcher); - } - }; - - Expectation.Factory = function(options) { - options = options || {}; - - var expect = new Expectation(options); - - // TODO: this would be nice as its own Object - NegativeExpectation - // TODO: copy instead of mutate options - options.isNot = true; - expect.not = new Expectation(options); - - return expect; - }; - - return Expectation; -}; - -//TODO: expectation result may make more sense as a presentation of an expectation. -getJasmineRequireObj().buildExpectationResult = function() { - function buildExpectationResult(options) { - var messageFormatter = options.messageFormatter || function() {}, - stackFormatter = options.stackFormatter || function() {}; - - var result = { - matcherName: options.matcherName, - message: message(), - stack: stack(), - passed: options.passed - }; - - if(!result.passed) { - result.expected = options.expected; - result.actual = options.actual; - } - - return result; - - function message() { - if (options.passed) { - return 'Passed.'; - } else if (options.message) { - return options.message; - } else if (options.error) { - return messageFormatter(options.error); - } - return ''; - } - - function stack() { - if (options.passed) { - return ''; - } - - var error = options.error; - if (!error) { - try { - throw new Error(message()); - } catch (e) { - error = e; - } - } - return stackFormatter(error); - } - } - - return buildExpectationResult; -}; - -getJasmineRequireObj().MockDate = function() { - function MockDate(global) { - var self = this; - var currentTime = 0; - - if (!global || !global.Date) { - self.install = function() {}; - self.tick = function() {}; - self.uninstall = function() {}; - return self; - } - - var GlobalDate = global.Date; - - self.install = function(mockDate) { - if (mockDate instanceof GlobalDate) { - currentTime = mockDate.getTime(); - } else { - currentTime = new GlobalDate().getTime(); - } - - global.Date = FakeDate; - }; - - self.tick = function(millis) { - millis = millis || 0; - currentTime = currentTime + millis; - }; - - self.uninstall = function() { - currentTime = 0; - global.Date = GlobalDate; - }; - - createDateProperties(); - - return self; - - function FakeDate() { - switch(arguments.length) { - case 0: - return new GlobalDate(currentTime); - case 1: - return new GlobalDate(arguments[0]); - case 2: - return new GlobalDate(arguments[0], arguments[1]); - case 3: - return new GlobalDate(arguments[0], arguments[1], arguments[2]); - case 4: - return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]); - case 5: - return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4]); - case 6: - return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5]); - default: - return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6]); - } - } - - function createDateProperties() { - FakeDate.prototype = GlobalDate.prototype; - - FakeDate.now = function() { - if (GlobalDate.now) { - return currentTime; - } else { - throw new Error('Browser does not support Date.now()'); - } - }; - - FakeDate.toSource = GlobalDate.toSource; - FakeDate.toString = GlobalDate.toString; - FakeDate.parse = GlobalDate.parse; - FakeDate.UTC = GlobalDate.UTC; - } - } - - return MockDate; -}; - -getJasmineRequireObj().pp = function(j$) { - - function PrettyPrinter() { - this.ppNestLevel_ = 0; - this.seen = []; - } - - PrettyPrinter.prototype.format = function(value) { - this.ppNestLevel_++; - try { - if (j$.util.isUndefined(value)) { - this.emitScalar('undefined'); - } else if (value === null) { - this.emitScalar('null'); - } else if (value === 0 && 1/value === -Infinity) { - this.emitScalar('-0'); - } else if (value === j$.getGlobal()) { - this.emitScalar('<global>'); - } else if (value.jasmineToString) { - this.emitScalar(value.jasmineToString()); - } else if (typeof value === 'string') { - this.emitString(value); - } else if (j$.isSpy(value)) { - this.emitScalar('spy on ' + value.and.identity()); - } else if (value instanceof RegExp) { - this.emitScalar(value.toString()); - } else if (typeof value === 'function') { - this.emitScalar('Function'); - } else if (typeof value.nodeType === 'number') { - this.emitScalar('HTMLNode'); - } else if (value instanceof Date) { - this.emitScalar('Date(' + value + ')'); - } else if (j$.util.arrayContains(this.seen, value)) { - this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>'); - } else if (j$.isArray_(value) || j$.isA_('Object', value)) { - this.seen.push(value); - if (j$.isArray_(value)) { - this.emitArray(value); - } else { - this.emitObject(value); - } - this.seen.pop(); - } else { - this.emitScalar(value.toString()); - } - } finally { - this.ppNestLevel_--; - } - }; - - PrettyPrinter.prototype.iterateObject = function(obj, fn) { - for (var property in obj) { - if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; } - fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) && - obj.__lookupGetter__(property) !== null) : false); - } - }; - - PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_; - PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_; - PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_; - PrettyPrinter.prototype.emitString = j$.unimplementedMethod_; - - function StringPrettyPrinter() { - PrettyPrinter.call(this); - - this.string = ''; - } - - j$.util.inherit(StringPrettyPrinter, PrettyPrinter); - - StringPrettyPrinter.prototype.emitScalar = function(value) { - this.append(value); - }; - - StringPrettyPrinter.prototype.emitString = function(value) { - this.append('\'' + value + '\''); - }; - - StringPrettyPrinter.prototype.emitArray = function(array) { - if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { - this.append('Array'); - return; - } - var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); - this.append('[ '); - for (var i = 0; i < length; i++) { - if (i > 0) { - this.append(', '); - } - this.format(array[i]); - } - if(array.length > length){ - this.append(', ...'); - } - - var self = this; - var first = array.length === 0; - this.iterateObject(array, function(property, isGetter) { - if (property.match(/^\d+$/)) { - return; - } - - if (first) { - first = false; - } else { - self.append(', '); - } - - self.formatProperty(array, property, isGetter); - }); - - this.append(' ]'); - }; - - StringPrettyPrinter.prototype.emitObject = function(obj) { - var constructorName = obj.constructor ? j$.fnNameFor(obj.constructor) : 'null'; - this.append(constructorName); - - if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { - return; - } - - var self = this; - this.append('({ '); - var first = true; - - this.iterateObject(obj, function(property, isGetter) { - if (first) { - first = false; - } else { - self.append(', '); - } - - self.formatProperty(obj, property, isGetter); - }); - - this.append(' })'); - }; - - StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) { - this.append(property); - this.append(': '); - if (isGetter) { - this.append('<getter>'); - } else { - this.format(obj[property]); - } - }; - - StringPrettyPrinter.prototype.append = function(value) { - this.string += value; - }; - - return function(value) { - var stringPrettyPrinter = new StringPrettyPrinter(); - stringPrettyPrinter.format(value); - return stringPrettyPrinter.string; - }; -}; - -getJasmineRequireObj().QueueRunner = function(j$) { - - function once(fn) { - var called = false; - return function() { - if (!called) { - called = true; - fn(); - } - }; - } - - function QueueRunner(attrs) { - this.queueableFns = attrs.queueableFns || []; - this.onComplete = attrs.onComplete || function() {}; - this.clearStack = attrs.clearStack || function(fn) {fn();}; - this.onException = attrs.onException || function() {}; - this.catchException = attrs.catchException || function() { return true; }; - this.userContext = attrs.userContext || {}; - this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; - this.fail = attrs.fail || function() {}; - } - - QueueRunner.prototype.execute = function() { - this.run(this.queueableFns, 0); - }; - - QueueRunner.prototype.run = function(queueableFns, recursiveIndex) { - var length = queueableFns.length, - self = this, - iterativeIndex; - - - for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { - var queueableFn = queueableFns[iterativeIndex]; - if (queueableFn.fn.length > 0) { - attemptAsync(queueableFn); - return; - } else { - attemptSync(queueableFn); - } - } - - var runnerDone = iterativeIndex >= length; - - if (runnerDone) { - this.clearStack(this.onComplete); - } - - function attemptSync(queueableFn) { - try { - queueableFn.fn.call(self.userContext); - } catch (e) { - handleException(e, queueableFn); - } - } - - function attemptAsync(queueableFn) { - var clearTimeout = function () { - Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]); - }, - next = once(function () { - clearTimeout(timeoutId); - self.run(queueableFns, iterativeIndex + 1); - }), - timeoutId; - - next.fail = function() { - self.fail.apply(null, arguments); - next(); - }; - - if (queueableFn.timeout) { - timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() { - var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); - onException(error, queueableFn); - next(); - }, queueableFn.timeout()]]); - } - - try { - queueableFn.fn.call(self.userContext, next); - } catch (e) { - handleException(e, queueableFn); - next(); - } - } - - function onException(e, queueableFn) { - self.onException(e); - } - - function handleException(e, queueableFn) { - onException(e, queueableFn); - if (!self.catchException(e)) { - //TODO: set a var when we catch an exception and - //use a finally block to close the loop in a nice way.. - throw e; - } - } - }; - - return QueueRunner; -}; - -getJasmineRequireObj().ReportDispatcher = function() { - function ReportDispatcher(methods) { - - var dispatchedMethods = methods || []; - - for (var i = 0; i < dispatchedMethods.length; i++) { - var method = dispatchedMethods[i]; - this[method] = (function(m) { - return function() { - dispatch(m, arguments); - }; - }(method)); - } - - var reporters = []; - - this.addReporter = function(reporter) { - reporters.push(reporter); - }; - - return this; - - function dispatch(method, args) { - for (var i = 0; i < reporters.length; i++) { - var reporter = reporters[i]; - if (reporter[method]) { - reporter[method].apply(reporter, args); - } - } - } - } - - return ReportDispatcher; -}; - - -getJasmineRequireObj().SpyRegistry = function(j$) { - - function SpyRegistry(options) { - options = options || {}; - var currentSpies = options.currentSpies || function() { return []; }; - - this.spyOn = function(obj, methodName) { - if (j$.util.isUndefined(obj)) { - throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()'); - } - - if (j$.util.isUndefined(methodName)) { - throw new Error('No method name supplied'); - } - - if (j$.util.isUndefined(obj[methodName])) { - throw new Error(methodName + '() method does not exist'); - } - - if (obj[methodName] && j$.isSpy(obj[methodName])) { - //TODO?: should this return the current spy? Downside: may cause user confusion about spy state - throw new Error(methodName + ' has already been spied upon'); - } - - var spy = j$.createSpy(methodName, obj[methodName]); - - currentSpies().push({ - spy: spy, - baseObj: obj, - methodName: methodName, - originalValue: obj[methodName] - }); - - obj[methodName] = spy; - - return spy; - }; - - this.clearSpies = function() { - var spies = currentSpies(); - for (var i = 0; i < spies.length; i++) { - var spyEntry = spies[i]; - spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue; - } - }; - } - - return SpyRegistry; -}; - -getJasmineRequireObj().SpyStrategy = function() { - - function SpyStrategy(options) { - options = options || {}; - - var identity = options.name || 'unknown', - originalFn = options.fn || function() {}, - getSpy = options.getSpy || function() {}, - plan = function() {}; - - this.identity = function() { - return identity; - }; - - this.exec = function() { - return plan.apply(this, arguments); - }; - - this.callThrough = function() { - plan = originalFn; - return getSpy(); - }; - - this.returnValue = function(value) { - plan = function() { - return value; - }; - return getSpy(); - }; - - this.returnValues = function() { - var values = Array.prototype.slice.call(arguments); - plan = function () { - return values.shift(); - }; - return getSpy(); - }; - - this.throwError = function(something) { - var error = (something instanceof Error) ? something : new Error(something); - plan = function() { - throw error; - }; - return getSpy(); - }; - - this.callFake = function(fn) { - plan = fn; - return getSpy(); - }; - - this.stub = function(fn) { - plan = function() {}; - return getSpy(); - }; - } - - return SpyStrategy; -}; - -getJasmineRequireObj().Suite = function(j$) { - function Suite(attrs) { - this.env = attrs.env; - this.id = attrs.id; - this.parentSuite = attrs.parentSuite; - this.description = attrs.description; - this.expectationFactory = attrs.expectationFactory; - this.expectationResultFactory = attrs.expectationResultFactory; - this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; - - this.beforeFns = []; - this.afterFns = []; - this.beforeAllFns = []; - this.afterAllFns = []; - this.disabled = false; - - this.children = []; - - this.result = { - id: this.id, - description: this.description, - fullName: this.getFullName(), - failedExpectations: [] - }; - } - - Suite.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Suite.prototype.getFullName = function() { - var fullName = this.description; - for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { - if (parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; - } - } - return fullName; - }; - - Suite.prototype.disable = function() { - this.disabled = true; - }; - - Suite.prototype.beforeEach = function(fn) { - this.beforeFns.unshift(fn); - }; - - Suite.prototype.beforeAll = function(fn) { - this.beforeAllFns.push(fn); - }; - - Suite.prototype.afterEach = function(fn) { - this.afterFns.unshift(fn); - }; - - Suite.prototype.afterAll = function(fn) { - this.afterAllFns.push(fn); - }; - - Suite.prototype.addChild = function(child) { - this.children.push(child); - }; - - Suite.prototype.status = function() { - if (this.disabled) { - return 'disabled'; - } - - if (this.result.failedExpectations.length > 0) { - return 'failed'; - } else { - return 'finished'; - } - }; - - Suite.prototype.isExecutable = function() { - return !this.disabled; - }; - - Suite.prototype.canBeReentered = function() { - return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0; - }; - - Suite.prototype.getResult = function() { - this.result.status = this.status(); - return this.result; - }; - - Suite.prototype.sharedUserContext = function() { - if (!this.sharedContext) { - this.sharedContext = this.parentSuite ? clone(this.parentSuite.sharedUserContext()) : {}; - } - - return this.sharedContext; - }; - - Suite.prototype.clonedSharedUserContext = function() { - return clone(this.sharedUserContext()); - }; - - Suite.prototype.onException = function() { - if (arguments[0] instanceof j$.errors.ExpectationFailed) { - return; - } - - if(isAfterAll(this.children)) { - var data = { - matcherName: '', - passed: false, - expected: '', - actual: '', - error: arguments[0] - }; - this.result.failedExpectations.push(this.expectationResultFactory(data)); - } else { - for (var i = 0; i < this.children.length; i++) { - var child = this.children[i]; - child.onException.apply(child, arguments); - } - } - }; - - Suite.prototype.addExpectationResult = function () { - if(isAfterAll(this.children) && isFailure(arguments)){ - var data = arguments[1]; - this.result.failedExpectations.push(this.expectationResultFactory(data)); - if(this.throwOnExpectationFailure) { - throw new j$.errors.ExpectationFailed(); - } - } else { - for (var i = 0; i < this.children.length; i++) { - var child = this.children[i]; - try { - child.addExpectationResult.apply(child, arguments); - } catch(e) { - // keep going - } - } - } - }; - - function isAfterAll(children) { - return children && children[0].result.status; - } - - function isFailure(args) { - return !args[0]; - } - - function clone(obj) { - var clonedObj = {}; - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - clonedObj[prop] = obj[prop]; - } - } - - return clonedObj; - } - - return Suite; -}; - -if (typeof window == void 0 && typeof exports == 'object') { - exports.Suite = jasmineRequire.Suite; -} - -getJasmineRequireObj().Timer = function() { - var defaultNow = (function(Date) { - return function() { return new Date().getTime(); }; - })(Date); - - function Timer(options) { - options = options || {}; - - var now = options.now || defaultNow, - startTime; - - this.start = function() { - startTime = now(); - }; - - this.elapsed = function() { - return now() - startTime; - }; - } - - return Timer; -}; - -getJasmineRequireObj().TreeProcessor = function() { - function TreeProcessor(attrs) { - var tree = attrs.tree, - runnableIds = attrs.runnableIds, - queueRunnerFactory = attrs.queueRunnerFactory, - nodeStart = attrs.nodeStart || function() {}, - nodeComplete = attrs.nodeComplete || function() {}, - stats = { valid: true }, - processed = false, - defaultMin = Infinity, - defaultMax = 1 - Infinity; - - this.processTree = function() { - processNode(tree, false); - processed = true; - return stats; - }; - - this.execute = function(done) { - if (!processed) { - this.processTree(); - } - - if (!stats.valid) { - throw 'invalid order'; - } - - var childFns = wrapChildren(tree, 0); - - queueRunnerFactory({ - queueableFns: childFns, - userContext: tree.sharedUserContext(), - onException: function() { - tree.onException.apply(tree, arguments); - }, - onComplete: done - }); - }; - - function runnableIndex(id) { - for (var i = 0; i < runnableIds.length; i++) { - if (runnableIds[i] === id) { - return i; - } - } - } - - function processNode(node, parentEnabled) { - var executableIndex = runnableIndex(node.id); - - if (executableIndex !== undefined) { - parentEnabled = true; - } - - parentEnabled = parentEnabled && node.isExecutable(); - - if (!node.children) { - stats[node.id] = { - executable: parentEnabled && node.isExecutable(), - segments: [{ - index: 0, - owner: node, - nodes: [node], - min: startingMin(executableIndex), - max: startingMax(executableIndex) - }] - }; - } else { - var hasExecutableChild = false; - - for (var i = 0; i < node.children.length; i++) { - var child = node.children[i]; - - processNode(child, parentEnabled); - - if (!stats.valid) { - return; - } - - var childStats = stats[child.id]; - - hasExecutableChild = hasExecutableChild || childStats.executable; - } - - stats[node.id] = { - executable: hasExecutableChild - }; - - segmentChildren(node, stats[node.id], executableIndex); - - if (!node.canBeReentered() && stats[node.id].segments.length > 1) { - stats = { valid: false }; - } - } - } - - function startingMin(executableIndex) { - return executableIndex === undefined ? defaultMin : executableIndex; - } - - function startingMax(executableIndex) { - return executableIndex === undefined ? defaultMax : executableIndex; - } - - function segmentChildren(node, nodeStats, executableIndex) { - var currentSegment = { index: 0, owner: node, nodes: [], min: startingMin(executableIndex), max: startingMax(executableIndex) }, - result = [currentSegment], - lastMax = defaultMax, - orderedChildSegments = orderChildSegments(node.children); - - function isSegmentBoundary(minIndex) { - return lastMax !== defaultMax && minIndex !== defaultMin && lastMax < minIndex - 1; - } - - for (var i = 0; i < orderedChildSegments.length; i++) { - var childSegment = orderedChildSegments[i], - maxIndex = childSegment.max, - minIndex = childSegment.min; - - if (isSegmentBoundary(minIndex)) { - currentSegment = {index: result.length, owner: node, nodes: [], min: defaultMin, max: defaultMax}; - result.push(currentSegment); - } - - currentSegment.nodes.push(childSegment); - currentSegment.min = Math.min(currentSegment.min, minIndex); - currentSegment.max = Math.max(currentSegment.max, maxIndex); - lastMax = maxIndex; - } - - nodeStats.segments = result; - } - - function orderChildSegments(children) { - var specifiedOrder = [], - unspecifiedOrder = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i], - segments = stats[child.id].segments; - - for (var j = 0; j < segments.length; j++) { - var seg = segments[j]; - - if (seg.min === defaultMin) { - unspecifiedOrder.push(seg); - } else { - specifiedOrder.push(seg); - } - } - } - - specifiedOrder.sort(function(a, b) { - return a.min - b.min; - }); - - return specifiedOrder.concat(unspecifiedOrder); - } - - function executeNode(node, segmentNumber) { - if (node.children) { - return { - fn: function(done) { - nodeStart(node); - - queueRunnerFactory({ - onComplete: function() { - nodeComplete(node, node.getResult()); - done(); - }, - queueableFns: wrapChildren(node, segmentNumber), - userContext: node.sharedUserContext(), - onException: function() { - node.onException.apply(node, arguments); - } - }); - } - }; - } else { - return { - fn: function(done) { node.execute(done, stats[node.id].executable); } - }; - } - } - - function wrapChildren(node, segmentNumber) { - var result = [], - segmentChildren = stats[node.id].segments[segmentNumber].nodes; - - for (var i = 0; i < segmentChildren.length; i++) { - result.push(executeNode(segmentChildren[i].owner, segmentChildren[i].index)); - } - - if (!stats[node.id].executable) { - return result; - } - - return node.beforeAllFns.concat(result).concat(node.afterAllFns); - } - } - - return TreeProcessor; -}; - -getJasmineRequireObj().Any = function(j$) { - - function Any(expectedObject) { - this.expectedObject = expectedObject; - } - - Any.prototype.asymmetricMatch = function(other) { - if (this.expectedObject == String) { - return typeof other == 'string' || other instanceof String; - } - - if (this.expectedObject == Number) { - return typeof other == 'number' || other instanceof Number; - } - - if (this.expectedObject == Function) { - return typeof other == 'function' || other instanceof Function; - } - - if (this.expectedObject == Object) { - return typeof other == 'object'; - } - - if (this.expectedObject == Boolean) { - return typeof other == 'boolean'; - } - - return other instanceof this.expectedObject; - }; - - Any.prototype.jasmineToString = function() { - return '<jasmine.any(' + j$.fnNameFor(this.expectedObject) + ')>'; - }; - - return Any; -}; - -getJasmineRequireObj().Anything = function(j$) { - - function Anything() {} - - Anything.prototype.asymmetricMatch = function(other) { - return !j$.util.isUndefined(other) && other !== null; - }; - - Anything.prototype.jasmineToString = function() { - return '<jasmine.anything>'; - }; - - return Anything; -}; - -getJasmineRequireObj().ArrayContaining = function(j$) { - function ArrayContaining(sample) { - this.sample = sample; - } - - ArrayContaining.prototype.asymmetricMatch = function(other) { - var className = Object.prototype.toString.call(this.sample); - if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); } - - for (var i = 0; i < this.sample.length; i++) { - var item = this.sample[i]; - if (!j$.matchersUtil.contains(other, item)) { - return false; - } - } - - return true; - }; - - ArrayContaining.prototype.jasmineToString = function () { - return '<jasmine.arrayContaining(' + jasmine.pp(this.sample) +')>'; - }; - - return ArrayContaining; -}; - -getJasmineRequireObj().ObjectContaining = function(j$) { - - function ObjectContaining(sample) { - this.sample = sample; - } - - function getPrototype(obj) { - if (Object.getPrototypeOf) { - return Object.getPrototypeOf(obj); - } - - if (obj.constructor.prototype == obj) { - return null; - } - - return obj.constructor.prototype; - } - - function hasProperty(obj, property) { - if (!obj) { - return false; - } - - if (Object.prototype.hasOwnProperty.call(obj, property)) { - return true; - } - - return hasProperty(getPrototype(obj), property); - } - - ObjectContaining.prototype.asymmetricMatch = function(other) { - if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); } - - for (var property in this.sample) { - if (!hasProperty(other, property) || - !j$.matchersUtil.equals(this.sample[property], other[property])) { - return false; - } - } - - return true; - }; - - ObjectContaining.prototype.jasmineToString = function() { - return '<jasmine.objectContaining(' + j$.pp(this.sample) + ')>'; - }; - - return ObjectContaining; -}; - -getJasmineRequireObj().StringMatching = function(j$) { - - function StringMatching(expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { - throw new Error('Expected is not a String or a RegExp'); - } - - this.regexp = new RegExp(expected); - } - - StringMatching.prototype.asymmetricMatch = function(other) { - return this.regexp.test(other); - }; - - StringMatching.prototype.jasmineToString = function() { - return '<jasmine.stringMatching(' + this.regexp + ')>'; - }; - - return StringMatching; -}; - -getJasmineRequireObj().errors = function() { - function ExpectationFailed() {} - - ExpectationFailed.prototype = new Error(); - ExpectationFailed.prototype.constructor = ExpectationFailed; - - return { - ExpectationFailed: ExpectationFailed - }; -}; -getJasmineRequireObj().matchersUtil = function(j$) { - // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? - - return { - equals: function(a, b, customTesters) { - customTesters = customTesters || []; - - return eq(a, b, [], [], customTesters); - }, - - contains: function(haystack, needle, customTesters) { - customTesters = customTesters || []; - - if ((Object.prototype.toString.apply(haystack) === '[object Array]') || - (!!haystack && !haystack.indexOf)) - { - for (var i = 0; i < haystack.length; i++) { - if (eq(haystack[i], needle, [], [], customTesters)) { - return true; - } - } - return false; - } - - return !!haystack && haystack.indexOf(needle) >= 0; - }, - - buildFailureMessage: function() { - var args = Array.prototype.slice.call(arguments, 0), - matcherName = args[0], - isNot = args[1], - actual = args[2], - expected = args.slice(3), - englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); - - var message = 'Expected ' + - j$.pp(actual) + - (isNot ? ' not ' : ' ') + - englishyPredicate; - - if (expected.length > 0) { - for (var i = 0; i < expected.length; i++) { - if (i > 0) { - message += ','; - } - message += ' ' + j$.pp(expected[i]); - } - } - - return message + '.'; - } - }; - - function isAsymmetric(obj) { - return obj && j$.isA_('Function', obj.asymmetricMatch); - } - - function asymmetricMatch(a, b) { - var asymmetricA = isAsymmetric(a), - asymmetricB = isAsymmetric(b); - - if (asymmetricA && asymmetricB) { - return undefined; - } - - if (asymmetricA) { - return a.asymmetricMatch(b); - } - - if (asymmetricB) { - return b.asymmetricMatch(a); - } - } - - // Equality function lovingly adapted from isEqual in - // [Underscore](http://underscorejs.org) - function eq(a, b, aStack, bStack, customTesters) { - var result = true; - - var asymmetricResult = asymmetricMatch(a, b); - if (!j$.util.isUndefined(asymmetricResult)) { - return asymmetricResult; - } - - for (var i = 0; i < customTesters.length; i++) { - var customTesterResult = customTesters[i](a, b); - if (!j$.util.isUndefined(customTesterResult)) { - return customTesterResult; - } - } - - if (a instanceof Error && b instanceof Error) { - return a.message == b.message; - } - - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) { return a !== 0 || 1 / a == 1 / b; } - // A strict comparison is necessary because `null == undefined`. - if (a === null || b === null) { return a === b; } - var className = Object.prototype.toString.call(a); - if (className != Object.prototype.toString.call(b)) { return false; } - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') { return false; } - - var aIsDomNode = j$.isDomNode(a); - var bIsDomNode = j$.isDomNode(b); - if (aIsDomNode && bIsDomNode) { - // At first try to use DOM3 method isEqualNode - if (a.isEqualNode) { - return a.isEqualNode(b); - } - // IE8 doesn't support isEqualNode, try to use outerHTML && innerText - var aIsElement = a instanceof Element; - var bIsElement = b instanceof Element; - if (aIsElement && bIsElement) { - return a.outerHTML == b.outerHTML; - } - if (aIsElement || bIsElement) { - return false; - } - return a.innerText == b.innerText && a.textContent == b.textContent; - } - if (aIsDomNode || bIsDomNode) { - return false; - } - - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) { return bStack[length] == b; } - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0; - // Recursively compare objects and arrays. - // Compare array lengths to determine if a deep comparison is necessary. - if (className == '[object Array]' && a.length !== b.length) { - result = false; - } - - if (result) { - // Objects with different constructors are not equivalent, but `Object`s - // or `Array`s from different frames are. - if (className !== '[object Array]') { - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && - isFunction(bCtor) && bCtor instanceof bCtor)) { - return false; - } - } - // Deep compare objects. - for (var key in a) { - if (has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; } - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (has(b, key) && !(size--)) { break; } - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - - return result; - - function has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } - - function isFunction(obj) { - return typeof obj === 'function'; - } - } -}; - -getJasmineRequireObj().toBe = function() { - function toBe() { - return { - compare: function(actual, expected) { - return { - pass: actual === expected - }; - } - }; - } - - return toBe; -}; - -getJasmineRequireObj().toBeCloseTo = function() { - - function toBeCloseTo() { - return { - compare: function(actual, expected, precision) { - if (precision !== 0) { - precision = precision || 2; - } - - return { - pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2) - }; - } - }; - } - - return toBeCloseTo; -}; - -getJasmineRequireObj().toBeDefined = function() { - function toBeDefined() { - return { - compare: function(actual) { - return { - pass: (void 0 !== actual) - }; - } - }; - } - - return toBeDefined; -}; - -getJasmineRequireObj().toBeFalsy = function() { - function toBeFalsy() { - return { - compare: function(actual) { - return { - pass: !!!actual - }; - } - }; - } - - return toBeFalsy; -}; - -getJasmineRequireObj().toBeGreaterThan = function() { - - function toBeGreaterThan() { - return { - compare: function(actual, expected) { - return { - pass: actual > expected - }; - } - }; - } - - return toBeGreaterThan; -}; - - -getJasmineRequireObj().toBeLessThan = function() { - function toBeLessThan() { - return { - - compare: function(actual, expected) { - return { - pass: actual < expected - }; - } - }; - } - - return toBeLessThan; -}; -getJasmineRequireObj().toBeNaN = function(j$) { - - function toBeNaN() { - return { - compare: function(actual) { - var result = { - pass: (actual !== actual) - }; - - if (result.pass) { - result.message = 'Expected actual not to be NaN.'; - } else { - result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; }; - } - - return result; - } - }; - } - - return toBeNaN; -}; - -getJasmineRequireObj().toBeNull = function() { - - function toBeNull() { - return { - compare: function(actual) { - return { - pass: actual === null - }; - } - }; - } - - return toBeNull; -}; - -getJasmineRequireObj().toBeTruthy = function() { - - function toBeTruthy() { - return { - compare: function(actual) { - return { - pass: !!actual - }; - } - }; - } - - return toBeTruthy; -}; - -getJasmineRequireObj().toBeUndefined = function() { - - function toBeUndefined() { - return { - compare: function(actual) { - return { - pass: void 0 === actual - }; - } - }; - } - - return toBeUndefined; -}; - -getJasmineRequireObj().toContain = function() { - function toContain(util, customEqualityTesters) { - customEqualityTesters = customEqualityTesters || []; - - return { - compare: function(actual, expected) { - - return { - pass: util.contains(actual, expected, customEqualityTesters) - }; - } - }; - } - - return toContain; -}; - -getJasmineRequireObj().toEqual = function() { - - function toEqual(util, customEqualityTesters) { - customEqualityTesters = customEqualityTesters || []; - - return { - compare: function(actual, expected) { - var result = { - pass: false - }; - - result.pass = util.equals(actual, expected, customEqualityTesters); - - return result; - } - }; - } - - return toEqual; -}; - -getJasmineRequireObj().toHaveBeenCalled = function(j$) { - - function toHaveBeenCalled() { - return { - compare: function(actual) { - var result = {}; - - if (!j$.isSpy(actual)) { - throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); - } - - if (arguments.length > 1) { - throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); - } - - result.pass = actual.calls.any(); - - result.message = result.pass ? - 'Expected spy ' + actual.and.identity() + ' not to have been called.' : - 'Expected spy ' + actual.and.identity() + ' to have been called.'; - - return result; - } - }; - } - - return toHaveBeenCalled; -}; - -getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - - function toHaveBeenCalledWith(util, customEqualityTesters) { - return { - compare: function() { - var args = Array.prototype.slice.call(arguments, 0), - actual = args[0], - expectedArgs = args.slice(1), - result = { pass: false }; - - if (!j$.isSpy(actual)) { - throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); - } - - if (!actual.calls.any()) { - result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; }; - return result; - } - - if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) { - result.pass = true; - result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; }; - } else { - result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; }; - } - - return result; - } - }; - } - - return toHaveBeenCalledWith; -}; - -getJasmineRequireObj().toMatch = function(j$) { - - function toMatch() { - return { - compare: function(actual, expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { - throw new Error('Expected is not a String or a RegExp'); - } - - var regexp = new RegExp(expected); - - return { - pass: regexp.test(actual) - }; - } - }; - } - - return toMatch; -}; - -getJasmineRequireObj().toThrow = function(j$) { - - function toThrow(util) { - return { - compare: function(actual, expected) { - var result = { pass: false }, - threw = false, - thrown; - - if (typeof actual != 'function') { - throw new Error('Actual is not a Function'); - } - - try { - actual(); - } catch (e) { - threw = true; - thrown = e; - } - - if (!threw) { - result.message = 'Expected function to throw an exception.'; - return result; - } - - if (arguments.length == 1) { - result.pass = true; - result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; }; - - return result; - } - - if (util.equals(thrown, expected)) { - result.pass = true; - result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; }; - } else { - result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; }; - } - - return result; - } - }; - } - - return toThrow; -}; - -getJasmineRequireObj().toThrowError = function(j$) { - function toThrowError (util) { - return { - compare: function(actual) { - var threw = false, - pass = {pass: true}, - fail = {pass: false}, - thrown; - - if (typeof actual != 'function') { - throw new Error('Actual is not a Function'); - } - - var errorMatcher = getMatcher.apply(null, arguments); - - try { - actual(); - } catch (e) { - threw = true; - thrown = e; - } - - if (!threw) { - fail.message = 'Expected function to throw an Error.'; - return fail; - } - - if (!(thrown instanceof Error)) { - fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; }; - return fail; - } - - if (errorMatcher.hasNoSpecifics()) { - pass.message = 'Expected function not to throw an Error, but it threw ' + j$.fnNameFor(thrown) + '.'; - return pass; - } - - if (errorMatcher.matches(thrown)) { - pass.message = function() { - return 'Expected function not to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + '.'; - }; - return pass; - } else { - fail.message = function() { - return 'Expected function to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + - ', but it threw ' + errorMatcher.thrownDescription(thrown) + '.'; - }; - return fail; - } - } - }; - - function getMatcher() { - var expected = null, - errorType = null; - - if (arguments.length == 2) { - expected = arguments[1]; - if (isAnErrorType(expected)) { - errorType = expected; - expected = null; - } - } else if (arguments.length > 2) { - errorType = arguments[1]; - expected = arguments[2]; - if (!isAnErrorType(errorType)) { - throw new Error('Expected error type is not an Error.'); - } - } - - if (expected && !isStringOrRegExp(expected)) { - if (errorType) { - throw new Error('Expected error message is not a string or RegExp.'); - } else { - throw new Error('Expected is not an Error, string, or RegExp.'); - } - } - - function messageMatch(message) { - if (typeof expected == 'string') { - return expected == message; - } else { - return expected.test(message); - } - } - - return { - errorTypeDescription: errorType ? j$.fnNameFor(errorType) : 'an exception', - thrownDescription: function(thrown) { - var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception', - thrownMessage = ''; - - if (expected) { - thrownMessage = ' with message ' + j$.pp(thrown.message); - } - - return thrownName + thrownMessage; - }, - messageDescription: function() { - if (expected === null) { - return ''; - } else if (expected instanceof RegExp) { - return ' with a message matching ' + j$.pp(expected); - } else { - return ' with message ' + j$.pp(expected); - } - }, - hasNoSpecifics: function() { - return expected === null && errorType === null; - }, - matches: function(error) { - return (errorType === null || error instanceof errorType) && - (expected === null || messageMatch(error.message)); - } - }; - } - - function isStringOrRegExp(potential) { - return potential instanceof RegExp || (typeof potential == 'string'); - } - - function isAnErrorType(type) { - if (typeof type !== 'function') { - return false; - } - - var Surrogate = function() {}; - Surrogate.prototype = type.prototype; - return (new Surrogate()) instanceof Error; - } - } - - return toThrowError; -}; - -getJasmineRequireObj().interface = function(jasmine, env) { - var jasmineInterface = { - describe: function(description, specDefinitions) { - return env.describe(description, specDefinitions); - }, - - xdescribe: function(description, specDefinitions) { - return env.xdescribe(description, specDefinitions); - }, - - fdescribe: function(description, specDefinitions) { - return env.fdescribe(description, specDefinitions); - }, - - it: function() { - return env.it.apply(env, arguments); - }, - - xit: function() { - return env.xit.apply(env, arguments); - }, - - fit: function() { - return env.fit.apply(env, arguments); - }, - - beforeEach: function() { - return env.beforeEach.apply(env, arguments); - }, - - afterEach: function() { - return env.afterEach.apply(env, arguments); - }, - - beforeAll: function() { - return env.beforeAll.apply(env, arguments); - }, - - afterAll: function() { - return env.afterAll.apply(env, arguments); - }, - - expect: function(actual) { - return env.expect(actual); - }, - - pending: function() { - return env.pending.apply(env, arguments); - }, - - fail: function() { - return env.fail.apply(env, arguments); - }, - - spyOn: function(obj, methodName) { - return env.spyOn(obj, methodName); - }, - - jsApiReporter: new jasmine.JsApiReporter({ - timer: new jasmine.Timer() - }), - - jasmine: jasmine - }; - - jasmine.addCustomEqualityTester = function(tester) { - env.addCustomEqualityTester(tester); - }; - - jasmine.addMatchers = function(matchers) { - return env.addMatchers(matchers); - }; - - jasmine.clock = function() { - return env.clock; - }; - - return jasmineInterface; -}; - -getJasmineRequireObj().version = function() { - return '2.3.4'; -}; diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine_favicon.png b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine_favicon.png deleted file mode 100755 index 3b84583be4b9d5ae9cd5cae07b2dbaa5ebb0ad1c..0000000000000000000000000000000000000000 Binary files a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/jasmine_favicon.png and /dev/null differ diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/terminal.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/terminal.js deleted file mode 100755 index b9cf1a5e79c1bbdabe7a23ca12f76c19fe6779a5..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/lib/jasmine-2.3.4/terminal.js +++ /dev/null @@ -1,261 +0,0 @@ -(function(global) { - var UNDEFINED, - exportObject; - - if (typeof module !== "undefined" && module.exports) { - exportObject = exports; - } else { - exportObject = global.jasmineReporters = global.jasmineReporters || {}; - } - - function elapsed(start, end) { return (end - start)/1000; } - function isFailed(obj) { return obj.status === "failed"; } - function isSkipped(obj) { return obj.status === "pending"; } - function isDisabled(obj) { return obj.status === "disabled"; } - function extend(dupe, obj) { // performs a shallow copy of all props of `obj` onto `dupe` - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - dupe[prop] = obj[prop]; - } - } - return dupe; - } - function log(str) { - var con = global.console || console; - if (con && con.log && str && str.length) { - con.log(str); - } - } - - - /** - * Basic reporter that outputs spec results to the terminal. - * Use this reporter in your build pipeline. - * - * Usage: - * - * jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter(options); - * - * @param {object} [options] - * @param {number} [options.verbosity] meaningful values are 0 through 3; anything - * greater than 3 is treated as 3 (default: 2) - * @param {boolean} [options.color] print in color or not (default: true) - * @param {boolean} [opts.showStack] show stack trace for failed specs (default: false) - */ - var DEFAULT_VERBOSITY = 2, - ATTRIBUTES_TO_ANSI = { - "off": 0, - "bold": 1, - "red": 31, - "green": 32, - "yellow": 33, - "blue": 34, - "magenta": 35, - "cyan": 36 - }; - - exportObject.TerminalReporter = function(options) { - var self = this; - self.started = false; - self.finished = false; - - // sanitize arguments - options = options || {}; - self.verbosity = typeof options.verbosity === "number" ? options.verbosity : DEFAULT_VERBOSITY; - self.color = options.color; - self.showStack = options.showStack; - - var indent_string = ' ', - startTime, - currentSuite = null, - totalSpecsExecuted = 0, - totalSpecsSkipped = 0, - totalSpecsDisabled = 0, - totalSpecsFailed = 0, - totalSpecsDefined, - // when use use fit, jasmine never calls suiteStarted / suiteDone, so make a fake one to use - fakeFocusedSuite = { - id: 'focused', - description: 'focused specs', - fullName: 'focused specs' - }; - - var __suites = {}, __specs = {}; - function getSuite(suite) { - __suites[suite.id] = extend(__suites[suite.id] || {}, suite); - return __suites[suite.id]; - } - function getSpec(spec) { - __specs[spec.id] = extend(__specs[spec.id] || {}, spec); - return __specs[spec.id]; - } - - self.jasmineStarted = function(summary) { - totalSpecsDefined = summary && summary.totalSpecsDefined || NaN; - startTime = exportObject.startTime = new Date(); - self.started = true; - }; - self.suiteStarted = function(suite) { - suite = getSuite(suite); - suite._specs = 0; - suite._nestedSpecs = 0; - suite._failures = 0; - suite._nestedFailures = 0; - suite._skipped = 0; - suite._nestedSkipped = 0; - suite._disabled = 0; - suite._nestedDisabled = 0; - suite._depth = currentSuite ? currentSuite._depth+1 : 1; - suite._parent = currentSuite; - currentSuite = suite; - if (self.verbosity > 2) { - log(indentWithLevel(suite._depth, inColor(suite.description, "bold"))); - } - }; - self.specStarted = function(spec) { - if (!currentSuite) { - // focused spec (fit) -- suiteStarted was never called - self.suiteStarted(fakeFocusedSuite); - } - spec = getSpec(spec); - spec._suite = currentSuite; - spec._depth = currentSuite._depth+1; - currentSuite._specs++; - if (self.verbosity > 2) { - log(indentWithLevel(spec._depth, spec.description + ' ...')); - } - }; - self.specDone = function(spec) { - spec = getSpec(spec); - var failed = false, - skipped = false, - disabled = false, - color = 'green', - resultText = ''; - if (isSkipped(spec)) { - skipped = true; - color = ''; - spec._suite._skipped++; - totalSpecsSkipped++; - } - if (isFailed(spec)) { - failed = true; - color = 'red'; - spec._suite._failures++; - totalSpecsFailed++; - } - if (isDisabled(spec)) { - disabled = true; - color = 'yellow'; - spec._suite._disabled++; - totalSpecsDisabled++; - } - totalSpecsExecuted++; - - if (self.verbosity === 2) { - resultText = failed ? 'F' : skipped ? 'S' : disabled ? 'D' : '.'; - } else if (self.verbosity > 2) { - resultText = ' ' + (failed ? 'Failed' : skipped ? 'Skipped' : disabled ? 'Disabled' : 'Passed'); - } - log(inColor(resultText, color)); - - if (failed) { - if (self.verbosity === 1) { - log(spec.fullName); - } else if (self.verbosity === 2) { - log(' '); - log(indentWithLevel(spec._depth, spec.fullName)); - } - - for (var i = 0; i < spec.failedExpectations.length; i++) { - log(inColor(indentWithLevel(spec._depth, indent_string + spec.failedExpectations[i].message), color)); - if (self.showStack){ - logStackLines(spec._depth, spec.failedExpectations[i].stack.split('\n')); - } - } - } - }; - self.suiteDone = function(suite) { - suite = getSuite(suite); - if (suite._parent === UNDEFINED) { - // disabled suite (xdescribe) -- suiteStarted was never called - self.suiteStarted(suite); - } - if (suite._parent) { - suite._parent._specs += suite._specs + suite._nestedSpecs; - suite._parent._failures += suite._failures + suite._nestedFailures; - suite._parent._skipped += suite._skipped + suite._nestedSkipped; - suite._parent._disabled += suite._disabled + suite._nestedDisabled; - - } - currentSuite = suite._parent; - if (self.verbosity < 3) { - return; - } - - var total = suite._specs + suite._nestedSpecs, - failed = suite._failures + suite._nestedFailures, - skipped = suite._skipped + suite._nestedSkipped, - disabled = suite._disabled + suite._nestedDisabled, - passed = total - failed - skipped, - color = failed ? 'red+bold' : 'green+bold', - str = passed + ' of ' + total + ' passed (' + skipped + ' skipped, ' + disabled + ' disabled)'; - log(indentWithLevel(suite._depth, inColor(str+'.', color))); - }; - self.jasmineDone = function() { - if (currentSuite) { - // focused spec (fit) -- suiteDone was never called - self.suiteDone(fakeFocusedSuite); - } - var now = new Date(), - dur = elapsed(startTime, now), - total = totalSpecsDefined || totalSpecsExecuted, - disabled = total - totalSpecsExecuted + totalSpecsDisabled, - skipped = totalSpecsSkipped, - spec_str = total + (total === 1 ? " spec, " : " specs, "), - fail_str = totalSpecsFailed + (totalSpecsFailed === 1 ? " failure, " : " failures, "), - skip_str = skipped + " skipped, ", - disabled_str = disabled + " disabled in ", - summary_str = spec_str + fail_str + skip_str + disabled_str + dur + "s.", - result_str = (totalSpecsFailed && "FAILURE: " || "SUCCESS: ") + summary_str, - result_color = totalSpecsFailed && "red+bold" || "green+bold"; - - if (self.verbosity === 2) { - log(''); - } - - if (self.verbosity > 0) { - log(inColor(result_str, result_color)); - } - //log("Specs skipped but not reported (entire suite skipped or targeted to specific specs)", totalSpecsDefined - totalSpecsExecuted + totalSpecsDisabled); - - self.finished = true; - // this is so phantomjs-testrunner.js can tell if we're done executing - exportObject.endTime = now; - }; - function indentWithLevel(level, string) { - return new Array(level).join(indent_string) + string; - } - function logStackLines(depth, lines) { - lines.forEach(function(line){ - log(inColor(indentWithLevel(depth, indent_string + line), 'magenta')); - }); - } - function inColor(string, color) { - var color_attributes = color && color.split("+"), - ansi_string = "", - i; - - if (!self.color || !color_attributes) { - return string; - } - - for(i = 0; i < color_attributes.length; i++) { - ansi_string += "\033[" + ATTRIBUTES_TO_ANSI[color_attributes[i]] + "m"; - } - ansi_string += string + "\033[" + ATTRIBUTES_TO_ANSI["off"] + "m"; - - return ansi_string; - } - }; -})(this); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs-testrunner.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs-testrunner.js deleted file mode 100755 index c0f4c6a46c728de6ccaeca9c70964253dbd44154..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs-testrunner.js +++ /dev/null @@ -1,230 +0,0 @@ -/* globals jasmineRequire, phantom */ -// Verify arguments -var system = require('system'); -var args; - -if(phantom.args) { - args = phantom.args; -} else { - args = system.args.slice(1);//use system args for phantom 2.0+ -} - -if (args.length === 0) { - console.log("Simple JasmineBDD test runner for phantom.js"); - console.log("Usage: phantomjs-testrunner.js url_to_runner.html"); - console.log("Accepts http:// and file:// urls"); - console.log(""); - console.log("NOTE: This script depends on jasmine.HtmlReporter being used\non the page, for the DOM elements it creates.\n"); - phantom.exit(2); -} -else { - var fs = require("fs"), - pages = [], - page, address, resultsKey, i, l; - - - var setupPageFn = function(p, k) { - return function() { - overloadPageEvaluate(p); - setupWriteFileFunction(p, k, fs.separator); - }; - }; - - for (i = 0, l = args.length; i < l; i++) { - address = args[i]; - console.log("Loading " + address); - - // if provided a url without a protocol, try to use file:// - address = address.indexOf("://") === -1 ? "file://" + address : address; - - // create a WebPage object to work with - page = require("webpage").create(); - page.url = address; - - // When initialized, inject the reporting functions before the page is loaded - // (and thus before it will try to utilize the functions) - resultsKey = "__jr" + Math.ceil(Math.random() * 1000000); - page.onInitialized = setupPageFn(page, resultsKey); - page.open(address, processPage(null, page, resultsKey)); - pages.push(page); - - page.onConsoleMessage = logAndWorkAroundDefaultLineBreaking; - } - - // bail when all pages have been processed - setInterval(function(){ - var exit_code = 0; - for (i = 0, l = pages.length; i < l; i++) { - page = pages[i]; - if (page.__exit_code === null) { - // wait until later - return; - } - exit_code |= page.__exit_code; - } - phantom.exit(exit_code); - }, 100); -} - -// Thanks to hoisting, these helpers are still available when needed above -/** - * Logs a message. Does not add a line-break for single characters '.' and 'F' or lines ending in ' ...' - * - * @param msg - */ -function logAndWorkAroundDefaultLineBreaking(msg) { - var interpretAsWithoutNewline = /(^(\033\[\d+m)*[\.F](\033\[\d+m)*$)|( \.\.\.$)/; - if (navigator.userAgent.indexOf("Windows") < 0 && interpretAsWithoutNewline.test(msg)) { - try { - system.stdout.write(msg); - } catch (e) { - var fs = require('fs'); - fs.write('/dev/stdout', msg, 'w'); - } - } else { - console.log(msg); - } -} - -/** - * Stringifies the function, replacing any %placeholders% with mapped values. - * - * @param {function} fn The function to replace occurrences within. - * @param {object} replacements Key => Value object of string replacements. - */ -function replaceFunctionPlaceholders(fn, replacements) { - if (replacements && typeof replacements === "object") { - fn = fn.toString(); - for (var p in replacements) { - if (replacements.hasOwnProperty(p)) { - var match = new RegExp("%" + p + "%", "g"); - do { - fn = fn.replace(match, replacements[p]); - } while(fn.indexOf(match) !== -1); - } - } - } - return fn; -} - -/** - * Replaces the "evaluate" method with one we can easily do substitution with. - * - * @param {phantomjs.WebPage} page The WebPage object to overload - */ -function overloadPageEvaluate(page) { - page._evaluate = page.evaluate; - page.evaluate = function(fn, replacements) { return page._evaluate(replaceFunctionPlaceholders(fn, replacements)); }; - return page; -} - -/** Stubs a fake writeFile function into the test runner. - * - * @param {phantomjs.WebPage} page The WebPage object to inject functions into. - * @param {string} key The name of the global object in which file data should - * be stored for later retrieval. - */ -// TODO: not bothering with error checking for now (closed environment) -function setupWriteFileFunction(page, key, path_separator) { - page.evaluate(function(){ - window["%resultsObj%"] = {}; - window.fs_path_separator = "%fs_path_separator%"; - window.__phantom_writeFile = function(filename, text) { - window["%resultsObj%"][filename] = text; - }; - }, {resultsObj: key, fs_path_separator: path_separator.replace("\\", "\\\\")}); -} - -/** - * Returns the loaded page's filename => output object. - * - * @param {phantomjs.WebPage} page The WebPage object to retrieve data from. - * @param {string} key The name of the global object to be returned. Should - * be the same key provided to setupWriteFileFunction. - */ -function getXmlResults(page, key) { - return page.evaluate(function(){ - return window["%resultsObj%"] || {}; - }, {resultsObj: key}); -} - -/** - * Processes a page. - * - * @param {string} status The status from opening the page via WebPage#open. - * @param {phantomjs.WebPage} page The WebPage to be processed. - */ -function processPage(status, page, resultsKey) { - if (status === null && page) { - page.__exit_code = null; - return function(stat){ - processPage(stat, page, resultsKey); - }; - } - if (status !== "success") { - console.error("Unable to load resource: " + address); - page.__exit_code = 2; - } - else { - var isFinished = function() { - return page.evaluate(function(){ - // if there's a JUnitXmlReporter, return a boolean indicating if it is finished - if (window.jasmineReporters && window.jasmineReporters.startTime) { - return !!window.jasmineReporters.endTime; - } - // otherwise, scrape the DOM for the HtmlReporter "finished in ..." output - var durElem = document.querySelector(".html-reporter .duration"); - if (!durElem) { - durElem = document.querySelector(".jasmine_html-reporter .duration"); - } - return durElem && durElem.textContent && durElem.textContent.toLowerCase().indexOf("finished in") === 0; - }); - }; - var getResultsFromHtmlRunner = function() { - return page.evaluate(function(){ - var resultElem = document.querySelector(".html-reporter .alert .bar"); - if (!resultElem) { - resultElem = document.querySelector(".jasmine_html-reporter .alert .bar"); - } - return resultElem && resultElem.textContent && - resultElem.textContent.match(/(\d+) spec.* (\d+) failure.*/) || - ["Unable to determine success or failure."]; - }); - }; - var timeout = 60000; - var loopInterval = 100; - var ival = setInterval(function(){ - if (isFinished()) { - // get the results that need to be written to disk - var fs = require("fs"), - xml_results = getXmlResults(page, resultsKey), - output; - for (var filename in xml_results) { - if (xml_results.hasOwnProperty(filename) && (output = xml_results[filename]) && typeof(output) === "string") { - fs.write(filename, output, "w"); - } - } - - // print out a success / failure message of the results - var results = getResultsFromHtmlRunner(); - var failures = Number(results[2]); - if (failures > 0) { - page.__exit_code = 1; - clearInterval(ival); - } - else { - page.__exit_code = 0; - clearInterval(ival); - } - } - else { - timeout -= loopInterval; - if (timeout <= 0) { - console.log('Page has timed out; aborting.'); - page.__exit_code = 2; - clearInterval(ival); - } - } - }, loopInterval); - } -} diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs.runner.sh b/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs.runner.sh deleted file mode 100755 index 22b61d99543e6b40d43458c3e54d4752cee3e38b..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/phantomjs.runner.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# sanity check to make sure phantomjs exists in the PATH -hash /usr/bin/env phantomjs &> /dev/null -if [ $? -eq 1 ]; then - echo "ERROR: phantomjs is not installed" - echo "Please visit http://www.phantomjs.org/" - exit 1 -fi - -# sanity check number of args -if [ $# -lt 1 ] -then - echo "Usage: `basename $0` path_to_runner.html" - echo - exit 1 -fi - -SCRIPTDIR=$(dirname `perl -e 'use Cwd "abs_path";print abs_path(shift)' $0`) -TESTFILE="" -while (( "$#" )); do - if [ ${1:0:7} == "http://" -o ${1:0:8} == "https://" ]; then - TESTFILE="$TESTFILE $1" - else - TESTFILE="$TESTFILE `perl -e 'use Cwd "abs_path";print abs_path(shift)' $1`" - fi - shift -done - -# cleanup previous test runs -cd $SCRIPTDIR -rm -f *.xml - -# make sure phantomjs submodule is initialized -cd .. -git submodule update --init - -# fire up the phantomjs environment and run the test -cd $SCRIPTDIR -/usr/bin/env phantomjs $SCRIPTDIR/phantomjs-testrunner.js $TESTFILE diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/spec_runner.html b/apps/maarch_entreprise/tools/fingerprintjs2/specs/spec_runner.html deleted file mode 100755 index 6125ec1e19085b8727e315a54f2979c7e1735acc..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/spec_runner.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title>Fingerprint2 spec runner</title> - - <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.3.4/jasmine_favicon.png"> - <link rel="stylesheet" href="lib/jasmine-2.3.4/jasmine.css"> - - <script src="lib/jasmine-2.3.4/jasmine.js"></script> - <script src="lib/jasmine-2.3.4/jasmine-html.js"></script> - <script src="lib/jasmine-2.3.4/boot.js"></script> - <script src="lib/jasmine-2.3.4/terminal.js"></script> - <script src="lib/jasmine-2.3.4/jasmine-matchers.js"></script> - - <!-- include source files here... --> - <script src="../fingerprint2.js"></script> - - <!-- include spec files here... --> - <script src="./specs.js"></script> - - <script> - if(navigator.userAgent.match(/phantom/i)) { - jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({ - verbosity: 3, - color: true, - showStack: true - })); - } - </script> -</head> - -<body> -</body> -</html> diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/specs/specs.js b/apps/maarch_entreprise/tools/fingerprintjs2/specs/specs.js deleted file mode 100755 index 054104baf55739e4d6992aecf4683ef36ba54af0..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/specs/specs.js +++ /dev/null @@ -1,228 +0,0 @@ -"use strict"; -describe("Fingerprint2", function () { - describe("new", function () { - it("creates a new instance of FP2", function () { - expect(new Fingerprint2()).not.toBeNull(); - }); - - it("accepts an empty options object", function () { - expect(new Fingerprint2({})).not.toBeNull(); - }); - - it("uses default options", function () { - var fp2 = new Fingerprint2(); - expect(fp2.options.swfContainerId).toEqual("fingerprintjs2"); - expect(fp2.options.swfPath).toEqual("flash/compiled/FontList.swf"); - expect(fp2.options.userDefinedFonts).toEqual([]); - }); - - it("allows to override default options", function () { - var fp2 = new Fingerprint2({swfPath: "newpath", userDefinedFonts: ["Ethos", "Quenda"]}); - expect(fp2.options.swfContainerId).toEqual("fingerprintjs2"); - expect(fp2.options.swfPath).toEqual("newpath"); - expect(fp2.options.userDefinedFonts).toEqual(["Ethos", "Quenda"]); - }); - - it("allows to add new options", function () { - var fp2 = new Fingerprint2({excludeUserAgent: true}); - expect(fp2.options.swfContainerId).toEqual("fingerprintjs2"); - expect(fp2.options.swfPath).toEqual("flash/compiled/FontList.swf"); - expect(fp2.options.excludeUserAgent).toBe(true); - }); - - describe("sortPluginsFor", function () { - it("has default value", function (){ - var fp2 = new Fingerprint2(); - expect(fp2.options.sortPluginsFor).toEqual([/palemoon/i]); - }); - - it("allows to set new array of regexes", function () { - var fp2 = new Fingerprint2({sortPluginsFor: [/firefox/i, /chrome/i]}); - expect(fp2.options.sortPluginsFor).toEqual([/firefox/i, /chrome/i]); - }); - }); - }); - - describe("without new keyword", function () { - it("creates a new instance of FP2", function () { - expect(Fingerprint2()).not.toBeNull(); - }); - }) - - describe("get", function () { - describe("default options", function () { - it("calculates fingerprint", function (done) { - var fp2 = new Fingerprint2(); - fp2.get(function(result){ - expect(result).toMatch(/^[0-9a-f]{32}$/i); - done(); - }); - }); - - it("does not try calling flash font detection", function (done) { - var fp2 = new Fingerprint2(); - spyOn(fp2, "flashFontsKey"); - fp2.get(function(result) { - expect(fp2.flashFontsKey).not.toHaveBeenCalled(); - done(); - }); - }); - }); - - describe("non-default options", function () { - it("does not use userAgent when excluded", function (done) { - var fp2 = new Fingerprint2({excludeUserAgent: true}); - spyOn(fp2, "getUserAgent"); - fp2.get(function(result) { - expect(fp2.getUserAgent).not.toHaveBeenCalled(); - done(); - }); - }); - - it("does not use pixelRatio when excluded", function (done) { - var fp2 = new Fingerprint2({excludePixelRatio: true}); - spyOn(fp2, "getPixelRatio"); - fp2.get(function(result) { - expect(fp2.getPixelRatio).not.toHaveBeenCalled(); - done(); - }); - }); - - it("does not use screen resolution when excluded", function (done) { - var fp2 = new Fingerprint2({excludeScreenResolution: true}); - spyOn(fp2, "getScreenResolution"); - fp2.get(function(result) { - expect(fp2.getScreenResolution).not.toHaveBeenCalled(); - done(); - }); - }); - - it("does not use available screen resolution when excluded", function (done) { - var fp2 = new Fingerprint2({excludeAvailableScreenResolution: true}); - spyOn(fp2, "getAvailableScreenResolution"); - fp2.get(function(result) { - expect(fp2.getAvailableScreenResolution).not.toHaveBeenCalled(); - done(); - }); - }); - - it("does not use plugins info when excluded", function (done) { - var fp2 = new Fingerprint2({excludePlugins: true}); - spyOn(fp2, "getRegularPlugins"); - fp2.get(function(result) { - expect(fp2.getRegularPlugins).not.toHaveBeenCalled(); - done(); - }); - }); - - it("does not use IE plugins info when excluded", function (done) { - var fp2 = new Fingerprint2({excludeIEPlugins: true}); - spyOn(fp2, "getIEPlugins"); - fp2.get(function(result) { - expect(fp2.getIEPlugins).not.toHaveBeenCalled(); - done(); - }); - }); - - }); - - describe("returns components", function () { - it("does it return components as a second argument to callback", function (done) { - var fp2 = new Fingerprint2(); - fp2.get(function(result, components) { - expect(components).not.toBeNull(); - done(); - }); - }); - - it("checks if returned components is array", function (done) { - var fp2 = new Fingerprint2(); - fp2.get(function(result, components) { - expect(components).toBeArrayOfObjects(); - done(); - }); - }); - - it("checks if js_fonts component is array", function (done) { - var fp2 = new Fingerprint2(); - fp2.get(function(result, components) { - for(var x = 0; x < components.length; x++) { - if(components[x].key == "js_fonts") { - expect(components[x].value).toBeArray(); - } - } - done(); - }); - }); - - it("returns user_agent as the first element", function (done) { - var fp2 = new Fingerprint2(); - fp2.get(function(result, components) { - expect(components[0].key).toEqual("user_agent"); - done(); - }); - }); - }); - - describe("baseFontArray iteration", function () { - it("only iterates specified items", function (done) { - var baseFonts = ["monospace", "sans-serif", "serif"]; - var ctr = 0; - for (var x in baseFonts) { - ctr++; - } - - expect(baseFonts.length).toEqual(3); - expect(ctr).toEqual(baseFonts.length); - - // Somewhere deep in your JavaScript library... - Array.prototype.foo = 1; - Array.prototype.bar = 2; - ctr = 0; - for (var x in baseFonts) { - console.log(x); - ctr++; - // Now foo & bar is a part of EVERY array and - // will show up here as a value of 'x'. - } - - expect(baseFonts.length).toEqual(3); - // sadface - expect(ctr).not.toEqual(baseFonts.length); - expect(ctr).toEqual(5); - done(); - }); - }); - - describe("userDefinedFonts option", function () { - it("concatinates existing fonts with user-defined", function (done) { - var fontList = [ - "Andale Mono", "Arial", "Arial Black", "Arial Hebrew", "Arial MT", "Arial Narrow", "Arial Rounded MT Bold", "Arial Unicode MS", - "Bitstream Vera Sans Mono", "Book Antiqua", "Bookman Old Style", - "Calibri", "Cambria", "Cambria Math", "Century", "Century Gothic", "Century Schoolbook", "Comic Sans", "Comic Sans MS", "Consolas", "Courier", "Courier New", - "Garamond", "Geneva", "Georgia", - "Helvetica", "Helvetica Neue", - "Impact", - "Lucida Bright", "Lucida Calligraphy", "Lucida Console", "Lucida Fax", "LUCIDA GRANDE", "Lucida Handwriting", "Lucida Sans", "Lucida Sans Typewriter", "Lucida Sans Unicode", - "Microsoft Sans Serif", "Monaco", "Monotype Corsiva", "MS Gothic", "MS Outlook", "MS PGothic", "MS Reference Sans Serif", "MS Sans Serif", "MS Serif", "MYRIAD", "MYRIAD PRO", - "Palatino", "Palatino Linotype", - "Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", - "Tahoma", "Times", "Times New Roman", "Times New Roman PS", "Trebuchet MS", - "Verdana", "Wingdings", "Wingdings 2", "Wingdings 3" - ]; - - expect(fontList.length).toEqual(65); - var userDefinedFonts = []; - fontList.concat(userDefinedFonts); - expect(fontList.length).toEqual(65); - - - userDefinedFonts = ["Adria Grotesk", "Butler", "Nimbus Mono"]; - expect(userDefinedFonts.length).toEqual(3); - fontList = fontList.concat(userDefinedFonts); - expect(fontList.length).toEqual(65 + 3); - done(); - }); - }); - }); -}); diff --git a/apps/maarch_entreprise/tools/fingerprintjs2/yarn.lock b/apps/maarch_entreprise/tools/fingerprintjs2/yarn.lock deleted file mode 100755 index da43653554b9241e513a9425f08a551d74b24f8d..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/fingerprintjs2/yarn.lock +++ /dev/null @@ -1,1395 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -align-text@^0.1.1, align-text@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" - dependencies: - kind-of "^3.0.2" - longest "^1.0.1" - repeat-string "^1.5.2" - -ansi-regex@^0.2.0, ansi-regex@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - -ansi-styles@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - -archy@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" - -argparse@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" - dependencies: - sprintf-js "~1.0.2" - -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - -arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" - -array-differ@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" - -array-uniq@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" - -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - -async@~0.2.6: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" - -beeper@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" - -brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" - dependencies: - balanced-match "^0.4.1" - concat-map "0.0.1" - -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" - -buffer-shims@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - -bufferstreams@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/bufferstreams/-/bufferstreams-1.0.1.tgz#cfb1ad9568d3ba3cfe935ba9abdd952de88aab2a" - dependencies: - readable-stream "^1.0.33" - -camelcase@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" - -center-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" - dependencies: - align-text "^0.1.3" - lazy-cache "^1.0.3" - -chalk@^1.0.0, chalk@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@~0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" - dependencies: - ansi-styles "^1.1.0" - escape-string-regexp "^1.0.0" - has-ansi "^0.1.0" - strip-ansi "^0.3.0" - supports-color "^0.2.0" - -cliui@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" - dependencies: - center-align "^0.1.1" - right-align "^0.1.1" - wordwrap "0.0.2" - -clone-stats@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" - -clone@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" - -clone@^1.0.0, clone@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -concat-stream@^1.4.6: - version "1.6.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" - dependencies: - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - -d@^0.1.1, d@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/d/-/d-0.1.1.tgz#da184c535d18d8ee7ba2aa229b914009fae11309" - dependencies: - es5-ext "~0.10.2" - -dateformat@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17" - -deap@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/deap/-/deap-1.0.0.tgz#b148bf82430a27699b7483a03eb6b67585bfc888" - -debug@^2.1.1: - version "2.6.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" - dependencies: - ms "0.7.2" - -decamelize@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - -deep-is@~0.1.2: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - -defaults@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - dependencies: - clone "^1.0.2" - -deprecated@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" - -detect-file@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-0.1.0.tgz#4935dedfd9488648e006b0129566e9386711ea63" - dependencies: - fs-exists-sync "^0.1.0" - -doctrine@^0.6.2: - version "0.6.4" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.6.4.tgz#81428491a942ef18b0492056eda3800eee57d61d" - dependencies: - esutils "^1.1.6" - isarray "0.0.1" - -duplexer2@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" - dependencies: - readable-stream "~1.1.9" - -end-of-stream@~0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" - dependencies: - once "~1.3.0" - -es5-ext@^0.10.7, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.5, es5-ext@~0.10.6, es5-ext@~0.10.7: - version "0.10.12" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047" - dependencies: - es6-iterator "2" - es6-symbol "~3.1" - -es6-iterator@2: - version "2.0.0" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.0.tgz#bd968567d61635e33c0b80727613c9cb4b096bac" - dependencies: - d "^0.1.1" - es5-ext "^0.10.7" - es6-symbol "3" - -es6-iterator@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-0.1.3.tgz#d6f58b8c4fc413c249b4baa19768f8e4d7c8944e" - dependencies: - d "~0.1.1" - es5-ext "~0.10.5" - es6-symbol "~2.0.1" - -es6-map@^0.1.1: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.4.tgz#a34b147be224773a4d7da8072794cefa3632b897" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-set "~0.1.3" - es6-symbol "~3.1.0" - event-emitter "~0.3.4" - -es6-set@~0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-symbol "3" - event-emitter "~0.3.4" - -es6-symbol@3, es6-symbol@~3.1, es6-symbol@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.0.tgz#94481c655e7a7cad82eba832d97d5433496d7ffa" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - -es6-symbol@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-2.0.1.tgz#761b5c67cfd4f1d18afb234f691d678682cb3bf3" - dependencies: - d "~0.1.1" - es5-ext "~0.10.5" - -es6-weak-map@^0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-0.1.4.tgz#706cef9e99aa236ba7766c239c8b9e286ea7d228" - dependencies: - d "~0.1.1" - es5-ext "~0.10.6" - es6-iterator "~0.1.3" - es6-symbol "~2.0.1" - -escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - -escope@^2.0.4: - version "2.0.7" - resolved "https://registry.yarnpkg.com/escope/-/escope-2.0.7.tgz#b3dc8e605eddccf1c83ec8cf7cce6d04427ec8eb" - dependencies: - es6-map "^0.1.1" - es6-weak-map "^0.1.2" - esrecurse "^1.2.0" - estraverse "^1.9.1" - util-extend "^1.0.1" - -eslint@^0.14.1: - version "0.14.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-0.14.1.tgz#2a08811ca094ff85cafcd42acafa7405d7f11500" - dependencies: - chalk "~0.5.1" - concat-stream "^1.4.6" - debug "^2.1.1" - doctrine "^0.6.2" - escape-string-regexp "^1.0.2" - escope "^2.0.4" - espree "^1.8.1" - estraverse "^1.9.1" - estraverse-fb "^1.3.0" - globals "^6.1.0" - js-yaml "^3.2.5" - minimatch "^2.0.1" - mkdirp "^0.5.0" - object-assign "^2.0.0" - optionator "^0.5.0" - strip-json-comments "~1.0.1" - text-table "~0.2.0" - user-home "^1.0.0" - xml-escape "~1.0.0" - -espree@^1.8.1: - version "1.12.3" - resolved "https://registry.yarnpkg.com/espree/-/espree-1.12.3.tgz#04ceeada91bda077a38c040c125ba186b13bb3cc" - -esprima@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" - -esrecurse@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-1.2.0.tgz#25e3b3ab76ad8a1da2d38e9393fd76b8456a706f" - dependencies: - estraverse ">=1.9.0" - -estraverse-fb@^1.3.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/estraverse-fb/-/estraverse-fb-1.3.1.tgz#160e75a80e605b08ce894bcce2fe3e429abf92bf" - -estraverse@>=1.9.0, estraverse@^1.9.1: - version "1.9.3" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" - -esutils@^1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" - -event-emitter@~0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.4.tgz#8d63ddfb4cfe1fae3b32ca265c4c720222080bb5" - dependencies: - d "~0.1.1" - es5-ext "~0.10.7" - -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" - dependencies: - is-posix-bracket "^0.1.0" - -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" - dependencies: - fill-range "^2.1.0" - -expand-tilde@^1.2.1, expand-tilde@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-1.2.2.tgz#0b81eba897e5a3d31d1c3d102f8f01441e559449" - dependencies: - os-homedir "^1.0.1" - -extend@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" - -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" - dependencies: - is-extglob "^1.0.0" - -fancy-log@^1.0.0, fancy-log@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.0.tgz#45be17d02bb9917d60ccffd4995c999e6c8c9948" - dependencies: - chalk "^1.1.1" - time-stamp "^1.0.0" - -fast-levenshtein@~1.0.0: - version "1.0.7" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.0.7.tgz#0178dcdee023b92905193af0959e8a7639cfdcb9" - -filename-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" - -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" - -find-index@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" - -findup-sync@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.4.3.tgz#40043929e7bc60adf0b7f4827c4c6e75a0deca12" - dependencies: - detect-file "^0.1.0" - is-glob "^2.0.1" - micromatch "^2.3.7" - resolve-dir "^0.1.0" - -fined@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/fined/-/fined-1.0.2.tgz#5b28424b760d7598960b7ef8480dff8ad3660e97" - dependencies: - expand-tilde "^1.2.1" - lodash.assignwith "^4.0.7" - lodash.isempty "^4.2.1" - lodash.isplainobject "^4.0.4" - lodash.isstring "^4.0.1" - lodash.pick "^4.2.1" - parse-filepath "^1.0.1" - -first-chunk-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" - -flagged-respawn@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-0.3.2.tgz#ff191eddcd7088a675b2610fffc976be9b8074b5" - -for-in@^0.1.5: - version "0.1.6" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8" - -for-own@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.4.tgz#0149b41a39088c7515f51ebe1c1386d45f935072" - dependencies: - for-in "^0.1.5" - -fs-exists-sync@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" - -gaze@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" - dependencies: - globule "~0.1.0" - -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" - -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" - dependencies: - is-glob "^2.0.0" - -glob-stream@^3.1.5: - version "3.1.18" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" - dependencies: - glob "^4.3.1" - glob2base "^0.0.12" - minimatch "^2.0.1" - ordered-read-streams "^0.1.0" - through2 "^0.6.1" - unique-stream "^1.0.0" - -glob-watcher@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" - dependencies: - gaze "^0.5.1" - -glob2base@^0.0.12: - version "0.0.12" - resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" - dependencies: - find-index "^0.1.1" - -glob@^4.3.1: - version "4.5.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "^2.0.1" - once "^1.3.0" - -glob@~3.1.21: - version "3.1.21" - resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" - dependencies: - graceful-fs "~1.2.0" - inherits "1" - minimatch "~0.2.11" - -global-modules@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-0.2.3.tgz#ea5a3bed42c6d6ce995a4f8a1269b5dae223828d" - dependencies: - global-prefix "^0.1.4" - is-windows "^0.2.0" - -global-prefix@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-0.1.5.tgz#8d3bc6b8da3ca8112a160d8d496ff0462bfef78f" - dependencies: - homedir-polyfill "^1.0.0" - ini "^1.3.4" - is-windows "^0.2.0" - which "^1.2.12" - -globals@^6.1.0: - version "6.4.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-6.4.1.tgz#8498032b3b6d1cc81eebc5f79690d8fe29fabf4f" - -globule@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" - dependencies: - glob "~3.1.21" - lodash "~1.0.1" - minimatch "~0.2.11" - -glogg@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.0.tgz#7fe0f199f57ac906cf512feead8f90ee4a284fc5" - dependencies: - sparkles "^1.0.0" - -graceful-fs@^3.0.0: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - dependencies: - natives "^1.1.0" - -graceful-fs@~1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" - -gulp-eslint@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/gulp-eslint/-/gulp-eslint-0.4.3.tgz#40c65ea78aaa91eb83e3cd2f10fe5b79e4da6c95" - dependencies: - bufferstreams "1.0.1" - eslint "^0.14.1" - gulp-util "^3.0.1" - object-assign "^2.0.0" - optional "^0.1.2" - through2 "^0.6.3" - -gulp-rename@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" - -gulp-uglify@^1.1.0: - version "1.5.4" - resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-1.5.4.tgz#524788d87666d09f9d0c21fb2177f90039a658c9" - dependencies: - deap "^1.0.0" - fancy-log "^1.0.0" - gulp-util "^3.0.0" - isobject "^2.0.0" - through2 "^2.0.0" - uglify-js "2.6.4" - uglify-save-license "^0.4.1" - vinyl-sourcemaps-apply "^0.2.0" - -gulp-util@^3.0.0, gulp-util@^3.0.1: - version "3.0.8" - resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" - dependencies: - array-differ "^1.0.0" - array-uniq "^1.0.2" - beeper "^1.0.0" - chalk "^1.0.0" - dateformat "^2.0.0" - fancy-log "^1.1.0" - gulplog "^1.0.0" - has-gulplog "^0.1.0" - lodash._reescape "^3.0.0" - lodash._reevaluate "^3.0.0" - lodash._reinterpolate "^3.0.0" - lodash.template "^3.0.0" - minimist "^1.1.0" - multipipe "^0.1.2" - object-assign "^3.0.0" - replace-ext "0.0.1" - through2 "^2.0.0" - vinyl "^0.5.0" - -gulp@^3.8.11: - version "3.9.1" - resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" - dependencies: - archy "^1.0.0" - chalk "^1.0.0" - deprecated "^0.0.1" - gulp-util "^3.0.0" - interpret "^1.0.0" - liftoff "^2.1.0" - minimist "^1.1.0" - orchestrator "^0.3.0" - pretty-hrtime "^1.0.0" - semver "^4.1.0" - tildify "^1.0.0" - v8flags "^2.0.2" - vinyl-fs "^0.3.0" - -gulplog@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/gulplog/-/gulplog-1.0.0.tgz#e28c4d45d05ecbbed818363ce8f9c5926229ffe5" - dependencies: - glogg "^1.0.0" - -has-ansi@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" - dependencies: - ansi-regex "^0.2.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - -has-gulplog@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" - dependencies: - sparkles "^1.0.0" - -homedir-polyfill@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc" - dependencies: - parse-passwd "^1.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" - -inherits@2, inherits@^2.0.3, inherits@~2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - -ini@^1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" - -interpret@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" - -is-absolute@^0.2.3: - version "0.2.6" - resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.2.6.tgz#20de69f3db942ef2d87b9c2da36f172235b1b5eb" - dependencies: - is-relative "^0.2.1" - is-windows "^0.2.0" - -is-buffer@^1.0.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" - -is-dotfile@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" - -is-number@^2.0.2, is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" - -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" - -is-relative@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-0.2.1.tgz#d27f4c7d516d175fb610db84bbeef23c3bc97aa5" - dependencies: - is-unc-path "^0.1.1" - -is-unc-path@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-0.1.2.tgz#6ab053a72573c10250ff416a3814c35178af39b9" - dependencies: - unc-path-regex "^0.1.0" - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - -is-windows@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c" - -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - -isarray@1.0.0, isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isexe@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0" - -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - dependencies: - isarray "1.0.0" - -js-yaml@^3.2.5: - version "3.8.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.1.tgz#782ba50200be7b9e5a8537001b7804db3ad02628" - dependencies: - argparse "^1.0.7" - esprima "^3.1.1" - -kind-of@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" - dependencies: - is-buffer "^1.0.2" - -lazy-cache@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" - -levn@~0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.2.5.tgz#ba8d339d0ca4a610e3a3f145b9caf48807155054" - dependencies: - prelude-ls "~1.1.0" - type-check "~0.3.1" - -liftoff@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.3.0.tgz#a98f2ff67183d8ba7cfaca10548bd7ff0550b385" - dependencies: - extend "^3.0.0" - findup-sync "^0.4.2" - fined "^1.0.1" - flagged-respawn "^0.3.2" - lodash.isplainobject "^4.0.4" - lodash.isstring "^4.0.1" - lodash.mapvalues "^4.4.0" - rechoir "^0.6.2" - resolve "^1.1.7" - -lodash._basecopy@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" - -lodash._basetostring@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" - -lodash._basevalues@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" - -lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - -lodash._isiterateecall@^3.0.0: - version "3.0.9" - resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" - -lodash._reescape@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reescape/-/lodash._reescape-3.0.0.tgz#2b1d6f5dfe07c8a355753e5f27fac7f1cde1616a" - -lodash._reevaluate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz#58bc74c40664953ae0b124d806996daca431e2ed" - -lodash._reinterpolate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - -lodash._root@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" - -lodash.assignwith@^4.0.7: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz#127a97f02adc41751a954d24b0de17e100e038eb" - -lodash.escape@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" - dependencies: - lodash._root "^3.0.0" - -lodash.isarguments@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" - -lodash.isarray@^3.0.0: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" - -lodash.isempty@^4.2.1: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" - -lodash.isplainobject@^4.0.4: - version "4.0.6" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" - -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - -lodash.keys@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" - dependencies: - lodash._getnative "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - -lodash.mapvalues@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz#1bafa5005de9dd6f4f26668c30ca37230cc9689c" - -lodash.pick@^4.2.1: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" - -lodash.restparam@^3.0.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" - -lodash.template@^3.0.0: - version "3.6.2" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f" - dependencies: - lodash._basecopy "^3.0.0" - lodash._basetostring "^3.0.0" - lodash._basevalues "^3.0.0" - lodash._isiterateecall "^3.0.0" - lodash._reinterpolate "^3.0.0" - lodash.escape "^3.0.0" - lodash.keys "^3.0.0" - lodash.restparam "^3.0.0" - lodash.templatesettings "^3.0.0" - -lodash.templatesettings@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz#fb307844753b66b9f1afa54e262c745307dba8e5" - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.escape "^3.0.0" - -lodash@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" - -longest@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" - -lru-cache@2: - version "2.7.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" - -map-cache@^0.2.0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" - -micromatch@^2.3.7: - version "2.3.11" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - dependencies: - brace-expansion "^1.0.0" - -minimatch@~0.2.11: - version "0.2.14" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" - dependencies: - lru-cache "2" - sigmund "~1.0.0" - -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -minimist@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - -mkdirp@^0.5.0: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -ms@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" - -multipipe@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" - dependencies: - duplexer2 "0.0.2" - -natives@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" - -normalize-path@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" - -object-assign@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" - -object-assign@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" - -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - -once@^1.3.0, once@~1.3.0: - version "1.3.3" - resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" - dependencies: - wrappy "1" - -optional@^0.1.2: - version v0.1.3 - resolved "https://registry.yarnpkg.com/optional/-/optional-0.1.3.tgz#f87537517b59a5e732cfd8f18e4f7eea7ab4761e" - -optionator@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.5.0.tgz#b75a8995a2d417df25b6e4e3862f50aa88651368" - dependencies: - deep-is "~0.1.2" - fast-levenshtein "~1.0.0" - levn "~0.2.5" - prelude-ls "~1.1.1" - type-check "~0.3.1" - wordwrap "~0.0.2" - -orchestrator@^0.3.0: - version "0.3.8" - resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" - dependencies: - end-of-stream "~0.1.5" - sequencify "~0.0.7" - stream-consume "~0.1.0" - -ordered-read-streams@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" - -os-homedir@^1.0.0, os-homedir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - -parse-filepath@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.1.tgz#159d6155d43904d16c10ef698911da1e91969b73" - dependencies: - is-absolute "^0.2.3" - map-cache "^0.2.0" - path-root "^0.1.1" - -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" - dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" - -parse-passwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" - -path-root-regex@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" - -path-root@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7" - dependencies: - path-root-regex "^0.1.0" - -prelude-ls@~1.1.0, prelude-ls@~1.1.1, prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - -pretty-hrtime@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - -randomatic@^1.1.3: - version "1.1.6" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" - dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" - -"readable-stream@>=1.0.33-1 <1.1.0-0": - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@^1.0.33, readable-stream@~1.1.9: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@^2.1.5, readable-stream@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - dependencies: - resolve "^1.1.6" - -regex-cache@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" - dependencies: - is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" - -repeat-element@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" - -repeat-string@^1.5.2: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - -replace-ext@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" - -resolve-dir@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-0.1.1.tgz#b219259a5602fac5c5c496ad894a6e8cc430261e" - dependencies: - expand-tilde "^1.2.2" - global-modules "^0.2.3" - -resolve@^1.1.6, resolve@^1.1.7: - version "1.2.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c" - -right-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" - dependencies: - align-text "^0.1.1" - -semver@^4.1.0: - version "4.3.6" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" - -sequencify@~0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" - -sigmund@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" - -source-map@^0.5.1, source-map@~0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - -sparkles@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - -stream-consume@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f" - -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - -strip-ansi@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" - dependencies: - ansi-regex "^0.2.1" - -strip-ansi@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - dependencies: - ansi-regex "^2.0.0" - -strip-bom@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" - dependencies: - first-chunk-stream "^1.0.0" - is-utf8 "^0.2.0" - -strip-json-comments@~1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" - -supports-color@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - -text-table@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - -through2@^0.6.1, through2@^0.6.3: - version "0.6.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" - dependencies: - readable-stream ">=1.0.33-1 <1.1.0-0" - xtend ">=4.0.0 <4.1.0-0" - -through2@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" - dependencies: - readable-stream "^2.1.5" - xtend "~4.0.1" - -tildify@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" - dependencies: - os-homedir "^1.0.0" - -time-stamp@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.0.1.tgz#9f4bd23559c9365966f3302dbba2b07c6b99b151" - -type-check@~0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - dependencies: - prelude-ls "~1.1.2" - -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - -uglify-js@2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.6.4.tgz#65ea2fb3059c9394692f15fed87c2b36c16b9adf" - dependencies: - async "~0.2.6" - source-map "~0.5.1" - uglify-to-browserify "~1.0.0" - yargs "~3.10.0" - -uglify-save-license@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/uglify-save-license/-/uglify-save-license-0.4.1.tgz#95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1" - -uglify-to-browserify@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" - -unc-path-regex@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" - -unique-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" - -user-home@^1.0.0, user-home@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - -util-extend@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/util-extend/-/util-extend-1.0.3.tgz#a7c216d267545169637b3b6edc6ca9119e2ff93f" - -v8flags@^2.0.2: - version "2.0.11" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" - dependencies: - user-home "^1.1.1" - -vinyl-fs@^0.3.0: - version "0.3.14" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" - dependencies: - defaults "^1.0.0" - glob-stream "^3.1.5" - glob-watcher "^0.0.6" - graceful-fs "^3.0.0" - mkdirp "^0.5.0" - strip-bom "^1.0.0" - through2 "^0.6.1" - vinyl "^0.4.0" - -vinyl-sourcemaps-apply@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" - dependencies: - source-map "^0.5.1" - -vinyl@^0.4.0: - version "0.4.6" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" - dependencies: - clone "^0.2.0" - clone-stats "^0.0.1" - -vinyl@^0.5.0: - version "0.5.3" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.5.3.tgz#b0455b38fc5e0cf30d4325132e461970c2091cde" - dependencies: - clone "^1.0.0" - clone-stats "^0.0.1" - replace-ext "0.0.1" - -which@^1.2.12: - version "1.2.12" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" - dependencies: - isexe "^1.1.1" - -window-size@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" - -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - -xml-escape@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/xml-escape/-/xml-escape-1.0.0.tgz#00963d697b2adf0c185c4e04e73174ba9b288eb2" - -"xtend@>=4.0.0 <4.1.0-0", xtend@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" - -yargs@~3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" - dependencies: - camelcase "^1.0.2" - cliui "^2.1.0" - decamelize "^1.0.0" - window-size "0.1.0" diff --git a/apps/maarch_entreprise/tools/signature_pad/css/signature-pad.css b/apps/maarch_entreprise/tools/signature_pad/css/signature-pad.css deleted file mode 100755 index e787c34c2649bfa6c19afaea431893ddc59ddc57..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/signature_pad/css/signature-pad.css +++ /dev/null @@ -1,227 +0,0 @@ -.m-signature-pad { - position: absolute; - font-size: 10px; - width: 100%; - height: 99%; - /*top: 50%;*/ - /*left: 3%;*/ - /*margin-left: -350px; - margin-top: -200px;*/ - border: 1px solid #e8e8e8; - background-color: #fff; - box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.08) inset; - border-radius: 4px; -} - -/*.m-signature-pad:before, .m-signature-pad:after { - position: absolute; - z-index: -1; - content: ""; - width: 40%; - height: 10px; - left: 20px; - bottom: 10px; - background: transparent; - -webkit-transform: skew(-3deg) rotate(-3deg); - -moz-transform: skew(-3deg) rotate(-3deg); - -ms-transform: skew(-3deg) rotate(-3deg); - -o-transform: skew(-3deg) rotate(-3deg); - transform: skew(-3deg) rotate(-3deg); - box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4); -} - -.m-signature-pad:after { - left: auto; - right: 20px; - -webkit-transform: skew(3deg) rotate(3deg); - -moz-transform: skew(3deg) rotate(3deg); - -ms-transform: skew(3deg) rotate(3deg); - -o-transform: skew(3deg) rotate(3deg); - transform: skew(3deg) rotate(3deg); -}*/ - -.m-signature-pad--body { - position: absolute; - left: 120px; - right: 5px; - top: 5px; - bottom: 45px; - border: 1px solid #f4f4f4; -} - -.m-signature-pad--body - canvas { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - border-radius: 4px; - box-shadow: 0 0 5px rgba(0, 0, 0, 0.02) inset; - } - -.m-signature-pad--left { - position: absolute; - left: 0px; - top: 5px; - bottom: 50px; - width: 120px; -} - -#list_tnl_sign{ - width: 100px; - height: 100%; - margin: 5px auto; - background: #f4f4f4; - overflow: auto; -} - -.m-signature-pad--footer { - position: absolute; - left: 20px; - right: 20px; - bottom: 5px; - height: 30px; -} - -.m-signature-pad--footer - .description { - color: #C3C3C3; - text-align: center; - font-size: 1.2em; - margin-top: 1.8em; - } - -.m-signature-pad--footer - .action_but_sign { - position: relative; - font-size: 14px; - margin-right: 7%; - bottom: 0; - cursor: pointer; - opacity: 0.4; - } - -.m-signature-pad--footer - .action_but_sign.selected_but{ - opacity: 1; - } - - -.m-signature-pad--footer - .action_but_sign.disabled_but{ - opacity: 0.4; - } -/* COULEURS */ -.m-signature-pad--footer - .action_but_sign.colBlue { - background: rgb(0, 0, 255) none repeat scroll 0% 0%; - border-radius: 50%; - } -.m-signature-pad--footer - .action_but_sign.colGreen { - background: rgb(0, 255, 0) none repeat scroll 0% 0%; - border-radius: 50%; - } -.m-signature-pad--footer - .action_but_sign.colRed { - background: rgb(255, 0, 0) none repeat scroll 0% 0%; - border-radius: 50%; - } -.m-signature-pad--footer - .action_but_sign.colBlack { - background: rgb(0,0,0) none repeat scroll 0% 0%; - border-radius: 50%; - } - -.m-signature-pad--footer - .action_but_sign.colorBut { - display: inline-block; - height: 15px; - margin-left: 2px; - margin-right: 15px; - width: 15px; - } - -/* TAILLES */ -.m-signature-pad--footer - .action_but_sign.sizeBut { - display: inline-block; - margin-left: 2px; - margin-right: 15px; - } - -.m-signature-pad--footer - .action_but_sign.smallPen { - height: 5px; - width: 5px; - } - -.m-signature-pad--footer - .action_but_sign.midPen { - height: 10px; - width: 10px; - } - -.m-signature-pad--footer - .action_but_sign.bigPen { - height: 15px; - width: 15px; - margin-right: 8%; - } - -.m-signature-pad--footer - .action_but_sign.saveBut { - right: 0; - } - -.m-signature-pad--footer - .action_but_sign.stampBut { - height: 15px; - margin-right: 8%; - width: 15px; - } - -/* -@media screen and (max-width: 1024px) { - .m-signature-pad { - left: 0; - right: 0; - bottom: 0; - width: auto; - height: auto; - min-width: 85%; - min-height: 40%; - margin: 5%; - } - #github { - display: none; - } -} - -@media screen and (min-device-width: 768px) and (max-device-width: 1024px) { - .m-signature-pad { - margin: 10%; - } -} - -@media screen and (max-height: 320px) { - .m-signature-pad--body { - left: 0; - right: 0; - top: 0; - bottom: 32px; - } - .m-signature-pad--footer { - left: 20px; - right: 20px; - bottom: 4px; - height: 100px; - } - .m-signature-pad--footer - .description { - font-size: 1em; - margin-top: 1em; - } -} -*/ \ No newline at end of file diff --git a/apps/maarch_entreprise/tools/signature_pad/index.html b/apps/maarch_entreprise/tools/signature_pad/index.html deleted file mode 100755 index 4f0bd323a8c9cc4c2f9c379c740ed73d1aaabd89..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/signature_pad/index.html +++ /dev/null @@ -1,46 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <title>Signature Pad demo</title> - <meta name="description" content="Signature Pad - HTML5 canvas based smooth signature drawing using variable width spline interpolation."> - - <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"> - - <meta name="apple-mobile-web-app-capable" content="yes"> - <meta name="apple-mobile-web-app-status-bar-style" content="black"> - - <link rel="stylesheet" href="css/signature-pad.css"> - - <script type="text/javascript"> - var _gaq = _gaq || []; - _gaq.push(['_setAccount', 'UA-39365077-1']); - _gaq.push(['_trackPageview']); - - (function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); - })(); - </script> -</head> -<body onselectstart="return false"> - <a id="github" href="https://github.com/szimek/signature_pad"> - <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"> - </a> - - <div id="signature-pad" class="m-signature-pad"> - <div class="m-signature-pad--body"> - <canvas></canvas> - </div> - <div class="m-signature-pad--footer"> - <div class="description">Sign above</div> - <button class="button clear" data-action="clear">Clear</button> - <button class="button save" data-action="save">Save</button> - </div> - </div> - - <script src="js/signature_pad.js"></script> - <script src="js/app.js"></script> -</body> -</html> diff --git a/apps/maarch_entreprise/tools/signature_pad/js/app.js b/apps/maarch_entreprise/tools/signature_pad/js/app.js deleted file mode 100755 index da5a4b8c8c3f5fbbe8d9e8a836d598a175277da3..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/signature_pad/js/app.js +++ /dev/null @@ -1,30 +0,0 @@ -var wrapper = document.getElementById("signature-pad"), - clearButton = wrapper.querySelector("[data-action=clear]"), - saveButton = wrapper.querySelector("[data-action=save]"), - deleteButton = wrapper.querySelector("[data-action=delete]"), - canvas = wrapper.querySelector("canvas"), - signaturePad; - -// Adjust canvas coordinate space taking into account pixel ratio, -// to make it look crisp on mobile devices. -// This also causes canvas to be cleared. -function resizeCanvas() { - // When zoomed out to less than 100%, for some very strange reason, - // some browsers report devicePixelRatio as less than 1 - // and only part of the canvas is cleared then. - var ratio = Math.max(window.devicePixelRatio || 1, 1); - canvas.width = canvas.offsetWidth * ratio; - canvas.height = canvas.offsetHeight * ratio; - canvas.getContext("2d").scale(ratio, ratio); -} - -window.onresize = resizeCanvas; -resizeCanvas(); - -signaturePad = new SignaturePad(canvas); - -clearButton.addEventListener("click", function (event) { - signaturePad.clear(); -}); - - diff --git a/apps/maarch_entreprise/tools/signature_pad/js/signature_pad.js b/apps/maarch_entreprise/tools/signature_pad/js/signature_pad.js deleted file mode 100755 index 3ae49638c44fd9ccb8e85c079771f8dc0abc86fd..0000000000000000000000000000000000000000 --- a/apps/maarch_entreprise/tools/signature_pad/js/signature_pad.js +++ /dev/null @@ -1,428 +0,0 @@ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module unless amdModuleId is set - define([], function () { - return (root['SignaturePad'] = factory()); - }); - } else if (typeof exports === 'object') { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(); - } else { - root['SignaturePad'] = factory(); - } -}(this, function () { - -/*! - * Signature Pad v1.5.1 - * https://github.com/szimek/signature_pad - * - * Copyright 2015 Szymon Nowak - * Released under the MIT license - * - * The main idea and some parts of the code (e.g. drawing variable width Bézier curve) are taken from: - * http://corner.squareup.com/2012/07/smoother-signatures.html - * - * Implementation of interpolation using cubic Bézier curves is taken from: - * http://benknowscode.wordpress.com/2012/09/14/path-interpolation-using-cubic-bezier-and-control-point-estimation-in-javascript - * - * Algorithm for approximated length of a Bézier curve is taken from: - * http://www.lemoda.net/maths/bezier-length/index.html - * - */ -var SignaturePad = (function (document) { - "use strict"; - - var SignaturePad = function (canvas, options) { - var self = this, - opts = options || {}; - this.velocityFilterWeight = opts.velocityFilterWeight || 0.7; - this.minWidth = opts.minWidth || 2; - this.maxWidth = opts.maxWidth || 6; - this.dotSize = opts.dotSize || function () { - return (this.minWidth + this.maxWidth) / 2; - }; - this.penColor = opts.penColor || "black"; - this.backgroundColor = opts.backgroundColor || "rgba(0,0,0,0)"; - this.onEnd = opts.onEnd; - this.onBegin = opts.onBegin; - - this.stampImg = opts.stampImg; - - this._canvas = canvas; - this._ctx = canvas.getContext("2d"); - this.clear(); - - // we need add these inline so they are available to unbind while still having - // access to 'self' we could use _.bind but it's not worth adding a dependency - this._handleMouseDown = function (event) { - if (event.which === 1) { - self._mouseButtonDown = true; - self._strokeBegin(event); - } - }; - - this._handleMouseMove = function (event) { - if (self._mouseButtonDown) { - self._strokeUpdate(event); - } - }; - - this._handleMouseUp = function (event) { - if (event.which === 1 && self._mouseButtonDown) { - self._mouseButtonDown = false; - self._strokeEnd(event); - } - }; - - this._handleTouchStart = function (event) { - var touch = event.changedTouches[0]; - self._strokeBegin(touch); - }; - - this._handleTouchMove = function (event) { - // Prevent scrolling. - event.preventDefault(); - - var touch = event.changedTouches[0]; - self._strokeUpdate(touch); - }; - - this._handleTouchEnd = function (event) { - var wasCanvasTouched = event.target === self._canvas; - if (wasCanvasTouched) { - event.preventDefault(); - self._strokeEnd(event); - } - }; - - this._handleMouseEvents(); - this._handleTouchEvents(); - }; - - SignaturePad.prototype.clear = function () { - var ctx = this._ctx, - canvas = this._canvas; - - ctx.fillStyle = this.backgroundColor; - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.fillRect(0, 0, canvas.width, canvas.height); - this._reset(); - }; - - SignaturePad.prototype.toDataURL = function (imageType, quality) { - var canvas = this._canvas; - return canvas.toDataURL.apply(canvas, arguments); - }; - - SignaturePad.prototype.fromDataURL = function (dataUrl) { - var self = this, - image = new Image(), - ratio = window.devicePixelRatio || 1, - width = this._canvas.width / ratio, - height = this._canvas.height / ratio; - - this._reset(); - image.src = dataUrl; - - image.onload = function () { - var img_width = image.width; - var img_height = image.height; - var img_ratio = img_width / img_height; - - var new_height = width / img_ratio; - - var y_margin = height - new_height; - self._ctx.drawImage(image, 0, y_margin/2, width, new_height); - }; - this._isEmpty = false; - document.getElementById("clearBut").classList.add('selected_but'); - document.getElementById("clearBut").classList.remove('disabled_but'); - document.getElementById("saveBut").classList.add('selected_but'); - document.getElementById("saveBut").classList.remove('disabled_but'); - }; - - SignaturePad.prototype._strokeUpdate = function (event) { - var point = this._createPoint(event); - this._addPoint(point); - }; - - SignaturePad.prototype._strokeBegin = function (event) { - this._reset(); - this._strokeUpdate(event); - if (typeof this.onBegin === 'function') { - this.onBegin(event); - } - }; - - SignaturePad.prototype._strokeDraw = function (point) { - var ctx = this._ctx, - dotSize = typeof(this.dotSize) === 'function' ? this.dotSize() : this.dotSize; - - ctx.beginPath(); - this._drawPoint(point.x, point.y, dotSize); - ctx.closePath(); - ctx.fill(); - }; - - SignaturePad.prototype._strokeEnd = function (event) { - var canDrawCurve = this.points.length > 2, - point = this.points[0]; - - if (!canDrawCurve && point) { - this._strokeDraw(point); - } - if (typeof this.onEnd === 'function') { - this.onEnd(event); - } - }; - - SignaturePad.prototype._handleMouseEvents = function () { - this._mouseButtonDown = false; - - this._canvas.addEventListener("mousedown", this._handleMouseDown); - this._canvas.addEventListener("mousemove", this._handleMouseMove); - document.addEventListener("mouseup", this._handleMouseUp); - }; - - SignaturePad.prototype._handleTouchEvents = function () { - // Pass touch events to canvas element on mobile IE. - this._canvas.style.msTouchAction = 'none'; - - this._canvas.addEventListener("touchstart", this._handleTouchStart); - this._canvas.addEventListener("touchmove", this._handleTouchMove); - document.addEventListener("touchend", this._handleTouchEnd); - }; - - SignaturePad.prototype.on = function () { - this._handleMouseEvents(); - this._handleTouchEvents(); - }; - - SignaturePad.prototype.off = function () { - this._canvas.removeEventListener("mousedown", this._handleMouseDown); - this._canvas.removeEventListener("mousemove", this._handleMouseMove); - document.removeEventListener("mouseup", this._handleMouseUp); - - this._canvas.removeEventListener("touchstart", this._handleTouchStart); - this._canvas.removeEventListener("touchmove", this._handleTouchMove); - document.removeEventListener("touchend", this._handleTouchEnd); - }; - - SignaturePad.prototype.isEmpty = function () { - return this._isEmpty; - }; - - SignaturePad.prototype._reset = function () { - this.points = []; - this._lastVelocity = 0; - this._lastWidth = (this.minWidth + this.maxWidth) / 2; - this._isEmpty = true; - this._ctx.fillStyle = this.penColor; - - document.getElementById("clearBut").classList.remove('selected_but'); - document.getElementById("clearBut").classList.add('disabled_but'); - document.getElementById("saveBut").classList.remove('selected_but'); - document.getElementById("saveBut").classList.add('disabled_but'); - }; - - SignaturePad.prototype._createPoint = function (event) { - var rect = this._canvas.getBoundingClientRect(); - return new Point( - event.clientX - rect.left, - event.clientY - rect.top - ); - }; - - SignaturePad.prototype._addPoint = function (point) { - var points = this.points, - c2, c3, - curve, tmp; - - points.push(point); - - if (points.length > 2) { - // To reduce the initial lag make it work with 3 points - // by copying the first point to the beginning. - if (points.length === 3) points.unshift(points[0]); - - tmp = this._calculateCurveControlPoints(points[0], points[1], points[2]); - c2 = tmp.c2; - tmp = this._calculateCurveControlPoints(points[1], points[2], points[3]); - c3 = tmp.c1; - curve = new Bezier(points[1], c2, c3, points[2]); - this._addCurve(curve); - - // Remove the first element from the list, - // so that we always have no more than 4 points in points array. - points.shift(); - } - }; - - SignaturePad.prototype._calculateCurveControlPoints = function (s1, s2, s3) { - var dx1 = s1.x - s2.x, dy1 = s1.y - s2.y, - dx2 = s2.x - s3.x, dy2 = s2.y - s3.y, - - m1 = {x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0}, - m2 = {x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0}, - - l1 = Math.sqrt(dx1*dx1 + dy1*dy1), - l2 = Math.sqrt(dx2*dx2 + dy2*dy2), - - dxm = (m1.x - m2.x), - dym = (m1.y - m2.y), - - k = l2 / (l1 + l2), - cm = {x: m2.x + dxm*k, y: m2.y + dym*k}, - - tx = s2.x - cm.x, - ty = s2.y - cm.y; - - return { - c1: new Point(m1.x + tx, m1.y + ty), - c2: new Point(m2.x + tx, m2.y + ty) - }; - }; - - SignaturePad.prototype._addCurve = function (curve) { - if (this.stampImg == ''){ - var startPoint = curve.startPoint, - endPoint = curve.endPoint, - velocity, newWidth; - - velocity = endPoint.velocityFrom(startPoint); - velocity = this.velocityFilterWeight * velocity - + (1 - this.velocityFilterWeight) * this._lastVelocity; - - newWidth = this._strokeWidth(velocity); - this._drawCurve(curve, this._lastWidth, newWidth); - - this._lastVelocity = velocity; - this._lastWidth = newWidth; - } - }; - - SignaturePad.prototype._drawPoint = function (x, y, size) { - var ctx = this._ctx; - - ctx.moveTo(x, y); - if (this.stampImg == ''){ - ctx.arc(x, y, size, 0, 2 * Math.PI, false); - } - else{ - var image = new Image(); - image.src = this.stampImg; - var wImg = image.width; - var hImg = image.height; - - image.onload = function () { - ctx.drawImage(image, x-wImg/2, y-hImg/2); - }; - - this.stampImg = ''; - document.getElementById("stampBut").style.visibility = 'hidden'; - document.getElementById("stampBut").classList.remove('selected_but'); - } - if (this._isEmpty){ - document.getElementById("clearBut").classList.add('selected_but'); - document.getElementById("clearBut").classList.remove('disabled_but'); - document.getElementById("saveBut").classList.add('selected_but'); - document.getElementById("saveBut").classList.remove('disabled_but'); - } - this._isEmpty = false; - }; - - SignaturePad.prototype._drawCurve = function (curve, startWidth, endWidth) { - var ctx = this._ctx, - widthDelta = endWidth - startWidth, - drawSteps, width, i, t, tt, ttt, u, uu, uuu, x, y; - - drawSteps = Math.floor(curve.length()); - ctx.beginPath(); - for (i = 0; i < drawSteps; i++) { - // Calculate the Bezier (x, y) coordinate for this step. - t = i / drawSteps; - tt = t * t; - ttt = tt * t; - u = 1 - t; - uu = u * u; - uuu = uu * u; - - x = uuu * curve.startPoint.x; - x += 3 * uu * t * curve.control1.x; - x += 3 * u * tt * curve.control2.x; - x += ttt * curve.endPoint.x; - - y = uuu * curve.startPoint.y; - y += 3 * uu * t * curve.control1.y; - y += 3 * u * tt * curve.control2.y; - y += ttt * curve.endPoint.y; - - width = startWidth + ttt * widthDelta; - this._drawPoint(x, y, width); - } - ctx.closePath(); - ctx.fill(); - }; - - SignaturePad.prototype._strokeWidth = function (velocity) { - return Math.max(this.maxWidth / (velocity + 1), this.minWidth); - }; - - - var Point = function (x, y, time) { - this.x = x; - this.y = y; - this.time = time || new Date().getTime(); - }; - - Point.prototype.velocityFrom = function (start) { - return (this.time !== start.time) ? this.distanceTo(start) / (this.time - start.time) : 1; - }; - - Point.prototype.distanceTo = function (start) { - return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2)); - }; - - var Bezier = function (startPoint, control1, control2, endPoint) { - this.startPoint = startPoint; - this.control1 = control1; - this.control2 = control2; - this.endPoint = endPoint; - }; - - // Returns approximated length. - Bezier.prototype.length = function () { - var steps = 10, - length = 0, - i, t, cx, cy, px, py, xdiff, ydiff; - - for (i = 0; i <= steps; i++) { - t = i / steps; - cx = this._point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x); - cy = this._point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y); - if (i > 0) { - xdiff = cx - px; - ydiff = cy - py; - length += Math.sqrt(xdiff * xdiff + ydiff * ydiff); - } - px = cx; - py = cy; - } - return length; - }; - - Bezier.prototype._point = function (t, start, c1, c2, end) { - return start * (1.0 - t) * (1.0 - t) * (1.0 - t) - + 3.0 * c1 * (1.0 - t) * (1.0 - t) * t - + 3.0 * c2 * (1.0 - t) * t * t - + end * t * t * t; - }; - - return SignaturePad; -})(document); - -return SignaturePad; - -})); diff --git a/core/class/class_core_tools.php b/core/class/class_core_tools.php index 569e6269427c646e1e181c8e05a0f617acfc7bc1..4a23b5caebbe7c51643f4f5eb6c2bbe8968d8a55 100755 --- a/core/class/class_core_tools.php +++ b/core/class/class_core_tools.php @@ -1233,7 +1233,6 @@ class core_tools extends functions $arrOrder = $modules_services[$value][$iService]['whereamiused'][$k]['tab_order']; $frameSrc = $_SESSION['config']['businessappurl'].'index.php?display=true&module='.$value.'&page='.$modules_services[$value][$iService]['servicepage']; - //$frameSrc = $_SESSION['urltomodules'].$value."/".$modules_services[$value][$iService]['servicepage']; $tab_view[$arrOrder]['tab_label'] = $arrLabel; $tab_view[$arrOrder]['frame_src'] = $frameSrc; } elseif ($modules_services[$value][$iService]['whereamiused'][$k]['nature'] == 'popup' @@ -1294,12 +1293,10 @@ class core_tools extends functions } } } - } //print_r($executedServices); + } } } - // $this->show_array($executedServices); if ($servicenature == 'tab') { - //print_r($tab_view); for ($u = 1; $u <= count($tab_view); ++$u) { if ($u == 1) { ?> @@ -1323,7 +1320,6 @@ class core_tools extends functions } } } - // $this->show_array($executedServices); } /** @@ -1534,10 +1530,7 @@ class core_tools extends functions if (isset($_GET['module']) && $_GET['module'] != 'core') { // Page is defined in a module $found = false; - //$this->show_array($_SESSION['maarchFilesWhiteList']['modules'][$_GET['module']]); for ($cptM = 0; $cptM < count($_SESSION['maarchFilesWhiteList']['modules'][$_GET['module']]); ++$cptM) { - //echo $_SESSION['maarchFilesWhiteList']['modules'][$_GET['module']][$cptM] . '<br />'; - //echo 'modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; if ( $_SESSION['maarchFilesWhiteList']['modules'][$_GET['module']][$cptM] == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.'.php' @@ -1557,21 +1550,10 @@ class core_tools extends functions if (!$found) { $this->loadDefaultPage(); } - - // if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } elseif(file_exists($_SESSION['config']['corepath'].'modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require('modules'.DIRECTORY_SEPARATOR.$_GET['module'].DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } else { - // $this->loadDefaultPage(); - // } } elseif (isset($_GET['module']) && $_GET['module'] == 'core') { // Page is defined the core $found = false; - //$this->show_array($_SESSION['maarchFilesWhiteList']['core']); for ($cptM = 0; $cptM < count($_SESSION['maarchFilesWhiteList']['core']); ++$cptM) { - //echo $_SESSION['maarchFilesWhiteList']['core'][$cptM] . '<br />'; - //echo 'core'.DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; if ( $_SESSION['maarchFilesWhiteList']['core'][$cptM] == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.$this->f_page.'.php' @@ -1591,14 +1573,6 @@ class core_tools extends functions if (!$found) { $this->loadDefaultPage(); } - - // if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } elseif(file_exists($_SESSION['config']['corepath'].'core'.DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require('core'.DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } else { - // $this->loadDefaultPage(); - // } } elseif (isset($_GET['admin']) && !empty($_GET['admin'])) { if ( !isset($_SESSION['user']['services']['admin']) @@ -1608,10 +1582,7 @@ class core_tools extends functions $this->loadDefaultPage(); } else { $found = false; - //$this->show_array($_SESSION['maarchFilesWhiteList']['apps']); for ($cptM = 0; $cptM < count($_SESSION['maarchFilesWhiteList']['apps']); ++$cptM) { - //echo $_SESSION['maarchFilesWhiteList']['apps'][$cptM] . '<br />'; - //echo 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; if ( $_SESSION['maarchFilesWhiteList']['apps'][$cptM] == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.'.php' @@ -1631,23 +1602,11 @@ class core_tools extends functions if (!$found) { $this->loadDefaultPage(); } - - // Page is defined the admin directory of the application - /*if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.".php")) { - require($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.".php"); - } elseif(file_exists($_SESSION['config']['corepath'].'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.".php")) { - require('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.trim($_GET['admin']).DIRECTORY_SEPARATOR.$this->f_page.".php"); - } else { - $this->loadDefaultPage(); - }*/ } } elseif (isset($_GET['dir']) && !empty($_GET['dir'])) { // Page is defined in a dir directory of the application $found = false; - //$this->show_array($_SESSION['maarchFilesWhiteList']['apps']); for ($cptM = 0; $cptM < count($_SESSION['maarchFilesWhiteList']['apps']); ++$cptM) { - //echo $_SESSION['maarchFilesWhiteList']['apps'][$cptM] . '<br />'; - //echo 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; if ( $_SESSION['maarchFilesWhiteList']['apps'][$cptM] == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.'.php' @@ -1668,21 +1627,10 @@ class core_tools extends functions $this->loadDefaultPage(); } - // if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } elseif(file_exists($_SESSION['config']['corepath'].'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.trim($_GET['dir']).DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } else { - // $this->loadDefaultPage(); - // } } else { // Page is defined in the application $found = false; - //$this->show_array($_SESSION['maarchFilesWhiteList']['apps']); for ($cptM = 0; $cptM < count($_SESSION['maarchFilesWhiteList']['apps']); ++$cptM) { - //echo $_SESSION['maarchFilesWhiteList']['apps'][$cptM] . '<br />'; - //echo 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; - //echo 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php" . '<br />'; if ( $_SESSION['maarchFilesWhiteList']['apps'][$cptM] == 'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.'.php' @@ -1721,30 +1669,6 @@ class core_tools extends functions if (!$found) { $this->loadDefaultPage(); } - - // if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } elseif(file_exists($_SESSION['config']['corepath'].'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php")) { - // require('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$this->f_page.".php"); - // } else { - // require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php"); - // $app = new business_app_tools(); - // $path = $app->insert_app_page($this->f_page); - // echo $path;exit; - // if( - // (!$path || empty($path)) - // && !file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.$path) - // && !file_exists($path)) { - // //require($_SESSION["config"]["defaultPage"].".php"); - // $this->loadDefaultPage(); - // } else { - // if (!file_exists($path)) { - // $this->loadDefaultPage(); - // } else { - // require($path); - // } - // } - // } } return true; @@ -1820,7 +1744,7 @@ class core_tools extends functions */ public function load_footer() { - echo 'Powered by Maarch™ 2019'; + echo 'Powered by Maarch™ 2020'; } /** @@ -1913,24 +1837,6 @@ class core_tools extends functions return _NO_LABEL_FOUND; } - /** - * Test if a service is enabled. - * - * @param $id_service string Service identifier - * - * @return bool true if enabled false if not - */ - public function service_is_enabled($id_service) - { - for ($i = 0; $i < count($_SESSION['enabled_services']); ++$i) { - if ($_SESSION['enabled_services'][$i]['id'] == $id_service) { - return true; - } - } - - return false; - } - /** * Tests if the user has admin rights on the service. * @@ -2127,29 +2033,6 @@ class core_tools extends functions } } - public function is_action_defined($action_id) - { - require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_db.php'; - if (empty($action_id)) { - return false; - } - $db = new Database(); - $stmt = $db->query('select origin from '.$_SESSION['tablename']['actions'].' where id = ?', array($action_id)); - $res = $stmt->fetchObject(); - $origin = strtolower($res->origin); - - if ($origin == 'apps' || $origin == 'core') { - return true; - } - for ($i = 0; $i < count($_SESSION['modules']); ++$i) { - if (strtolower($_SESSION['modules'][$i]['moduleid']) == $origin) { - return true; - } - } - - return false; - } - public function get_custom_id() { if (!file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.'custom.xml')) { @@ -2173,7 +2056,6 @@ class core_tools extends functions } $xml = simplexml_load_file($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.'custom.xml'); - //var_dump($xml); foreach ($xml->custom as $custom) { if (trim($path) != '' && isset($custom->path) && $custom->path == trim($path)) { return (string) $custom->custom_id; @@ -2188,83 +2070,4 @@ class core_tools extends functions return ''; } - - /** - * Detects if the user agent is a smartphone. - */ - public function detectSmartphone() - { - $user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed - $accept = $_SERVER['HTTP_ACCEPT']; // get the content accept value - this should be cleaned to ensure no nefarious input gets executed - return false - || (preg_match('/ipad/i', $user_agent)) - || (preg_match('/ipod/i', $user_agent) || preg_match('/iphone/i', $user_agent)) - || (preg_match('/android/i', $user_agent)) - || (preg_match('/opera mini/i', $user_agent)) - || (preg_match('/blackberry/i', $user_agent)) - || (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i', $user_agent)) - || (preg_match('/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i', $user_agent)) - || (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i', $user_agent)) - || ((strpos($accept, 'text/vnd.wap.wml') > 0) || (strpos($accept, 'application/vnd.wap.xhtml+xml') > 0)) - || (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) - || (in_array(strtolower(substr($user_agent, 0, 4)), array('1207' => '1207', '3gso' => '3gso', '4thp' => '4thp', '501i' => '501i', '502i' => '502i', '503i' => '503i', '504i' => '504i', '505i' => '505i', '506i' => '506i', '6310' => '6310', '6590' => '6590', '770s' => '770s', '802s' => '802s', 'a wa' => 'a wa', 'acer' => 'acer', 'acs-' => 'acs-', 'airn' => 'airn', 'alav' => 'alav', 'asus' => 'asus', 'attw' => 'attw', 'au-m' => 'au-m', 'aur ' => 'aur ', 'aus ' => 'aus ', 'abac' => 'abac', 'acoo' => 'acoo', 'aiko' => 'aiko', 'alco' => 'alco', 'alca' => 'alca', 'amoi' => 'amoi', 'anex' => 'anex', 'anny' => 'anny', 'anyw' => 'anyw', 'aptu' => 'aptu', 'arch' => 'arch', 'argo' => 'argo', 'bell' => 'bell', 'bird' => 'bird', 'bw-n' => 'bw-n', 'bw-u' => 'bw-u', 'beck' => 'beck', 'benq' => 'benq', 'bilb' => 'bilb', 'blac' => 'blac', 'c55/' => 'c55/', 'cdm-' => 'cdm-', 'chtm' => 'chtm', 'capi' => 'capi', 'cond' => 'cond', 'craw' => 'craw', 'dall' => 'dall', 'dbte' => 'dbte', 'dc-s' => 'dc-s', 'dica' => 'dica', 'ds-d' => 'ds-d', 'ds12' => 'ds12', 'dait' => 'dait', 'devi' => 'devi', 'dmob' => 'dmob', 'doco' => 'doco', 'dopo' => 'dopo', 'el49' => 'el49', 'erk0' => 'erk0', 'esl8' => 'esl8', 'ez40' => 'ez40', 'ez60' => 'ez60', 'ez70' => 'ez70', 'ezos' => 'ezos', 'ezze' => 'ezze', 'elai' => 'elai', 'emul' => 'emul', 'eric' => 'eric', 'ezwa' => 'ezwa', 'fake' => 'fake', 'fly-' => 'fly-', 'fly_' => 'fly_', 'g-mo' => 'g-mo', 'g1 u' => 'g1 u', 'g560' => 'g560', 'gf-5' => 'gf-5', 'grun' => 'grun', 'gene' => 'gene', 'go.w' => 'go.w', 'good' => 'good', 'grad' => 'grad', 'hcit' => 'hcit', 'hd-m' => 'hd-m', 'hd-p' => 'hd-p', 'hd-t' => 'hd-t', 'hei-' => 'hei-', 'hp i' => 'hp i', 'hpip' => 'hpip', 'hs-c' => 'hs-c', 'htc ' => 'htc ', 'htc-' => 'htc-', 'htca' => 'htca', 'htcg' => 'htcg', 'htcp' => 'htcp', 'htcs' => 'htcs', 'htct' => 'htct', 'htc_' => 'htc_', 'haie' => 'haie', 'hita' => 'hita', 'huaw' => 'huaw', 'hutc' => 'hutc', 'i-20' => 'i-20', 'i-go' => 'i-go', 'i-ma' => 'i-ma', 'i230' => 'i230', 'iac' => 'iac', 'iac-' => 'iac-', 'iac/' => 'iac/', 'ig01' => 'ig01', 'im1k' => 'im1k', 'inno' => 'inno', 'iris' => 'iris', 'jata' => 'jata', 'java' => 'java', 'kddi' => 'kddi', 'kgt' => 'kgt', 'kgt/' => 'kgt/', 'kpt ' => 'kpt ', 'kwc-' => 'kwc-', 'klon' => 'klon', 'lexi' => 'lexi', 'lg g' => 'lg g', 'lg-a' => 'lg-a', 'lg-b' => 'lg-b', 'lg-c' => 'lg-c', 'lg-d' => 'lg-d', 'lg-f' => 'lg-f', 'lg-g' => 'lg-g', 'lg-k' => 'lg-k', 'lg-l' => 'lg-l', 'lg-m' => 'lg-m', 'lg-o' => 'lg-o', 'lg-p' => 'lg-p', 'lg-s' => 'lg-s', 'lg-t' => 'lg-t', 'lg-u' => 'lg-u', 'lg-w' => 'lg-w', 'lg/k' => 'lg/k', 'lg/l' => 'lg/l', 'lg/u' => 'lg/u', 'lg50' => 'lg50', 'lg54' => 'lg54', 'lge-' => 'lge-', 'lge/' => 'lge/', 'lynx' => 'lynx', 'leno' => 'leno', 'm1-w' => 'm1-w', 'm3ga' => 'm3ga', 'm50/' => 'm50/', 'maui' => 'maui', 'mc01' => 'mc01', 'mc21' => 'mc21', 'mcca' => 'mcca', 'medi' => 'medi', 'meri' => 'meri', 'mio8' => 'mio8', 'mioa' => 'mioa', 'mo01' => 'mo01', 'mo02' => 'mo02', 'mode' => 'mode', 'modo' => 'modo', 'mot ' => 'mot ', 'mot-' => 'mot-', 'mt50' => 'mt50', 'mtp1' => 'mtp1', 'mtv ' => 'mtv ', 'mate' => 'mate', 'maxo' => 'maxo', 'merc' => 'merc', 'mits' => 'mits', 'mobi' => 'mobi', 'motv' => 'motv', 'mozz' => 'mozz', 'n100' => 'n100', 'n101' => 'n101', 'n102' => 'n102', 'n202' => 'n202', 'n203' => 'n203', 'n300' => 'n300', 'n302' => 'n302', 'n500' => 'n500', 'n502' => 'n502', 'n505' => 'n505', 'n700' => 'n700', 'n701' => 'n701', 'n710' => 'n710', 'nec-' => 'nec-', 'nem-' => 'nem-', 'newg' => 'newg', 'neon' => 'neon', 'netf' => 'netf', 'noki' => 'noki', 'nzph' => 'nzph', 'o2 x' => 'o2 x', 'o2-x' => 'o2-x', 'opwv' => 'opwv', 'owg1' => 'owg1', 'opti' => 'opti', 'oran' => 'oran', 'p800' => 'p800', 'pand' => 'pand', 'pg-1' => 'pg-1', 'pg-2' => 'pg-2', 'pg-3' => 'pg-3', 'pg-6' => 'pg-6', 'pg-8' => 'pg-8', 'pg-c' => 'pg-c', 'pg13' => 'pg13', 'phil' => 'phil', 'pn-2' => 'pn-2', 'pt-g' => 'pt-g', 'palm' => 'palm', 'pana' => 'pana', 'pire' => 'pire', 'pock' => 'pock', 'pose' => 'pose', 'psio' => 'psio', 'qa-a' => 'qa-a', 'qc-2' => 'qc-2', 'qc-3' => 'qc-3', 'qc-5' => 'qc-5', 'qc-7' => 'qc-7', 'qc07' => 'qc07', 'qc12' => 'qc12', 'qc21' => 'qc21', 'qc32' => 'qc32', 'qc60' => 'qc60', 'qci-' => 'qci-', 'qwap' => 'qwap', 'qtek' => 'qtek', 'r380' => 'r380', 'r600' => 'r600', 'raks' => 'raks', 'rim9' => 'rim9', 'rove' => 'rove', 's55/' => 's55/', 'sage' => 'sage', 'sams' => 'sams', 'sc01' => 'sc01', 'sch-' => 'sch-', 'scp-' => 'scp-', 'sdk/' => 'sdk/', 'se47' => 'se47', 'sec-' => 'sec-', 'sec0' => 'sec0', 'sec1' => 'sec1', 'semc' => 'semc', 'sgh-' => 'sgh-', 'shar' => 'shar', 'sie-' => 'sie-', 'sk-0' => 'sk-0', 'sl45' => 'sl45', 'slid' => 'slid', 'smb3' => 'smb3', 'smt5' => 'smt5', 'sp01' => 'sp01', 'sph-' => 'sph-', 'spv ' => 'spv ', 'spv-' => 'spv-', 'sy01' => 'sy01', 'samm' => 'samm', 'sany' => 'sany', 'sava' => 'sava', 'scoo' => 'scoo', 'send' => 'send', 'siem' => 'siem', 'smar' => 'smar', 'smit' => 'smit', 'soft' => 'soft', 'sony' => 'sony', 't-mo' => 't-mo', 't218' => 't218', 't250' => 't250', 't600' => 't600', 't610' => 't610', 't618' => 't618', 'tcl-' => 'tcl-', 'tdg-' => 'tdg-', 'telm' => 'telm', 'tim-' => 'tim-', 'ts70' => 'ts70', 'tsm-' => 'tsm-', 'tsm3' => 'tsm3', 'tsm5' => 'tsm5', 'tx-9' => 'tx-9', 'tagt' => 'tagt', 'talk' => 'talk', 'teli' => 'teli', 'topl' => 'topl', 'hiba' => 'hiba', 'up.b' => 'up.b', 'upg1' => 'upg1', 'utst' => 'utst', 'v400' => 'v400', 'v750' => 'v750', 'veri' => 'veri', 'vk-v' => 'vk-v', 'vk40' => 'vk40', 'vk50' => 'vk50', 'vk52' => 'vk52', 'vk53' => 'vk53', 'vm40' => 'vm40', 'vx98' => 'vx98', 'virg' => 'virg', 'vite' => 'vite', 'voda' => 'voda', 'vulc' => 'vulc', 'w3c ' => 'w3c ', 'w3c-' => 'w3c-', 'wapj' => 'wapj', 'wapp' => 'wapp', 'wapu' => 'wapu', 'wapm' => 'wapm', 'wig ' => 'wig ', 'wapi' => 'wapi', 'wapr' => 'wapr', 'wapv' => 'wapv', 'wapy' => 'wapy', 'wapa' => 'wapa', 'waps' => 'waps', 'wapt' => 'wapt', 'winc' => 'winc', 'winw' => 'winw', 'wonu' => 'wonu', 'x700' => 'x700', 'xda2' => 'xda2', 'xdag' => 'xdag', 'yas-' => 'yas-', 'your' => 'your', 'zte-' => 'zte-', 'zeto' => 'zeto', 'acs-' => 'acs-', 'alav' => 'alav', 'alca' => 'alca', 'amoi' => 'amoi', 'aste' => 'aste', 'audi' => 'audi', 'avan' => 'avan', 'benq' => 'benq', 'bird' => 'bird', 'blac' => 'blac', 'blaz' => 'blaz', 'brew' => 'brew', 'brvw' => 'brvw', 'bumb' => 'bumb', 'ccwa' => 'ccwa', 'cell' => 'cell', 'cldc' => 'cldc', 'cmd-' => 'cmd-', 'dang' => 'dang', 'doco' => 'doco', 'eml2' => 'eml2', 'eric' => 'eric', 'fetc' => 'fetc', 'hipt' => 'hipt', 'http' => 'http', 'ibro' => 'ibro', 'idea' => 'idea', 'ikom' => 'ikom', 'inno' => 'inno', 'ipaq' => 'ipaq', 'jbro' => 'jbro', 'jemu' => 'jemu', 'java' => 'java', 'jigs' => 'jigs', 'kddi' => 'kddi', 'keji' => 'keji', 'kyoc' => 'kyoc', 'kyok' => 'kyok', 'leno' => 'leno', 'lg-c' => 'lg-c', 'lg-d' => 'lg-d', 'lg-g' => 'lg-g', 'lge-' => 'lge-', 'libw' => 'libw', 'm-cr' => 'm-cr', 'maui' => 'maui', 'maxo' => 'maxo', 'midp' => 'midp', 'mits' => 'mits', 'mmef' => 'mmef', 'mobi' => 'mobi', 'mot-' => 'mot-', 'moto' => 'moto', 'mwbp' => 'mwbp', 'mywa' => 'mywa', 'nec-' => 'nec-', 'newt' => 'newt', 'nok6' => 'nok6', 'noki' => 'noki', 'o2im' => 'o2im', 'opwv' => 'opwv', 'palm' => 'palm', 'pana' => 'pana', 'pant' => 'pant', 'pdxg' => 'pdxg', 'phil' => 'phil', 'play' => 'play', 'pluc' => 'pluc', 'port' => 'port', 'prox' => 'prox', 'qtek' => 'qtek', 'qwap' => 'qwap', 'rozo' => 'rozo', 'sage' => 'sage', 'sama' => 'sama', 'sams' => 'sams', 'sany' => 'sany', 'sch-' => 'sch-', 'sec-' => 'sec-', 'send' => 'send', 'seri' => 'seri', 'sgh-' => 'sgh-', 'shar' => 'shar', 'sie-' => 'sie-', 'siem' => 'siem', 'smal' => 'smal', 'smar' => 'smar', 'sony' => 'sony', 'sph-' => 'sph-', 'symb' => 'symb', 't-mo' => 't-mo', 'teli' => 'teli', 'tim-' => 'tim-', 'tosh' => 'tosh', 'treo' => 'treo', 'tsm-' => 'tsm-', 'upg1' => 'upg1', 'upsi' => 'upsi', 'vk-v' => 'vk-v', 'voda' => 'voda', 'vx52' => 'vx52', 'vx53' => 'vx53', 'vx60' => 'vx60', 'vx61' => 'vx61', 'vx70' => 'vx70', 'vx80' => 'vx80', 'vx81' => 'vx81', 'vx83' => 'vx83', 'vx85' => 'vx85', 'wap-' => 'wap-', 'wapa' => 'wapa', 'wapi' => 'wapi', 'wapp' => 'wapp', 'wapr' => 'wapr', 'webc' => 'webc', 'whit' => 'whit', 'winw' => 'winw', 'wmlb' => 'wmlb', 'xda-' => 'xda-'))) - ; - } - - /** - * Loads the html header for smartphone. - * - * @param $title string Title tag value (empty by default) - */ - public function loadSmartphoneHeader($title = '', $load_css = true, $load_js = true) - { - if (empty($title)) { - $title = $_SESSION['config']['applicationname']; - } ?> - <head> - <title><?php functions::xecho($title); ?></title> - <meta name="apple-mobile-web-app-capable" content="yes"> - <meta name="apple-touch-fullscreen" content="yes"> - <link rel="apple-touch-icon" href="img/board.png"> - <link rel="apple-touch-icon-precomposed" href="img/board.png"> - <?php - if ($load_css) { - $this->loadSmartphoneCss(); - } - if ($load_js) { - //$this->load_js();?> - <script type="application/javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>smartphone/js/maarch_functions.js"></script> - <script type="application/x-javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>smartphone/js/iui/iui.js"></script> - <script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>smartphone/js/iscroll.js?v3.7.1"></script> - <script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>js/prototype.js"></script> - <script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl']; ?>js/scriptaculous.js"></script> - <script src="<?php echo $_SESSION['config']['businessappurl']; ?>tools/signature_pad/js/signature_pad.js" type="text/javascript"></script> - - <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> - <script src="<?php echo $_SESSION['config']['businessappurl']; ?>tools/fingerprintjs2/fingerprint2.js" type="text/javascript"></script> - <?php - } ?> - </head> - <?php - } - - /** - * Loads the smartphone css. - */ - private function loadSmartphoneCss() - { - ?> - <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> - <!--<link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['config']['businessappurl'].'smartphone/css/style.css'; ?>" media="screen" />--> - <link rel="stylesheet" href="<?php echo $_SESSION['config']['coreurl'] - .'node_modules/@fortawesome/fontawesome-free/css/all.css'; ?>" media="screen" /> - <link rel="stylesheet" href="<?php echo $_SESSION['config']['businessappurl'] - .'css/font-awesome-maarch/css/font-maarch.css'; ?>" media="screen" /> - <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['config']['businessappurl'].'smartphone/css/iui-panel-list.css'; ?>" media="screen" /> - <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['config']['businessappurl'].'smartphone/js/iui/iui.css'; ?>" media="screen" /> - - <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['config']['businessappurl'].'smartphone/js/iui/t/maarch/maarch-theme.css'; ?>" media="screen" /> - <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['config']['businessappurl'].'tools/signature_pad/css/signature-pad.css'; ?>" media="screen" /> - <?php - } } diff --git a/core/class/resources_controler.php b/core/class/resources_controler.php deleted file mode 100755 index ec3984b7f9c16672af46c04ec682e1a71fce2bc4..0000000000000000000000000000000000000000 --- a/core/class/resources_controler.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/* -* Copyright 2011-2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Contains the controler of the Resource Object -* -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -// To activate de debug mode of the class -$_ENV['DEBUG'] = false; -/* -define("_CODE_SEPARATOR","/"); -define("_CODE_INCREMENT",1); -*/ - -// Loads the required class -try { - require_once 'core/class/resources.php'; - require_once 'core/core_tables.php'; - require_once 'core/class/class_functions.php'; - require_once 'core/class/docservers_controler.php'; - require_once 'core/class/class_resource.php'; -} catch (Exception $e) { - echo functions::xssafe($e->getMessage()).' // '; -} - -/** -* @brief Controler of the Resource Object -* -* @ingroup core -*/ -class resources_controler -{ - - ##################################### - ## Web Service to retrieve attachment from an identifier - ##################################### - public function retrieveMasterResByChrono($identifier, $collId) - { - try { - $db = new Database(); - $resultArr = array(); - - if ($identifier == '') { - $resultArr = array( - 'returnCode' => (int) -2, - 'resId' => '', - 'title' => '', - 'identifier' => '', - 'status' => '', - 'attachment_type' => '', - 'dest_contact_id' => '', - 'dest_address_id' => '', - 'error' => 'param identifier empty', - ); - return $resultArr; - } - - if ($collId == '') { - $resultArr = array( - 'returnCode' => (int) -2, - 'resId' => '', - 'title' => '', - 'identifier' => '', - 'status' => '', - 'attachment_type' => '', - 'dest_contact_id' => '', - 'dest_address_id' => '', - 'error' => 'param collId empty', - ); - return $resultArr; - } - - $queryAttachments = "select * from res_attachments where " - . "identifier = ? and coll_id = ? order by res_id"; - $stmt = $db->query( - $queryAttachments, - array($identifier, $collId) - ); - - $line = $stmt->fetchObject(); - - //var_dump($line); - - if ($line->res_id_master == '') { - $resultArr = array( - 'returnCode' => (int) -3, - 'resId' => '', - 'title' => '', - 'identifier' => '', - 'status' => '', - 'attachment_type' => '', - 'dest_contact_id' => '', - 'dest_address_id' => '', - 'error' => 'resource not found : ' - . $identifier . ' ' . $collId, - ); - return $resultArr; - } else { - $resultArr = array( - 'returnCode' => (int) 0, - 'resId' => $line->res_id_master, - 'title' => $line->title, - 'identifier' => $line->identifier, - 'status' => $line->status, - 'attachment_type' => $line->attachment_type, - 'dest_contact_id' => $line->dest_contact_id, - 'dest_address_id' => $line->dest_address_id, - 'error' => '', - ); - return $resultArr; - } - - return $resultArr; - } catch (Exception $e) { - $resultArr = array( - 'returnCode' => (int) -1, - 'resId' => '', - 'title' => '', - 'identifier' => '', - 'status' => '', - 'attachment_type' => '', - 'dest_contact_id' => '', - 'dest_address_id' => '', - 'error' => 'unknown error : ' - . $e->getMessage(), - ); - return $resultArr; - } - } -} diff --git a/core/class/users_controler.php b/core/class/users_controler.php index 4f629b42b85ccf306a05710a906c695884a607df..4ee4d1ce4870a73b326b84f902370bf9ff050479 100755 --- a/core/class/users_controler.php +++ b/core/class/users_controler.php @@ -879,38 +879,6 @@ class users_controler extends ObjectControler implements ObjectControlerIF } } - /** - * Check if the user exist in the database given his mail - * - * @param $userMail string user mail - * @return Array or null - */ - public function checkUserMail($userMail) - { - self::$db = new Database(); - $func = new functions(); - $queryUser = "SELECT user_id FROM users WHERE mail = ? and status = 'OK'"; - $stmt = self::$db->query($queryUser, array($userMail)); - $userIdFound = $stmt->fetchObject(); - $UserEntities = array(); - if (!empty($userIdFound->user_id)) { - $isUser = true; - $UserEntities = $this->getEntities($userIdFound->user_id); - } else { - $isUser = false; - } - $return = array(); - array_push( - $return, - array( - 'isUser' => $isUser, - 'userEntities' => $UserEntities - ) - ); - - return $return; - } - /** * Returns in an array all the entities associated with a user (user_id, * entity_id, primary and role) diff --git a/core/class/web_service/Maarch_SOAP_DISCO_Server.php b/core/class/web_service/Maarch_SOAP_DISCO_Server.php deleted file mode 100755 index 8be671a7b7daa5259a568711b9ed1a693bd121c8..0000000000000000000000000000000000000000 --- a/core/class/web_service/Maarch_SOAP_DISCO_Server.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - require_once('apps/maarch_entreprise/tools/PEAR/SOAP/Disco.php'); -} else { - require_once('SOAP/Disco.php'); -} -require_once('core/class/Url.php'); - -class Maarch_SOAP_DISCO_Server extends SOAP_DISCO_Server -{ - public function __construct($server, $service_name = 'MaarchSoapServer') - { - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - $SOAP_DISCO_Server = new SOAP_DISCO_Server($server, $service_name); - - $this->soap_server = $SOAP_DISCO_Server->soap_server; - - $this->soap_server->_namespaces = $SOAP_DISCO_Server->namespaces; - - $this->_service_name = $service_name; - $this->_service_ns = "urn:$service_name"; - } else { - $funcGetArgs = func_get_args(); - call_user_func_array(array(parent, 'SOAP_DISCO_Server'), - $funcGetArgs); - } - - $this->host = array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER) - ? $_SERVER['HTTP_X_FORWARDED_HOST'] - : $_SERVER['HTTP_HOST']; - } - - private function selfUrl() - { - $rootUri = self::_getRootUri(); - $protocol = ( (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') || - (array_key_exists('HTTP_FORCE_HTTPS', $_SERVER) && $_SERVER['HTTP_FORCE_HTTPS'] == 'on') ) - ? 'https://' : 'http://' ; - $lastChar = strlen($rootUri) - 1; - if ($rootUri[$lastChar] != '/') { - $rootUri .= '/'; - } - return $protocol . $this->host . $rootUri . basename(Url::scriptName()); - } - - private static function _getRootUri() - { - return Url::baseUri(); - } - - public function _generate_WSDL() - { - parent::_generate_WSDL(); - - $this->_wsdl['definitions']['service']['port']['soap:address']['attr']['location'] = - $this->selfUrl(); - - $this->_generate_WSDL_XML(); - } - - public function _generate_DISCO() - { - parent::_generate_DISCO(); - - $this->_disco['disco:discovery']['scl:contractRef']['attr']['ref'] = - $this->selfUrl() . '?wsdl'; - - // generate disco xml - $this->_generate_DISCO_XML($this->_disco); - } -} diff --git a/core/class/web_service/class_rest_server.php b/core/class/web_service/class_rest_server.php deleted file mode 100755 index c6d00b4dab943399b45d6bb7c5bdf2e32bee1344..0000000000000000000000000000000000000000 --- a/core/class/web_service/class_rest_server.php +++ /dev/null @@ -1,332 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Maarch REST class -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -//declaration of descriptions services vars -if (!isset ($REST_dispatch_map)) { - $REST_dispatch_map = Array (); -} - -/** - * Class for manage REST web service - */ -class MyRestServer extends webService -{ - var $dispatchMap; - var $crudMethod; - var $resController; - var $requestedCollection; - var $requestedResource; - var $requestedResourceId; - var $atomFileContent; - - function __construct() - { - global $REST_dispatch_map; - $this->dispatchMap = $REST_dispatch_map; - //$this->retrieveHttpMethod(); - $this->parseTheRequest(); - } - - /*function retrieveHttpMethod() - { - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->crudMethod = 'create'; - } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') { - $this->crudMethod = 'retrieve'; - } if ($_SERVER['REQUEST_METHOD'] == 'PUT') { - $this->crudMethod = 'update'; - } if ($_SERVER['REQUEST_METHOD'] == 'DELETE') { - $this->crudMethod = 'delete'; - } - }*/ - - /** - * parse the request - * @return nothing - */ - function parseTheRequest() - { - if ( - strtolower($_SERVER['QUERY_STRING']) == 'cmis/id=workspace://' - || strtolower($_SERVER['QUERY_STRING']) == 'cmis&repositoryId=' - . $this->getUuid() - ) { - $this->makeAtomEntryRootFolder(); - } else { - $restRequest = explode('/', $_SERVER['QUERY_STRING']); - //var_dump($restRequest); - if ($restRequest[1] <> '') { - $this->requestedCollection = $restRequest[1]; - } - if ($restRequest[2] <> '') { - $this->requestedResource = $restRequest[2]; - } - if ($restRequest[3] <> '') { - $this->requestedResourceId = $restRequest[3]; - } - if ( - isset($_REQUEST['atomFileContent']) - && !empty($_REQUEST['atomFileContent']) - ) { - $this->atomFileContent = $_REQUEST['atomFileContent']; - } - //var_dump($this); - } - } - - /** - * parse the requested resource object and call the good method of - * the requested resource controller - * @return call of the good method - */ - public function call() - { - // var_dump($this->dispatchMap); - // var_dump($this->requestedResource); - // var_dump($this->dispatchMap[$this->requestedResource]['pathToController']); - if ( - file_exists( - $this->dispatchMap[$this->requestedResource]['pathToController'] - ) - ) { - require_once( - $this->dispatchMap[$this->requestedResource]['pathToController'] - ); - $objectControllerName = $this->requestedResource . 'CMIS'; - $objectController = new $objectControllerName(); - $args = array( - 'atomFileContent' => $this->atomFileContent, - 'requestedResourceId' => $this->requestedResourceId, - 'requestedCollection' => $this->requestedCollection - ); - return call_user_func_array( - array($objectController, 'entryMethod'), $args - ); - } - } - - /** - * generate REST server - */ - function makeRESTServer() - { - //only for tests - header("Content-type: text/xml"); - $this->call(); - } - - /** - * Get the uuid from the database or generate it - * @return string the uuid - */ - function getUuid() - { - $func = new functions(); - $db = new Database(); - $uuid = ''; - $reqUuid = "select param_value_string from parameters " - . "where id = 'cmis_uuid'"; - $stmt = $db->query($reqUuid); - while ($reqResult = $stmt->fetchObject()) { - $uuid = $reqResult->param_value_string; - } - if (empty($uuid)) { - $uuid = $func->gen_uuid(); - $reqInsertUuid = - "insert into parameters (id, param_value_string) values " - . "('cmis_uuid', ?)"; - $stmt = $db->query($reqInsertUuid, array($uuid)); - } - return $uuid; - } - - /** - * generate CMIS catalog - */ - function makeCMISCatalog() - { - header("Content-type: text/xml"); - echo '<?xml version="1.0" encoding="utf-8"?> -<app:service xmlns:app="http://www.w3.org/2007/app" -xmlns:atom="http://www.w3.org/2005/Atom" -xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" -xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" -xmlns:maarch="http://www.maarch.org"> - <app:workspace> - <atom:title>Maarch main Repository</atom:title> - <collection href="' . $_SESSION['config']['coreurl'] - . 'ws_server.php?CMIS"> - <atom:title>Maarch root collection</atom:title> - <cmisra:collectionType>root</cmisra:collectionType> - </collection> - <cmisra:repositoryInfo> - <cmis:repositoryId>' . $this->getUuid() . '</cmis:repositoryId> - <cmis:repositoryName>Maarch main Repository</cmis:repositoryName> - <cmis:repositoryDescription>Maarch main Repository</cmis:repositoryDescription> - <cmis:vendorName>Maarch</cmis:vendorName> - <cmis:productName>MaarchCourrier</cmis:productName> - <cmis:productVersion>1.6.0</cmis:productVersion> - <cmis:rootFolderId>workspace://</cmis:rootFolderId> - <cmis:capabilities> - <cmis:capabilityACL>none</cmis:capabilityACL> - <cmis:capabilityAllVersionsSearchable>false</cmis:capabilityAllVersionsSearchable> - <cmis:capabilityChanges>none</cmis:capabilityChanges> - <cmis:capabilityContentStreamUpdatability>none</cmis:capabilityContentStreamUpdatability> - <cmis:capabilityGetDescendants>true</cmis:capabilityGetDescendants> - <cmis:capabilityGetFolderTree>false</cmis:capabilityGetFolderTree> - <cmis:capabilityMultifiling>false</cmis:capabilityMultifiling> - <cmis:capabilityPWCSearchable>false</cmis:capabilityPWCSearchable> - <cmis:capabilityPWCUpdatable>false</cmis:capabilityPWCUpdatable> - <cmis:capabilityQuery>metadataonly</cmis:capabilityQuery> - <cmis:capabilityRenditions>none</cmis:capabilityRenditions> - <cmis:capabilityUnfiling>true</cmis:capabilityUnfiling> - <cmis:capabilityVersionSpecificFiling>false</cmis:capabilityVersionSpecificFiling> - <cmis:capabilityJoin>none</cmis:capabilityJoin> - </cmis:capabilities> - <cmis:cmisVersionSupported>1.0</cmis:cmisVersionSupported> - </cmisra:repositoryInfo> - <cmisra:uritemplate> - <cmisra:template>' . $_SESSION['config']['coreurl'] - . 'ws_server.php?CMIS/id={id}</cmisra:template> - <cmisra:type>entrybyid</cmisra:type> - <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype> - </cmisra:uritemplate> - <cmisra:uritemplate> - <cmisra:template>' . $_SESSION['config']['coreurl'] - . 'ws_server.php?CMIS/path={path}</cmisra:template> - <cmisra:type>folderbypath</cmisra:type> - <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype> - </cmisra:uritemplate> - <cmisra:uritemplate> - <cmisra:template>' . $_SESSION['config']['coreurl'] - . 'ws_server.php?CMIS/type={id}/</cmisra:template> - <cmisra:type>query</cmisra:type> - <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype> - </cmisra:uritemplate> - </app:workspace> -</app:service>'; - exit; - } - - /** - * generate the atom:entry root folder - */ - function makeAtomEntryRootFolder() - { - header("Content-type: text/xml"); - echo '<?xml version="1.0" encoding="UTF-8"?> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" -xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" -xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" -xmlns:app="http://www.w3.org/2007/app" -xmlns:maarch="http://www.maarch.org"> - <atom:author> - <atom:name>Maarch</atom:name> - </atom:author> - <atom:id>ROOT</atom:id> - <atom:published>2010-09-28T11:51:47Z</atom:published> - <atom:title>' . $_SESSION['config']['applicationname'] . '</atom:title> - <app:edited>2012-11-21T14:44:59Z</app:edited> - <atom:updated>2012-11-21T14:44:59Z</atom:updated> - <cmisra:object xmlns:ns3="http://docs.oasis-open.org/ns/cmis/messaging/200908/"> - <cmis:properties> - <cmis:propertyId queryName="cmis:allowedChildObjectTypeIds" displayName="Allowed Child Object Types Ids" localName="allowedChildObjectTypeIds" propertyDefinitionId="cmis:allowedChildObjectTypeIds"/> - <cmis:propertyId queryName="cmis:objectTypeId" displayName="Object Type Id" localName="objectTypeId" propertyDefinitionId="cmis:objectTypeId"> - <cmis:value>cmis:folder</cmis:value> - </cmis:propertyId> - <cmis:propertyString queryName="cmis:path" displayName="Path" localName="path" propertyDefinitionId="cmis:path"> - <cmis:value>/</cmis:value> - </cmis:propertyString> - <cmis:propertyString queryName="cmis:name" displayName="Name" localName="name" propertyDefinitionId="cmis:name"> - <cmis:value>Company Home</cmis:value> - </cmis:propertyString> - <cmis:propertyDateTime queryName="cmis:creationDate" displayName="Creation Date" localName="creationDate" propertyDefinitionId="cmis:creationDate"> - <cmis:value>2010-09-28T12:51:47.684+01:00</cmis:value> - </cmis:propertyDateTime> - <cmis:propertyString queryName="cmis:changeToken" displayName="Change token" localName="changeToken" propertyDefinitionId="cmis:changeToken"/> - <cmis:propertyString queryName="cmis:lastModifiedBy" displayName="Last Modified By" localName="lastModifiedBy" propertyDefinitionId="cmis:lastModifiedBy"> - <cmis:value>admin</cmis:value> - </cmis:propertyString> - <cmis:propertyString queryName="cmis:createdBy" displayName="Created by" localName="createdBy" propertyDefinitionId="cmis:createdBy"> - <cmis:value>System</cmis:value> - </cmis:propertyString> - <cmis:propertyId queryName="cmis:objectId" displayName="Object Id" localName="objectId" propertyDefinitionId="cmis:objectId"> - <cmis:value>workspace://SpacesStore/87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1</cmis:value> - </cmis:propertyId> - <cmis:propertyId queryName="cmis:baseTypeId" displayName="Base Type Id" localName="baseTypeId" propertyDefinitionId="cmis:baseTypeId"> - <cmis:value>cmis:folder</cmis:value> - </cmis:propertyId> - <cmis:propertyId queryName="alfcmis:nodeRef" displayName="Alfresco Node Ref" localName="nodeRef" propertyDefinitionId="alfcmis:nodeRef"> - <cmis:value>workspace://SpacesStore/87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1</cmis:value> - </cmis:propertyId> - <cmis:propertyDateTime queryName="cmis:lastModificationDate" displayName="Last Modified Date" localName="lastModificationDate" propertyDefinitionId="cmis:lastModificationDate"> - <cmis:value>2012-11-21T14:44:59.164Z</cmis:value> - </cmis:propertyDateTime> - <cmis:propertyId queryName="cmis:parentId" displayName="Parent Id" localName="parentId" propertyDefinitionId="cmis:parentId"/> - <aspects:aspects xmlns="http://www.alfresco.org" xmlns:aspects="http://www.alfresco.org"> - <appliedAspects>P:app:uifacets</appliedAspects> - <properties> - <cmis:propertyString xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:ns0="http://docs.oasis-open.org/ns/cmis/core/200908/" propertyDefinitionId="app:icon"> - <value>space-icon-default</value> - </cmis:propertyString> - <cmis:propertyString xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:ns0="http://docs.oasis-open.org/ns/cmis/core/200908/" propertyDefinitionId="cm:description"> - <value>The company root space</value> - </cmis:propertyString> - <cmis:propertyString xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:ns0="http://docs.oasis-open.org/ns/cmis/core/200908/" propertyDefinitionId="cmis:policyText"/> - <cmis:propertyString xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:ns0="http://docs.oasis-open.org/ns/cmis/core/200908/" propertyDefinitionId="cm:title"> - <value>Company Home</value> - </cmis:propertyString> - </properties> - <appliedAspects>P:cm:titled</appliedAspects> - <appliedAspects>P:sys:localized</appliedAspects> - </aspects:aspects> - </cmis:properties> - </cmisra:object> - <atom:link rel="service" href="' . $_SESSION['config']['coreurl'] . 'ws_server.php?cmis&repositoryId=' . $this->getUuid() . '" type="application/atomsvc+xml"/> - -</atom:entry>'; - exit; - } -} - -/* -'<atom:link rel="self" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/entry?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=entry" cmisra:id="workspace://SpacesStore/87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1"/> - <atom:link rel="enclosure" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/entry?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=entry"/> - <atom:link rel="edit" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/entry?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=entry"/> - <atom:link rel="describedby" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/type?id=cmis%3Afolder" type="application/atom+xml;type=entry"/> - <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/allowableactions?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/cmisallowableactions+xml"/> - <atom:link rel="down" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/children?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=feed"/> - <atom:link rel="down" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/descendants?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/cmistree+xml"/> - <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/foldertree" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/foldertree?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/cmistree+xml"/> - <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/acl" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/acl?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/cmisacl+xml"/> - <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/policies" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/policies?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=feed"/> - <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/relationships" href="http://cmis.alfresco.com/cmisatom/371554cd-ac06-40ba-98b8-e6b60275cca7/relationships?id=workspace%3A%2F%2FSpacesStore%2F87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1" type="application/atom+xml;type=feed"/>'; - */ diff --git a/core/class/web_service/class_soap_server.php b/core/class/web_service/class_soap_server.php deleted file mode 100755 index c71d8a4a07e9426028aed09dbf94d13db519751c..0000000000000000000000000000000000000000 --- a/core/class/web_service/class_soap_server.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php - -/* -* Copyright 2010 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Maarch SOAP class -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -require_once('Maarch_SOAP_DISCO_Server.php'); - -//declaration of descriptions services vars -if(!isset ($SOAP_dispatch_map)) { - $SOAP_dispatch_map = Array (); -} -if(!isset ($SOAP_typedef)) { - $SOAP_typedef = Array (); -} - -/** - * Class for manage SOAP web service - */ -class MaarchSoapServer extends webService { - - var $__dispatch_map; - var $__typedef; - - function __construct() { - global $SOAP_dispatch_map, $SOAP_typedef; - $this->__dispatch_map = $SOAP_dispatch_map; - $this->__typedef = $SOAP_typedef; - } - - function __dispatch($methodname) { - if(isset($this->__dispatch_map[$methodname])) { - return $this->__dispatch_map[$methodname]; - } - return null; - } - - /** - * parse the requested method and return path, object and method to call - * @param $method string the methode in the signature - * @param $args array array of method arguments - * @return call of the method - */ - public function __call($method, $args) { - $webService = new webService(); - $methodArray = array(); - $methodArray = $webService->parseRequestedMethod($method, $this->__dispatch_map); - if($methodArray['path'] == "custom") { - return call_user_func_array($method, $args); - } else { - if(file_exists($methodArray['path']) && $methodArray['object'] <> "" && $methodArray['method'] <> "") { - require_once($methodArray['path']); - $objectControler = new $methodArray['object'](); - try { - return call_user_func_array(array($objectControler, $methodArray['method']), $args); - } catch (Exception $e) { - if ($_SESSION['config']['debug'] == "true") { - var_dump($e); - } - } - - } - } - } - - /** - * import of the SOAP library - */ - function importSOAPLibs() { - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - require ('apps/maarch_entreprise/tools/PEAR/SOAP/Server.php'); - } else { - require ('SOAP/Server.php'); - } - } - - /** - * launch SOAP server - */ - function launchSOAPServer() { - $server = new SOAP_Server(); - $webservice = new MaarchSoapServer(); - //var_dump($webservice); - $server->addObjectMap($webservice, 'urn:MaarchSoapServer'); - return $server; - } - - /** - * generate WSDL - */ - function makeWSDL() { - $this->importSOAPLibs(); - $server = $this->launchSOAPServer(); - $disco = new Maarch_SOAP_DISCO_Server($server, 'MaarchSoapServer'); - header("Content-type: text/xml"); - echo $disco->getWSDL(); - } - - /** - * generate SOAP server - */ - function makeSOAPServer() { - //global $HTTP_RAW_POST_DATA; - $data = file_get_contents("php://input"); - //var_export($HTTP_RAW_POST_DATA); -// echo " -// ------------------------------------------------ -// "; - //var_export($data); - $this->importSOAPLibs(); - $server = $this->launchSOAPServer(); - $server->service($data); - } - - /** - * discover server - */ - function makeDISCO() { - $this->importSOAPLibs(); - $server = $this->launchSOAPServer(); - $disco = new Maarch_SOAP_DISCO_Server($server, 'MaarchSoapServer'); - header("Content-type: text/xml"); - echo $disco->getDISCO(); - } -} diff --git a/core/class/web_service/class_web_service.php b/core/class/web_service/class_web_service.php deleted file mode 100755 index 561fbdcc2d4676b486fb498058fdf21f51f2ca00..0000000000000000000000000000000000000000 --- a/core/class/web_service/class_web_service.php +++ /dev/null @@ -1,323 +0,0 @@ -<?php - -/* -* Copyright 2012 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Maarch web service class -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -/** - * Class for manage web service - */ -class webService -{ - - /** - * load web service catalog of the Maarch core - */ - public function WSCoreCatalog() - { - if (file_exists($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'class' - . DIRECTORY_SEPARATOR . 'ws.php') - ) { - require($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR - . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ); - } elseif (file_exists($_SESSION['config']['corepath'] - . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'class' - . DIRECTORY_SEPARATOR . 'ws.php') - ) { - require('core' . DIRECTORY_SEPARATOR . 'class' - . DIRECTORY_SEPARATOR . 'ws.php' - ); - } - } - - /** - * load web service catalog of the Maarch application - */ - public function WSAppsCatalog() - { - if (file_exists($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR - . $_SESSION['businessapps'][0]['appid'] . DIRECTORY_SEPARATOR - . 'class' . DIRECTORY_SEPARATOR . 'ws.php') - ) { - require($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR - . $_SESSION['businessapps'][0]['appid'] . DIRECTORY_SEPARATOR - . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ); - } else { - require('apps' . DIRECTORY_SEPARATOR - . $_SESSION['businessapps'][0]['appid'] . DIRECTORY_SEPARATOR - . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ); - } - } - - /** - * load web service catalog of the Maarch loading modules - */ - public function WSModulesCatalog() - { - for ($cptModules=0;$cptModules<count($_SESSION['modules']);$cptModules++) { - if ( - $_SESSION['modules'][$cptModules]['moduleid'] <> "" - && file_exists( - $_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR - . $_SESSION['modules'][$cptModules]['moduleid'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ) - ) { - require($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR - . $_SESSION['modules'][$cptModules]['moduleid'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ); - } elseif ( - $_SESSION['modules'][$cptModules]['moduleid'] <> "" - && file_exists( - $_SESSION['config']['corepath'] - . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR - . $_SESSION['modules'][$cptModules]['moduleid'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ) - ) { - require($_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . 'modules' . DIRECTORY_SEPARATOR - . $_SESSION['modules'][$cptModules]['moduleid'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'ws.php' - ); - } - } - } - - /** - * load web service catalog of the Maarch custom required - */ - public function WScustomCatalog() - { - if (file_exists($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'ws.php') - ) { - require($_SESSION['config']['corepath'] . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'ws.php' - ); - } - } - - /** - * web service authentification - */ - public function authentication() - { - if ( - ( - isset($_SERVER["PHP_AUTH_USER"]) - && isset($_SERVER["PHP_AUTH_PW"]) - && isset($_SERVER["HTTP_AUTHORIZATION"]) - ) - && $_SERVER["PHP_AUTH_USER"] && $_SERVER["PHP_AUTH_PW"] - && preg_match("/^Basic /", $_SERVER["HTTP_AUTHORIZATION"]) - ) { - list($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]) - = explode(":", base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6))); - } - $authenticated = false; - if ( - ( - isset($_SERVER["PHP_AUTH_USER"]) - && isset($_SERVER["PHP_AUTH_PW"]) - ) - && ($_SERVER["PHP_AUTH_USER"] || $_SERVER["PHP_AUTH_PW"]) - ) { - require_once("core" . DIRECTORY_SEPARATOR . "class" - . DIRECTORY_SEPARATOR . "class_functions.php"); - require_once('core' . DIRECTORY_SEPARATOR . 'class' - . DIRECTORY_SEPARATOR . 'class_security.php'); - $func = new functions(); - if ($func->isEncrypted() == "true") { - $_SESSION['user']['UserId'] = $func->decrypt($_SERVER["PHP_AUTH_USER"]); - $password = $func->decrypt($_SERVER["PHP_AUTH_PW"]); - } else { - $_SESSION['user']['UserId'] = $_SERVER["PHP_AUTH_USER"]; - $password = $_SERVER["PHP_AUTH_PW"]; - } - - $userID = str_replace('\'', '', $_SESSION['user']['UserId']); - $userID = str_replace('=', '', $userID); - $userID = str_replace('"', '', $userID); - $userID = str_replace('*', '', $userID); - $userID = str_replace(';', '', $userID); - $userID = str_replace('--', '', $userID); - $userID = str_replace(',', '', $userID); - $userID = str_replace('$', '', $userID); - $userID = str_replace('>', '', $userID); - $userID = str_replace('<', '', $userID); - - $authenticated = \SrcCore\models\AuthenticationModel::authentication(['userId' => $userID, 'password' => $password]); - } - return $authenticated; - } - - /** - * launch the web service engine required - */ - public function launchWs() - { - require_once('core/class/web_service/class_rest_server.php'); - require_once('core/class/web_service/class_soap_server.php'); - require_once('core/class/web_service/class_xmlrpc_server.php'); - $restServer = new MyRestServer(); - $soapServer = new MaarchSoapServer(); - $xmlRPC = new MyXmlRPCServer(); - $wsMode = explode('/', $_SERVER['QUERY_STRING']); - - if (isset($wsMode[0]) && !empty($wsMode[0])) { - $wsMode = $wsMode[0]; - } else { - $wsMode = 'RAS'; - } - $wsMode = explode('&', $wsMode); - if (isset($wsMode[0]) && !empty($wsMode[0])) { - $wsMode = $wsMode[0]; - } - if ( - isset($wsMode) - && strcasecmp($wsMode, 'wsdl') == 0 - ) { - //WSDL - $soapServer->makeWSDL(); - } elseif ( - isset($wsMode) - && strcasecmp($wsMode, 'xmlrpc') == 0 - ) { - //XMLRPC - $xmlRPC->makeXMLRPCServer(); - } elseif ( - isset($wsMode) - && strcasecmp($wsMode, 'rest') == 0 - ) { - //REST - $restServer->makeRESTServer(); - } elseif ( - isset($wsMode) - && strcasecmp($wsMode, 'cmis') == 0 - ) { - //CMIS - $restRequest = explode('/', $_SERVER['QUERY_STRING']); - if (count($restRequest) > 1) { - $restServer->makeRESTServer(); - } else { - $restServer->makeCMISCatalog(); - } - } else { - - //SOAP BY DEFAULT - if ( - isset($_SERVER['REQUEST_METHOD']) - && $_SERVER['REQUEST_METHOD']=='POST' - ) { - $soapServer->makeSOAPServer(); - } else { - //default : xml Discovery - $soapServer->makeDISCO(); - } - } - } - - /** - * parse the requested method and return path, object and method to call - * @param $method string the methode in the signature - * @param $methods array array of signature - * @return array with path, object and method - */ - public function parseRequestedMethod($method, $methods) - { - if (is_array($methods)) { - require_once('core/class/class_functions.php'); - $arrayMethods = array(); - $func = new functions(); - //var_dump($methods); - $arrayMethods = $func->object2array($methods); - //$func->show_array($arrayMethods); - foreach (array_keys($arrayMethods) as $keyMethod) { - if ($arrayMethods[$keyMethod]["method"] == "custom") { - $resultArray = array("path" => "custom", "method" => null); - break; - } elseif ($keyMethod == $method) { - $rootPathArray = array(); - $stringMethod = $arrayMethods[$keyMethod]["method"]; - $rootPathArray = explode("#", $stringMethod); - $rootPath = $rootPathArray[0]; - $objectPath = $rootPathArray[1]; - $objectPathArray = array(); - $objectPathArray = explode("::", $objectPath); - if ($rootPath == "core") { - $path = "core" . DIRECTORY_SEPARATOR . "class" - . DIRECTORY_SEPARATOR . $objectPathArray[0] . "_controler.php"; - } elseif ($rootPath == "apps") { - $path = "apps" . DIRECTORY_SEPARATOR - . $_SESSION['businessapps'][0]['appid'] - . DIRECTORY_SEPARATOR . "class" - . DIRECTORY_SEPARATOR . $objectPathArray[0] . "_controler.php"; - } else { - preg_match("'modules'", $rootPath, $out); - if (!empty($out[0])) { - $modulePathArray = array(); - $modulePathArray = explode("/", $rootPath); - $path = "modules" . DIRECTORY_SEPARATOR - . $modulePathArray[1] . DIRECTORY_SEPARATOR - . "class" . DIRECTORY_SEPARATOR - . $objectPathArray[0] . "_controler.php"; - } - } - $resultArray = array( - "path" => $path, - "object" => $objectPathArray[0] . "_controler", - "method" => $objectPathArray[1] - ); - break; - } - } - } else { - $resultArray = array("path" => null, "method" => null); - } - return $resultArray; - } -} diff --git a/core/class/web_service/class_xmlrpc_server.php b/core/class/web_service/class_xmlrpc_server.php deleted file mode 100755 index 25902b5482e583afe45639cb44a2b88a8c4b9b1e..0000000000000000000000000000000000000000 --- a/core/class/web_service/class_xmlrpc_server.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -/* -* Copyright 2010 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Maarch XMLRPC class -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -//declaration of descriptions services vars -if(!isset($XMLRPC_dispatch_map)) { - $XMLRPC_dispatch_map = Array(); -} - -/** - * Class for manage XMLRPC web service - */ -class MyXmlRPCServer { - - var $__dispatch_map; - - function __construct() { - global $XMLRPC_dispatch_map; - $this->__dispatch_map = $XMLRPC_dispatch_map; - } - - function __dispatch($methodname) { - if (isset($this->__dispatch_map[$methodname])){ - return $this->__dispatch_map[$methodname]; - } - return null; - } - - public function __call($method, $args) { - return call_user_func_array($method, $args); - } - - /** - * import of the XMLRPC library - */ - function importXMLRPCLibs() { - include("lib/xmlrpc.inc"); - include("lib/xmlrpcs.inc"); - include("lib/xmlrpc_wrappers.inc"); - } - - /** - * generate XMLRPC server - */ - function makeXMLRPCServer() { - global $XMLRPC_dispatch_map; - $this->importXMLRPCLibs(); - $server = new xmlrpc_server($XMLRPC_dispatch_map, false); - $server->functions_parameters_type = 'phpvals'; - $server->service(); - } -} diff --git a/core/class/web_service/cmis_test/create_folder.atom.xml b/core/class/web_service/cmis_test/create_folder.atom.xml deleted file mode 100755 index aedeef56b22e89f69c136479fd506515b4cb2408..0000000000000000000000000000000000000000 --- a/core/class/web_service/cmis_test/create_folder.atom.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" -xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" -xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" -xmlns:maarch="http://www.maarch.org"> -<title>Someco</title> -<cmisra:object> -<cmis:properties> -<cmis:propertyId -propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId> -</cmis:properties> -</cmisra:object> -</entry> diff --git a/core/class/web_service/cmis_test/curl_query.txt b/core/class/web_service/cmis_test/curl_query.txt deleted file mode 100755 index 43ddd3d598ec438e9919559c8697c68619b91465..0000000000000000000000000000000000000000 --- a/core/class/web_service/cmis_test/curl_query.txt +++ /dev/null @@ -1,12 +0,0 @@ -#voir le document -curl -X GET -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/res/101" -#recherche avancée de documents -curl -X POST -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/res" -d atomFileContent=thexmlcontentfilebase64encode -#consulter le dossier -curl -X GET -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/folder/RH" -#créer un dossier -curl -X POST -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/folder" -d atomFileContent=thexmlcontentfilebase64encode -#voir la liste des bannettes -curl -X GET -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/basket" -#Liste des documents d'une bannette -curl -X GET -ubblier:maarch "http://127.0.0.1/maarch_entreprise/ws_server.php?REST/basket/MesCourriersATraiter" diff --git a/core/class/web_service/cmis_test/query.xml b/core/class/web_service/cmis_test/query.xml deleted file mode 100755 index 334deddfa07f3eabd1cb93d2ceb0b553c250aa65..0000000000000000000000000000000000000000 --- a/core/class/web_service/cmis_test/query.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<cmis:query xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmism="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:maarch="http://www.maarch.org"> - <cmis:statement> SELECT cmis:objectId , maarch:type , maarch:entity , maarch:dest_user FROM cmis:document where maarch:dest_user is not null ORDER BY cmis:objectId asc </cmis:statement> - <cmis:searchAllVersions>false</cmis:searchAllVersions> - <cmis:includeAllowableActions>false</cmis:includeAllowableActions> - <cmis:includeRelationships>none</cmis:includeRelationships> - <cmis:renditionFilter>*</cmis:renditionFilter> - <cmis:maxItems>50</cmis:maxItems> - <cmis:skipCount>0</cmis:skipCount> -</cmis:query> diff --git a/core/class/web_service/cmis_test/test_rest.php b/core/class/web_service/cmis_test/test_rest.php deleted file mode 100755 index 249b085911c94d1f9c7e544efc22e6004cbb762b..0000000000000000000000000000000000000000 --- a/core/class/web_service/cmis_test/test_rest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -include_once ('../../../init.php'); -if (!isset($_REQUEST['collection'])) { - $_REQUEST['collection'] = 'letterbox_coll'; -} -if (!isset($_REQUEST['resource'])) { - $_REQUEST['resource'] = 'folder'; -} - -//INIT CURL -$curl = curl_init(); - -//BASIC AUTHENTICATION -curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); -curl_setopt($curl, CURLOPT_USERPWD, 'bblier:maarch'); -//curl_setopt($curl, CURLOPT_USERPWD, 'pparker:maarch'); - -//WS URL -$url = $_SESSION['config']['coreurl'] . 'ws_server.php?CMIS'; -if (isset($_REQUEST['collection']) && !empty($_REQUEST['collection'])) { - $url .= '/' . $_REQUEST['collection']; -} -if (isset($_REQUEST['resource']) && !empty($_REQUEST['resource'])) { - $url .= '/' . $_REQUEST['resource']; -} -if (isset($_REQUEST['idResource']) && !empty($_REQUEST['idResource'])) { - $url .= '/' . $_REQUEST['idResource']; -} -curl_setopt($curl, CURLOPT_URL, $url . '/'); - -if (($_REQUEST['method'] == 'post' || !isset($_REQUEST['method']))&& isset($_REQUEST['xmlFile'])) { - $xmlAtomFileContent = file_get_contents('core/class/web_service/cmis_test/' . $_REQUEST['xmlFile']); - curl_setopt($curl, CURLOPT_POSTFIELDS, 'atomFileContent=' . $xmlAtomFileContent); - curl_setopt($curl, CURLOPT_POST, 1); -} -else { - //GET, PUT, DELETE METHOD - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($_REQUEST['method'])); -} -//var_dump($url); -//var_dump($_SESSION); - -//POST CONTENT -//$xmlAtomFileContent = base64_encode(file_get_contents('create_folder.atom.xml')); -//$xmlAtomFileContent = file_get_contents('query.xml'); -//$xmlAtomFileContent = file_get_contents('testcreatefolder.atom.xml'); -//curl_setopt($curl, CURLOPT_POSTFIELDS, 'atomFileContent=' . $xmlAtomFileContent); -//HTTP METHOD -//if ($_REQUEST['method'] == 'post' || !isset($_REQUEST['method'])) { -// curl_setopt($curl, CURLOPT_POST, 1); -//} else { - //GET, PUT, DELETE METHOD - //curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($_REQUEST['method'])); - //curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: ' . $_REQUEST['method'])); -//} -//RESULT -curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); -$page = curl_exec($curl); -//var_dump($curl); -curl_close($curl); -print($page); diff --git a/core/class/web_service/cmis_test/testcreatefolder.atom.xml b/core/class/web_service/cmis_test/testcreatefolder.atom.xml deleted file mode 100755 index fbb0103f7d4e9b8c8d4841d44c52489515789f04..0000000000000000000000000000000000000000 --- a/core/class/web_service/cmis_test/testcreatefolder.atom.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" -xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" -xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" -xmlns:maarch="http://www.maarch.org"> - <title>Test creation folder</title> - <cmisra:object> - <cmis:properties> - <cmis:propertyId propertyDefinitionId="cmis:objectTypeId"> - <cmis:value>cmis:folder</cmis:value> - </cmis:propertyId> - <cmis:propertyId propertyDefinitionId="folderId"> - <cmis:value>TEST</cmis:value> - </cmis:propertyId> - </cmis:properties> - </cmisra:object> -</entry> diff --git a/core/class/web_service/lib/compat/xmlrpc.inc b/core/class/web_service/lib/compat/xmlrpc.inc deleted file mode 100755 index 7fb2b5aa8fccff7023721b5b35aaa62029975649..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/compat/xmlrpc.inc +++ /dev/null @@ -1,3718 +0,0 @@ -<?php -// by Edd Dumbill (C) 1999-2002 -// <edd@usefulinc.com> -// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $ - -// Copyright (c) 1999,2000,2002 Edd Dumbill. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of the "XML-RPC for PHP" nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - - if(!function_exists('xml_parser_create')) - { - // For PHP 4 onward, XML functionality is always compiled-in on windows: - // no more need to dl-open it. It might have been compiled out on *nix... - if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) - { - dl('xml.so'); - } - } - - // Try to be backward compat with php < 4.2 (are we not being nice ?) - $phpversion = phpversion(); - if($phpversion[0] == '4' && $phpversion[2] < 2) - { - // give an opportunity to user to specify where to include other files from - if(!defined('PHP_XMLRPC_COMPAT_DIR')) - { - define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/'); - } - if($phpversion[2] == '0') - { - if($phpversion[4] < 6) - { - include(PHP_XMLRPC_COMPAT_DIR.'is_callable.php'); - } - include(PHP_XMLRPC_COMPAT_DIR.'is_scalar.php'); - include(PHP_XMLRPC_COMPAT_DIR.'array_key_exists.php'); - include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php'); - } - include(PHP_XMLRPC_COMPAT_DIR.'var_export.php'); - include(PHP_XMLRPC_COMPAT_DIR.'is_a.php'); - } - - // G. Giunta 2005/01/29: declare global these variables, - // so that xmlrpc.inc will work even if included from within a function - // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used. - $GLOBALS['xmlrpcI4']='i4'; - $GLOBALS['xmlrpcInt']='int'; - $GLOBALS['xmlrpcBoolean']='boolean'; - $GLOBALS['xmlrpcDouble']='double'; - $GLOBALS['xmlrpcString']='string'; - $GLOBALS['xmlrpcDateTime']='dateTime.iso8601'; - $GLOBALS['xmlrpcBase64']='base64'; - $GLOBALS['xmlrpcArray']='array'; - $GLOBALS['xmlrpcStruct']='struct'; - $GLOBALS['xmlrpcValue']='undefined'; - - $GLOBALS['xmlrpcTypes']=array( - $GLOBALS['xmlrpcI4'] => 1, - $GLOBALS['xmlrpcInt'] => 1, - $GLOBALS['xmlrpcBoolean'] => 1, - $GLOBALS['xmlrpcString'] => 1, - $GLOBALS['xmlrpcDouble'] => 1, - $GLOBALS['xmlrpcDateTime'] => 1, - $GLOBALS['xmlrpcBase64'] => 1, - $GLOBALS['xmlrpcArray'] => 2, - $GLOBALS['xmlrpcStruct'] => 3 - ); - - $GLOBALS['xmlrpc_valid_parents'] = array( - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'), - 'BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'FAULT' => array('METHODRESPONSE'), - 'NIL' => array('VALUE') // only used when extension activated - ); - - // define extra types for supporting NULL (useful for json or <NIL/>) - $GLOBALS['xmlrpcNull']='null'; - $GLOBALS['xmlrpcTypes']['null']=1; - - // Not in use anymore since 2.0. Shall we remove it? - /// @deprecated - $GLOBALS['xmlEntities']=array( - 'amp' => '&', - 'quot' => '"', - 'lt' => '<', - 'gt' => '>', - 'apos' => "'" - ); - - // tables used for transcoding different charsets into us-ascii xml - - $GLOBALS['xml_iso88591_Entities']=array(); - $GLOBALS['xml_iso88591_Entities']['in'] = array(); - $GLOBALS['xml_iso88591_Entities']['out'] = array(); - for ($i = 0; $i < 32; $i++) - { - $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); - $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; - } - for ($i = 160; $i < 256; $i++) - { - $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); - $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; - } - - /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159? - /// These will NOT be present in true ISO-8859-1, but will save the unwary - /// windows user from sending junk (though no luck when reciving them...) - /* - $GLOBALS['xml_cp1252_Entities']=array(); - for ($i = 128; $i < 160; $i++) - { - $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i); - } - $GLOBALS['xml_cp1252_Entities']['out'] = array( - '€', '?', '‚', 'ƒ', - '„', '…', '†', '‡', - 'ˆ', '‰', 'Š', '‹', - 'Œ', '?', 'Ž', '?', - '?', '‘', '’', '“', - '”', '•', '–', '—', - '˜', '™', 'š', '›', - 'œ', '?', 'ž', 'Ÿ' - ); - */ - - $GLOBALS['xmlrpcerr'] = array( - 'unknown_method'=>1, - 'invalid_return'=>2, - 'incorrect_params'=>3, - 'introspect_unknown'=>4, - 'http_error'=>5, - 'no_data'=>6, - 'no_ssl'=>7, - 'curl_fail'=>8, - 'invalid_request'=>15, - 'no_curl'=>16, - 'server_error'=>17, - 'multicall_error'=>18, - 'multicall_notstruct'=>9, - 'multicall_nomethod'=>10, - 'multicall_notstring'=>11, - 'multicall_recursion'=>12, - 'multicall_noparams'=>13, - 'multicall_notarray'=>14, - - 'cannot_decompress'=>103, - 'decompress_fail'=>104, - 'dechunk_fail'=>105, - 'server_cannot_decompress'=>106, - 'server_decompress_fail'=>107 - ); - - $GLOBALS['xmlrpcstr'] = array( - 'unknown_method'=>'Unknown method', - 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload', - 'incorrect_params'=>'Incorrect parameters passed to method', - 'introspect_unknown'=>"Can't introspect: method unknown", - 'http_error'=>"Didn't receive 200 OK from remote server.", - 'no_data'=>'No data received from server.', - 'no_ssl'=>'No SSL support compiled in.', - 'curl_fail'=>'CURL error', - 'invalid_request'=>'Invalid request payload', - 'no_curl'=>'No CURL support compiled in.', - 'server_error'=>'Internal server error', - 'multicall_error'=>'Received from server invalid multicall response', - 'multicall_notstruct'=>'system.multicall expected struct', - 'multicall_nomethod'=>'missing methodName', - 'multicall_notstring'=>'methodName is not a string', - 'multicall_recursion'=>'recursive system.multicall forbidden', - 'multicall_noparams'=>'missing params', - 'multicall_notarray'=>'params is not an array', - - 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress', - 'decompress_fail'=>'Received from server invalid compressed HTTP', - 'dechunk_fail'=>'Received from server invalid chunked HTTP', - 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress', - 'server_decompress_fail'=>'Received from client invalid compressed HTTP request' - ); - - // The charset encoding used by the server for received messages and - // by the client for received responses when received charset cannot be determined - // or is not supported - $GLOBALS['xmlrpc_defencoding']='UTF-8'; - - // The encoding used internally by PHP. - // String values received as xml will be converted to this, and php strings will be converted to xml - // as if having been coded with this - $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1'; - - $GLOBALS['xmlrpcName']='XML-RPC for PHP'; - $GLOBALS['xmlrpcVersion']='2.2.2'; - - // let user errors start at 800 - $GLOBALS['xmlrpcerruser']=800; - // let XML parse errors start at 100 - $GLOBALS['xmlrpcerrxml']=100; - - // formulate backslashes for escaping regexp - // Not in use anymore since 2.0. Shall we remove it? - /// @deprecated - $GLOBALS['xmlrpc_backslash']=chr(92).chr(92); - - // set to TRUE to enable correct decoding of <NIL/> values - $GLOBALS['xmlrpc_null_extension']=false; - - // used to store state during parsing - // quick explanation of components: - // ac - used to accumulate values - // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1) - // isf_reason - used for storing xmlrpcresp fault string - // lv - used to indicate "looking for a value": implements - // the logic to allow values with no types to be strings - // params - used to store parameters in method calls - // method - used to store method name - // stack - array with genealogy of xml elements names: - // used to validate nesting of xmlrpc elements - $GLOBALS['_xh']=null; - - /** - * Convert a string to the correct XML representation in a target charset - * To help correct communication of non-ascii chars inside strings, regardless - * of the charset used when sending requests, parsing them, sending responses - * and parsing responses, an option is to convert all non-ascii chars present in the message - * into their equivalent 'charset entity'. Charset entities enumerated this way - * are independent of the charset encoding used to transmit them, and all XML - * parsers are bound to understand them. - * Note that in the std case we are not sending a charset encoding mime type - * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii. - * - * @todo do a bit of basic benchmarking (strtr vs. str_replace) - * @todo make usage of iconv() or recode_string() or mb_string() where available - */ - function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='') - { - if ($src_encoding == '') - { - // lame, but we know no better... - $src_encoding = $GLOBALS['xmlrpc_internalencoding']; - } - - switch(strtoupper($src_encoding.'_'.$dest_encoding)) - { - case 'ISO-8859-1_': - case 'ISO-8859-1_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); - break; - case 'ISO-8859-1_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = utf8_encode($escaped_data); - break; - case 'ISO-8859-1_ISO-8859-1': - case 'US-ASCII_US-ASCII': - case 'US-ASCII_UTF-8': - case 'US-ASCII_': - case 'US-ASCII_ISO-8859-1': - case 'UTF-8_UTF-8': - //case 'CP1252_CP1252': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - break; - case 'UTF-8_': - case 'UTF-8_US-ASCII': - case 'UTF-8_ISO-8859-1': - // NB: this will choke on invalid UTF-8, going most likely beyond EOF - $escaped_data = ''; - // be kind to users creating string xmlrpcvals out of different php types - $data = (string) $data; - $ns = strlen ($data); - for ($nn = 0; $nn < $ns; $nn++) - { - $ch = $data[$nn]; - $ii = ord($ch); - //1 7 0bbbbbbb (127) - if ($ii < 128) - { - /// @todo shall we replace this with a (supposedly) faster str_replace? - switch($ii){ - case 34: - $escaped_data .= '"'; - break; - case 38: - $escaped_data .= '&'; - break; - case 39: - $escaped_data .= '''; - break; - case 60: - $escaped_data .= '<'; - break; - case 62: - $escaped_data .= '>'; - break; - default: - $escaped_data .= $ch; - } // switch - } - //2 11 110bbbbb 10bbbbbb (2047) - else if ($ii>>5 == 6) - { - $b1 = ($ii & 31); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ($b1 * 64) + $b2; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 1; - } - //3 16 1110bbbb 10bbbbbb 10bbbbbb - else if ($ii>>4 == 14) - { - $b1 = ($ii & 15); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ord($data[$nn+2]); - $b3 = ($ii & 63); - $ii = ((($b1 * 64) + $b2) * 64) + $b3; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 2; - } - //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb - else if ($ii>>3 == 30) - { - $b1 = ($ii & 7); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ord($data[$nn+2]); - $b3 = ($ii & 63); - $ii = ord($data[$nn+3]); - $b4 = ($ii & 63); - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 3; - } - } - break; -/* - case 'CP1252_': - case 'CP1252_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - break; - case 'CP1252_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them) - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - $escaped_data = utf8_encode($escaped_data); - break; - case 'CP1252_ISO-8859-1': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities... - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - break; -*/ - default: - $escaped_data = ''; - error_log("Converting from $src_encoding to $dest_encoding: not supported..."); - } - return $escaped_data; - } - - /// xml parser handler function for opening element tags - function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false) - { - // if invalid xmlrpc already detected, skip all processing - if ($GLOBALS['_xh']['isf'] < 2) - { - // check for correct element nesting - // top level element can only be of 2 types - /// @todo optimization creep: save this check into a bool variable, instead of using count() every time: - /// there is only a single top level element in xml anyway - if (count($GLOBALS['_xh']['stack']) == 0) - { - if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && ( - $name != 'VALUE' && !$accept_single_vals)) - { - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element'; - return; - } - else - { - $GLOBALS['_xh']['rt'] = strtolower($name); - } - } - else - { - // not top level element: see if parent is OK - $parent = end($GLOBALS['_xh']['stack']); - if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name])) - { - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent"; - return; - } - } - - switch($name) - { - // optimize for speed switch cases: most common cases first - case 'VALUE': - /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element - $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet - $GLOBALS['_xh']['ac']=''; - $GLOBALS['_xh']['lv']=1; - $GLOBALS['_xh']['php_class']=null; - break; - case 'I4': - case 'INT': - case 'STRING': - case 'BOOLEAN': - case 'DOUBLE': - case 'DATETIME.ISO8601': - case 'BASE64': - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - $GLOBALS['_xh']['ac']=''; // reset the accumulator - break; - case 'STRUCT': - case 'ARRAY': - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - // create an empty array to hold child values, and push it onto appropriate stack - $cur_val = array(); - $cur_val['values'] = array(); - $cur_val['type'] = $name; - // check for out-of-band information to rebuild php objs - // and in case it is found, save it - if (@isset($attrs['PHP_CLASS'])) - { - $cur_val['php_class'] = $attrs['PHP_CLASS']; - } - $GLOBALS['_xh']['valuestack'][] = $cur_val; - $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next - break; - case 'DATA': - if ($GLOBALS['_xh']['vt']!='data') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element"; - return; - } - case 'METHODCALL': - case 'METHODRESPONSE': - case 'PARAMS': - // valid elements that add little to processing - break; - case 'METHODNAME': - case 'NAME': - /// @todo we could check for 2 NAME elements inside a MEMBER element - $GLOBALS['_xh']['ac']=''; - break; - case 'FAULT': - $GLOBALS['_xh']['isf']=1; - break; - case 'MEMBER': - $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on - //$GLOBALS['_xh']['ac']=''; - // Drop trough intentionally - case 'PARAM': - // clear value type, so we can check later if no value has been passed for this param/member - $GLOBALS['_xh']['vt']=null; - break; - case 'NIL': - if ($GLOBALS['xmlrpc_null_extension']) - { - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - $GLOBALS['_xh']['ac']=''; // reset the accumulator - break; - } - // we do not support the <NIL/> extension, so - // drop through intentionally - default: - /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name"; - break; - } - - // Save current element name to stack, to validate nesting - $GLOBALS['_xh']['stack'][] = $name; - - /// @todo optimization creep: move this inside the big switch() above - if($name!='VALUE') - { - $GLOBALS['_xh']['lv']=0; - } - } - } - - /// Used in decoding xml chunks that might represent single xmlrpc values - function xmlrpc_se_any($parser, $name, $attrs) - { - xmlrpc_se($parser, $name, $attrs, true); - } - - /// xml parser handler function for close element tags - function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) - { - if ($GLOBALS['_xh']['isf'] < 2) - { - // push this element name from stack - // NB: if XML validates, correct opening/closing is guaranteed and - // we do not have to check for $name == $curr_elem. - // we also checked for proper nesting at start of elements... - $curr_elem = array_pop($GLOBALS['_xh']['stack']); - - switch($name) - { - case 'VALUE': - // This if() detects if no scalar was inside <VALUE></VALUE> - if ($GLOBALS['_xh']['vt']=='value') - { - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString']; - } - - if ($rebuild_xmlrpcvals) - { - // build the xmlrpc val out of the data received, and substitute it - $temp =& new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']); - // in case we got info about underlying php class, save it - // in the object we're rebuilding - if (isset($GLOBALS['_xh']['php_class'])) - $temp->_php_class = $GLOBALS['_xh']['php_class']; - // check if we are inside an array or struct: - // if value just built is inside an array, let's move it into array on the stack - $vscount = count($GLOBALS['_xh']['valuestack']); - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') - { - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp; - } - else - { - $GLOBALS['_xh']['value'] = $temp; - } - } - else - { - /// @todo this needs to treat correctly php-serialized objects, - /// since std deserializing is done by php_xmlrpc_decode, - /// which we will not be calling... - if (isset($GLOBALS['_xh']['php_class'])) - { - } - - // check if we are inside an array or struct: - // if value just built is inside an array, let's move it into array on the stack - $vscount = count($GLOBALS['_xh']['valuestack']); - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') - { - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value']; - } - } - break; - case 'BOOLEAN': - case 'I4': - case 'INT': - case 'STRING': - case 'DOUBLE': - case 'DATETIME.ISO8601': - case 'BASE64': - $GLOBALS['_xh']['vt']=strtolower($name); - /// @todo: optimization creep - remove the if/elseif cycle below - /// since the case() in which we are already did that - if ($name=='STRING') - { - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - } - elseif ($name=='DATETIME.ISO8601') - { - if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) - { - error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']); - } - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime']; - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - } - elseif ($name=='BASE64') - { - /// @todo check for failure of base64 decoding / catch warnings - $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']); - } - elseif ($name=='BOOLEAN') - { - // special case here: we translate boolean 1 or 0 into PHP - // constants true or false. - // Strings 'true' and 'false' are accepted, even though the - // spec never mentions them (see eg. Blogger api docs) - // NB: this simple checks helps a lot sanitizing input, ie no - // security problems around here - if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) - { - $GLOBALS['_xh']['value']=true; - } - else - { - // log if receiveing something strange, even though we set the value to false anyway - if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) - error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']=false; - } - } - elseif ($name=='DOUBLE') - { - // we have a DOUBLE - // we must check that only 0123456789-.<space> are characters here - // NOTE: regexp could be much stricter than this... - if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac'])) - { - /// @todo: find a better way of throwing an error than this! - error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; - } - else - { - // it's ok, add it on - $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac']; - } - } - else - { - // we have an I4/INT - // we must check that only 0123456789-<space> are characters here - if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac'])) - { - /// @todo find a better way of throwing an error than this! - error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; - } - else - { - // it's ok, add it on - $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac']; - } - } - //$GLOBALS['_xh']['ac']=''; // is this necessary? - $GLOBALS['_xh']['lv']=3; // indicate we've found a value - break; - case 'NAME': - $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac']; - break; - case 'MEMBER': - //$GLOBALS['_xh']['ac']=''; // is this necessary? - // add to array in the stack the last element built, - // unless no VALUE was found - if ($GLOBALS['_xh']['vt']) - { - $vscount = count($GLOBALS['_xh']['valuestack']); - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value']; - } else - error_log('XML-RPC: missing VALUE inside STRUCT in received xml'); - break; - case 'DATA': - //$GLOBALS['_xh']['ac']=''; // is this necessary? - $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty - break; - case 'STRUCT': - case 'ARRAY': - // fetch out of stack array of values, and promote it to current value - $curr_val = array_pop($GLOBALS['_xh']['valuestack']); - $GLOBALS['_xh']['value'] = $curr_val['values']; - $GLOBALS['_xh']['vt']=strtolower($name); - if (isset($curr_val['php_class'])) - { - $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; - } - break; - case 'PARAM': - // add to array of params the current value, - // unless no VALUE was found - if ($GLOBALS['_xh']['vt']) - { - $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; - $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; - } - else - error_log('XML-RPC: missing VALUE inside PARAM in received xml'); - break; - case 'METHODNAME': - $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); - break; - case 'NIL': - if ($GLOBALS['xmlrpc_null_extension']) - { - $GLOBALS['_xh']['vt']='null'; - $GLOBALS['_xh']['value']=null; - $GLOBALS['_xh']['lv']=3; - break; - } - // drop through intentionally if nil extension not enabled - case 'PARAMS': - case 'FAULT': - case 'METHODCALL': - case 'METHORESPONSE': - break; - default: - // End of INVALID ELEMENT! - // shall we add an assert here for unreachable code??? - break; - } - } - } - - /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values - function xmlrpc_ee_fast($parser, $name) - { - xmlrpc_ee($parser, $name, false); - } - - /// xml parser handler function for character data - function xmlrpc_cd($parser, $data) - { - // skip processing if xml fault already detected - if ($GLOBALS['_xh']['isf'] < 2) - { - // "lookforvalue==3" means that we've found an entire value - // and should discard any further character data - if($GLOBALS['_xh']['lv']!=3) - { - // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2 - //if($GLOBALS['_xh']['lv']==1) - //{ - // if we've found text and we're just in a <value> then - // say we've found a value - //$GLOBALS['_xh']['lv']=2; - //} - // we always initialize the accumulator before starting parsing, anyway... - //if(!@isset($GLOBALS['_xh']['ac'])) - //{ - // $GLOBALS['_xh']['ac'] = ''; - //} - $GLOBALS['_xh']['ac'].=$data; - } - } - } - - /// xml parser handler function for 'other stuff', ie. not char data or - /// element start/end tag. In fact it only gets called on unknown entities... - function xmlrpc_dh($parser, $data) - { - // skip processing if xml fault already detected - if ($GLOBALS['_xh']['isf'] < 2) - { - if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') - { - // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2 - //if($GLOBALS['_xh']['lv']==1) - //{ - // $GLOBALS['_xh']['lv']=2; - //} - $GLOBALS['_xh']['ac'].=$data; - } - } - return true; - } - - class xmlrpc_client - { - var $path; - var $server; - var $port=0; - var $method='http'; - var $errno; - var $errstr; - var $debug=0; - var $username=''; - var $password=''; - var $authtype=1; - var $cert=''; - var $certpass=''; - var $cacert=''; - var $cacertdir=''; - var $key=''; - var $keypass=''; - var $verifypeer=true; - var $verifyhost=1; - var $no_multicall=false; - var $proxy=''; - var $proxyport=0; - var $proxy_user=''; - var $proxy_pass=''; - var $proxy_authtype=1; - var $cookies=array(); - /** - * List of http compression methods accepted by the client for responses. - * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib - * - * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since - * in those cases it will be up to CURL to decide the compression methods - * it supports. You might check for the presence of 'zlib' in the output of - * curl_version() to determine wheter compression is supported or not - */ - var $accepted_compression = array(); - /** - * Name of compression scheme to be used for sending requests. - * Either null, gzip or deflate - */ - var $request_compression = ''; - /** - * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see: - * http://curl.haxx.se/docs/faq.html#7.3) - */ - var $xmlrpc_curl_handle = null; - /// Wheter to use persistent connections for http 1.1 and https - var $keepalive = false; - /// Charset encodings that can be decoded without problems by the client - var $accepted_charset_encodings = array(); - /// Charset encoding to be used in serializing request. NULL = use ASCII - var $request_charset_encoding = ''; - /** - * Decides the content of xmlrpcresp objects returned by calls to send() - * valid strings are 'xmlrpcvals', 'phpvals' or 'xml' - */ - var $return_type = 'xmlrpcvals'; - - /** - * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php - * @param string $server the server name / ip address - * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used - * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed - */ - function xmlrpc_client($path, $server='', $port='', $method='') - { - // allow user to specify all params in $path - if($server == '' and $port == '' and $method == '') - { - $parts = parse_url($path); - $server = $parts['host']; - $path = isset($parts['path']) ? $parts['path'] : ''; - if(isset($parts['query'])) - { - $path .= '?'.$parts['query']; - } - if(isset($parts['fragment'])) - { - $path .= '#'.$parts['fragment']; - } - if(isset($parts['port'])) - { - $port = $parts['port']; - } - if(isset($parts['scheme'])) - { - $method = $parts['scheme']; - } - if(isset($parts['user'])) - { - $this->username = $parts['user']; - } - if(isset($parts['pass'])) - { - $this->password = $parts['pass']; - } - } - if($path == '' || $path[0] != '/') - { - $this->path='/'.$path; - } - else - { - $this->path=$path; - } - $this->server=$server; - if($port != '') - { - $this->port=$port; - } - if($method != '') - { - $this->method=$method; - } - - // if ZLIB is enabled, let the client by default accept compressed responses - if(function_exists('gzinflate') || ( - function_exists('curl_init') && (($info = curl_version()) && - ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) - )) - { - $this->accepted_compression = array('gzip', 'deflate'); - } - - // keepalives: enabled by default ONLY for PHP >= 4.3.8 - // (see http://curl.haxx.se/docs/faq.html#7.3) - if(version_compare(phpversion(), '4.3.8') >= 0) - { - $this->keepalive = true; - } - - // by default the xml parser can support these 3 charset encodings - $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); - } - - /** - * Enables/disables the echoing to screen of the xmlrpc responses received - * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) - * @access public - */ - function setDebug($in) - { - $this->debug=$in; - } - - /** - * Add some http BASIC AUTH credentials, used by the client to authenticate - * @param string $u username - * @param string $p password - * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth) - * @access public - */ - function setCredentials($u, $p, $t=1) - { - $this->username=$u; - $this->password=$p; - $this->authtype=$t; - } - - /** - * Add a client-side https certificate - * @param string $cert - * @param string $certpass - * @access public - */ - function setCertificate($cert, $certpass) - { - $this->cert = $cert; - $this->certpass = $certpass; - } - - /** - * Add a CA certificate to verify server with (see man page about - * CURLOPT_CAINFO for more details - * @param string $cacert certificate file name (or dir holding certificates) - * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false - * @access public - */ - function setCaCertificate($cacert, $is_dir=false) - { - if ($is_dir) - { - $this->cacertdir = $cacert; - } - else - { - $this->cacert = $cacert; - } - } - - /** - * Set attributes for SSL communication: private SSL key - * NB: does not work in older php/curl installs - * Thanks to Daniel Convissor - * @param string $key The name of a file containing a private SSL key - * @param string $keypass The secret password needed to use the private SSL key - * @access public - */ - function setKey($key, $keypass) - { - $this->key = $key; - $this->keypass = $keypass; - } - - /** - * Set attributes for SSL communication: verify server certificate - * @param bool $i enable/disable verification of peer certificate - * @access public - */ - function setSSLVerifyPeer($i) - { - $this->verifypeer = $i; - } - - /** - * Set attributes for SSL communication: verify match of server cert w. hostname - * @param int $i - * @access public - */ - function setSSLVerifyHost($i) - { - $this->verifyhost = $i; - } - - /** - * Set proxy info - * @param string $proxyhost - * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS - * @param string $proxyusername Leave blank if proxy has public access - * @param string $proxypassword Leave blank if proxy has public access - * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy - * @access public - */ - function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1) - { - $this->proxy = $proxyhost; - $this->proxyport = $proxyport; - $this->proxy_user = $proxyusername; - $this->proxy_pass = $proxypassword; - $this->proxy_authtype = $proxyauthtype; - } - - /** - * Enables/disables reception of compressed xmlrpc responses. - * Note that enabling reception of compressed responses merely adds some standard - * http headers to xmlrpc requests. It is up to the xmlrpc server to return - * compressed responses when receiving such requests. - * @param string $compmethod either 'gzip', 'deflate', 'any' or '' - * @access public - */ - function setAcceptedCompression($compmethod) - { - if ($compmethod == 'any') - $this->accepted_compression = array('gzip', 'deflate'); - else - $this->accepted_compression = array($compmethod); - } - - /** - * Enables/disables http compression of xmlrpc request. - * Take care when sending compressed requests: servers might not support them - * (and automatic fallback to uncompressed requests is not yet implemented) - * @param string $compmethod either 'gzip', 'deflate' or '' - * @access public - */ - function setRequestCompression($compmethod) - { - $this->request_compression = $compmethod; - } - - /** - * Adds a cookie to list of cookies that will be sent to server. - * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie: - * do not do it unless you know what you are doing - * @param string $name - * @param string $value - * @param string $path - * @param string $domain - * @param int $port - * @access public - * - * @todo check correctness of urlencoding cookie value (copied from php way of doing it...) - */ - function setCookie($name, $value='', $path='', $domain='', $port=null) - { - $this->cookies[$name]['value'] = urlencode($value); - if ($path || $domain || $port) - { - $this->cookies[$name]['path'] = $path; - $this->cookies[$name]['domain'] = $domain; - $this->cookies[$name]['port'] = $port; - $this->cookies[$name]['version'] = 1; - } - else - { - $this->cookies[$name]['version'] = 0; - } - } - - /** - * Send an xmlrpc request - * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request - * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply - * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used - * @return xmlrpcresp - * @access public - */ - function& send($msg, $timeout=0, $method='') - { - // if user deos not specify http protocol, use native method of this client - // (i.e. method set during call to constructor) - if($method == '') - { - $method = $this->method; - } - - if(is_array($msg)) - { - // $msg is an array of xmlrpcmsg's - $r = $this->multicall($msg, $timeout, $method); - return $r; - } - elseif(is_string($msg)) - { - $n =& new xmlrpcmsg(''); - $n->payload = $msg; - $msg = $n; - } - - // where msg is an xmlrpcmsg - $msg->debug=$this->debug; - - if($method == 'https') - { - $r =& $this->sendPayloadHTTPS( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - $this->cert, - $this->certpass, - $this->cacert, - $this->cacertdir, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype, - $this->keepalive, - $this->key, - $this->keypass - ); - } - elseif($method == 'http11') - { - $r =& $this->sendPayloadCURL( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - null, - null, - null, - null, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype, - 'http', - $this->keepalive - ); - } - else - { - $r =& $this->sendPayloadHTTP10( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype - ); - } - - return $r; - } - - /** - * @access private - */ - function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, - $username='', $password='', $authtype=1, $proxyhost='', - $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1) - { - if($port==0) - { - $port=80; - } - - // Only create the payload if it was not created previously - if(empty($msg->payload)) - { - $msg->createPayload($this->request_charset_encoding); - } - - $payload = $msg->payload; - // Deflate request body and set appropriate request headers - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) - { - if($this->request_compression == 'gzip') - { - $a = @gzencode($payload); - if($a) - { - $payload = $a; - $encoding_hdr = "Content-Encoding: gzip\r\n"; - } - } - else - { - $a = @gzcompress($payload); - if($a) - { - $payload = $a; - $encoding_hdr = "Content-Encoding: deflate\r\n"; - } - } - } - else - { - $encoding_hdr = ''; - } - - // thanks to Grant Rauscher <grant7@firstworld.net> for this - $credentials=''; - if($username!='') - { - $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; - if ($authtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported with HTTP 1.0'); - } - } - - $accepted_encoding = ''; - if(is_array($this->accepted_compression) && count($this->accepted_compression)) - { - $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; - } - - $proxy_credentials = ''; - if($proxyhost) - { - if($proxyport == 0) - { - $proxyport = 8080; - } - $connectserver = $proxyhost; - $connectport = $proxyport; - $uri = 'http://'.$server.':'.$port.$this->path; - if($proxyusername != '') - { - if ($proxyauthtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported with HTTP 1.0'); - } - $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; - } - } - else - { - $connectserver = $server; - $connectport = $port; - $uri = $this->path; - } - - // Cookie generation, as per rfc2965 (version 1 cookies) or - // netscape's rules (version 0 cookies) - $cookieheader=''; - if (count($this->cookies)) - { - $version = ''; - foreach ($this->cookies as $name => $cookie) - { - if ($cookie['version']) - { - $version = ' $Version="' . $cookie['version'] . '";'; - $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; - if ($cookie['path']) - $cookieheader .= ' $Path="' . $cookie['path'] . '";'; - if ($cookie['domain']) - $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; - if ($cookie['port']) - $cookieheader .= ' $Port="' . $cookie['port'] . '";'; - } - else - { - $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; - } - } - $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; - } - - $op= 'POST ' . $uri. " HTTP/1.0\r\n" . - 'User-Agent: ' . $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'] . "\r\n" . - 'Host: '. $server . ':' . $port . "\r\n" . - $credentials . - $proxy_credentials . - $accepted_encoding . - $encoding_hdr . - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . - $cookieheader . - 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " . - strlen($payload) . "\r\n\r\n" . - $payload; - - if($this->debug > 1) - { - print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>"; - // let the client see this now in case http times out... - flush(); - } - - if($timeout>0) - { - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); - } - else - { - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); - } - if($fp) - { - if($timeout>0 && function_exists('stream_set_timeout')) - { - stream_set_timeout($fp, $timeout); - } - } - else - { - $this->errstr='Connect error: '.$this->errstr; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')'); - return $r; - } - - if(!fputs($fp, $op, strlen($op))) - { - fclose($fp); - $this->errstr='Write error'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); - return $r; - } - else - { - // reset errno and errstr on succesful socket connection - $this->errstr = ''; - } - // G. Giunta 2005/10/24: close socket before parsing. - // should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) - $ipd=''; - do - { - // shall we check for $data === FALSE? - // as per the manual, it signals an error - $ipd.=fread($fp, 32768); - } while(!feof($fp)); - fclose($fp); - $r =& $msg->parseResponse($ipd, false, $this->return_type); - return $r; - - } - - /** - * @access private - */ - function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='', - $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='', - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, - $keepalive=false, $key='', $keypass='') - { - $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username, - $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport, - $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass); - return $r; - } - - /** - * Contributed by Justin Miller <justin@voxel.net> - * Requires curl to be built into PHP - * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers! - * @access private - */ - function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='', - $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='', - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https', - $keepalive=false, $key='', $keypass='') - { - if(!function_exists('curl_init')) - { - $this->errstr='CURL unavailable on this install'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']); - return $r; - } - if($method == 'https') - { - if(($info = curl_version()) && - ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))) - { - $this->errstr='SSL unavailable on this install'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']); - return $r; - } - } - - if($port == 0) - { - if($method == 'http') - { - $port = 80; - } - else - { - $port = 443; - } - } - - // Only create the payload if it was not created previously - if(empty($msg->payload)) - { - $msg->createPayload($this->request_charset_encoding); - } - - // Deflate request body and set appropriate request headers - $payload = $msg->payload; - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) - { - if($this->request_compression == 'gzip') - { - $a = @gzencode($payload); - if($a) - { - $payload = $a; - $encoding_hdr = 'Content-Encoding: gzip'; - } - } - else - { - $a = @gzcompress($payload); - if($a) - { - $payload = $a; - $encoding_hdr = 'Content-Encoding: deflate'; - } - } - } - else - { - $encoding_hdr = ''; - } - - if($this->debug > 1) - { - print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>"; - // let the client see this now in case http times out... - flush(); - } - - if(!$keepalive || !$this->xmlrpc_curl_handle) - { - $curl = curl_init($method . '://' . $server . ':' . $port . $this->path); - if($keepalive) - { - $this->xmlrpc_curl_handle = $curl; - } - } - else - { - $curl = $this->xmlrpc_curl_handle; - } - - // results into variable - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - - if($this->debug) - { - curl_setopt($curl, CURLOPT_VERBOSE, 1); - } - curl_setopt($curl, CURLOPT_USERAGENT, $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']); - // required for XMLRPC: post the data - curl_setopt($curl, CURLOPT_POST, 1); - // the data - curl_setopt($curl, CURLOPT_POSTFIELDS, $payload); - - // return the header too - curl_setopt($curl, CURLOPT_HEADER, 1); - - // will only work with PHP >= 5.0 - // NB: if we set an empty string, CURL will add http header indicating - // ALL methods it is supporting. This is possibly a better option than - // letting the user tell what curl can / cannot do... - if(is_array($this->accepted_compression) && count($this->accepted_compression)) - { - //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression)); - // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if (count($this->accepted_compression) == 1) - { - curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]); - } - else - curl_setopt($curl, CURLOPT_ENCODING, ''); - } - // extra headers - $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); - // if no keepalive is wanted, let the server know it in advance - if(!$keepalive) - { - $headers[] = 'Connection: close'; - } - // request compression header - if($encoding_hdr) - { - $headers[] = $encoding_hdr; - } - - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - // timeout is borked - if($timeout) - { - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); - } - - if($username && $password) - { - curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); - if (defined('CURLOPT_HTTPAUTH')) - { - curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype); - } - else if ($authtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported by the current PHP/curl install'); - } - } - - if($method == 'https') - { - // set cert file - if($cert) - { - curl_setopt($curl, CURLOPT_SSLCERT, $cert); - } - // set cert password - if($certpass) - { - curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass); - } - // whether to verify remote host's cert - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer); - // set ca certificates file/dir - if($cacert) - { - curl_setopt($curl, CURLOPT_CAINFO, $cacert); - } - if($cacertdir) - { - curl_setopt($curl, CURLOPT_CAPATH, $cacertdir); - } - // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if($key) - { - curl_setopt($curl, CURLOPT_SSLKEY, $key); - } - // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if($keypass) - { - curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass); - } - // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost); - } - - // proxy info - if($proxyhost) - { - if($proxyport == 0) - { - $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080 - } - curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport); - //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport); - if($proxyusername) - { - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword); - if (defined('CURLOPT_PROXYAUTH')) - { - curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype); - } - else if ($proxyauthtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported by the current PHP/curl install'); - } - } - } - - // NB: should we build cookie http headers by hand rather than let CURL do it? - // the following code does not honour 'expires', 'path' and 'domain' cookie attributes - // set to client obj the the user... - if (count($this->cookies)) - { - $cookieheader = ''; - foreach ($this->cookies as $name => $cookie) - { - $cookieheader .= $name . '=' . $cookie['value'] . '; '; - } - curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2)); - } - - $result = curl_exec($curl); - - if ($this->debug > 1) - { - print "<PRE>\n---CURL INFO---\n"; - foreach(curl_getinfo($curl) as $name => $val) - print $name . ': ' . htmlentities($val). "\n"; - print "---END---\n</PRE>"; - } - - if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'? - { - $this->errstr='no response'; - $resp=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl)); - curl_close($curl); - if($keepalive) - { - $this->xmlrpc_curl_handle = null; - } - } - else - { - if(!$keepalive) - { - curl_close($curl); - } - $resp =& $msg->parseResponse($result, true, $this->return_type); - } - return $resp; - } - - /** - * Send an array of request messages and return an array of responses. - * Unless $this->no_multicall has been set to true, it will try first - * to use one single xmlrpc call to server method system.multicall, and - * revert to sending many successive calls in case of failure. - * This failure is also stored in $this->no_multicall for subsequent calls. - * Unfortunately, there is no server error code universally used to denote - * the fact that multicall is unsupported, so there is no way to reliably - * distinguish between that and a temporary failure. - * If you are sure that server supports multicall and do not want to - * fallback to using many single calls, set the fourth parameter to FALSE. - * - * NB: trying to shoehorn extra functionality into existing syntax has resulted - * in pretty much convoluted code... - * - * @param array $msgs an array of xmlrpcmsg objects - * @param integer $timeout connection timeout (in seconds) - * @param string $method the http protocol variant to be used - * @param boolean fallback When true, upon receiveing an error during multicall, multiple single calls will be attempted - * @return array - * @access public - */ - function multicall($msgs, $timeout=0, $method='', $fallback=true) - { - if ($method == '') - { - $method = $this->method; - } - if(!$this->no_multicall) - { - $results = $this->_try_multicall($msgs, $timeout, $method); - if(is_array($results)) - { - // System.multicall succeeded - return $results; - } - else - { - // either system.multicall is unsupported by server, - // or call failed for some other reason. - if ($fallback) - { - // Don't try it next time... - $this->no_multicall = true; - } - else - { - if (is_a($results, 'xmlrpcresp')) - { - $result = $results; - } - else - { - $result =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']); - } - } - } - } - else - { - // override fallback, in case careless user tries to do two - // opposite things at the same time - $fallback = true; - } - - $results = array(); - if ($fallback) - { - // system.multicall is (probably) unsupported by server: - // emulate multicall via multiple requests - foreach($msgs as $msg) - { - $results[] =& $this->send($msg, $timeout, $method); - } - } - else - { - // user does NOT want to fallback on many single calls: - // since we should always return an array of responses, - // return an array with the same error repeated n times - foreach($msgs as $msg) - { - $results[] = $result; - } - } - return $results; - } - - /** - * Attempt to boxcar $msgs via system.multicall. - * Returns either an array of xmlrpcreponses, an xmlrpc error response - * or false (when received response does not respect valid multicall syntax) - * @access private - */ - function _try_multicall($msgs, $timeout, $method) - { - // Construct multicall message - $calls = array(); - foreach($msgs as $msg) - { - $call['methodName'] =& new xmlrpcval($msg->method(),'string'); - $numParams = $msg->getNumParams(); - $params = array(); - for($i = 0; $i < $numParams; $i++) - { - $params[$i] = $msg->getParam($i); - } - $call['params'] =& new xmlrpcval($params, 'array'); - $calls[] =& new xmlrpcval($call, 'struct'); - } - $multicall =& new xmlrpcmsg('system.multicall'); - $multicall->addParam(new xmlrpcval($calls, 'array')); - - // Attempt RPC call - $result =& $this->send($multicall, $timeout, $method); - - if($result->faultCode() != 0) - { - // call to system.multicall failed - return $result; - } - - // Unpack responses. - $rets = $result->value(); - - if ($this->return_type == 'xml') - { - return $rets; - } - else if ($this->return_type == 'phpvals') - { - ///@todo test this code branch... - $rets = $result->value(); - if(!is_array($rets)) - { - return false; // bad return type from system.multicall - } - $numRets = count($rets); - if($numRets != count($msgs)) - { - return false; // wrong number of return values. - } - - $response = array(); - for($i = 0; $i < $numRets; $i++) - { - $val = $rets[$i]; - if (!is_array($val)) { - return false; - } - switch(count($val)) - { - case 1: - if(!isset($val[0])) - { - return false; // Bad value - } - // Normal return value - $response[$i] =& new xmlrpcresp($val[0], 0, '', 'phpvals'); - break; - case 2: - /// @todo remove usage of @: it is apparently quite slow - $code = @$val['faultCode']; - if(!is_int($code)) - { - return false; - } - $str = @$val['faultString']; - if(!is_string($str)) - { - return false; - } - $response[$i] =& new xmlrpcresp(0, $code, $str); - break; - default: - return false; - } - } - return $response; - } - else // return type == 'xmlrpcvals' - { - $rets = $result->value(); - if($rets->kindOf() != 'array') - { - return false; // bad return type from system.multicall - } - $numRets = $rets->arraysize(); - if($numRets != count($msgs)) - { - return false; // wrong number of return values. - } - - $response = array(); - for($i = 0; $i < $numRets; $i++) - { - $val = $rets->arraymem($i); - switch($val->kindOf()) - { - case 'array': - if($val->arraysize() != 1) - { - return false; // Bad value - } - // Normal return value - $response[$i] =& new xmlrpcresp($val->arraymem(0)); - break; - case 'struct': - $code = $val->structmem('faultCode'); - if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') - { - return false; - } - $str = $val->structmem('faultString'); - if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') - { - return false; - } - $response[$i] =& new xmlrpcresp(0, $code->scalarval(), $str->scalarval()); - break; - default: - return false; - } - } - return $response; - } - } - } // end class xmlrpc_client - - class xmlrpcresp - { - var $val = 0; - var $valtyp; - var $errno = 0; - var $errstr = ''; - var $payload; - var $hdrs = array(); - var $_cookies = array(); - var $content_type = 'text/xml'; - var $raw_data = ''; - - /** - * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string) - * @param integer $fcode set it to anything but 0 to create an error response - * @param string $fstr the error string, in case of an error response - * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml' - * - * @todo add check that $val / $fcode / $fstr is of correct type??? - * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain - * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called... - */ - function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='') - { - if($fcode != 0) - { - // error response - $this->errno = $fcode; - $this->errstr = $fstr; - //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later. - } - else - { - // successful response - $this->val = $val; - if ($valtyp == '') - { - // user did not declare type of response value: try to guess it - if (is_object($this->val) && is_a($this->val, 'xmlrpcval')) - { - $this->valtyp = 'xmlrpcvals'; - } - else if (is_string($this->val)) - { - $this->valtyp = 'xml'; - - } - else - { - $this->valtyp = 'phpvals'; - } - } - else - { - // user declares type of resp value: believe him - $this->valtyp = $valtyp; - } - } - } - - /** - * Returns the error code of the response. - * @return integer the error code of this response (0 for not-error responses) - * @access public - */ - function faultCode() - { - return $this->errno; - } - - /** - * Returns the error code of the response. - * @return string the error string of this response ('' for not-error responses) - * @access public - */ - function faultString() - { - return $this->errstr; - } - - /** - * Returns the value received by the server. - * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects - * @access public - */ - function value() - { - return $this->val; - } - - /** - * Returns an array with the cookies received from the server. - * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...) - * with attributes being e.g. 'expires', 'path', domain'. - * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past) - * are still present in the array. It is up to the user-defined code to decide - * how to use the received cookies, and wheter they have to be sent back with the next - * request to the server (using xmlrpc_client::setCookie) or not - * @return array array of cookies received from the server - * @access public - */ - function cookies() - { - return $this->_cookies; - } - - /** - * Returns xml representation of the response. XML prologue not included - * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed - * @return string the xml representation of the response - * @access public - */ - function serialize($charset_encoding='') - { - if ($charset_encoding != '') - $this->content_type = 'text/xml; charset=' . $charset_encoding; - else - $this->content_type = 'text/xml'; - $result = "<methodResponse>\n"; - if($this->errno) - { - // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients - // by xml-encoding non ascii chars - $result .= "<fault>\n" . -"<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . -"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . -xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" . -"</struct>\n</value>\n</fault>"; - } - else - { - if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) - { - if (is_string($this->val) && $this->valtyp == 'xml') - { - $result .= "<params>\n<param>\n" . - $this->val . - "</param>\n</params>"; - } - else - { - /// @todo try to build something serializable? - die('cannot serialize xmlrpcresp objects whose content is native php values'); - } - } - else - { - $result .= "<params>\n<param>\n" . - $this->val->serialize($charset_encoding) . - "</param>\n</params>"; - } - } - $result .= "\n</methodResponse>"; - $this->payload = $result; - return $result; - } - } - - class xmlrpcmsg - { - var $payload; - var $methodname; - var $params=array(); - var $debug=0; - var $content_type = 'text/xml'; - - /** - * @param string $meth the name of the method to invoke - * @param array $pars array of parameters to be paased to the method (xmlrpcval objects) - */ - function xmlrpcmsg($meth, $pars=0) - { - $this->methodname=$meth; - if(is_array($pars) && count($pars)>0) - { - for($i=0; $i<count($pars); $i++) - { - $this->addParam($pars[$i]); - } - } - } - - /** - * @access private - */ - function xml_header($charset_encoding='') - { - if ($charset_encoding != '') - { - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n"; - } - else - { - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; - } - } - - /** - * @access private - */ - function xml_footer() - { - return '</methodCall>'; - } - - /** - * @access private - */ - function kindOf() - { - return 'msg'; - } - - /** - * @access private - */ - function createPayload($charset_encoding='') - { - if ($charset_encoding != '') - $this->content_type = 'text/xml; charset=' . $charset_encoding; - else - $this->content_type = 'text/xml'; - $this->payload=$this->xml_header($charset_encoding); - $this->payload.='<methodName>' . $this->methodname . "</methodName>\n"; - $this->payload.="<params>\n"; - for($i=0; $i<count($this->params); $i++) - { - $p=$this->params[$i]; - $this->payload.="<param>\n" . $p->serialize($charset_encoding) . - "</param>\n"; - } - $this->payload.="</params>\n"; - $this->payload.=$this->xml_footer(); - } - - /** - * Gets/sets the xmlrpc method to be invoked - * @param string $meth the method to be set (leave empty not to set it) - * @return string the method that will be invoked - * @access public - */ - function method($meth='') - { - if($meth!='') - { - $this->methodname=$meth; - } - return $this->methodname; - } - - /** - * Returns xml representation of the message. XML prologue included - * @return string the xml representation of the message, xml prologue included - * @access public - */ - function serialize($charset_encoding='') - { - $this->createPayload($charset_encoding); - return $this->payload; - } - - /** - * Add a parameter to the list of parameters to be used upon method invocation - * @param xmlrpcval $par - * @return boolean false on failure - * @access public - */ - function addParam($par) - { - // add check: do not add to self params which are not xmlrpcvals - if(is_object($par) && is_a($par, 'xmlrpcval')) - { - $this->params[]=$par; - return true; - } - else - { - return false; - } - } - - /** - * Returns the nth parameter in the message. The index zero-based. - * @param integer $i the index of the parameter to fetch (zero based) - * @return xmlrpcval the i-th parameter - * @access public - */ - function getParam($i) { return $this->params[$i]; } - - /** - * Returns the number of parameters in the messge. - * @return integer the number of parameters currently set - * @access public - */ - function getNumParams() { return count($this->params); } - - /** - * Given an open file handle, read all data available and parse it as axmlrpc response. - * NB: the file handle is not closed by this function. - * NNB: might have trouble in rare cases to work on network streams, as we - * check for a read of 0 bytes instead of feof($fp). - * But since checking for feof(null) returns false, we would risk an - * infinite loop in that case, because we cannot trust the caller - * to give us a valid pointer to an open file... - * @access public - * @return xmlrpcresp - * @todo add 2nd & 3rd param to be passed to ParseResponse() ??? - */ - function &parseResponseFile($fp) - { - $ipd=''; - while($data=fread($fp, 32768)) - { - $ipd.=$data; - } - //fclose($fp); - $r =& $this->parseResponse($ipd); - return $r; - } - - /** - * Parses HTTP headers and separates them from data. - * @access private - */ - function &parseResponseHeaders(&$data, $headers_processed=false) - { - // Support "web-proxy-tunelling" connections for https through proxies - if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) - { - // Look for CR/LF or simple LF as line separator, - // (even though it is not valid http) - $pos = strpos($data,"\r\n\r\n"); - if($pos || is_int($pos)) - { - $bd = $pos+4; - } - else - { - $pos = strpos($data,"\n\n"); - if($pos || is_int($pos)) - { - $bd = $pos+2; - } - else - { - // No separation between response headers and body: fault? - $bd = 0; - } - } - if ($bd) - { - // this filters out all http headers from proxy. - // maybe we could take them into account, too? - $data = substr($data, $bd); - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTPS via proxy error, tunnel connection possibly failed'); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)'); - return $r; - } - } - - // Strip HTTP 1.1 100 Continue header if present - while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) - { - $pos = strpos($data, 'HTTP', 12); - // server sent a Continue header without any (valid) content following... - // give the client a chance to know it - if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 - { - break; - } - $data = substr($data, $pos); - } - if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) - { - $errstr= substr($data, 0, strpos($data, "\n")-1); - error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTP error, got response: ' .$errstr); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')'); - return $r; - } - - $GLOBALS['_xh']['headers'] = array(); - $GLOBALS['_xh']['cookies'] = array(); - - // be tolerant to usage of \n instead of \r\n to separate headers and data - // (even though it is not valid http) - $pos = strpos($data,"\r\n\r\n"); - if($pos || is_int($pos)) - { - $bd = $pos+4; - } - else - { - $pos = strpos($data,"\n\n"); - if($pos || is_int($pos)) - { - $bd = $pos+2; - } - else - { - // No separation between response headers and body: fault? - // we could take some action here instead of going on... - $bd = 0; - } - } - // be tolerant to line endings, and extra empty lines - $ar = split("\r?\n", trim(substr($data, 0, $pos))); - while(list(,$line) = @each($ar)) - { - // take care of multi-line headers and cookies - $arr = explode(':',$line,2); - if(count($arr) > 1) - { - $header_name = strtolower(trim($arr[0])); - /// @todo some other headers (the ones that allow a CSV list of values) - /// do allow many values to be passed using multiple header lines. - /// We should add content to $GLOBALS['_xh']['headers'][$header_name] - /// instead of replacing it for those... - if ($header_name == 'set-cookie' || $header_name == 'set-cookie2') - { - if ($header_name == 'set-cookie2') - { - // version 2 cookies: - // there could be many cookies on one line, comma separated - $cookies = explode(',', $arr[1]); - } - else - { - $cookies = array($arr[1]); - } - foreach ($cookies as $cookie) - { - // glue together all received cookies, using a comma to separate them - // (same as php does with getallheaders()) - if (isset($GLOBALS['_xh']['headers'][$header_name])) - $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); - else - $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); - // parse cookie attributes, in case user wants to correctly honour them - // feature creep: only allow rfc-compliant cookie attributes? - // @todo support for server sending multiple time cookie with same name, but using different PATHs - $cookie = explode(';', $cookie); - foreach ($cookie as $pos => $val) - { - $val = explode('=', $val, 2); - $tag = trim($val[0]); - $val = trim(@$val[1]); - /// @todo with version 1 cookies, we should strip leading and trailing " chars - if ($pos == 0) - { - $cookiename = $tag; - $GLOBALS['_xh']['cookies'][$tag] = array(); - $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val); - } - else - { - if ($tag != 'value') - { - $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val; - } - } - } - } - } - else - { - $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]); - } - } - elseif(isset($header_name)) - { - /// @todo version1 cookies might span multiple lines, thus breaking the parsing above - $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line); - } - } - - $data = substr($data, $bd); - - if($this->debug && count($GLOBALS['_xh']['headers'])) - { - print '<PRE>'; - foreach($GLOBALS['_xh']['headers'] as $header => $value) - { - print htmlentities("HEADER: $header: $value\n"); - } - foreach($GLOBALS['_xh']['cookies'] as $header => $value) - { - print htmlentities("COOKIE: $header={$value['value']}\n"); - } - print "</PRE>\n"; - } - - // if CURL was used for the call, http headers have been processed, - // and dechunking + reinflating have been carried out - if(!$headers_processed) - { - // Decode chunked encoding sent by http 1.1 servers - if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') - { - if(!$data = decode_chunked($data)) - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to rebuild the chunked data received from server'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']); - return $r; - } - } - - // Decode gzip-compressed stuff - // code shamelessly inspired from nusoap library by Dietrich Ayala - if(isset($GLOBALS['_xh']['headers']['content-encoding'])) - { - $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']); - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') - { - // if decoding works, use it. else assume data wasn't gzencoded - if(function_exists('gzinflate')) - { - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) - { - $data = $degzdata; - if($this->debug) - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; - } - elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) - { - $data = $degzdata; - if($this->debug) - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to decode the deflated data received from server'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']); - return $r; - } - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']); - return $r; - } - } - } - } // end of 'if needed, de-chunk, re-inflate response' - - // real stupid hack to avoid PHP 4 complaining about returning NULL by ref - $r = null; - $r =& $r; - return $r; - } - - /** - * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object. - * @param string $data the xmlrpc response, eventually including http headers - * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding - * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals' - * @return xmlrpcresp - * @access public - */ - function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals') - { - if($this->debug) - { - //by maHo, replaced htmlspecialchars with htmlentities - print "<PRE>---GOT---\n" . htmlentities($data) . "\n---END---\n</PRE>"; - } - - if($data == '') - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: no response received from server.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']); - return $r; - } - - $GLOBALS['_xh']=array(); - - $raw_data = $data; - // parse the HTTP headers of the response, if present, and separate them from data - if(substr($data, 0, 4) == 'HTTP') - { - $r =& $this->parseResponseHeaders($data, $headers_processed); - if ($r) - { - // failed processing of HTTP response headers - // save into response obj the full payload received, for debugging - $r->raw_data = $data; - return $r; - } - } - else - { - $GLOBALS['_xh']['headers'] = array(); - $GLOBALS['_xh']['cookies'] = array(); - } - - if($this->debug) - { - $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); - if ($start) - { - $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); - $end = strpos($data, '-->', $start); - $comments = substr($data, $start, $end-$start); - print "<PRE>---SERVER DEBUG INFO (DECODED) ---\n\t".htmlentities(str_replace("\n", "\n\t", base64_decode($comments)))."\n---END---\n</PRE>"; - } - } - - // be tolerant of extra whitespace in response body - $data = trim($data); - - /// @todo return an error msg if $data=='' ? - - // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts) - // idea from Luca Mariano <luca.mariano@email.it> originally in PEARified version of the lib - $bd = false; - // Poor man's version of strrpos for php 4... - $pos = strpos($data, '</methodResponse>'); - while($pos || is_int($pos)) - { - $bd = $pos+17; - $pos = strpos($data, '</methodResponse>', $bd); - } - if($bd) - { - $data = substr($data, 0, $bd); - } - - // if user wants back raw xml, give it to him - if ($return_type == 'xml') - { - $r =& new xmlrpcresp($data, 0, '', 'xml'); - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - - // try to 'guestimate' the character encoding of the received response - $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data); - - $GLOBALS['_xh']['ac']=''; - //$GLOBALS['_xh']['qt']=''; //unused... - $GLOBALS['_xh']['stack'] = array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc - $GLOBALS['_xh']['isf_reason']=''; - $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse' - - // if response charset encoding is not known / supported, try to use - // the default encoding and parse the xml anyway, but log a warning... - if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - // the following code might be better for mb_string enabled installs, but - // makes the lib about 200% slower... - //if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: invalid charset encoding of received response: '.$resp_encoding); - $resp_encoding = $GLOBALS['xmlrpc_defencoding']; - } - $parser = xml_parser_create($resp_encoding); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell - // the xml parser to give us back data in the expected charset. - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8 - // This allows to send data which is native in various charset, - // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - - if ($return_type == 'phpvals') - { - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); - } - else - { - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); - } - - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - - // first error check: xml not well formed - if(!xml_parse($parser, $data, count($data))) - { - // thanks to Peter Kocks <peter.kocks@baygate.com> - if((xml_get_current_line_number($parser)) == 1) - { - $errstr = 'XML error at line 1, check URL'; - } - else - { - $errstr = sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser)); - } - error_log($errstr); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')'); - xml_parser_free($parser); - if($this->debug) - { - print $errstr; - } - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - xml_parser_free($parser); - // second error check: xml well formed but not xml-rpc compliant - if ($GLOBALS['_xh']['isf'] > 1) - { - if ($this->debug) - { - /// @todo echo something for user? - } - - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], - $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']); - } - // third error check: parsing of the response has somehow gone boink. - // NB: shall we omit this check, since we trust the parsing code? - elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value'])) - { - // something odd has happened - // and it's time to generate a client side error - // indicating something odd went on - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], - $GLOBALS['xmlrpcstr']['invalid_return']); - } - else - { - if ($this->debug) - { - print "<PRE>---PARSED---\n"; - // somehow htmlentities chokes on var_export, and some full html string... - //print htmlentitites(var_export($GLOBALS['_xh']['value'], true)); - print htmlspecialchars(var_export($GLOBALS['_xh']['value'], true)); - print "\n---END---</PRE>"; - } - - // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object. - $v =& $GLOBALS['_xh']['value']; - - if($GLOBALS['_xh']['isf']) - { - /// @todo we should test here if server sent an int and a string, - /// and/or coerce them into such... - if ($return_type == 'xmlrpcvals') - { - $errno_v = $v->structmem('faultCode'); - $errstr_v = $v->structmem('faultString'); - $errno = $errno_v->scalarval(); - $errstr = $errstr_v->scalarval(); - } - else - { - $errno = $v['faultCode']; - $errstr = $v['faultString']; - } - - if($errno == 0) - { - // FAULT returned, errno needs to reflect that - $errno = -1; - } - - $r =& new xmlrpcresp(0, $errno, $errstr); - } - else - { - $r=&new xmlrpcresp($v, 0, '', $return_type); - } - } - - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - } - - class xmlrpcval - { - var $me=array(); - var $mytype=0; - var $_php_class=null; - - /** - * @param mixed $val - * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed - */ - function xmlrpcval($val=-1, $type='') - { - /// @todo: optimization creep - do not call addXX, do it all inline. - /// downside: booleans will not be coerced anymore - if($val!==-1 || $type!='') - { - // optimization creep: inlined all work done by constructor - switch($type) - { - case '': - $this->mytype=1; - $this->me['string']=$val; - break; - case 'i4': - case 'int': - case 'double': - case 'string': - case 'boolean': - case 'dateTime.iso8601': - case 'base64': - case 'null': - $this->mytype=1; - $this->me[$type]=$val; - break; - case 'array': - $this->mytype=2; - $this->me['array']=$val; - break; - case 'struct': - $this->mytype=3; - $this->me['struct']=$val; - break; - default: - error_log("XML-RPC: xmlrpcval::xmlrpcval: not a known type ($type)"); - } - /*if($type=='') - { - $type='string'; - } - if($GLOBALS['xmlrpcTypes'][$type]==1) - { - $this->addScalar($val,$type); - } - elseif($GLOBALS['xmlrpcTypes'][$type]==2) - { - $this->addArray($val); - } - elseif($GLOBALS['xmlrpcTypes'][$type]==3) - { - $this->addStruct($val); - }*/ - } - } - - /** - * Add a single php value to an (unitialized) xmlrpcval - * @param mixed $val - * @param string $type - * @return int 1 or 0 on failure - */ - function addScalar($val, $type='string') - { - $typeof=@$GLOBALS['xmlrpcTypes'][$type]; - if($typeof!=1) - { - error_log("XML-RPC: xmlrpcval::addScalar: not a scalar type ($type)"); - return 0; - } - - // coerce booleans into correct values - // NB: we should iether do it for datetimes, integers and doubles, too, - // or just plain remove this check, implemnted on booleans only... - if($type==$GLOBALS['xmlrpcBoolean']) - { - if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) - { - $val=true; - } - else - { - $val=false; - } - } - - switch($this->mytype) - { - case 1: - error_log('XML-RPC: xmlrpcval::addScalar: scalar xmlrpcval can have only one value'); - return 0; - case 3: - error_log('XML-RPC: xmlrpcval::addScalar: cannot add anonymous scalar to struct xmlrpcval'); - return 0; - case 2: - // we're adding a scalar value to an array here - //$ar=$this->me['array']; - //$ar[]=&new xmlrpcval($val, $type); - //$this->me['array']=$ar; - // Faster (?) avoid all the costly array-copy-by-val done here... - $this->me['array'][]=&new xmlrpcval($val, $type); - return 1; - default: - // a scalar, so set the value and remember we're scalar - $this->me[$type]=$val; - $this->mytype=$typeof; - return 1; - } - } - - /** - * Add an array of xmlrpcval objects to an xmlrpcval - * @param array $vals - * @return int 1 or 0 on failure - * @access public - * - * @todo add some checking for $vals to be an array of xmlrpcvals? - */ - function addArray($vals) - { - if($this->mytype==0) - { - $this->mytype=$GLOBALS['xmlrpcTypes']['array']; - $this->me['array']=$vals; - return 1; - } - elseif($this->mytype==2) - { - // we're adding to an array here - $this->me['array'] = array_merge($this->me['array'], $vals); - return 1; - } - else - { - error_log('XML-RPC: xmlrpcval::addArray: already initialized as a [' . $this->kindOf() . ']'); - return 0; - } - } - - /** - * Add an array of named xmlrpcval objects to an xmlrpcval - * @param array $vals - * @return int 1 or 0 on failure - * @access public - * - * @todo add some checking for $vals to be an array? - */ - function addStruct($vals) - { - if($this->mytype==0) - { - $this->mytype=$GLOBALS['xmlrpcTypes']['struct']; - $this->me['struct']=$vals; - return 1; - } - elseif($this->mytype==3) - { - // we're adding to a struct here - $this->me['struct'] = array_merge($this->me['struct'], $vals); - return 1; - } - else - { - error_log('XML-RPC: xmlrpcval::addStruct: already initialized as a [' . $this->kindOf() . ']'); - return 0; - } - } - - // poor man's version of print_r ??? - // DEPRECATED! - function dump($ar) - { - foreach($ar as $key => $val) - { - echo "$key => $val<br />"; - if($key == 'array') - { - while(list($key2, $val2) = each($val)) - { - echo "-- $key2 => $val2<br />"; - } - } - } - } - - /** - * Returns a string containing "struct", "array" or "scalar" describing the base type of the value - * @return string - * @access public - */ - function kindOf() - { - switch($this->mytype) - { - case 3: - return 'struct'; - break; - case 2: - return 'array'; - break; - case 1: - return 'scalar'; - break; - default: - return 'undef'; - } - } - - /** - * @access private - */ - function serializedata($typ, $val, $charset_encoding='') - { - $rs=''; - switch(@$GLOBALS['xmlrpcTypes'][$typ]) - { - case 1: - switch($typ) - { - case $GLOBALS['xmlrpcBase64']: - $rs.="<${typ}>" . base64_encode($val) . "</${typ}>"; - break; - case $GLOBALS['xmlrpcBoolean']: - $rs.="<${typ}>" . ($val ? '1' : '0') . "</${typ}>"; - break; - case $GLOBALS['xmlrpcString']: - // G. Giunta 2005/2/13: do NOT use htmlentities, since - // it will produce named html entities, which are invalid xml - $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). "</${typ}>"; - break; - case $GLOBALS['xmlrpcInt']: - case $GLOBALS['xmlrpcI4']: - $rs.="<${typ}>".(int)$val."</${typ}>"; - break; - case $GLOBALS['xmlrpcDouble']: - // avoid using standard conversion of float to string because it is locale-dependent, - // and also because the xmlrpc spec forbids exponential notation - // sprintf('%F') would be most likely ok but it is only available since PHP 4.3.10 and PHP 5.0.3. - // The code below tries its best at keeping max precision while avoiding exp notation, - // but there is of course no limit in the number of decimal places to be used... - $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>"; - break; - case $GLOBALS['xmlrpcNull']: - $rs.="<nil/>"; - break; - default: - // no standard type value should arrive here, but provide a possibility - // for xmlrpcvals of unknown type... - $rs.="<${typ}>${val}</${typ}>"; - } - break; - case 3: - // struct - if ($this->_php_class) - { - $rs.='<struct php_class="' . $this->_php_class . "\">\n"; - } - else - { - $rs.="<struct>\n"; - } - foreach($val as $key2 => $val2) - { - $rs.='<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n"; - //$rs.=$this->serializeval($val2); - $rs.=$val2->serialize($charset_encoding); - $rs.="</member>\n"; - } - $rs.='</struct>'; - break; - case 2: - // array - $rs.="<array>\n<data>\n"; - for($i=0; $i<count($val); $i++) - { - //$rs.=$this->serializeval($val[$i]); - $rs.=$val[$i]->serialize($charset_encoding); - } - $rs.="</data>\n</array>"; - break; - default: - break; - } - return $rs; - } - - /** - * Returns xml representation of the value. XML prologue not included - * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed - * @return string - * @access public - */ - function serialize($charset_encoding='') - { - // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... - //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) - //{ - reset($this->me); - list($typ, $val) = each($this->me); - return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n"; - //} - } - - // DEPRECATED - function serializeval($o) - { - // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... - //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) - //{ - $ar=$o->me; - reset($ar); - list($typ, $val) = each($ar); - return '<value>' . $this->serializedata($typ, $val) . "</value>\n"; - //} - } - - /** - * Checks wheter a struct member with a given name is present. - * Works only on xmlrpcvals of type struct. - * @param string $m the name of the struct member to be looked up - * @return boolean - * @access public - */ - function structmemexists($m) - { - return array_key_exists($m, $this->me['struct']); - } - - /** - * Returns the value of a given struct member (an xmlrpcval object in itself). - * Will raise a php warning if struct member of given name does not exist - * @param string $m the name of the struct member to be looked up - * @return xmlrpcval - * @access public - */ - function structmem($m) - { - return $this->me['struct'][$m]; - } - - /** - * Reset internal pointer for xmlrpcvals of type struct. - * @access public - */ - function structreset() - { - reset($this->me['struct']); - } - - /** - * Return next member element for xmlrpcvals of type struct. - * @return xmlrpcval - * @access public - */ - function structeach() - { - return each($this->me['struct']); - } - - // DEPRECATED! this code looks like it is very fragile and has not been fixed - // for a long long time. Shall we remove it for 2.0? - function getval() - { - // UNSTABLE - reset($this->me); - list($a,$b)=each($this->me); - // contributed by I Sofer, 2001-03-24 - // add support for nested arrays to scalarval - // i've created a new method here, so as to - // preserve back compatibility - - if(is_array($b)) - { - @reset($b); - while(list($id,$cont) = @each($b)) - { - $b[$id] = $cont->scalarval(); - } - } - - // add support for structures directly encoding php objects - if(is_object($b)) - { - $t = get_object_vars($b); - @reset($t); - while(list($id,$cont) = @each($t)) - { - $t[$id] = $cont->scalarval(); - } - @reset($t); - while(list($id,$cont) = @each($t)) - { - @$b->{$id} = $cont; - } - } - // end contrib - return $b; - } - - /** - * Returns the value of a scalar xmlrpcval - * @return mixed - * @access public - */ - function scalarval() - { - reset($this->me); - list(,$b)=each($this->me); - return $b; - } - - /** - * Returns the type of the xmlrpcval. - * For integers, 'int' is always returned in place of 'i4' - * @return string - * @access public - */ - function scalartyp() - { - reset($this->me); - list($a,)=each($this->me); - if($a==$GLOBALS['xmlrpcI4']) - { - $a=$GLOBALS['xmlrpcInt']; - } - return $a; - } - - /** - * Returns the m-th member of an xmlrpcval of struct type - * @param integer $m the index of the value to be retrieved (zero based) - * @return xmlrpcval - * @access public - */ - function arraymem($m) - { - return $this->me['array'][$m]; - } - - /** - * Returns the number of members in an xmlrpcval of array type - * @return integer - * @access public - */ - function arraysize() - { - return count($this->me['array']); - } - - /** - * Returns the number of members in an xmlrpcval of struct type - * @return integer - * @access public - */ - function structsize() - { - return count($this->me['struct']); - } - } - - - // date helpers - - /** - * Given a timestamp, return the corresponding ISO8601 encoded string. - * - * Really, timezones ought to be supported - * but the XML-RPC spec says: - * - * "Don't assume a timezone. It should be specified by the server in its - * documentation what assumptions it makes about timezones." - * - * These routines always assume localtime unless - * $utc is set to 1, in which case UTC is assumed - * and an adjustment for locale is made when encoding - * - * @param int $timet (timestamp) - * @param int $utc (0 or 1) - * @return string - */ - function iso8601_encode($timet, $utc=0) - { - if(!$utc) - { - $t=strftime("%Y%m%dT%H:%M:%S", $timet); - } - else - { - if(function_exists('gmstrftime')) - { - // gmstrftime doesn't exist in some versions - // of PHP - $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet); - } - else - { - $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); - } - } - return $t; - } - - /** - * Given an ISO8601 date string, return a timet in the localtime, or UTC - * @param string $idate - * @param int $utc either 0 or 1 - * @return int (datetime) - */ - function iso8601_decode($idate, $utc=0) - { - $t=0; - if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) - { - if($utc) - { - $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); - } - else - { - $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); - } - } - return $t; - } - - /** - * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types. - * - * Works with xmlrpc message objects as input, too. - * - * Given proper options parameter, can rebuild generic php object instances - * (provided those have been encoded to xmlrpc format using a corresponding - * option in php_xmlrpc_encode()) - * PLEASE NOTE that rebuilding php objects involves calling their constructor function. - * This means that the remote communication end can decide which php code will - * get executed on your server, leaving the door possibly open to 'php-injection' - * style of attacks (provided you have some classes defined on your server that - * might wreak havoc if instances are built outside an appropriate context). - * Make sure you trust the remote server/client before eanbling this! - * - * @author Dan Libby (dan@libby.com) - * - * @param xmlrpcval $xmlrpc_val - * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects - * @return mixed - */ - function php_xmlrpc_decode($xmlrpc_val, $options=array()) - { - switch($xmlrpc_val->kindOf()) - { - case 'scalar': - if (in_array('extension_api', $options)) - { - reset($xmlrpc_val->me); - list($typ,$val) = each($xmlrpc_val->me); - switch ($typ) - { - case 'dateTime.iso8601': - $xmlrpc_val->scalar = $val; - $xmlrpc_val->xmlrpc_type = 'datetime'; - $xmlrpc_val->timestamp = iso8601_decode($val); - return $xmlrpc_val; - case 'base64': - $xmlrpc_val->scalar = $val; - $xmlrpc_val->type = $typ; - return $xmlrpc_val; - default: - return $xmlrpc_val->scalarval(); - } - } - return $xmlrpc_val->scalarval(); - case 'array': - $size = $xmlrpc_val->arraysize(); - $arr = array(); - for($i = 0; $i < $size; $i++) - { - $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options); - } - return $arr; - case 'struct': - $xmlrpc_val->structreset(); - // If user said so, try to rebuild php objects for specific struct vals. - /// @todo should we raise a warning for class not found? - // shall we check for proper subclass of xmlrpcval instead of - // presence of _php_class to detect what we can do? - if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != '' - && class_exists($xmlrpc_val->_php_class)) - { - $obj = @new $xmlrpc_val->_php_class; - while(list($key,$value)=$xmlrpc_val->structeach()) - { - $obj->{$key} = php_xmlrpc_decode($value, $options); - } - return $obj; - } - else - { - $arr = array(); - while(list($key,$value)=$xmlrpc_val->structeach()) - { - $arr[$key] = php_xmlrpc_decode($value, $options); - } - return $arr; - } - case 'msg': - $paramcount = $xmlrpc_val->getNumParams(); - $arr = array(); - for($i = 0; $i < $paramcount; $i++) - { - $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i)); - } - return $arr; - } - } - - // This constant left here only for historical reasons... - // it was used to decide if we have to define xmlrpc_encode on our own, but - // we do not do it anymore - if(function_exists('xmlrpc_decode')) - { - define('XMLRPC_EPI_ENABLED','1'); - } - else - { - define('XMLRPC_EPI_ENABLED','0'); - } - - /** - * Takes native php types and encodes them into xmlrpc PHP object format. - * It will not re-encode xmlrpcval objects. - * - * Feature creep -- could support more types via optional type argument - * (string => datetime support has been added, ??? => base64 not yet) - * - * If given a proper options parameter, php object instances will be encoded - * into 'special' xmlrpc values, that can later be decoded into php objects - * by calling php_xmlrpc_decode() with a corresponding option - * - * @author Dan Libby (dan@libby.com) - * - * @param mixed $php_val the value to be converted into an xmlrpcval object - * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api' - * @return xmlrpcval - */ - function &php_xmlrpc_encode($php_val, $options=array()) - { - $type = gettype($php_val); - switch($type) - { - case 'string': - if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']); - else - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcString']); - break; - case 'integer': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']); - break; - case 'double': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']); - break; - // <G_Giunta_2001-02-29> - // Add support for encoding/decoding of booleans, since they are supported in PHP - case 'boolean': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']); - break; - // </G_Giunta_2001-02-29> - case 'array': - // PHP arrays can be encoded to either xmlrpc structs or arrays, - // depending on wheter they are hashes or plain 0..n integer indexed - // A shorter one-liner would be - // $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1)); - // but execution time skyrockets! - $j = 0; - $arr = array(); - $ko = false; - foreach($php_val as $key => $val) - { - $arr[$key] =& php_xmlrpc_encode($val, $options); - if(!$ko && $key !== $j) - { - $ko = true; - } - $j++; - } - if($ko) - { - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); - } - else - { - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcArray']); - } - break; - case 'object': - if(is_a($php_val, 'xmlrpcval')) - { - $xmlrpc_val = $php_val; - } - else - { - $arr = array(); - while(list($k,$v) = each($php_val)) - { - $arr[$k] = php_xmlrpc_encode($v, $options); - } - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); - if (in_array('encode_php_objs', $options)) - { - // let's save original class name into xmlrpcval: - // might be useful later on... - $xmlrpc_val->_php_class = get_class($php_val); - } - } - break; - case 'NULL': - if (in_array('extension_api', $options)) - { - $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcString']); - } - if (in_array('null_extension', $options)) - { - $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcNull']); - } - else - { - $xmlrpc_val =& new xmlrpcval(); - } - break; - case 'resource': - if (in_array('extension_api', $options)) - { - $xmlrpc_val =& new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); - } - else - { - $xmlrpc_val =& new xmlrpcval(); - } - // catch "user function", "unknown type" - default: - // giancarlo pinerolo <ping@alt.it> - // it has to return - // an empty object in case, not a boolean. - $xmlrpc_val =& new xmlrpcval(); - break; - } - return $xmlrpc_val; - } - - /** - * Convert the xml representation of a method response, method request or single - * xmlrpc value into the appropriate object (a.k.a. deserialize) - * @param string $xml_val - * @param array $options - * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp - */ - function php_xmlrpc_decode_xml($xml_val, $options=array()) - { - $GLOBALS['_xh'] = array(); - $GLOBALS['_xh']['ac'] = ''; - $GLOBALS['_xh']['stack'] = array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['params'] = array(); - $GLOBALS['_xh']['pt'] = array(); - $GLOBALS['_xh']['isf'] = 0; - $GLOBALS['_xh']['isf_reason'] = ''; - $GLOBALS['_xh']['method'] = false; - $GLOBALS['_xh']['rt'] = ''; - /// @todo 'guestimate' encoding - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8! - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee'); - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - if(!xml_parse($parser, $xml_val, 1)) - { - $errstr = sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser)); - error_log($errstr); - xml_parser_free($parser); - return false; - } - xml_parser_free($parser); - if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too??? - { - error_log($GLOBALS['_xh']['isf_reason']); - return false; - } - switch ($GLOBALS['_xh']['rt']) - { - case 'methodresponse': - $v =& $GLOBALS['_xh']['value']; - if ($GLOBALS['_xh']['isf'] == 1) - { - $vc = $v->structmem('faultCode'); - $vs = $v->structmem('faultString'); - $r =& new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval()); - } - else - { - $r =& new xmlrpcresp($v); - } - return $r; - case 'methodcall': - $m =& new xmlrpcmsg($GLOBALS['_xh']['method']); - for($i=0; $i < count($GLOBALS['_xh']['params']); $i++) - { - $m->addParam($GLOBALS['_xh']['params'][$i]); - } - return $m; - case 'value': - return $GLOBALS['_xh']['value']; - default: - return false; - } - } - - /** - * decode a string that is encoded w/ "chunked" transfer encoding - * as defined in rfc2068 par. 19.4.6 - * code shamelessly stolen from nusoap library by Dietrich Ayala - * - * @param string $buffer the string to be decoded - * @return string - */ - function decode_chunked($buffer) - { - // length := 0 - $length = 0; - $new = ''; - - // read chunk-size, chunk-extension (if any) and crlf - // get the position of the linebreak - $chunkend = strpos($buffer,"\r\n") + 2; - $temp = substr($buffer,0,$chunkend); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend; - while($chunk_size > 0) - { - $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size); - - // just in case we got a broken connection - if($chunkend == false) - { - $chunk = substr($buffer,$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - $length += strlen($chunk); - break; - } - - // read chunk-data and crlf - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - // length := length + chunk-size - $length += strlen($chunk); - // read chunk-size and crlf - $chunkstart = $chunkend + 2; - - $chunkend = strpos($buffer,"\r\n",$chunkstart)+2; - if($chunkend == false) - { - break; //just in case we got a broken connection - } - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend; - } - return $new; - } - - /** - * xml charset encoding guessing helper function. - * Tries to determine the charset encoding of an XML chunk received over HTTP. - * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type, - * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers, - * which will be most probably using UTF-8 anyway... - * - * @param string $httpheaders the http Content-type header - * @param string $xmlchunk xml content buffer - * @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled) - * - * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!! - */ - function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null) - { - // discussion: see http://www.yale.edu/pclt/encoding/ - // 1 - test if encoding is specified in HTTP HEADERS - - //Details: - // LWS: (\13\10)?( |\t)+ - // token: (any char but excluded stuff)+ - // quoted string: " (any char but double quotes and cointrol chars)* " - // header: Content-type = ...; charset=value(; ...)* - // where value is of type token, no LWS allowed between 'charset' and value - // Note: we do not check for invalid chars in VALUE: - // this had better be done using pure ereg as below - // Note 2: we might be removing whitespace/tabs that ought to be left in if - // the received charset is a quoted string. But nobody uses such charset names... - - /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it? - $matches = array(); - if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches)) - { - return strtoupper(trim($matches[1], " \t\"")); - } - - // 2 - scan the first bytes of the data for a UTF-16 (or other) BOM pattern - // (source: http://www.w3.org/TR/2000/REC-xml-20001006) - // NOTE: actually, according to the spec, even if we find the BOM and determine - // an encoding, we should check if there is an encoding specified - // in the xml declaration, and verify if they match. - /// @todo implement check as described above? - /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM) - if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) - { - return 'UCS-4'; - } - elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) - { - return 'UTF-16'; - } - elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) - { - return 'UTF-8'; - } - - // 3 - test if encoding is specified in the xml declaration - // Details: - // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ - // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* - if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", - $xmlchunk, $matches)) - { - return strtoupper(substr($matches[2], 1, -1)); - } - - // 4 - if mbstring is available, let it do the guesswork - // NB: we favour finding an encoding that is compatible with what we can process - if(extension_loaded('mbstring')) - { - if($encoding_prefs) - { - $enc = mb_detect_encoding($xmlchunk, $encoding_prefs); - } - else - { - $enc = mb_detect_encoding($xmlchunk); - } - // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... - // IANA also likes better US-ASCII, so go with it - if($enc == 'ASCII') - { - $enc = 'US-'.$enc; - } - return $enc; - } - else - { - // no encoding specified: as per HTTP1.1 assume it is iso-8859-1? - // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types - // this should be the standard. And we should be getting text/xml as request and response. - // BUT we have to be backward compatible with the lib, which always used UTF-8 as default... - return $GLOBALS['xmlrpc_defencoding']; - } - } - - /** - * Checks if a given charset encoding is present in a list of encodings or - * if it is a valid subset of any encoding in the list - * @param string $encoding charset to be tested - * @param mixed $validlist comma separated list of valid charsets (or array of charsets) - */ - function is_valid_charset($encoding, $validlist) - { - $charset_supersets = array( - 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', - 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', - 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12', - 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8', - 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN') - ); - if (is_string($validlist)) - $validlist = explode(',', $validlist); - if (@in_array(strtoupper($encoding), $validlist)) - return true; - else - { - if (array_key_exists($encoding, $charset_supersets)) - foreach ($validlist as $allowed) - if (in_array($allowed, $charset_supersets[$encoding])) - return true; - return false; - } - } - -?> diff --git a/core/class/web_service/lib/compat/xmlrpc_wrappers.inc b/core/class/web_service/lib/compat/xmlrpc_wrappers.inc deleted file mode 100755 index f0433a5bfe852512adeeccf6f83871580adfb88e..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/compat/xmlrpc_wrappers.inc +++ /dev/null @@ -1,944 +0,0 @@ -<?php -/** - * PHP-XMLRPC "wrapper" functions - * Generate stubs to transparently access xmlrpc methods as php functions and viceversa - * - * @version $Id: xmlrpc_wrappers.inc,v 1.13 2008/09/20 01:23:47 ggiunta Exp $ - * @author Gaetano Giunta - * @copyright (C) 2006-2008 G. Giunta - * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt - * - * @todo separate introspection from code generation for func-2-method wrapping - * @todo use some better templating system for code generation? - * @todo implement method wrapping with preservation of php objs in calls - * @todo when wrapping methods without obj rebuilding, use return_type = 'phpvals' (faster) - * @todo implement self-parsing of php code for PHP <= 4 - */ - - // requires: xmlrpc.inc - - /** - * Given a string defining a php type or phpxmlrpc type (loosely defined: strings - * accepted come from javadoc blocks), return corresponding phpxmlrpc type. - * NB: for php 'resource' types returns empty string, since resources cannot be serialized; - * for php class names returns 'struct', since php objects can be serialized as xmlrpc structs - * @param string $phptype - * @return string - */ - function php_2_xmlrpc_type($phptype) - { - switch(strtolower($phptype)) - { - case 'string': - return $GLOBALS['xmlrpcString']; - case 'integer': - case $GLOBALS['xmlrpcInt']: // 'int' - case $GLOBALS['xmlrpcI4']: - return $GLOBALS['xmlrpcInt']; - case 'double': - return $GLOBALS['xmlrpcDouble']; - case 'boolean': - return $GLOBALS['xmlrpcBoolean']; - case 'array': - return $GLOBALS['xmlrpcArray']; - case 'object': - return $GLOBALS['xmlrpcStruct']; - case $GLOBALS['xmlrpcBase64']: - case $GLOBALS['xmlrpcStruct']: - return strtolower($phptype); - case 'resource': - return ''; - default: - if(class_exists($phptype)) - { - return $GLOBALS['xmlrpcStruct']; - } - else - { - // unknown: might be any 'extended' xmlrpc type - return $GLOBALS['xmlrpcValue']; - } - } - } - - /** - * Given a string defining a phpxmlrpc type return corresponding php type. - * @param string $xmlrpctype - * @return string - */ - function xmlrpc_2_php_type($xmlrpctype) - { - switch(strtolower($xmlrpctype)) - { - case 'base64': - case 'datetime.iso8601': - case 'string': - return $GLOBALS['xmlrpcString']; - case 'int': - case 'i4': - return 'integer'; - case 'struct': - case 'array': - return 'array'; - case 'double': - return 'float'; - case 'undefined': - return 'mixed'; - case 'boolean': - case 'null': - default: - // unknown: might be any xmlrpc type - return strtolower($xmlrpctype); - } - } - - /** - * Given a user-defined PHP function, create a PHP 'wrapper' function that can - * be exposed as xmlrpc method from an xmlrpc_server object and called from remote - * clients (as well as its corresponding signature info). - * - * Since php is a typeless language, to infer types of input and output parameters, - * it relies on parsing the javadoc-style comment block associated with the given - * function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64) - * in the @param tag is also allowed, if you need the php function to receive/send - * data in that particular format (note that base64 encoding/decoding is transparently - * carried out by the lib, while datetime vals are passed around as strings) - * - * Known limitations: - * - requires PHP 5.0.3 + - * - only works for user-defined functions, not for PHP internal functions - * (reflection does not support retrieving number/type of params for those) - * - functions returning php objects will generate special xmlrpc responses: - * when the xmlrpc decoding of those responses is carried out by this same lib, using - * the appropriate param in php_xmlrpc_decode, the php objects will be rebuilt. - * In short: php objects can be serialized, too (except for their resource members), - * using this function. - * Other libs might choke on the very same xml that will be generated in this case - * (i.e. it has a nonstandard attribute on struct element tags) - * - usage of javadoc @param tags using param names in a different order from the - * function prototype is not considered valid (to be fixed?) - * - * Note that since rel. 2.0RC3 the preferred method to have the server call 'standard' - * php functions (ie. functions not expecting a single xmlrpcmsg obj as parameter) - * is by making use of the functions_parameters_type class member. - * - * @param string $funcname the name of the PHP user function to be exposed as xmlrpc method; array($obj, 'methodname') and array('class', 'methodname') are ok too - * @param string $newfuncname (optional) name for function to be created - * @param array $extra_options (optional) array of options for conversion. valid values include: - * bool return_source when true, php code w. function definition will be returned, not evaluated - * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects - * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers --- - * bool suppress_warnings remove from produced xml any runtime warnings due to the php function being invoked - * @return false on error, or an array containing the name of the new php function, - * its signature and docs, to be used in the server dispatch map - * - * @todo decide how to deal with params passed by ref: bomb out or allow? - * @todo finish using javadoc info to build method sig if all params are named but out of order - * @todo add a check for params of 'resource' type - * @todo add some trigger_errors / error_log when returning false? - * @todo what to do when the PHP function returns NULL? we are currently returning an empty string value... - * @todo add an option to suppress php warnings in invocation of user function, similar to server debug level 3? - * @todo if $newfuncname is empty, we could use create_user_func instead of eval, as it is possibly faster - * @todo add a verbatim_object_copy parameter to allow avoiding the same obj instance? - */ - function wrap_php_function($funcname, $newfuncname='', $extra_options=array()) - { - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $catch_warnings = isset($extra_options['suppress_warnings']) && $extra_options['suppress_warnings'] ? '@' : ''; - - if(version_compare(phpversion(), '5.0.3') == -1) - { - // up to php 5.0.3 some useful reflection methods were missing - error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3'); - return false; - } - - $exists = false; - if(is_array($funcname)) - { - if(count($funcname) < 2 || (!is_string($funcname[0]) && !is_object($funcname[0]))) - { - error_log('XML-RPC: syntax for function to be wrapped is wrong'); - return false; - } - if(is_string($funcname[0])) - { - $plainfuncname = implode('::', $funcname); - } - elseif(is_object($funcname[0])) - { - $plainfuncname = get_class($funcname[0]) . '->' . $funcname[1]; - } - $exists = method_exists($funcname[0], $funcname[1]); - } - else - { - $plainfuncname = $funcname; - $exists = function_exists($funcname); - } - - if(!$exists) - { - error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname); - return false; - } - else - { - // determine name of new php function - if($newfuncname == '') - { - if(is_array($funcname)) - { - if(is_string($funcname[0])) - $xmlrpcfuncname = "{$prefix}_".implode('_', $funcname); - else - $xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1]; - } - else - { - $xmlrpcfuncname = "{$prefix}_$funcname"; - } - } - else - { - $xmlrpcfuncname = $newfuncname; - } - while($buildit && function_exists($xmlrpcfuncname)) - { - $xmlrpcfuncname .= 'x'; - } - - // start to introspect PHP code - if(is_array($funcname)) - { - $func =& new ReflectionMethod($funcname[0], $funcname[1]); - if($func->isPrivate()) - { - error_log('XML-RPC: method to be wrapped is private: '.$plainfuncname); - return false; - } - if($func->isProtected()) - { - error_log('XML-RPC: method to be wrapped is protected: '.$plainfuncname); - return false; - } - if($func->isConstructor()) - { - error_log('XML-RPC: method to be wrapped is the constructor: '.$plainfuncname); - return false; - } - if($func->isDestructor()) - { - error_log('XML-RPC: method to be wrapped is the destructor: '.$plainfuncname); - return false; - } - if($func->isAbstract()) - { - error_log('XML-RPC: method to be wrapped is abstract: '.$plainfuncname); - return false; - } - /// @todo add more checks for static vs. nonstatic? - } - else - { - $func =& new ReflectionFunction($funcname); - } - if($func->isInternal()) - { - // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs - // instead of getparameters to fully reflect internal php functions ? - error_log('XML-RPC: function to be wrapped is internal: '.$plainfuncname); - return false; - } - - // retrieve parameter names, types and description from javadoc comments - - // function description - $desc = ''; - // type of return val: by default 'any' - $returns = $GLOBALS['xmlrpcValue']; - // desc of return val - $returnsDocs = ''; - // type + name of function parameters - $paramDocs = array(); - - $docs = $func->getDocComment(); - if($docs != '') - { - $docs = explode("\n", $docs); - $i = 0; - foreach($docs as $doc) - { - $doc = trim($doc, " \r\t/*"); - if(strlen($doc) && strpos($doc, '@') !== 0 && !$i) - { - if($desc) - { - $desc .= "\n"; - } - $desc .= $doc; - } - elseif(strpos($doc, '@param') === 0) - { - // syntax: @param type [$name] desc - if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) - { - if(strpos($matches[1], '|')) - { - //$paramDocs[$i]['type'] = explode('|', $matches[1]); - $paramDocs[$i]['type'] = 'mixed'; - } - else - { - $paramDocs[$i]['type'] = $matches[1]; - } - $paramDocs[$i]['name'] = trim($matches[2]); - $paramDocs[$i]['doc'] = $matches[3]; - } - $i++; - } - elseif(strpos($doc, '@return') === 0) - { - // syntax: @return type desc - //$returns = preg_split('/\s+/', $doc); - if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) - { - $returns = php_2_xmlrpc_type($matches[1]); - if(isset($matches[2])) - { - $returnsDocs = $matches[2]; - } - } - } - } - } - - // execute introspection of actual function prototype - $params = array(); - $i = 0; - foreach($func->getParameters() as $paramobj) - { - $params[$i] = array(); - $params[$i]['name'] = '$'.$paramobj->getName(); - $params[$i]['isoptional'] = $paramobj->isOptional(); - $i++; - } - - - // start building of PHP code to be eval'd - $innercode = ''; - $i = 0; - $parsvariations = array(); - $pars = array(); - $pnum = count($params); - foreach($params as $param) - { - if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name'])) - { - // param name from phpdoc info does not match param definition! - $paramDocs[$i]['type'] = 'mixed'; - } - - if($param['isoptional']) - { - // this particular parameter is optional. save as valid previous list of parameters - $innercode .= "if (\$paramcount > $i) {\n"; - $parsvariations[] = $pars; - } - $innercode .= "\$p$i = \$msg->getParam($i);\n"; - if ($decode_php_objects) - { - $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n"; - } - else - { - $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n"; - } - - $pars[] = "\$p$i"; - $i++; - if($param['isoptional']) - { - $innercode .= "}\n"; - } - if($i == $pnum) - { - // last allowed parameters combination - $parsvariations[] = $pars; - } - } - - $sigs = array(); - $psigs = array(); - if(count($parsvariations) == 0) - { - // only known good synopsis = no parameters - $parsvariations[] = array(); - $minpars = 0; - } - else - { - $minpars = count($parsvariations[0]); - } - - if($minpars) - { - // add to code the check for min params number - // NB: this check needs to be done BEFORE decoding param values - $innercode = "\$paramcount = \$msg->getNumParams();\n" . - "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode; - } - else - { - $innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode; - } - - $innercode .= "\$np = false;\n"; - // since there are no closures in php, if we are given an object instance, - // we store a pointer to it in a global var... - if ( is_array($funcname) && is_object($funcname[0]) ) - { - $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0]; - $innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n"; - $realfuncname = '$obj->'.$funcname[1]; - } - else - { - $realfuncname = $plainfuncname; - } - foreach($parsvariations as $pars) - { - $innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$realfuncname(" . implode(',', $pars) . "); else\n"; - // build a 'generic' signature (only use an appropriate return type) - $sig = array($returns); - $psig = array($returnsDocs); - for($i=0; $i < count($pars); $i++) - { - if (isset($paramDocs[$i]['type'])) - { - $sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']); - } - else - { - $sig[] = $GLOBALS['xmlrpcValue']; - } - $psig[] = isset($paramDocs[$i]['doc']) ? $paramDocs[$i]['doc'] : ''; - } - $sigs[] = $sig; - $psigs[] = $psig; - } - $innercode .= "\$np = true;\n"; - $innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n"; - //$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n"; - $innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n"; - if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) - { - $innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));"; - } - else - { - if ($encode_php_objects) - $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n"; - else - $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n"; - } - // shall we exclude functions returning by ref? - // if($func->returnsReference()) - // return false; - $code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}"; - //print_r($code); - if ($buildit) - { - $allOK = 0; - eval($code.'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - - if(!$allOK) - { - error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$plainfuncname); - return false; - } - } - - /// @todo examine if $paramDocs matches $parsvariations and build array for - /// usage as method signature, plus put together a nice string for docs - - $ret = array('function' => $xmlrpcfuncname, 'signature' => $sigs, 'docstring' => $desc, 'signature_docs' => $psigs, 'source' => $code); - return $ret; - } - } - - /** - * Given a user-defined PHP class or php object, map its methods onto a list of - * PHP 'wrapper' functions that can be exposed as xmlrpc methods from an xmlrpc_server - * object and called from remote clients (as well as their corresponding signature info). - * - * @param mixed $classname the name of the class whose methods are to be exposed as xmlrpc methods, or an object instance of that class - * @param array $extra_options see the docs for wrap_php_method for more options - * string method_type 'static', 'nonstatic', 'all' and 'auto' (default); the latter will switch between static and non-static depending on wheter $classname is a class name or object instance - * @return array or false on failure - * - * @todo get_class_methods will return both static and non-static methods. - * we have to differentiate the action, depending on wheter we recived a class name or object - */ - function wrap_php_class($classname, $extra_options=array()) - { - $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; - $methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto'; - - if(version_compare(phpversion(), '5.0.3') == -1) - { - // up to php 5.0.3 some useful reflection methods were missing - error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3'); - return false; - } - - $result = array(); - $mlist = get_class_methods($classname); - foreach($mlist as $mname) - { - if ($methodfilter == '' || preg_match($methodfilter, $mname)) - { - // echo $mlist."\n"; - $func =& new ReflectionMethod($classname, $mname); - if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) - { - if(($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) || - (!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname))))) - { - $methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options); - if ( $methodwrap ) - { - $result[$methodwrap['function']] = $methodwrap['function']; - } - } - } - } - } - return $result; - } - - /** - * Given an xmlrpc client and a method name, register a php wrapper function - * that will call it and return results using native php types for both - * params and results. The generated php function will return an xmlrpcresp - * oject for failed xmlrpc calls - * - * Known limitations: - * - server must support system.methodsignature for the wanted xmlrpc method - * - for methods that expose many signatures, only one can be picked (we - * could in priciple check if signatures differ only by number of params - * and not by type, but it would be more complication than we can spare time) - * - nested xmlrpc params: the caller of the generated php function has to - * encode on its own the params passed to the php function if these are structs - * or arrays whose (sub)members include values of type datetime or base64 - * - * Notes: the connection properties of the given client will be copied - * and reused for the connection used during the call to the generated - * php function. - * Calling the generated php function 'might' be slow: a new xmlrpc client - * is created on every invocation and an xmlrpc-connection opened+closed. - * An extra 'debug' param is appended to param list of xmlrpc method, useful - * for debugging purposes. - * - * @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server - * @param string $methodname the xmlrpc method to be mapped to a php function - * @param array $extra_options array of options that specify conversion details. valid ptions include - * integer signum the index of the method signature to use in mapping (if method exposes many sigs) - * integer timeout timeout (in secs) to be used when executing function/calling remote method - * string protocol 'http' (default), 'http11' or 'https' - * string new_function_name the name of php function to create. If unsepcified, lib will pick an appropriate name - * string return_source if true return php code w. function definition instead fo function name - * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects - * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers --- - * mixed return_on_fault a php value to be returned when the xmlrpc call fails/returns a fault response (by default the xmlrpcresp object is returned in this case). If a string is used, '%faultCode%' and '%faultString%' tokens will be substituted with actual error values - * bool debug set it to 1 or 2 to see debug results of querying server for method synopsis - * @return string the name of the generated php function (or false) - OR AN ARRAY... - */ - function wrap_xmlrpc_method($client, $methodname, $extra_options=0, $timeout=0, $protocol='', $newfuncname='') - { - // mind numbing: let caller use sane calling convention (as per javadoc, 3 params), - // OR the 2.0 calling convention (no options) - we really love backward compat, don't we? - if (!is_array($extra_options)) - { - $signum = $extra_options; - $extra_options = array(); - } - else - { - $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; - $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; - $newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : ''; - } - //$encode_php_objects = in_array('encode_php_objects', $extra_options); - //$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 : - // in_array('build_class_code', $extra_options) ? 2 : 0; - - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0; - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - if (isset($extra_options['return_on_fault'])) - { - $decode_fault = true; - $fault_response = $extra_options['return_on_fault']; - } - else - { - $decode_fault = false; - $fault_response = ''; - } - $debug = isset($extra_options['debug']) ? ($extra_options['debug']) : 0; - - $msgclass = $prefix.'msg'; - $valclass = $prefix.'val'; - $decodefunc = 'php_'.$prefix.'_decode'; - - $msg =& new $msgclass('system.methodSignature'); - $msg->addparam(new $valclass($methodname)); - $client->setDebug($debug); - $response =& $client->send($msg, $timeout, $protocol); - if($response->faultCode()) - { - error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname); - return false; - } - else - { - $msig = $response->value(); - if ($client->return_type != 'phpvals') - { - $msig = $decodefunc($msig); - } - if(!is_array($msig) || count($msig) <= $signum) - { - error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname); - return false; - } - else - { - // pick a suitable name for the new function, avoiding collisions - if($newfuncname != '') - { - $xmlrpcfuncname = $newfuncname; - } - else - { - // take care to insure that methodname is translated to valid - // php function name - $xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $methodname); - } - while($buildit && function_exists($xmlrpcfuncname)) - { - $xmlrpcfuncname .= 'x'; - } - - $msig = $msig[$signum]; - $mdesc = ''; - // if in 'offline' mode, get method description too. - // in online mode, favour speed of operation - if(!$buildit) - { - $msg =& new $msgclass('system.methodHelp'); - $msg->addparam(new $valclass($methodname)); - $response =& $client->send($msg, $timeout, $protocol); - if (!$response->faultCode()) - { - $mdesc = $response->value(); - if ($client->return_type != 'phpvals') - { - $mdesc = $mdesc->scalarval(); - } - } - } - - $results = build_remote_method_wrapper_code($client, $methodname, - $xmlrpcfuncname, $msig, $mdesc, $timeout, $protocol, $simple_client_copy, - $prefix, $decode_php_objects, $encode_php_objects, $decode_fault, - $fault_response); - - //print_r($code); - if ($buildit) - { - $allOK = 0; - eval($results['source'].'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - if($allOK) - { - return $xmlrpcfuncname; - } - else - { - error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname); - return false; - } - } - else - { - $results['function'] = $xmlrpcfuncname; - return $results; - } - } - } - } - - /** - * Similar to wrap_xmlrpc_method, but will generate a php class that wraps - * all xmlrpc methods exposed by the remote server as own methods. - * For more details see wrap_xmlrpc_method. - * @param xmlrpc_client $client the client obj all set to query the desired server - * @param array $extra_options list of options for wrapped code - * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options) - */ - function wrap_xmlrpc_server($client, $extra_options=array()) - { - $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; - //$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; - $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; - $newclassname = isset($extra_options['new_class_name']) ? $extra_options['new_class_name'] : ''; - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $verbatim_client_copy = isset($extra_options['simple_client_copy']) ? !($extra_options['simple_client_copy']) : true; - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - - $msgclass = $prefix.'msg'; - //$valclass = $prefix.'val'; - $decodefunc = 'php_'.$prefix.'_decode'; - - $msg =& new $msgclass('system.listMethods'); - $response =& $client->send($msg, $timeout, $protocol); - if($response->faultCode()) - { - error_log('XML-RPC: could not retrieve method list from remote server'); - return false; - } - else - { - $mlist = $response->value(); - if ($client->return_type != 'phpvals') - { - $mlist = $decodefunc($mlist); - } - if(!is_array($mlist) || !count($mlist)) - { - error_log('XML-RPC: could not retrieve meaningful method list from remote server'); - return false; - } - else - { - // pick a suitable name for the new function, avoiding collisions - if($newclassname != '') - { - $xmlrpcclassname = $newclassname; - } - else - { - $xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $client->server).'_client'; - } - while($buildit && class_exists($xmlrpcclassname)) - { - $xmlrpcclassname .= 'x'; - } - - /// @todo add function setdebug() to new class, to enable/disable debugging - $source = "class $xmlrpcclassname\n{\nvar \$client;\n\n"; - $source .= "function $xmlrpcclassname()\n{\n"; - $source .= build_client_wrapper_code($client, $verbatim_client_copy, $prefix); - $source .= "\$this->client =& \$client;\n}\n\n"; - $opts = array('simple_client_copy' => 2, 'return_source' => true, - 'timeout' => $timeout, 'protocol' => $protocol, - 'encode_php_objs' => $encode_php_objects, 'prefix' => $prefix, - 'decode_php_objs' => $decode_php_objects - ); - /// @todo build javadoc for class definition, too - foreach($mlist as $mname) - { - if ($methodfilter == '' || preg_match($methodfilter, $mname)) - { - $opts['new_function_name'] = preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $mname); - $methodwrap = wrap_xmlrpc_method($client, $mname, $opts); - if ($methodwrap) - { - if (!$buildit) - { - $source .= $methodwrap['docstring']; - } - $source .= $methodwrap['source']."\n"; - } - else - { - error_log('XML-RPC: will not create class method to wrap remote method '.$mname); - } - } - } - $source .= "}\n"; - if ($buildit) - { - $allOK = 0; - eval($source.'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - if($allOK) - { - return $xmlrpcclassname; - } - else - { - error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server); - return false; - } - } - else - { - return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => ''); - } - } - } - } - - /** - * Given the necessary info, build php code that creates a new function to - * invoke a remote xmlrpc method. - * Take care that no full checking of input parameters is done to ensure that - * valid php code is emitted. - * Note: real spaghetti code follows... - * @access private - */ - function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname, - $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc', - $decode_php_objects=false, $encode_php_objects=false, $decode_fault=false, - $fault_response='') - { - $code = "function $xmlrpcfuncname ("; - if ($client_copy_mode < 2) - { - // client copy mode 0 or 1 == partial / full client copy in emitted code - $innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix); - $innercode .= "\$client->setDebug(\$debug);\n"; - $this_ = ''; - } - else - { - // client copy mode 2 == no client copy in emitted code - $innercode = ''; - $this_ = 'this->'; - } - $innercode .= "\$msg =& new {$prefix}msg('$methodname');\n"; - - if ($mdesc != '') - { - // take care that PHP comment is not terminated unwillingly by method description - $mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n"; - } - else - { - $mdesc = "/**\nFunction $xmlrpcfuncname\n"; - } - - // param parsing - $plist = array(); - $pcount = count($msig); - for($i = 1; $i < $pcount; $i++) - { - $plist[] = "\$p$i"; - $ptype = $msig[$i]; - if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' || - $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null') - { - // only build directly xmlrpcvals when type is known and scalar - $innercode .= "\$p$i =& new {$prefix}val(\$p$i, '$ptype');\n"; - } - else - { - if ($encode_php_objects) - { - $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n"; - } - else - { - $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n"; - } - } - $innercode .= "\$msg->addparam(\$p$i);\n"; - $mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n"; - } - if ($client_copy_mode < 2) - { - $plist[] = '$debug=0'; - $mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; - } - $plist = implode(', ', $plist); - $mdesc .= '* @return '.xmlrpc_2_php_type($msig[0])." (or an {$prefix}resp obj instance if call fails)\n*/\n"; - - $innercode .= "\$res =& \${$this_}client->send(\$msg, $timeout, '$protocol');\n"; - if ($decode_fault) - { - if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false))) - { - $respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')"; - } - else - { - $respcode = var_export($fault_response, true); - } - } - else - { - $respcode = '$res'; - } - if ($decode_php_objects) - { - $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));"; - } - else - { - $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());"; - } - - $code = $code . $plist. ") {\n" . $innercode . "\n}\n"; - - return array('source' => $code, 'docstring' => $mdesc); - } - - /** - * Given necessary info, generate php code that will rebuild a client object - * Take care that no full checking of input parameters is done to ensure that - * valid php code is emitted. - * @access private - */ - function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc') - { - $code = "\$client =& new {$prefix}_client('".str_replace("'", "\'", $client->path). - "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n"; - - // copy all client fields to the client that will be generated runtime - // (this provides for future expansion or subclassing of client obj) - if ($verbatim_client_copy) - { - foreach($client as $fld => $val) - { - if($fld != 'debug' && $fld != 'return_type') - { - $val = var_export($val, true); - $code .= "\$client->{$fld} = $val;\n"; - } - } - } - // only make sure that client always returns the correct data type - $code .= "\$client->return_type = '{$prefix}vals';\n"; - //$code .= "\$client->setDebug(\$debug);\n"; - return $code; - } -?> \ No newline at end of file diff --git a/core/class/web_service/lib/compat/xmlrpcs.inc b/core/class/web_service/lib/compat/xmlrpcs.inc deleted file mode 100755 index a089ca58d6706906419777c7e396984d325764a7..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/compat/xmlrpcs.inc +++ /dev/null @@ -1,1198 +0,0 @@ -<?php -// by Edd Dumbill (C) 1999-2002 -// <edd@usefulinc.com> -// $Id: xmlrpcs.inc,v 1.71 2008/10/29 23:41:28 ggiunta Exp $ - -// Copyright (c) 1999,2000,2002 Edd Dumbill. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of the "XML-RPC for PHP" nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - - // XML RPC Server class - // requires: xmlrpc.inc - - $GLOBALS['xmlrpcs_capabilities'] = array( - // xmlrpc spec: always supported - 'xmlrpc' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/spec', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'), - // if we support system.xxx functions, we always support multicall, too... - // Note that, as of 2006/09/17, the following URL does not respond anymore - 'system.multicall' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'), - // introspection: version 2! we support 'mixed', too - 'introspection' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'), - 'specVersion' => new xmlrpcval(2, 'int') - ), 'struct') - ); - - /* Functions that implement system.XXX methods of xmlrpc servers */ - $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); - $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; - $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); - function _xmlrpcs_getCapabilities($server, $m=null) - { - $outAr = $GLOBALS['xmlrpcs_capabilities']; - // NIL extension - if ($GLOBALS['xmlrpc_null_extension']) { - $outAr['nil'] = new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.ontosys.com/xml-rpc/extensions.php', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'); - } - return new xmlrpcresp(new xmlrpcval($outAr, 'struct')); - } - - // listMethods: signature was either a string, or nothing. - // The useless string variant has been removed - $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); - $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; - $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); - function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing - { - - $outAr=array(); - foreach($server->dmap as $key => $val) - { - $outAr[]=&new xmlrpcval($key, 'string'); - } - if($server->allow_system_funcs) - { - foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) - { - $outAr[]=&new xmlrpcval($key, 'string'); - } - } - return new xmlrpcresp(new xmlrpcval($outAr, 'array')); - } - - $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); - $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; - $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); - function _xmlrpcs_methodSignature($server, $m) - { - // let accept as parameter both an xmlrpcval or string - if (is_object($m)) - { - $methName=$m->getParam(0); - $methName=$methName->scalarval(); - } - else - { - $methName=$m; - } - if(strpos($methName, "system.") === 0) - { - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; - } - else - { - $dmap=$server->dmap; $sysCall=0; - } - if(isset($dmap[$methName])) - { - if(isset($dmap[$methName]['signature'])) - { - $sigs=array(); - foreach($dmap[$methName]['signature'] as $inSig) - { - $cursig=array(); - foreach($inSig as $sig) - { - $cursig[]=&new xmlrpcval($sig, 'string'); - } - $sigs[]=&new xmlrpcval($cursig, 'array'); - } - $r=&new xmlrpcresp(new xmlrpcval($sigs, 'array')); - } - else - { - // NB: according to the official docs, we should be returning a - // "none-array" here, which means not-an-array - $r=&new xmlrpcresp(new xmlrpcval('undef', 'string')); - } - } - else - { - $r=&new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); - } - return $r; - } - - $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); - $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; - $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); - function _xmlrpcs_methodHelp($server, $m) - { - // let accept as parameter both an xmlrpcval or string - if (is_object($m)) - { - $methName=$m->getParam(0); - $methName=$methName->scalarval(); - } - else - { - $methName=$m; - } - if(strpos($methName, "system.") === 0) - { - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; - } - else - { - $dmap=$server->dmap; $sysCall=0; - } - if(isset($dmap[$methName])) - { - if(isset($dmap[$methName]['docstring'])) - { - $r=&new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); - } - else - { - $r=&new xmlrpcresp(new xmlrpcval('', 'string')); - } - } - else - { - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); - } - return $r; - } - - $_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray'])); - $_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details'; - $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); - function _xmlrpcs_multicall_error($err) - { - if(is_string($err)) - { - $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; - $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; - } - else - { - $code = $err->faultCode(); - $str = $err->faultString(); - } - $struct = array(); - $struct['faultCode'] =& new xmlrpcval($code, 'int'); - $struct['faultString'] =& new xmlrpcval($str, 'string'); - return new xmlrpcval($struct, 'struct'); - } - - function _xmlrpcs_multicall_do_call($server, $call) - { - if($call->kindOf() != 'struct') - { - return _xmlrpcs_multicall_error('notstruct'); - } - $methName = @$call->structmem('methodName'); - if(!$methName) - { - return _xmlrpcs_multicall_error('nomethod'); - } - if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') - { - return _xmlrpcs_multicall_error('notstring'); - } - if($methName->scalarval() == 'system.multicall') - { - return _xmlrpcs_multicall_error('recursion'); - } - - $params = @$call->structmem('params'); - if(!$params) - { - return _xmlrpcs_multicall_error('noparams'); - } - if($params->kindOf() != 'array') - { - return _xmlrpcs_multicall_error('notarray'); - } - $numParams = $params->arraysize(); - - $msg =& new xmlrpcmsg($methName->scalarval()); - for($i = 0; $i < $numParams; $i++) - { - if(!$msg->addParam($params->arraymem($i))) - { - $i++; - return _xmlrpcs_multicall_error(new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['incorrect_params'], - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); - } - } - - $result = $server->execute($msg); - - if($result->faultCode() != 0) - { - return _xmlrpcs_multicall_error($result); // Method returned fault. - } - - return new xmlrpcval(array($result->value()), 'array'); - } - - function _xmlrpcs_multicall_do_call_phpvals($server, $call) - { - if(!is_array($call)) - { - return _xmlrpcs_multicall_error('notstruct'); - } - if(!array_key_exists('methodName', $call)) - { - return _xmlrpcs_multicall_error('nomethod'); - } - if (!is_string($call['methodName'])) - { - return _xmlrpcs_multicall_error('notstring'); - } - if($call['methodName'] == 'system.multicall') - { - return _xmlrpcs_multicall_error('recursion'); - } - if(!array_key_exists('params', $call)) - { - return _xmlrpcs_multicall_error('noparams'); - } - if(!is_array($call['params'])) - { - return _xmlrpcs_multicall_error('notarray'); - } - - // this is a real dirty and simplistic hack, since we might have received a - // base64 or datetime values, but they will be listed as strings here... - $numParams = count($call['params']); - $pt = array(); - foreach($call['params'] as $val) - $pt[] = php_2_xmlrpc_type(gettype($val)); - - $result = $server->execute($call['methodName'], $call['params'], $pt); - - if($result->faultCode() != 0) - { - return _xmlrpcs_multicall_error($result); // Method returned fault. - } - - return new xmlrpcval(array($result->value()), 'array'); - } - - function _xmlrpcs_multicall($server, $m) - { - $result = array(); - // let accept a plain list of php parameters, beside a single xmlrpc msg object - if (is_object($m)) - { - $calls = $m->getParam(0); - $numCalls = $calls->arraysize(); - for($i = 0; $i < $numCalls; $i++) - { - $call = $calls->arraymem($i); - $result[$i] = _xmlrpcs_multicall_do_call($server, $call); - } - } - else - { - $numCalls=count($m); - for($i = 0; $i < $numCalls; $i++) - { - $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); - } - } - - return new xmlrpcresp(new xmlrpcval($result, 'array')); - } - - $GLOBALS['_xmlrpcs_dmap']=array( - 'system.listMethods' => array( - 'function' => '_xmlrpcs_listMethods', - 'signature' => $_xmlrpcs_listMethods_sig, - 'docstring' => $_xmlrpcs_listMethods_doc, - 'signature_docs' => $_xmlrpcs_listMethods_sdoc), - 'system.methodHelp' => array( - 'function' => '_xmlrpcs_methodHelp', - 'signature' => $_xmlrpcs_methodHelp_sig, - 'docstring' => $_xmlrpcs_methodHelp_doc, - 'signature_docs' => $_xmlrpcs_methodHelp_sdoc), - 'system.methodSignature' => array( - 'function' => '_xmlrpcs_methodSignature', - 'signature' => $_xmlrpcs_methodSignature_sig, - 'docstring' => $_xmlrpcs_methodSignature_doc, - 'signature_docs' => $_xmlrpcs_methodSignature_sdoc), - 'system.multicall' => array( - 'function' => '_xmlrpcs_multicall', - 'signature' => $_xmlrpcs_multicall_sig, - 'docstring' => $_xmlrpcs_multicall_doc, - 'signature_docs' => $_xmlrpcs_multicall_sdoc), - 'system.getCapabilities' => array( - 'function' => '_xmlrpcs_getCapabilities', - 'signature' => $_xmlrpcs_getCapabilities_sig, - 'docstring' => $_xmlrpcs_getCapabilities_doc, - 'signature_docs' => $_xmlrpcs_getCapabilities_sdoc) - ); - - $GLOBALS['_xmlrpcs_occurred_errors'] = ''; - $GLOBALS['_xmlrpcs_prev_ehandler'] = ''; - /** - * Error handler used to track errors that occur during server-side execution of PHP code. - * This allows to report back to the client whether an internal error has occurred or not - * using an xmlrpc response object, instead of letting the client deal with the html junk - * that a PHP execution error on the server generally entails. - * - * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors. - * - */ - function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) - { - // obey the @ protocol - if (error_reporting() == 0) - return; - - //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING) - if($errcode != 2048) // do not use E_STRICT by name, since on PHP 4 it will not be defined - { - $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; - } - // Try to avoid as much as possible disruption to the previous error handling - // mechanism in place - if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') - { - // The previous error handler was the default: all we should do is log error - // to the default error log (if level high enough) - if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) - { - error_log($errstring); - } - } - else - { - // Pass control on to previous error handler, trying to avoid loops... - if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') - { - // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers - if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) - { - // the following works both with static class methods and plain object methods as error handler - call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); - } - else - { - $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context); - } - } - } - } - - $GLOBALS['_xmlrpc_debuginfo']=''; - - /** - * Add a string to the debug info that can be later seralized by the server - * as part of the response message. - * Note that for best compatbility, the debug string should be encoded using - * the $GLOBALS['xmlrpc_internalencoding'] character set. - * @param string $m - * @access public - */ - function xmlrpc_debugmsg($m) - { - $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; - } - - class xmlrpc_server - { - /// array defining php functions exposed as xmlrpc methods by this server - var $dmap=array(); - /** - * Defines how functions in dmap will be invokde: either using an xmlrpc msg object - * or plain php values. - * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' - */ - var $functions_parameters_type='xmlrpcvals'; - /// controls wether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3 - var $debug = 1; - /** - * When set to true, it will enable HTTP compression of the response, in case - * the client has declared its support for compression in the request. - */ - var $compress_response = false; - /** - * List of http compression methods accepted by the server for requests. - * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib - */ - var $accepted_compression = array(); - /// shall we serve calls to system.* methods? - var $allow_system_funcs = true; - /// list of charset encodings natively accepted for requests - var $accepted_charset_encodings = array(); - /** - * charset encoding to be used for response. - * NB: if we can, we will convert the generated response from internal_encoding to the intended one. - * can be: a supported xml encoding (only UTF-8 and ISO-8859-1 at present, unless mbstring is enabled), - * null (leave unspecified in response, convert output stream to US_ASCII), - * 'default' (use xmlrpc library default as specified in xmlrpc.inc, convert output stream if needed), - * or 'auto' (use client-specified charset encoding or same as request if request headers do not specify it (unless request is US-ASCII: then use library default anyway). - * NB: pretty dangerous if you accept every charset and do not have mbstring enabled) - */ - var $response_charset_encoding = ''; - /// storage for internal debug info - var $debug_info = ''; - /// extra data passed at runtime to method handling functions. Used only by EPI layer - var $user_data = null; - - /** - * @param array $dispmap the dispatch map withd efinition of exposed services - * @param boolean $servicenow set to false to prevent the server from runnung upon construction - */ - function xmlrpc_server($dispMap=null, $serviceNow=true) - { - // if ZLIB is enabled, let the server by default accept compressed requests, - // and compress responses sent to clients that support them - if(function_exists('gzinflate')) - { - $this->accepted_compression = array('gzip', 'deflate'); - $this->compress_response = true; - } - - // by default the xml parser can support these 3 charset encodings - $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); - - // dispMap is a dispatch array of methods - // mapped to function names and signatures - // if a method - // doesn't appear in the map then an unknown - // method error is generated - /* milosch - changed to make passing dispMap optional. - * instead, you can use the class add_to_map() function - * to add functions manually (borrowed from SOAPX4) - */ - if($dispMap) - { - $this->dmap = $dispMap; - if($serviceNow) - { - $this->service(); - } - } - } - - /** - * Set debug level of server. - * @param integer $in debug lvl: determines info added to xmlrpc responses (as xml comments) - * 0 = no debug info, - * 1 = msgs set from user with debugmsg(), - * 2 = add complete xmlrpc request (headers and body), - * 3 = add also all processing warnings happened during method processing - * (NB: this involves setting a custom error handler, and might interfere - * with the standard processing of the php function exposed as method. In - * particular, triggering an USER_ERROR level error will not halt script - * execution anymore, but just end up logged in the xmlrpc response) - * Note that info added at elevel 2 and 3 will be base64 encoded - * @access public - */ - function setDebug($in) - { - $this->debug=$in; - } - - /** - * Return a string with the serialized representation of all debug info - * @param string $charset_encoding the target charset encoding for the serialization - * @return string an XML comment (or two) - */ - function serializeDebug($charset_encoding='') - { - // Tough encoding problem: which internal charset should we assume for debug info? - // It might contain a copy of raw data received from client, ie with unknown encoding, - // intermixed with php generated data and user generated data... - // so we split it: system debug is base 64 encoded, - // user debug info should be encoded by the end user using the INTERNAL_ENCODING - $out = ''; - if ($this->debug_info != '') - { - $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; - } - if($GLOBALS['_xmlrpc_debuginfo']!='') - { - - $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; - // NB: a better solution MIGHT be to use CDATA, but we need to insert it - // into return payload AFTER the beginning tag - //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; - } - return $out; - } - - /** - * Execute the xmlrpc request, printing the response - * @param string $data the request body. If null, the http POST request will be examined - * @return xmlrpcresp the response object (usually not used by caller...) - * @access public - */ - function service($data=null, $return_payload=false) - { - if ($data === null) - { - // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA - $ver = phpversion(); - if ($ver[0] >= 5) - { - $data = file_get_contents('php://input'); - } - else - { - $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; - } - } - $raw_data = $data; - - // reset internal debug info - $this->debug_info = ''; - - // Echo back what we received, before parsing it - if($this->debug > 1) - { - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); - } - - $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); - if (!$r) - { - $r=$this->parseRequest($data, $req_charset); - } - - // save full body of request into response, for more debugging usages - $r->raw_data = $raw_data; - - if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) - { - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . - $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); - } - - $payload=$this->xml_header($resp_charset); - if($this->debug > 0) - { - $payload = $payload . $this->serializeDebug($resp_charset); - } - - // G. Giunta 2006-01-27: do not create response serialization if it has - // already happened. Helps building json magic - if (empty($r->payload)) - { - $r->serialize($resp_charset); - } - $payload = $payload . $r->payload; - - if ($return_payload) - { - return $payload; - } - - // if we get a warning/error that has output some text before here, then we cannot - // add a new header. We cannot say we are sending xml, either... - if(!headers_sent()) - { - header('Content-Type: '.$r->content_type); - // we do not know if client actually told us an accepted charset, but if he did - // we have to tell him what we did - header("Vary: Accept-Charset"); - - // http compression of output: only - // if we can do it, and we want to do it, and client asked us to, - // and php ini settings do not force it already - $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); - if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' - && $php_no_self_compress) - { - if(strpos($resp_encoding, 'gzip') !== false) - { - $payload = gzencode($payload); - header("Content-Encoding: gzip"); - header("Vary: Accept-Encoding"); - } - elseif (strpos($resp_encoding, 'deflate') !== false) - { - $payload = gzcompress($payload); - header("Content-Encoding: deflate"); - header("Vary: Accept-Encoding"); - } - } - - // do not ouput content-length header if php is compressing output for us: - // it will mess up measurements - if($php_no_self_compress) - { - header('Content-Length: ' . (int)strlen($payload)); - } - } - else - { - error_log('XML-RPC: xmlrpc_server::service: http headers already sent before response is fully generated. Check for php warning or error messages'); - } - - print $payload; - - // return request, in case subclasses want it - return $r; - } - - /** - * Add a method to the dispatch map - * @param string $methodname the name with which the method will be made available - * @param string $function the php function that will get invoked - * @param array $sig the array of valid method signatures - * @param string $doc method documentation - * @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type) - * @access public - */ - function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) - { - $this->dmap[$methodname] = array( - 'function' => $function, - 'docstring' => $doc - ); - if ($sig) - { - $this->dmap[$methodname]['signature'] = $sig; - } - if ($sigdoc) - { - $this->dmap[$methodname]['signature_docs'] = $sigdoc; - } - } - - /** - * Verify type and number of parameters received against a list of known signatures - * @param array $in array of either xmlrpcval objects or xmlrpc type definitions - * @param array $sig array of known signatures to match against - * @access private - */ - function verifySignature($in, $sig) - { - // check each possible signature in turn - if (is_object($in)) - { - $numParams = $in->getNumParams(); - } - else - { - $numParams = count($in); - } - foreach($sig as $cursig) - { - if(count($cursig)==$numParams+1) - { - $itsOK=1; - for($n=0; $n<$numParams; $n++) - { - if (is_object($in)) - { - $p=$in->getParam($n); - if($p->kindOf() == 'scalar') - { - $pt=$p->scalartyp(); - } - else - { - $pt=$p->kindOf(); - } - } - else - { - $pt= $in[$n] == 'i4' ? 'int' : $in[$n]; // dispatch maps never use i4... - } - - // param index is $n+1, as first member of sig is return type - if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) - { - $itsOK=0; - $pno=$n+1; - $wanted=$cursig[$n+1]; - $got=$pt; - break; - } - } - if($itsOK) - { - return array(1,''); - } - } - } - if(isset($wanted)) - { - return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); - } - else - { - return array(0, "No method signature matches number of parameters"); - } - } - - /** - * Parse http headers received along with xmlrpc request. If needed, inflate request - * @return null on success or an xmlrpcresp - * @access private - */ - function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression) - { - // Play nice to PHP 4.0.x: superglobals were not yet invented... - if(!isset($_SERVER)) - { - $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; - } - - if($this->debug > 1) - { - if(function_exists('getallheaders')) - { - $this->debugmsg(''); // empty line - foreach(getallheaders() as $name => $val) - { - $this->debugmsg("HEADER: $name: $val"); - } - } - - } - - if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) - { - $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); - } - else - { - $content_encoding = ''; - } - - // check if request body has been compressed and decompress it - if($content_encoding != '' && strlen($data)) - { - if($content_encoding == 'deflate' || $content_encoding == 'gzip') - { - // if decoding works, use it. else assume data wasn't gzencoded - if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) - { - if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) - { - $data = $degzdata; - if($this->debug > 1) - { - $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); - } - } - elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) - { - $data = $degzdata; - if($this->debug > 1) - $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); - } - else - { - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']); - return $r; - } - } - else - { - //error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']); - return $r; - } - } - } - - // check if client specified accepted charsets, and if we know how to fulfill - // the request - if ($this->response_charset_encoding == 'auto') - { - $resp_encoding = ''; - if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) - { - // here we should check if we can match the client-requested encoding - // with the encodings we know we can generate. - /// @todo we should parse q=0.x preferences instead of getting first charset specified... - $client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])); - // Give preference to internal encoding - $known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII'); - foreach ($known_charsets as $charset) - { - foreach ($client_accepted_charsets as $accepted) - if (strpos($accepted, $charset) === 0) - { - $resp_encoding = $charset; - break; - } - if ($resp_encoding) - break; - } - } - } - else - { - $resp_encoding = $this->response_charset_encoding; - } - - if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) - { - $resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING']; - } - else - { - $resp_compression = ''; - } - - // 'guestimate' request encoding - /// @todo check if mbstring is enabled and automagic input conversion is on: it might mingle with this check??? - $req_encoding = guess_encoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '', - $data); - - return null; - } - - /** - * Parse an xml chunk containing an xmlrpc request and execute the corresponding - * php function registered with the server - * @param string $data the xml request - * @param string $req_encoding (optional) the charset encoding of the xml request - * @return xmlrpcresp - * @access private - */ - function parseRequest($data, $req_encoding='') - { - // 2005/05/07 commented and moved into caller function code - //if($data=='') - //{ - // $data=$GLOBALS['HTTP_RAW_POST_DATA']; - //} - - // G. Giunta 2005/02/13: we do NOT expect to receive html entities - // so we do not try to convert them into xml character entities - //$data = xmlrpc_html_entity_xlate($data); - - $GLOBALS['_xh']=array(); - $GLOBALS['_xh']['ac']=''; - $GLOBALS['_xh']['stack']=array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['params']=array(); - $GLOBALS['_xh']['pt']=array(); - $GLOBALS['_xh']['isf']=0; - $GLOBALS['_xh']['isf_reason']=''; - $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not - $GLOBALS['_xh']['rt']=''; - - // decompose incoming XML into request structure - if ($req_encoding != '') - { - if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - // the following code might be better for mb_string enabled installs, but - // makes the lib about 200% slower... - //if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - error_log('XML-RPC: xmlrpc_server::parseRequest: invalid charset encoding of received request: '.$req_encoding); - $req_encoding = $GLOBALS['xmlrpc_defencoding']; - } - /// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue, - // the encoding is not UTF8 and there are non-ascii chars in the text... - /// @todo use an ampty string for php 5 ??? - $parser = xml_parser_create($req_encoding); - } - else - { - $parser = xml_parser_create(); - } - - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell - // the xml parser to give us back data in the expected charset - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8 - // This allows to send data which is native in various charset, - // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - - if ($this->functions_parameters_type != 'xmlrpcvals') - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); - else - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - if(!xml_parse($parser, $data, 1)) - { - // return XML error as a faultCode - $r=&new xmlrpcresp(0, - $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), - sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser))); - xml_parser_free($parser); - } - elseif ($GLOBALS['_xh']['isf']) - { - xml_parser_free($parser); - $r=&new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['invalid_request'], - $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); - } - else - { - xml_parser_free($parser); - if ($this->functions_parameters_type != 'xmlrpcvals') - { - if($this->debug > 1) - { - $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); - } - $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']); - } - else - { - // build an xmlrpcmsg object with data parsed from xml - $m=&new xmlrpcmsg($GLOBALS['_xh']['method']); - // now add parameters in - for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) - { - $m->addParam($GLOBALS['_xh']['params'][$i]); - } - - if($this->debug > 1) - { - $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); - } - $r = $this->execute($m); - } - } - return $r; - } - - /** - * Execute a method invoked by the client, checking parameters used - * @param mixed $m either an xmlrpcmsg obj or a method name - * @param array $params array with method parameters as php types (if m is method name only) - * @param array $paramtypes array with xmlrpc types of method parameters (if m is method name only) - * @return xmlrpcresp - * @access private - */ - function execute($m, $params=null, $paramtypes=null) - { - if (is_object($m)) - { - $methName = $m->method(); - } - else - { - $methName = $m; - } - $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); - $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; - - if(!isset($dmap[$methName]['function'])) - { - // No such method - return new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['unknown_method'], - $GLOBALS['xmlrpcstr']['unknown_method']); - } - - // Check signature - if(isset($dmap[$methName]['signature'])) - { - $sig = $dmap[$methName]['signature']; - if (is_object($m)) - { - list($ok, $errstr) = $this->verifySignature($m, $sig); - } - else - { - list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); - } - if(!$ok) - { - // Didn't match. - return new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['incorrect_params'], - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" - ); - } - } - - $func = $dmap[$methName]['function']; - // let the 'class::function' syntax be accepted in dispatch maps - if(is_string($func) && strpos($func, '::')) - { - $func = explode('::', $func); - } - // verify that function to be invoked is in fact callable - if(!is_callable($func)) - { - error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler is not callable"); - return new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['server_error'], - $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" - ); - } - - // If debug level is 3, we should catch all errors generated during - // processing of user function, and log them as part of response - if($this->debug > 2) - { - $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); - } - if (is_object($m)) - { - if($sysCall) - { - $r = call_user_func($func, $this, $m); - } - else - { - $r = call_user_func($func, $m); - } - if (!is_a($r, 'xmlrpcresp')) - { - error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler does not return an xmlrpcresp object"); - if (is_a($r, 'xmlrpcval')) - { - $r =& new xmlrpcresp($r); - } - else - { - $r =& new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['server_error'], - $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" - ); - } - } - } - else - { - // call a 'plain php' function - if($sysCall) - { - array_unshift($params, $this); - $r = call_user_func_array($func, $params); - } - else - { - // 3rd API convention for method-handling functions: EPI-style - if ($this->functions_parameters_type == 'epivals') - { - $r = call_user_func_array($func, array($methName, $params, $this->user_data)); - // mimic EPI behaviour: if we get an array that looks like an error, make it - // an eror response - if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) - { - $r =& new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); - } - else - { - // functions using EPI api should NOT return resp objects, - // so make sure we encode the return type correctly - $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api'))); - } - } - else - { - $r = call_user_func_array($func, $params); - } - } - // the return type can be either an xmlrpcresp object or a plain php value... - if (!is_a($r, 'xmlrpcresp')) - { - // what should we assume here about automatic encoding of datetimes - // and php classes instances??? - $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates'))); - } - } - if($this->debug > 2) - { - // note: restore the error handler we found before calling the - // user func, even if it has been changed inside the func itself - if($GLOBALS['_xmlrpcs_prev_ehandler']) - { - set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); - } - else - { - restore_error_handler(); - } - } - return $r; - } - - /** - * add a string to the 'internal debug message' (separate from 'user debug message') - * @param string $strings - * @access private - */ - function debugmsg($string) - { - $this->debug_info .= $string."\n"; - } - - /** - * @access private - */ - function xml_header($charset_encoding='') - { - if ($charset_encoding != '') - { - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n"; - } - else - { - return "<?xml version=\"1.0\"?" . ">\n"; - } - } - - /** - * A debugging routine: just echoes back the input packet as a string value - * DEPRECATED! - */ - function echoInput() - { - $r=&new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); - print $r->serialize(); - } - } -?> \ No newline at end of file diff --git a/core/class/web_service/lib/xmlrpc.inc b/core/class/web_service/lib/xmlrpc.inc deleted file mode 100755 index 7fb2b5aa8fccff7023721b5b35aaa62029975649..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/xmlrpc.inc +++ /dev/null @@ -1,3718 +0,0 @@ -<?php -// by Edd Dumbill (C) 1999-2002 -// <edd@usefulinc.com> -// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $ - -// Copyright (c) 1999,2000,2002 Edd Dumbill. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of the "XML-RPC for PHP" nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - - if(!function_exists('xml_parser_create')) - { - // For PHP 4 onward, XML functionality is always compiled-in on windows: - // no more need to dl-open it. It might have been compiled out on *nix... - if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) - { - dl('xml.so'); - } - } - - // Try to be backward compat with php < 4.2 (are we not being nice ?) - $phpversion = phpversion(); - if($phpversion[0] == '4' && $phpversion[2] < 2) - { - // give an opportunity to user to specify where to include other files from - if(!defined('PHP_XMLRPC_COMPAT_DIR')) - { - define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/'); - } - if($phpversion[2] == '0') - { - if($phpversion[4] < 6) - { - include(PHP_XMLRPC_COMPAT_DIR.'is_callable.php'); - } - include(PHP_XMLRPC_COMPAT_DIR.'is_scalar.php'); - include(PHP_XMLRPC_COMPAT_DIR.'array_key_exists.php'); - include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php'); - } - include(PHP_XMLRPC_COMPAT_DIR.'var_export.php'); - include(PHP_XMLRPC_COMPAT_DIR.'is_a.php'); - } - - // G. Giunta 2005/01/29: declare global these variables, - // so that xmlrpc.inc will work even if included from within a function - // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used. - $GLOBALS['xmlrpcI4']='i4'; - $GLOBALS['xmlrpcInt']='int'; - $GLOBALS['xmlrpcBoolean']='boolean'; - $GLOBALS['xmlrpcDouble']='double'; - $GLOBALS['xmlrpcString']='string'; - $GLOBALS['xmlrpcDateTime']='dateTime.iso8601'; - $GLOBALS['xmlrpcBase64']='base64'; - $GLOBALS['xmlrpcArray']='array'; - $GLOBALS['xmlrpcStruct']='struct'; - $GLOBALS['xmlrpcValue']='undefined'; - - $GLOBALS['xmlrpcTypes']=array( - $GLOBALS['xmlrpcI4'] => 1, - $GLOBALS['xmlrpcInt'] => 1, - $GLOBALS['xmlrpcBoolean'] => 1, - $GLOBALS['xmlrpcString'] => 1, - $GLOBALS['xmlrpcDouble'] => 1, - $GLOBALS['xmlrpcDateTime'] => 1, - $GLOBALS['xmlrpcBase64'] => 1, - $GLOBALS['xmlrpcArray'] => 2, - $GLOBALS['xmlrpcStruct'] => 3 - ); - - $GLOBALS['xmlrpc_valid_parents'] = array( - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'), - 'BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'FAULT' => array('METHODRESPONSE'), - 'NIL' => array('VALUE') // only used when extension activated - ); - - // define extra types for supporting NULL (useful for json or <NIL/>) - $GLOBALS['xmlrpcNull']='null'; - $GLOBALS['xmlrpcTypes']['null']=1; - - // Not in use anymore since 2.0. Shall we remove it? - /// @deprecated - $GLOBALS['xmlEntities']=array( - 'amp' => '&', - 'quot' => '"', - 'lt' => '<', - 'gt' => '>', - 'apos' => "'" - ); - - // tables used for transcoding different charsets into us-ascii xml - - $GLOBALS['xml_iso88591_Entities']=array(); - $GLOBALS['xml_iso88591_Entities']['in'] = array(); - $GLOBALS['xml_iso88591_Entities']['out'] = array(); - for ($i = 0; $i < 32; $i++) - { - $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); - $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; - } - for ($i = 160; $i < 256; $i++) - { - $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); - $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; - } - - /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159? - /// These will NOT be present in true ISO-8859-1, but will save the unwary - /// windows user from sending junk (though no luck when reciving them...) - /* - $GLOBALS['xml_cp1252_Entities']=array(); - for ($i = 128; $i < 160; $i++) - { - $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i); - } - $GLOBALS['xml_cp1252_Entities']['out'] = array( - '€', '?', '‚', 'ƒ', - '„', '…', '†', '‡', - 'ˆ', '‰', 'Š', '‹', - 'Œ', '?', 'Ž', '?', - '?', '‘', '’', '“', - '”', '•', '–', '—', - '˜', '™', 'š', '›', - 'œ', '?', 'ž', 'Ÿ' - ); - */ - - $GLOBALS['xmlrpcerr'] = array( - 'unknown_method'=>1, - 'invalid_return'=>2, - 'incorrect_params'=>3, - 'introspect_unknown'=>4, - 'http_error'=>5, - 'no_data'=>6, - 'no_ssl'=>7, - 'curl_fail'=>8, - 'invalid_request'=>15, - 'no_curl'=>16, - 'server_error'=>17, - 'multicall_error'=>18, - 'multicall_notstruct'=>9, - 'multicall_nomethod'=>10, - 'multicall_notstring'=>11, - 'multicall_recursion'=>12, - 'multicall_noparams'=>13, - 'multicall_notarray'=>14, - - 'cannot_decompress'=>103, - 'decompress_fail'=>104, - 'dechunk_fail'=>105, - 'server_cannot_decompress'=>106, - 'server_decompress_fail'=>107 - ); - - $GLOBALS['xmlrpcstr'] = array( - 'unknown_method'=>'Unknown method', - 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload', - 'incorrect_params'=>'Incorrect parameters passed to method', - 'introspect_unknown'=>"Can't introspect: method unknown", - 'http_error'=>"Didn't receive 200 OK from remote server.", - 'no_data'=>'No data received from server.', - 'no_ssl'=>'No SSL support compiled in.', - 'curl_fail'=>'CURL error', - 'invalid_request'=>'Invalid request payload', - 'no_curl'=>'No CURL support compiled in.', - 'server_error'=>'Internal server error', - 'multicall_error'=>'Received from server invalid multicall response', - 'multicall_notstruct'=>'system.multicall expected struct', - 'multicall_nomethod'=>'missing methodName', - 'multicall_notstring'=>'methodName is not a string', - 'multicall_recursion'=>'recursive system.multicall forbidden', - 'multicall_noparams'=>'missing params', - 'multicall_notarray'=>'params is not an array', - - 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress', - 'decompress_fail'=>'Received from server invalid compressed HTTP', - 'dechunk_fail'=>'Received from server invalid chunked HTTP', - 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress', - 'server_decompress_fail'=>'Received from client invalid compressed HTTP request' - ); - - // The charset encoding used by the server for received messages and - // by the client for received responses when received charset cannot be determined - // or is not supported - $GLOBALS['xmlrpc_defencoding']='UTF-8'; - - // The encoding used internally by PHP. - // String values received as xml will be converted to this, and php strings will be converted to xml - // as if having been coded with this - $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1'; - - $GLOBALS['xmlrpcName']='XML-RPC for PHP'; - $GLOBALS['xmlrpcVersion']='2.2.2'; - - // let user errors start at 800 - $GLOBALS['xmlrpcerruser']=800; - // let XML parse errors start at 100 - $GLOBALS['xmlrpcerrxml']=100; - - // formulate backslashes for escaping regexp - // Not in use anymore since 2.0. Shall we remove it? - /// @deprecated - $GLOBALS['xmlrpc_backslash']=chr(92).chr(92); - - // set to TRUE to enable correct decoding of <NIL/> values - $GLOBALS['xmlrpc_null_extension']=false; - - // used to store state during parsing - // quick explanation of components: - // ac - used to accumulate values - // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1) - // isf_reason - used for storing xmlrpcresp fault string - // lv - used to indicate "looking for a value": implements - // the logic to allow values with no types to be strings - // params - used to store parameters in method calls - // method - used to store method name - // stack - array with genealogy of xml elements names: - // used to validate nesting of xmlrpc elements - $GLOBALS['_xh']=null; - - /** - * Convert a string to the correct XML representation in a target charset - * To help correct communication of non-ascii chars inside strings, regardless - * of the charset used when sending requests, parsing them, sending responses - * and parsing responses, an option is to convert all non-ascii chars present in the message - * into their equivalent 'charset entity'. Charset entities enumerated this way - * are independent of the charset encoding used to transmit them, and all XML - * parsers are bound to understand them. - * Note that in the std case we are not sending a charset encoding mime type - * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii. - * - * @todo do a bit of basic benchmarking (strtr vs. str_replace) - * @todo make usage of iconv() or recode_string() or mb_string() where available - */ - function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='') - { - if ($src_encoding == '') - { - // lame, but we know no better... - $src_encoding = $GLOBALS['xmlrpc_internalencoding']; - } - - switch(strtoupper($src_encoding.'_'.$dest_encoding)) - { - case 'ISO-8859-1_': - case 'ISO-8859-1_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); - break; - case 'ISO-8859-1_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = utf8_encode($escaped_data); - break; - case 'ISO-8859-1_ISO-8859-1': - case 'US-ASCII_US-ASCII': - case 'US-ASCII_UTF-8': - case 'US-ASCII_': - case 'US-ASCII_ISO-8859-1': - case 'UTF-8_UTF-8': - //case 'CP1252_CP1252': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - break; - case 'UTF-8_': - case 'UTF-8_US-ASCII': - case 'UTF-8_ISO-8859-1': - // NB: this will choke on invalid UTF-8, going most likely beyond EOF - $escaped_data = ''; - // be kind to users creating string xmlrpcvals out of different php types - $data = (string) $data; - $ns = strlen ($data); - for ($nn = 0; $nn < $ns; $nn++) - { - $ch = $data[$nn]; - $ii = ord($ch); - //1 7 0bbbbbbb (127) - if ($ii < 128) - { - /// @todo shall we replace this with a (supposedly) faster str_replace? - switch($ii){ - case 34: - $escaped_data .= '"'; - break; - case 38: - $escaped_data .= '&'; - break; - case 39: - $escaped_data .= '''; - break; - case 60: - $escaped_data .= '<'; - break; - case 62: - $escaped_data .= '>'; - break; - default: - $escaped_data .= $ch; - } // switch - } - //2 11 110bbbbb 10bbbbbb (2047) - else if ($ii>>5 == 6) - { - $b1 = ($ii & 31); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ($b1 * 64) + $b2; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 1; - } - //3 16 1110bbbb 10bbbbbb 10bbbbbb - else if ($ii>>4 == 14) - { - $b1 = ($ii & 15); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ord($data[$nn+2]); - $b3 = ($ii & 63); - $ii = ((($b1 * 64) + $b2) * 64) + $b3; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 2; - } - //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb - else if ($ii>>3 == 30) - { - $b1 = ($ii & 7); - $ii = ord($data[$nn+1]); - $b2 = ($ii & 63); - $ii = ord($data[$nn+2]); - $b3 = ($ii & 63); - $ii = ord($data[$nn+3]); - $b4 = ($ii & 63); - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; - $ent = sprintf ('&#%d;', $ii); - $escaped_data .= $ent; - $nn += 3; - } - } - break; -/* - case 'CP1252_': - case 'CP1252_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - break; - case 'CP1252_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them) - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - $escaped_data = utf8_encode($escaped_data); - break; - case 'CP1252_ISO-8859-1': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities... - $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); - break; -*/ - default: - $escaped_data = ''; - error_log("Converting from $src_encoding to $dest_encoding: not supported..."); - } - return $escaped_data; - } - - /// xml parser handler function for opening element tags - function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false) - { - // if invalid xmlrpc already detected, skip all processing - if ($GLOBALS['_xh']['isf'] < 2) - { - // check for correct element nesting - // top level element can only be of 2 types - /// @todo optimization creep: save this check into a bool variable, instead of using count() every time: - /// there is only a single top level element in xml anyway - if (count($GLOBALS['_xh']['stack']) == 0) - { - if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && ( - $name != 'VALUE' && !$accept_single_vals)) - { - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element'; - return; - } - else - { - $GLOBALS['_xh']['rt'] = strtolower($name); - } - } - else - { - // not top level element: see if parent is OK - $parent = end($GLOBALS['_xh']['stack']); - if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name])) - { - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent"; - return; - } - } - - switch($name) - { - // optimize for speed switch cases: most common cases first - case 'VALUE': - /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element - $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet - $GLOBALS['_xh']['ac']=''; - $GLOBALS['_xh']['lv']=1; - $GLOBALS['_xh']['php_class']=null; - break; - case 'I4': - case 'INT': - case 'STRING': - case 'BOOLEAN': - case 'DOUBLE': - case 'DATETIME.ISO8601': - case 'BASE64': - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - $GLOBALS['_xh']['ac']=''; // reset the accumulator - break; - case 'STRUCT': - case 'ARRAY': - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - // create an empty array to hold child values, and push it onto appropriate stack - $cur_val = array(); - $cur_val['values'] = array(); - $cur_val['type'] = $name; - // check for out-of-band information to rebuild php objs - // and in case it is found, save it - if (@isset($attrs['PHP_CLASS'])) - { - $cur_val['php_class'] = $attrs['PHP_CLASS']; - } - $GLOBALS['_xh']['valuestack'][] = $cur_val; - $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next - break; - case 'DATA': - if ($GLOBALS['_xh']['vt']!='data') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element"; - return; - } - case 'METHODCALL': - case 'METHODRESPONSE': - case 'PARAMS': - // valid elements that add little to processing - break; - case 'METHODNAME': - case 'NAME': - /// @todo we could check for 2 NAME elements inside a MEMBER element - $GLOBALS['_xh']['ac']=''; - break; - case 'FAULT': - $GLOBALS['_xh']['isf']=1; - break; - case 'MEMBER': - $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on - //$GLOBALS['_xh']['ac']=''; - // Drop trough intentionally - case 'PARAM': - // clear value type, so we can check later if no value has been passed for this param/member - $GLOBALS['_xh']['vt']=null; - break; - case 'NIL': - if ($GLOBALS['xmlrpc_null_extension']) - { - if ($GLOBALS['_xh']['vt']!='value') - { - //two data elements inside a value: an error occurred! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; - return; - } - $GLOBALS['_xh']['ac']=''; // reset the accumulator - break; - } - // we do not support the <NIL/> extension, so - // drop through intentionally - default: - /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!! - $GLOBALS['_xh']['isf'] = 2; - $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name"; - break; - } - - // Save current element name to stack, to validate nesting - $GLOBALS['_xh']['stack'][] = $name; - - /// @todo optimization creep: move this inside the big switch() above - if($name!='VALUE') - { - $GLOBALS['_xh']['lv']=0; - } - } - } - - /// Used in decoding xml chunks that might represent single xmlrpc values - function xmlrpc_se_any($parser, $name, $attrs) - { - xmlrpc_se($parser, $name, $attrs, true); - } - - /// xml parser handler function for close element tags - function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) - { - if ($GLOBALS['_xh']['isf'] < 2) - { - // push this element name from stack - // NB: if XML validates, correct opening/closing is guaranteed and - // we do not have to check for $name == $curr_elem. - // we also checked for proper nesting at start of elements... - $curr_elem = array_pop($GLOBALS['_xh']['stack']); - - switch($name) - { - case 'VALUE': - // This if() detects if no scalar was inside <VALUE></VALUE> - if ($GLOBALS['_xh']['vt']=='value') - { - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString']; - } - - if ($rebuild_xmlrpcvals) - { - // build the xmlrpc val out of the data received, and substitute it - $temp =& new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']); - // in case we got info about underlying php class, save it - // in the object we're rebuilding - if (isset($GLOBALS['_xh']['php_class'])) - $temp->_php_class = $GLOBALS['_xh']['php_class']; - // check if we are inside an array or struct: - // if value just built is inside an array, let's move it into array on the stack - $vscount = count($GLOBALS['_xh']['valuestack']); - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') - { - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp; - } - else - { - $GLOBALS['_xh']['value'] = $temp; - } - } - else - { - /// @todo this needs to treat correctly php-serialized objects, - /// since std deserializing is done by php_xmlrpc_decode, - /// which we will not be calling... - if (isset($GLOBALS['_xh']['php_class'])) - { - } - - // check if we are inside an array or struct: - // if value just built is inside an array, let's move it into array on the stack - $vscount = count($GLOBALS['_xh']['valuestack']); - if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') - { - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value']; - } - } - break; - case 'BOOLEAN': - case 'I4': - case 'INT': - case 'STRING': - case 'DOUBLE': - case 'DATETIME.ISO8601': - case 'BASE64': - $GLOBALS['_xh']['vt']=strtolower($name); - /// @todo: optimization creep - remove the if/elseif cycle below - /// since the case() in which we are already did that - if ($name=='STRING') - { - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - } - elseif ($name=='DATETIME.ISO8601') - { - if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) - { - error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']); - } - $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime']; - $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; - } - elseif ($name=='BASE64') - { - /// @todo check for failure of base64 decoding / catch warnings - $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']); - } - elseif ($name=='BOOLEAN') - { - // special case here: we translate boolean 1 or 0 into PHP - // constants true or false. - // Strings 'true' and 'false' are accepted, even though the - // spec never mentions them (see eg. Blogger api docs) - // NB: this simple checks helps a lot sanitizing input, ie no - // security problems around here - if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) - { - $GLOBALS['_xh']['value']=true; - } - else - { - // log if receiveing something strange, even though we set the value to false anyway - if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) - error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']=false; - } - } - elseif ($name=='DOUBLE') - { - // we have a DOUBLE - // we must check that only 0123456789-.<space> are characters here - // NOTE: regexp could be much stricter than this... - if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac'])) - { - /// @todo: find a better way of throwing an error than this! - error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; - } - else - { - // it's ok, add it on - $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac']; - } - } - else - { - // we have an I4/INT - // we must check that only 0123456789-<space> are characters here - if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac'])) - { - /// @todo find a better way of throwing an error than this! - error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']); - $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; - } - else - { - // it's ok, add it on - $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac']; - } - } - //$GLOBALS['_xh']['ac']=''; // is this necessary? - $GLOBALS['_xh']['lv']=3; // indicate we've found a value - break; - case 'NAME': - $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac']; - break; - case 'MEMBER': - //$GLOBALS['_xh']['ac']=''; // is this necessary? - // add to array in the stack the last element built, - // unless no VALUE was found - if ($GLOBALS['_xh']['vt']) - { - $vscount = count($GLOBALS['_xh']['valuestack']); - $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value']; - } else - error_log('XML-RPC: missing VALUE inside STRUCT in received xml'); - break; - case 'DATA': - //$GLOBALS['_xh']['ac']=''; // is this necessary? - $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty - break; - case 'STRUCT': - case 'ARRAY': - // fetch out of stack array of values, and promote it to current value - $curr_val = array_pop($GLOBALS['_xh']['valuestack']); - $GLOBALS['_xh']['value'] = $curr_val['values']; - $GLOBALS['_xh']['vt']=strtolower($name); - if (isset($curr_val['php_class'])) - { - $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; - } - break; - case 'PARAM': - // add to array of params the current value, - // unless no VALUE was found - if ($GLOBALS['_xh']['vt']) - { - $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; - $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; - } - else - error_log('XML-RPC: missing VALUE inside PARAM in received xml'); - break; - case 'METHODNAME': - $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); - break; - case 'NIL': - if ($GLOBALS['xmlrpc_null_extension']) - { - $GLOBALS['_xh']['vt']='null'; - $GLOBALS['_xh']['value']=null; - $GLOBALS['_xh']['lv']=3; - break; - } - // drop through intentionally if nil extension not enabled - case 'PARAMS': - case 'FAULT': - case 'METHODCALL': - case 'METHORESPONSE': - break; - default: - // End of INVALID ELEMENT! - // shall we add an assert here for unreachable code??? - break; - } - } - } - - /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values - function xmlrpc_ee_fast($parser, $name) - { - xmlrpc_ee($parser, $name, false); - } - - /// xml parser handler function for character data - function xmlrpc_cd($parser, $data) - { - // skip processing if xml fault already detected - if ($GLOBALS['_xh']['isf'] < 2) - { - // "lookforvalue==3" means that we've found an entire value - // and should discard any further character data - if($GLOBALS['_xh']['lv']!=3) - { - // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2 - //if($GLOBALS['_xh']['lv']==1) - //{ - // if we've found text and we're just in a <value> then - // say we've found a value - //$GLOBALS['_xh']['lv']=2; - //} - // we always initialize the accumulator before starting parsing, anyway... - //if(!@isset($GLOBALS['_xh']['ac'])) - //{ - // $GLOBALS['_xh']['ac'] = ''; - //} - $GLOBALS['_xh']['ac'].=$data; - } - } - } - - /// xml parser handler function for 'other stuff', ie. not char data or - /// element start/end tag. In fact it only gets called on unknown entities... - function xmlrpc_dh($parser, $data) - { - // skip processing if xml fault already detected - if ($GLOBALS['_xh']['isf'] < 2) - { - if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') - { - // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2 - //if($GLOBALS['_xh']['lv']==1) - //{ - // $GLOBALS['_xh']['lv']=2; - //} - $GLOBALS['_xh']['ac'].=$data; - } - } - return true; - } - - class xmlrpc_client - { - var $path; - var $server; - var $port=0; - var $method='http'; - var $errno; - var $errstr; - var $debug=0; - var $username=''; - var $password=''; - var $authtype=1; - var $cert=''; - var $certpass=''; - var $cacert=''; - var $cacertdir=''; - var $key=''; - var $keypass=''; - var $verifypeer=true; - var $verifyhost=1; - var $no_multicall=false; - var $proxy=''; - var $proxyport=0; - var $proxy_user=''; - var $proxy_pass=''; - var $proxy_authtype=1; - var $cookies=array(); - /** - * List of http compression methods accepted by the client for responses. - * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib - * - * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since - * in those cases it will be up to CURL to decide the compression methods - * it supports. You might check for the presence of 'zlib' in the output of - * curl_version() to determine wheter compression is supported or not - */ - var $accepted_compression = array(); - /** - * Name of compression scheme to be used for sending requests. - * Either null, gzip or deflate - */ - var $request_compression = ''; - /** - * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see: - * http://curl.haxx.se/docs/faq.html#7.3) - */ - var $xmlrpc_curl_handle = null; - /// Wheter to use persistent connections for http 1.1 and https - var $keepalive = false; - /// Charset encodings that can be decoded without problems by the client - var $accepted_charset_encodings = array(); - /// Charset encoding to be used in serializing request. NULL = use ASCII - var $request_charset_encoding = ''; - /** - * Decides the content of xmlrpcresp objects returned by calls to send() - * valid strings are 'xmlrpcvals', 'phpvals' or 'xml' - */ - var $return_type = 'xmlrpcvals'; - - /** - * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php - * @param string $server the server name / ip address - * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used - * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed - */ - function xmlrpc_client($path, $server='', $port='', $method='') - { - // allow user to specify all params in $path - if($server == '' and $port == '' and $method == '') - { - $parts = parse_url($path); - $server = $parts['host']; - $path = isset($parts['path']) ? $parts['path'] : ''; - if(isset($parts['query'])) - { - $path .= '?'.$parts['query']; - } - if(isset($parts['fragment'])) - { - $path .= '#'.$parts['fragment']; - } - if(isset($parts['port'])) - { - $port = $parts['port']; - } - if(isset($parts['scheme'])) - { - $method = $parts['scheme']; - } - if(isset($parts['user'])) - { - $this->username = $parts['user']; - } - if(isset($parts['pass'])) - { - $this->password = $parts['pass']; - } - } - if($path == '' || $path[0] != '/') - { - $this->path='/'.$path; - } - else - { - $this->path=$path; - } - $this->server=$server; - if($port != '') - { - $this->port=$port; - } - if($method != '') - { - $this->method=$method; - } - - // if ZLIB is enabled, let the client by default accept compressed responses - if(function_exists('gzinflate') || ( - function_exists('curl_init') && (($info = curl_version()) && - ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) - )) - { - $this->accepted_compression = array('gzip', 'deflate'); - } - - // keepalives: enabled by default ONLY for PHP >= 4.3.8 - // (see http://curl.haxx.se/docs/faq.html#7.3) - if(version_compare(phpversion(), '4.3.8') >= 0) - { - $this->keepalive = true; - } - - // by default the xml parser can support these 3 charset encodings - $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); - } - - /** - * Enables/disables the echoing to screen of the xmlrpc responses received - * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) - * @access public - */ - function setDebug($in) - { - $this->debug=$in; - } - - /** - * Add some http BASIC AUTH credentials, used by the client to authenticate - * @param string $u username - * @param string $p password - * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth) - * @access public - */ - function setCredentials($u, $p, $t=1) - { - $this->username=$u; - $this->password=$p; - $this->authtype=$t; - } - - /** - * Add a client-side https certificate - * @param string $cert - * @param string $certpass - * @access public - */ - function setCertificate($cert, $certpass) - { - $this->cert = $cert; - $this->certpass = $certpass; - } - - /** - * Add a CA certificate to verify server with (see man page about - * CURLOPT_CAINFO for more details - * @param string $cacert certificate file name (or dir holding certificates) - * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false - * @access public - */ - function setCaCertificate($cacert, $is_dir=false) - { - if ($is_dir) - { - $this->cacertdir = $cacert; - } - else - { - $this->cacert = $cacert; - } - } - - /** - * Set attributes for SSL communication: private SSL key - * NB: does not work in older php/curl installs - * Thanks to Daniel Convissor - * @param string $key The name of a file containing a private SSL key - * @param string $keypass The secret password needed to use the private SSL key - * @access public - */ - function setKey($key, $keypass) - { - $this->key = $key; - $this->keypass = $keypass; - } - - /** - * Set attributes for SSL communication: verify server certificate - * @param bool $i enable/disable verification of peer certificate - * @access public - */ - function setSSLVerifyPeer($i) - { - $this->verifypeer = $i; - } - - /** - * Set attributes for SSL communication: verify match of server cert w. hostname - * @param int $i - * @access public - */ - function setSSLVerifyHost($i) - { - $this->verifyhost = $i; - } - - /** - * Set proxy info - * @param string $proxyhost - * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS - * @param string $proxyusername Leave blank if proxy has public access - * @param string $proxypassword Leave blank if proxy has public access - * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy - * @access public - */ - function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1) - { - $this->proxy = $proxyhost; - $this->proxyport = $proxyport; - $this->proxy_user = $proxyusername; - $this->proxy_pass = $proxypassword; - $this->proxy_authtype = $proxyauthtype; - } - - /** - * Enables/disables reception of compressed xmlrpc responses. - * Note that enabling reception of compressed responses merely adds some standard - * http headers to xmlrpc requests. It is up to the xmlrpc server to return - * compressed responses when receiving such requests. - * @param string $compmethod either 'gzip', 'deflate', 'any' or '' - * @access public - */ - function setAcceptedCompression($compmethod) - { - if ($compmethod == 'any') - $this->accepted_compression = array('gzip', 'deflate'); - else - $this->accepted_compression = array($compmethod); - } - - /** - * Enables/disables http compression of xmlrpc request. - * Take care when sending compressed requests: servers might not support them - * (and automatic fallback to uncompressed requests is not yet implemented) - * @param string $compmethod either 'gzip', 'deflate' or '' - * @access public - */ - function setRequestCompression($compmethod) - { - $this->request_compression = $compmethod; - } - - /** - * Adds a cookie to list of cookies that will be sent to server. - * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie: - * do not do it unless you know what you are doing - * @param string $name - * @param string $value - * @param string $path - * @param string $domain - * @param int $port - * @access public - * - * @todo check correctness of urlencoding cookie value (copied from php way of doing it...) - */ - function setCookie($name, $value='', $path='', $domain='', $port=null) - { - $this->cookies[$name]['value'] = urlencode($value); - if ($path || $domain || $port) - { - $this->cookies[$name]['path'] = $path; - $this->cookies[$name]['domain'] = $domain; - $this->cookies[$name]['port'] = $port; - $this->cookies[$name]['version'] = 1; - } - else - { - $this->cookies[$name]['version'] = 0; - } - } - - /** - * Send an xmlrpc request - * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request - * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply - * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used - * @return xmlrpcresp - * @access public - */ - function& send($msg, $timeout=0, $method='') - { - // if user deos not specify http protocol, use native method of this client - // (i.e. method set during call to constructor) - if($method == '') - { - $method = $this->method; - } - - if(is_array($msg)) - { - // $msg is an array of xmlrpcmsg's - $r = $this->multicall($msg, $timeout, $method); - return $r; - } - elseif(is_string($msg)) - { - $n =& new xmlrpcmsg(''); - $n->payload = $msg; - $msg = $n; - } - - // where msg is an xmlrpcmsg - $msg->debug=$this->debug; - - if($method == 'https') - { - $r =& $this->sendPayloadHTTPS( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - $this->cert, - $this->certpass, - $this->cacert, - $this->cacertdir, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype, - $this->keepalive, - $this->key, - $this->keypass - ); - } - elseif($method == 'http11') - { - $r =& $this->sendPayloadCURL( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - null, - null, - null, - null, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype, - 'http', - $this->keepalive - ); - } - else - { - $r =& $this->sendPayloadHTTP10( - $msg, - $this->server, - $this->port, - $timeout, - $this->username, - $this->password, - $this->authtype, - $this->proxy, - $this->proxyport, - $this->proxy_user, - $this->proxy_pass, - $this->proxy_authtype - ); - } - - return $r; - } - - /** - * @access private - */ - function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, - $username='', $password='', $authtype=1, $proxyhost='', - $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1) - { - if($port==0) - { - $port=80; - } - - // Only create the payload if it was not created previously - if(empty($msg->payload)) - { - $msg->createPayload($this->request_charset_encoding); - } - - $payload = $msg->payload; - // Deflate request body and set appropriate request headers - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) - { - if($this->request_compression == 'gzip') - { - $a = @gzencode($payload); - if($a) - { - $payload = $a; - $encoding_hdr = "Content-Encoding: gzip\r\n"; - } - } - else - { - $a = @gzcompress($payload); - if($a) - { - $payload = $a; - $encoding_hdr = "Content-Encoding: deflate\r\n"; - } - } - } - else - { - $encoding_hdr = ''; - } - - // thanks to Grant Rauscher <grant7@firstworld.net> for this - $credentials=''; - if($username!='') - { - $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; - if ($authtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported with HTTP 1.0'); - } - } - - $accepted_encoding = ''; - if(is_array($this->accepted_compression) && count($this->accepted_compression)) - { - $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; - } - - $proxy_credentials = ''; - if($proxyhost) - { - if($proxyport == 0) - { - $proxyport = 8080; - } - $connectserver = $proxyhost; - $connectport = $proxyport; - $uri = 'http://'.$server.':'.$port.$this->path; - if($proxyusername != '') - { - if ($proxyauthtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported with HTTP 1.0'); - } - $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; - } - } - else - { - $connectserver = $server; - $connectport = $port; - $uri = $this->path; - } - - // Cookie generation, as per rfc2965 (version 1 cookies) or - // netscape's rules (version 0 cookies) - $cookieheader=''; - if (count($this->cookies)) - { - $version = ''; - foreach ($this->cookies as $name => $cookie) - { - if ($cookie['version']) - { - $version = ' $Version="' . $cookie['version'] . '";'; - $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; - if ($cookie['path']) - $cookieheader .= ' $Path="' . $cookie['path'] . '";'; - if ($cookie['domain']) - $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; - if ($cookie['port']) - $cookieheader .= ' $Port="' . $cookie['port'] . '";'; - } - else - { - $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; - } - } - $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; - } - - $op= 'POST ' . $uri. " HTTP/1.0\r\n" . - 'User-Agent: ' . $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'] . "\r\n" . - 'Host: '. $server . ':' . $port . "\r\n" . - $credentials . - $proxy_credentials . - $accepted_encoding . - $encoding_hdr . - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . - $cookieheader . - 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " . - strlen($payload) . "\r\n\r\n" . - $payload; - - if($this->debug > 1) - { - print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>"; - // let the client see this now in case http times out... - flush(); - } - - if($timeout>0) - { - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); - } - else - { - $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); - } - if($fp) - { - if($timeout>0 && function_exists('stream_set_timeout')) - { - stream_set_timeout($fp, $timeout); - } - } - else - { - $this->errstr='Connect error: '.$this->errstr; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')'); - return $r; - } - - if(!fputs($fp, $op, strlen($op))) - { - fclose($fp); - $this->errstr='Write error'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); - return $r; - } - else - { - // reset errno and errstr on succesful socket connection - $this->errstr = ''; - } - // G. Giunta 2005/10/24: close socket before parsing. - // should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects) - $ipd=''; - do - { - // shall we check for $data === FALSE? - // as per the manual, it signals an error - $ipd.=fread($fp, 32768); - } while(!feof($fp)); - fclose($fp); - $r =& $msg->parseResponse($ipd, false, $this->return_type); - return $r; - - } - - /** - * @access private - */ - function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='', - $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='', - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, - $keepalive=false, $key='', $keypass='') - { - $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username, - $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport, - $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass); - return $r; - } - - /** - * Contributed by Justin Miller <justin@voxel.net> - * Requires curl to be built into PHP - * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers! - * @access private - */ - function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='', - $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='', - $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https', - $keepalive=false, $key='', $keypass='') - { - if(!function_exists('curl_init')) - { - $this->errstr='CURL unavailable on this install'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']); - return $r; - } - if($method == 'https') - { - if(($info = curl_version()) && - ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version'])))) - { - $this->errstr='SSL unavailable on this install'; - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']); - return $r; - } - } - - if($port == 0) - { - if($method == 'http') - { - $port = 80; - } - else - { - $port = 443; - } - } - - // Only create the payload if it was not created previously - if(empty($msg->payload)) - { - $msg->createPayload($this->request_charset_encoding); - } - - // Deflate request body and set appropriate request headers - $payload = $msg->payload; - if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) - { - if($this->request_compression == 'gzip') - { - $a = @gzencode($payload); - if($a) - { - $payload = $a; - $encoding_hdr = 'Content-Encoding: gzip'; - } - } - else - { - $a = @gzcompress($payload); - if($a) - { - $payload = $a; - $encoding_hdr = 'Content-Encoding: deflate'; - } - } - } - else - { - $encoding_hdr = ''; - } - - if($this->debug > 1) - { - print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>"; - // let the client see this now in case http times out... - flush(); - } - - if(!$keepalive || !$this->xmlrpc_curl_handle) - { - $curl = curl_init($method . '://' . $server . ':' . $port . $this->path); - if($keepalive) - { - $this->xmlrpc_curl_handle = $curl; - } - } - else - { - $curl = $this->xmlrpc_curl_handle; - } - - // results into variable - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - - if($this->debug) - { - curl_setopt($curl, CURLOPT_VERBOSE, 1); - } - curl_setopt($curl, CURLOPT_USERAGENT, $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']); - // required for XMLRPC: post the data - curl_setopt($curl, CURLOPT_POST, 1); - // the data - curl_setopt($curl, CURLOPT_POSTFIELDS, $payload); - - // return the header too - curl_setopt($curl, CURLOPT_HEADER, 1); - - // will only work with PHP >= 5.0 - // NB: if we set an empty string, CURL will add http header indicating - // ALL methods it is supporting. This is possibly a better option than - // letting the user tell what curl can / cannot do... - if(is_array($this->accepted_compression) && count($this->accepted_compression)) - { - //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression)); - // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if (count($this->accepted_compression) == 1) - { - curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]); - } - else - curl_setopt($curl, CURLOPT_ENCODING, ''); - } - // extra headers - $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); - // if no keepalive is wanted, let the server know it in advance - if(!$keepalive) - { - $headers[] = 'Connection: close'; - } - // request compression header - if($encoding_hdr) - { - $headers[] = $encoding_hdr; - } - - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - // timeout is borked - if($timeout) - { - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); - } - - if($username && $password) - { - curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); - if (defined('CURLOPT_HTTPAUTH')) - { - curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype); - } - else if ($authtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported by the current PHP/curl install'); - } - } - - if($method == 'https') - { - // set cert file - if($cert) - { - curl_setopt($curl, CURLOPT_SSLCERT, $cert); - } - // set cert password - if($certpass) - { - curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass); - } - // whether to verify remote host's cert - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer); - // set ca certificates file/dir - if($cacert) - { - curl_setopt($curl, CURLOPT_CAINFO, $cacert); - } - if($cacertdir) - { - curl_setopt($curl, CURLOPT_CAPATH, $cacertdir); - } - // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if($key) - { - curl_setopt($curl, CURLOPT_SSLKEY, $key); - } - // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?) - if($keypass) - { - curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass); - } - // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost); - } - - // proxy info - if($proxyhost) - { - if($proxyport == 0) - { - $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080 - } - curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport); - //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport); - if($proxyusername) - { - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword); - if (defined('CURLOPT_PROXYAUTH')) - { - curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype); - } - else if ($proxyauthtype != 1) - { - error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported by the current PHP/curl install'); - } - } - } - - // NB: should we build cookie http headers by hand rather than let CURL do it? - // the following code does not honour 'expires', 'path' and 'domain' cookie attributes - // set to client obj the the user... - if (count($this->cookies)) - { - $cookieheader = ''; - foreach ($this->cookies as $name => $cookie) - { - $cookieheader .= $name . '=' . $cookie['value'] . '; '; - } - curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2)); - } - - $result = curl_exec($curl); - - if ($this->debug > 1) - { - print "<PRE>\n---CURL INFO---\n"; - foreach(curl_getinfo($curl) as $name => $val) - print $name . ': ' . htmlentities($val). "\n"; - print "---END---\n</PRE>"; - } - - if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'? - { - $this->errstr='no response'; - $resp=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl)); - curl_close($curl); - if($keepalive) - { - $this->xmlrpc_curl_handle = null; - } - } - else - { - if(!$keepalive) - { - curl_close($curl); - } - $resp =& $msg->parseResponse($result, true, $this->return_type); - } - return $resp; - } - - /** - * Send an array of request messages and return an array of responses. - * Unless $this->no_multicall has been set to true, it will try first - * to use one single xmlrpc call to server method system.multicall, and - * revert to sending many successive calls in case of failure. - * This failure is also stored in $this->no_multicall for subsequent calls. - * Unfortunately, there is no server error code universally used to denote - * the fact that multicall is unsupported, so there is no way to reliably - * distinguish between that and a temporary failure. - * If you are sure that server supports multicall and do not want to - * fallback to using many single calls, set the fourth parameter to FALSE. - * - * NB: trying to shoehorn extra functionality into existing syntax has resulted - * in pretty much convoluted code... - * - * @param array $msgs an array of xmlrpcmsg objects - * @param integer $timeout connection timeout (in seconds) - * @param string $method the http protocol variant to be used - * @param boolean fallback When true, upon receiveing an error during multicall, multiple single calls will be attempted - * @return array - * @access public - */ - function multicall($msgs, $timeout=0, $method='', $fallback=true) - { - if ($method == '') - { - $method = $this->method; - } - if(!$this->no_multicall) - { - $results = $this->_try_multicall($msgs, $timeout, $method); - if(is_array($results)) - { - // System.multicall succeeded - return $results; - } - else - { - // either system.multicall is unsupported by server, - // or call failed for some other reason. - if ($fallback) - { - // Don't try it next time... - $this->no_multicall = true; - } - else - { - if (is_a($results, 'xmlrpcresp')) - { - $result = $results; - } - else - { - $result =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']); - } - } - } - } - else - { - // override fallback, in case careless user tries to do two - // opposite things at the same time - $fallback = true; - } - - $results = array(); - if ($fallback) - { - // system.multicall is (probably) unsupported by server: - // emulate multicall via multiple requests - foreach($msgs as $msg) - { - $results[] =& $this->send($msg, $timeout, $method); - } - } - else - { - // user does NOT want to fallback on many single calls: - // since we should always return an array of responses, - // return an array with the same error repeated n times - foreach($msgs as $msg) - { - $results[] = $result; - } - } - return $results; - } - - /** - * Attempt to boxcar $msgs via system.multicall. - * Returns either an array of xmlrpcreponses, an xmlrpc error response - * or false (when received response does not respect valid multicall syntax) - * @access private - */ - function _try_multicall($msgs, $timeout, $method) - { - // Construct multicall message - $calls = array(); - foreach($msgs as $msg) - { - $call['methodName'] =& new xmlrpcval($msg->method(),'string'); - $numParams = $msg->getNumParams(); - $params = array(); - for($i = 0; $i < $numParams; $i++) - { - $params[$i] = $msg->getParam($i); - } - $call['params'] =& new xmlrpcval($params, 'array'); - $calls[] =& new xmlrpcval($call, 'struct'); - } - $multicall =& new xmlrpcmsg('system.multicall'); - $multicall->addParam(new xmlrpcval($calls, 'array')); - - // Attempt RPC call - $result =& $this->send($multicall, $timeout, $method); - - if($result->faultCode() != 0) - { - // call to system.multicall failed - return $result; - } - - // Unpack responses. - $rets = $result->value(); - - if ($this->return_type == 'xml') - { - return $rets; - } - else if ($this->return_type == 'phpvals') - { - ///@todo test this code branch... - $rets = $result->value(); - if(!is_array($rets)) - { - return false; // bad return type from system.multicall - } - $numRets = count($rets); - if($numRets != count($msgs)) - { - return false; // wrong number of return values. - } - - $response = array(); - for($i = 0; $i < $numRets; $i++) - { - $val = $rets[$i]; - if (!is_array($val)) { - return false; - } - switch(count($val)) - { - case 1: - if(!isset($val[0])) - { - return false; // Bad value - } - // Normal return value - $response[$i] =& new xmlrpcresp($val[0], 0, '', 'phpvals'); - break; - case 2: - /// @todo remove usage of @: it is apparently quite slow - $code = @$val['faultCode']; - if(!is_int($code)) - { - return false; - } - $str = @$val['faultString']; - if(!is_string($str)) - { - return false; - } - $response[$i] =& new xmlrpcresp(0, $code, $str); - break; - default: - return false; - } - } - return $response; - } - else // return type == 'xmlrpcvals' - { - $rets = $result->value(); - if($rets->kindOf() != 'array') - { - return false; // bad return type from system.multicall - } - $numRets = $rets->arraysize(); - if($numRets != count($msgs)) - { - return false; // wrong number of return values. - } - - $response = array(); - for($i = 0; $i < $numRets; $i++) - { - $val = $rets->arraymem($i); - switch($val->kindOf()) - { - case 'array': - if($val->arraysize() != 1) - { - return false; // Bad value - } - // Normal return value - $response[$i] =& new xmlrpcresp($val->arraymem(0)); - break; - case 'struct': - $code = $val->structmem('faultCode'); - if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') - { - return false; - } - $str = $val->structmem('faultString'); - if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') - { - return false; - } - $response[$i] =& new xmlrpcresp(0, $code->scalarval(), $str->scalarval()); - break; - default: - return false; - } - } - return $response; - } - } - } // end class xmlrpc_client - - class xmlrpcresp - { - var $val = 0; - var $valtyp; - var $errno = 0; - var $errstr = ''; - var $payload; - var $hdrs = array(); - var $_cookies = array(); - var $content_type = 'text/xml'; - var $raw_data = ''; - - /** - * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string) - * @param integer $fcode set it to anything but 0 to create an error response - * @param string $fstr the error string, in case of an error response - * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml' - * - * @todo add check that $val / $fcode / $fstr is of correct type??? - * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain - * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called... - */ - function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='') - { - if($fcode != 0) - { - // error response - $this->errno = $fcode; - $this->errstr = $fstr; - //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later. - } - else - { - // successful response - $this->val = $val; - if ($valtyp == '') - { - // user did not declare type of response value: try to guess it - if (is_object($this->val) && is_a($this->val, 'xmlrpcval')) - { - $this->valtyp = 'xmlrpcvals'; - } - else if (is_string($this->val)) - { - $this->valtyp = 'xml'; - - } - else - { - $this->valtyp = 'phpvals'; - } - } - else - { - // user declares type of resp value: believe him - $this->valtyp = $valtyp; - } - } - } - - /** - * Returns the error code of the response. - * @return integer the error code of this response (0 for not-error responses) - * @access public - */ - function faultCode() - { - return $this->errno; - } - - /** - * Returns the error code of the response. - * @return string the error string of this response ('' for not-error responses) - * @access public - */ - function faultString() - { - return $this->errstr; - } - - /** - * Returns the value received by the server. - * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects - * @access public - */ - function value() - { - return $this->val; - } - - /** - * Returns an array with the cookies received from the server. - * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...) - * with attributes being e.g. 'expires', 'path', domain'. - * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past) - * are still present in the array. It is up to the user-defined code to decide - * how to use the received cookies, and wheter they have to be sent back with the next - * request to the server (using xmlrpc_client::setCookie) or not - * @return array array of cookies received from the server - * @access public - */ - function cookies() - { - return $this->_cookies; - } - - /** - * Returns xml representation of the response. XML prologue not included - * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed - * @return string the xml representation of the response - * @access public - */ - function serialize($charset_encoding='') - { - if ($charset_encoding != '') - $this->content_type = 'text/xml; charset=' . $charset_encoding; - else - $this->content_type = 'text/xml'; - $result = "<methodResponse>\n"; - if($this->errno) - { - // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients - // by xml-encoding non ascii chars - $result .= "<fault>\n" . -"<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . -"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . -xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" . -"</struct>\n</value>\n</fault>"; - } - else - { - if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval')) - { - if (is_string($this->val) && $this->valtyp == 'xml') - { - $result .= "<params>\n<param>\n" . - $this->val . - "</param>\n</params>"; - } - else - { - /// @todo try to build something serializable? - die('cannot serialize xmlrpcresp objects whose content is native php values'); - } - } - else - { - $result .= "<params>\n<param>\n" . - $this->val->serialize($charset_encoding) . - "</param>\n</params>"; - } - } - $result .= "\n</methodResponse>"; - $this->payload = $result; - return $result; - } - } - - class xmlrpcmsg - { - var $payload; - var $methodname; - var $params=array(); - var $debug=0; - var $content_type = 'text/xml'; - - /** - * @param string $meth the name of the method to invoke - * @param array $pars array of parameters to be paased to the method (xmlrpcval objects) - */ - function xmlrpcmsg($meth, $pars=0) - { - $this->methodname=$meth; - if(is_array($pars) && count($pars)>0) - { - for($i=0; $i<count($pars); $i++) - { - $this->addParam($pars[$i]); - } - } - } - - /** - * @access private - */ - function xml_header($charset_encoding='') - { - if ($charset_encoding != '') - { - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n"; - } - else - { - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; - } - } - - /** - * @access private - */ - function xml_footer() - { - return '</methodCall>'; - } - - /** - * @access private - */ - function kindOf() - { - return 'msg'; - } - - /** - * @access private - */ - function createPayload($charset_encoding='') - { - if ($charset_encoding != '') - $this->content_type = 'text/xml; charset=' . $charset_encoding; - else - $this->content_type = 'text/xml'; - $this->payload=$this->xml_header($charset_encoding); - $this->payload.='<methodName>' . $this->methodname . "</methodName>\n"; - $this->payload.="<params>\n"; - for($i=0; $i<count($this->params); $i++) - { - $p=$this->params[$i]; - $this->payload.="<param>\n" . $p->serialize($charset_encoding) . - "</param>\n"; - } - $this->payload.="</params>\n"; - $this->payload.=$this->xml_footer(); - } - - /** - * Gets/sets the xmlrpc method to be invoked - * @param string $meth the method to be set (leave empty not to set it) - * @return string the method that will be invoked - * @access public - */ - function method($meth='') - { - if($meth!='') - { - $this->methodname=$meth; - } - return $this->methodname; - } - - /** - * Returns xml representation of the message. XML prologue included - * @return string the xml representation of the message, xml prologue included - * @access public - */ - function serialize($charset_encoding='') - { - $this->createPayload($charset_encoding); - return $this->payload; - } - - /** - * Add a parameter to the list of parameters to be used upon method invocation - * @param xmlrpcval $par - * @return boolean false on failure - * @access public - */ - function addParam($par) - { - // add check: do not add to self params which are not xmlrpcvals - if(is_object($par) && is_a($par, 'xmlrpcval')) - { - $this->params[]=$par; - return true; - } - else - { - return false; - } - } - - /** - * Returns the nth parameter in the message. The index zero-based. - * @param integer $i the index of the parameter to fetch (zero based) - * @return xmlrpcval the i-th parameter - * @access public - */ - function getParam($i) { return $this->params[$i]; } - - /** - * Returns the number of parameters in the messge. - * @return integer the number of parameters currently set - * @access public - */ - function getNumParams() { return count($this->params); } - - /** - * Given an open file handle, read all data available and parse it as axmlrpc response. - * NB: the file handle is not closed by this function. - * NNB: might have trouble in rare cases to work on network streams, as we - * check for a read of 0 bytes instead of feof($fp). - * But since checking for feof(null) returns false, we would risk an - * infinite loop in that case, because we cannot trust the caller - * to give us a valid pointer to an open file... - * @access public - * @return xmlrpcresp - * @todo add 2nd & 3rd param to be passed to ParseResponse() ??? - */ - function &parseResponseFile($fp) - { - $ipd=''; - while($data=fread($fp, 32768)) - { - $ipd.=$data; - } - //fclose($fp); - $r =& $this->parseResponse($ipd); - return $r; - } - - /** - * Parses HTTP headers and separates them from data. - * @access private - */ - function &parseResponseHeaders(&$data, $headers_processed=false) - { - // Support "web-proxy-tunelling" connections for https through proxies - if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) - { - // Look for CR/LF or simple LF as line separator, - // (even though it is not valid http) - $pos = strpos($data,"\r\n\r\n"); - if($pos || is_int($pos)) - { - $bd = $pos+4; - } - else - { - $pos = strpos($data,"\n\n"); - if($pos || is_int($pos)) - { - $bd = $pos+2; - } - else - { - // No separation between response headers and body: fault? - $bd = 0; - } - } - if ($bd) - { - // this filters out all http headers from proxy. - // maybe we could take them into account, too? - $data = substr($data, $bd); - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTPS via proxy error, tunnel connection possibly failed'); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)'); - return $r; - } - } - - // Strip HTTP 1.1 100 Continue header if present - while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data)) - { - $pos = strpos($data, 'HTTP', 12); - // server sent a Continue header without any (valid) content following... - // give the client a chance to know it - if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5 - { - break; - } - $data = substr($data, $pos); - } - if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) - { - $errstr= substr($data, 0, strpos($data, "\n")-1); - error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTP error, got response: ' .$errstr); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')'); - return $r; - } - - $GLOBALS['_xh']['headers'] = array(); - $GLOBALS['_xh']['cookies'] = array(); - - // be tolerant to usage of \n instead of \r\n to separate headers and data - // (even though it is not valid http) - $pos = strpos($data,"\r\n\r\n"); - if($pos || is_int($pos)) - { - $bd = $pos+4; - } - else - { - $pos = strpos($data,"\n\n"); - if($pos || is_int($pos)) - { - $bd = $pos+2; - } - else - { - // No separation between response headers and body: fault? - // we could take some action here instead of going on... - $bd = 0; - } - } - // be tolerant to line endings, and extra empty lines - $ar = split("\r?\n", trim(substr($data, 0, $pos))); - while(list(,$line) = @each($ar)) - { - // take care of multi-line headers and cookies - $arr = explode(':',$line,2); - if(count($arr) > 1) - { - $header_name = strtolower(trim($arr[0])); - /// @todo some other headers (the ones that allow a CSV list of values) - /// do allow many values to be passed using multiple header lines. - /// We should add content to $GLOBALS['_xh']['headers'][$header_name] - /// instead of replacing it for those... - if ($header_name == 'set-cookie' || $header_name == 'set-cookie2') - { - if ($header_name == 'set-cookie2') - { - // version 2 cookies: - // there could be many cookies on one line, comma separated - $cookies = explode(',', $arr[1]); - } - else - { - $cookies = array($arr[1]); - } - foreach ($cookies as $cookie) - { - // glue together all received cookies, using a comma to separate them - // (same as php does with getallheaders()) - if (isset($GLOBALS['_xh']['headers'][$header_name])) - $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie); - else - $GLOBALS['_xh']['headers'][$header_name] = trim($cookie); - // parse cookie attributes, in case user wants to correctly honour them - // feature creep: only allow rfc-compliant cookie attributes? - // @todo support for server sending multiple time cookie with same name, but using different PATHs - $cookie = explode(';', $cookie); - foreach ($cookie as $pos => $val) - { - $val = explode('=', $val, 2); - $tag = trim($val[0]); - $val = trim(@$val[1]); - /// @todo with version 1 cookies, we should strip leading and trailing " chars - if ($pos == 0) - { - $cookiename = $tag; - $GLOBALS['_xh']['cookies'][$tag] = array(); - $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val); - } - else - { - if ($tag != 'value') - { - $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val; - } - } - } - } - } - else - { - $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]); - } - } - elseif(isset($header_name)) - { - /// @todo version1 cookies might span multiple lines, thus breaking the parsing above - $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line); - } - } - - $data = substr($data, $bd); - - if($this->debug && count($GLOBALS['_xh']['headers'])) - { - print '<PRE>'; - foreach($GLOBALS['_xh']['headers'] as $header => $value) - { - print htmlentities("HEADER: $header: $value\n"); - } - foreach($GLOBALS['_xh']['cookies'] as $header => $value) - { - print htmlentities("COOKIE: $header={$value['value']}\n"); - } - print "</PRE>\n"; - } - - // if CURL was used for the call, http headers have been processed, - // and dechunking + reinflating have been carried out - if(!$headers_processed) - { - // Decode chunked encoding sent by http 1.1 servers - if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked') - { - if(!$data = decode_chunked($data)) - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to rebuild the chunked data received from server'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']); - return $r; - } - } - - // Decode gzip-compressed stuff - // code shamelessly inspired from nusoap library by Dietrich Ayala - if(isset($GLOBALS['_xh']['headers']['content-encoding'])) - { - $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']); - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip') - { - // if decoding works, use it. else assume data wasn't gzencoded - if(function_exists('gzinflate')) - { - if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) - { - $data = $degzdata; - if($this->debug) - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; - } - elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) - { - $data = $degzdata; - if($this->debug) - print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>"; - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to decode the deflated data received from server'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']); - return $r; - } - } - else - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']); - return $r; - } - } - } - } // end of 'if needed, de-chunk, re-inflate response' - - // real stupid hack to avoid PHP 4 complaining about returning NULL by ref - $r = null; - $r =& $r; - return $r; - } - - /** - * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object. - * @param string $data the xmlrpc response, eventually including http headers - * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding - * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals' - * @return xmlrpcresp - * @access public - */ - function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals') - { - if($this->debug) - { - //by maHo, replaced htmlspecialchars with htmlentities - print "<PRE>---GOT---\n" . htmlentities($data) . "\n---END---\n</PRE>"; - } - - if($data == '') - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: no response received from server.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']); - return $r; - } - - $GLOBALS['_xh']=array(); - - $raw_data = $data; - // parse the HTTP headers of the response, if present, and separate them from data - if(substr($data, 0, 4) == 'HTTP') - { - $r =& $this->parseResponseHeaders($data, $headers_processed); - if ($r) - { - // failed processing of HTTP response headers - // save into response obj the full payload received, for debugging - $r->raw_data = $data; - return $r; - } - } - else - { - $GLOBALS['_xh']['headers'] = array(); - $GLOBALS['_xh']['cookies'] = array(); - } - - if($this->debug) - { - $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); - if ($start) - { - $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); - $end = strpos($data, '-->', $start); - $comments = substr($data, $start, $end-$start); - print "<PRE>---SERVER DEBUG INFO (DECODED) ---\n\t".htmlentities(str_replace("\n", "\n\t", base64_decode($comments)))."\n---END---\n</PRE>"; - } - } - - // be tolerant of extra whitespace in response body - $data = trim($data); - - /// @todo return an error msg if $data=='' ? - - // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts) - // idea from Luca Mariano <luca.mariano@email.it> originally in PEARified version of the lib - $bd = false; - // Poor man's version of strrpos for php 4... - $pos = strpos($data, '</methodResponse>'); - while($pos || is_int($pos)) - { - $bd = $pos+17; - $pos = strpos($data, '</methodResponse>', $bd); - } - if($bd) - { - $data = substr($data, 0, $bd); - } - - // if user wants back raw xml, give it to him - if ($return_type == 'xml') - { - $r =& new xmlrpcresp($data, 0, '', 'xml'); - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - - // try to 'guestimate' the character encoding of the received response - $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data); - - $GLOBALS['_xh']['ac']=''; - //$GLOBALS['_xh']['qt']=''; //unused... - $GLOBALS['_xh']['stack'] = array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc - $GLOBALS['_xh']['isf_reason']=''; - $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse' - - // if response charset encoding is not known / supported, try to use - // the default encoding and parse the xml anyway, but log a warning... - if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - // the following code might be better for mb_string enabled installs, but - // makes the lib about 200% slower... - //if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - error_log('XML-RPC: xmlrpcmsg::parseResponse: invalid charset encoding of received response: '.$resp_encoding); - $resp_encoding = $GLOBALS['xmlrpc_defencoding']; - } - $parser = xml_parser_create($resp_encoding); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell - // the xml parser to give us back data in the expected charset. - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8 - // This allows to send data which is native in various charset, - // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - - if ($return_type == 'phpvals') - { - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); - } - else - { - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); - } - - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - - // first error check: xml not well formed - if(!xml_parse($parser, $data, count($data))) - { - // thanks to Peter Kocks <peter.kocks@baygate.com> - if((xml_get_current_line_number($parser)) == 1) - { - $errstr = 'XML error at line 1, check URL'; - } - else - { - $errstr = sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser)); - } - error_log($errstr); - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')'); - xml_parser_free($parser); - if($this->debug) - { - print $errstr; - } - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - xml_parser_free($parser); - // second error check: xml well formed but not xml-rpc compliant - if ($GLOBALS['_xh']['isf'] > 1) - { - if ($this->debug) - { - /// @todo echo something for user? - } - - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], - $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']); - } - // third error check: parsing of the response has somehow gone boink. - // NB: shall we omit this check, since we trust the parsing code? - elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value'])) - { - // something odd has happened - // and it's time to generate a client side error - // indicating something odd went on - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], - $GLOBALS['xmlrpcstr']['invalid_return']); - } - else - { - if ($this->debug) - { - print "<PRE>---PARSED---\n"; - // somehow htmlentities chokes on var_export, and some full html string... - //print htmlentitites(var_export($GLOBALS['_xh']['value'], true)); - print htmlspecialchars(var_export($GLOBALS['_xh']['value'], true)); - print "\n---END---</PRE>"; - } - - // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object. - $v =& $GLOBALS['_xh']['value']; - - if($GLOBALS['_xh']['isf']) - { - /// @todo we should test here if server sent an int and a string, - /// and/or coerce them into such... - if ($return_type == 'xmlrpcvals') - { - $errno_v = $v->structmem('faultCode'); - $errstr_v = $v->structmem('faultString'); - $errno = $errno_v->scalarval(); - $errstr = $errstr_v->scalarval(); - } - else - { - $errno = $v['faultCode']; - $errstr = $v['faultString']; - } - - if($errno == 0) - { - // FAULT returned, errno needs to reflect that - $errno = -1; - } - - $r =& new xmlrpcresp(0, $errno, $errstr); - } - else - { - $r=&new xmlrpcresp($v, 0, '', $return_type); - } - } - - $r->hdrs = $GLOBALS['_xh']['headers']; - $r->_cookies = $GLOBALS['_xh']['cookies']; - $r->raw_data = $raw_data; - return $r; - } - } - - class xmlrpcval - { - var $me=array(); - var $mytype=0; - var $_php_class=null; - - /** - * @param mixed $val - * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed - */ - function xmlrpcval($val=-1, $type='') - { - /// @todo: optimization creep - do not call addXX, do it all inline. - /// downside: booleans will not be coerced anymore - if($val!==-1 || $type!='') - { - // optimization creep: inlined all work done by constructor - switch($type) - { - case '': - $this->mytype=1; - $this->me['string']=$val; - break; - case 'i4': - case 'int': - case 'double': - case 'string': - case 'boolean': - case 'dateTime.iso8601': - case 'base64': - case 'null': - $this->mytype=1; - $this->me[$type]=$val; - break; - case 'array': - $this->mytype=2; - $this->me['array']=$val; - break; - case 'struct': - $this->mytype=3; - $this->me['struct']=$val; - break; - default: - error_log("XML-RPC: xmlrpcval::xmlrpcval: not a known type ($type)"); - } - /*if($type=='') - { - $type='string'; - } - if($GLOBALS['xmlrpcTypes'][$type]==1) - { - $this->addScalar($val,$type); - } - elseif($GLOBALS['xmlrpcTypes'][$type]==2) - { - $this->addArray($val); - } - elseif($GLOBALS['xmlrpcTypes'][$type]==3) - { - $this->addStruct($val); - }*/ - } - } - - /** - * Add a single php value to an (unitialized) xmlrpcval - * @param mixed $val - * @param string $type - * @return int 1 or 0 on failure - */ - function addScalar($val, $type='string') - { - $typeof=@$GLOBALS['xmlrpcTypes'][$type]; - if($typeof!=1) - { - error_log("XML-RPC: xmlrpcval::addScalar: not a scalar type ($type)"); - return 0; - } - - // coerce booleans into correct values - // NB: we should iether do it for datetimes, integers and doubles, too, - // or just plain remove this check, implemnted on booleans only... - if($type==$GLOBALS['xmlrpcBoolean']) - { - if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false'))) - { - $val=true; - } - else - { - $val=false; - } - } - - switch($this->mytype) - { - case 1: - error_log('XML-RPC: xmlrpcval::addScalar: scalar xmlrpcval can have only one value'); - return 0; - case 3: - error_log('XML-RPC: xmlrpcval::addScalar: cannot add anonymous scalar to struct xmlrpcval'); - return 0; - case 2: - // we're adding a scalar value to an array here - //$ar=$this->me['array']; - //$ar[]=&new xmlrpcval($val, $type); - //$this->me['array']=$ar; - // Faster (?) avoid all the costly array-copy-by-val done here... - $this->me['array'][]=&new xmlrpcval($val, $type); - return 1; - default: - // a scalar, so set the value and remember we're scalar - $this->me[$type]=$val; - $this->mytype=$typeof; - return 1; - } - } - - /** - * Add an array of xmlrpcval objects to an xmlrpcval - * @param array $vals - * @return int 1 or 0 on failure - * @access public - * - * @todo add some checking for $vals to be an array of xmlrpcvals? - */ - function addArray($vals) - { - if($this->mytype==0) - { - $this->mytype=$GLOBALS['xmlrpcTypes']['array']; - $this->me['array']=$vals; - return 1; - } - elseif($this->mytype==2) - { - // we're adding to an array here - $this->me['array'] = array_merge($this->me['array'], $vals); - return 1; - } - else - { - error_log('XML-RPC: xmlrpcval::addArray: already initialized as a [' . $this->kindOf() . ']'); - return 0; - } - } - - /** - * Add an array of named xmlrpcval objects to an xmlrpcval - * @param array $vals - * @return int 1 or 0 on failure - * @access public - * - * @todo add some checking for $vals to be an array? - */ - function addStruct($vals) - { - if($this->mytype==0) - { - $this->mytype=$GLOBALS['xmlrpcTypes']['struct']; - $this->me['struct']=$vals; - return 1; - } - elseif($this->mytype==3) - { - // we're adding to a struct here - $this->me['struct'] = array_merge($this->me['struct'], $vals); - return 1; - } - else - { - error_log('XML-RPC: xmlrpcval::addStruct: already initialized as a [' . $this->kindOf() . ']'); - return 0; - } - } - - // poor man's version of print_r ??? - // DEPRECATED! - function dump($ar) - { - foreach($ar as $key => $val) - { - echo "$key => $val<br />"; - if($key == 'array') - { - while(list($key2, $val2) = each($val)) - { - echo "-- $key2 => $val2<br />"; - } - } - } - } - - /** - * Returns a string containing "struct", "array" or "scalar" describing the base type of the value - * @return string - * @access public - */ - function kindOf() - { - switch($this->mytype) - { - case 3: - return 'struct'; - break; - case 2: - return 'array'; - break; - case 1: - return 'scalar'; - break; - default: - return 'undef'; - } - } - - /** - * @access private - */ - function serializedata($typ, $val, $charset_encoding='') - { - $rs=''; - switch(@$GLOBALS['xmlrpcTypes'][$typ]) - { - case 1: - switch($typ) - { - case $GLOBALS['xmlrpcBase64']: - $rs.="<${typ}>" . base64_encode($val) . "</${typ}>"; - break; - case $GLOBALS['xmlrpcBoolean']: - $rs.="<${typ}>" . ($val ? '1' : '0') . "</${typ}>"; - break; - case $GLOBALS['xmlrpcString']: - // G. Giunta 2005/2/13: do NOT use htmlentities, since - // it will produce named html entities, which are invalid xml - $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). "</${typ}>"; - break; - case $GLOBALS['xmlrpcInt']: - case $GLOBALS['xmlrpcI4']: - $rs.="<${typ}>".(int)$val."</${typ}>"; - break; - case $GLOBALS['xmlrpcDouble']: - // avoid using standard conversion of float to string because it is locale-dependent, - // and also because the xmlrpc spec forbids exponential notation - // sprintf('%F') would be most likely ok but it is only available since PHP 4.3.10 and PHP 5.0.3. - // The code below tries its best at keeping max precision while avoiding exp notation, - // but there is of course no limit in the number of decimal places to be used... - $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>"; - break; - case $GLOBALS['xmlrpcNull']: - $rs.="<nil/>"; - break; - default: - // no standard type value should arrive here, but provide a possibility - // for xmlrpcvals of unknown type... - $rs.="<${typ}>${val}</${typ}>"; - } - break; - case 3: - // struct - if ($this->_php_class) - { - $rs.='<struct php_class="' . $this->_php_class . "\">\n"; - } - else - { - $rs.="<struct>\n"; - } - foreach($val as $key2 => $val2) - { - $rs.='<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n"; - //$rs.=$this->serializeval($val2); - $rs.=$val2->serialize($charset_encoding); - $rs.="</member>\n"; - } - $rs.='</struct>'; - break; - case 2: - // array - $rs.="<array>\n<data>\n"; - for($i=0; $i<count($val); $i++) - { - //$rs.=$this->serializeval($val[$i]); - $rs.=$val[$i]->serialize($charset_encoding); - } - $rs.="</data>\n</array>"; - break; - default: - break; - } - return $rs; - } - - /** - * Returns xml representation of the value. XML prologue not included - * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed - * @return string - * @access public - */ - function serialize($charset_encoding='') - { - // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... - //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) - //{ - reset($this->me); - list($typ, $val) = each($this->me); - return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n"; - //} - } - - // DEPRECATED - function serializeval($o) - { - // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals... - //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval'))) - //{ - $ar=$o->me; - reset($ar); - list($typ, $val) = each($ar); - return '<value>' . $this->serializedata($typ, $val) . "</value>\n"; - //} - } - - /** - * Checks wheter a struct member with a given name is present. - * Works only on xmlrpcvals of type struct. - * @param string $m the name of the struct member to be looked up - * @return boolean - * @access public - */ - function structmemexists($m) - { - return array_key_exists($m, $this->me['struct']); - } - - /** - * Returns the value of a given struct member (an xmlrpcval object in itself). - * Will raise a php warning if struct member of given name does not exist - * @param string $m the name of the struct member to be looked up - * @return xmlrpcval - * @access public - */ - function structmem($m) - { - return $this->me['struct'][$m]; - } - - /** - * Reset internal pointer for xmlrpcvals of type struct. - * @access public - */ - function structreset() - { - reset($this->me['struct']); - } - - /** - * Return next member element for xmlrpcvals of type struct. - * @return xmlrpcval - * @access public - */ - function structeach() - { - return each($this->me['struct']); - } - - // DEPRECATED! this code looks like it is very fragile and has not been fixed - // for a long long time. Shall we remove it for 2.0? - function getval() - { - // UNSTABLE - reset($this->me); - list($a,$b)=each($this->me); - // contributed by I Sofer, 2001-03-24 - // add support for nested arrays to scalarval - // i've created a new method here, so as to - // preserve back compatibility - - if(is_array($b)) - { - @reset($b); - while(list($id,$cont) = @each($b)) - { - $b[$id] = $cont->scalarval(); - } - } - - // add support for structures directly encoding php objects - if(is_object($b)) - { - $t = get_object_vars($b); - @reset($t); - while(list($id,$cont) = @each($t)) - { - $t[$id] = $cont->scalarval(); - } - @reset($t); - while(list($id,$cont) = @each($t)) - { - @$b->{$id} = $cont; - } - } - // end contrib - return $b; - } - - /** - * Returns the value of a scalar xmlrpcval - * @return mixed - * @access public - */ - function scalarval() - { - reset($this->me); - list(,$b)=each($this->me); - return $b; - } - - /** - * Returns the type of the xmlrpcval. - * For integers, 'int' is always returned in place of 'i4' - * @return string - * @access public - */ - function scalartyp() - { - reset($this->me); - list($a,)=each($this->me); - if($a==$GLOBALS['xmlrpcI4']) - { - $a=$GLOBALS['xmlrpcInt']; - } - return $a; - } - - /** - * Returns the m-th member of an xmlrpcval of struct type - * @param integer $m the index of the value to be retrieved (zero based) - * @return xmlrpcval - * @access public - */ - function arraymem($m) - { - return $this->me['array'][$m]; - } - - /** - * Returns the number of members in an xmlrpcval of array type - * @return integer - * @access public - */ - function arraysize() - { - return count($this->me['array']); - } - - /** - * Returns the number of members in an xmlrpcval of struct type - * @return integer - * @access public - */ - function structsize() - { - return count($this->me['struct']); - } - } - - - // date helpers - - /** - * Given a timestamp, return the corresponding ISO8601 encoded string. - * - * Really, timezones ought to be supported - * but the XML-RPC spec says: - * - * "Don't assume a timezone. It should be specified by the server in its - * documentation what assumptions it makes about timezones." - * - * These routines always assume localtime unless - * $utc is set to 1, in which case UTC is assumed - * and an adjustment for locale is made when encoding - * - * @param int $timet (timestamp) - * @param int $utc (0 or 1) - * @return string - */ - function iso8601_encode($timet, $utc=0) - { - if(!$utc) - { - $t=strftime("%Y%m%dT%H:%M:%S", $timet); - } - else - { - if(function_exists('gmstrftime')) - { - // gmstrftime doesn't exist in some versions - // of PHP - $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet); - } - else - { - $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z')); - } - } - return $t; - } - - /** - * Given an ISO8601 date string, return a timet in the localtime, or UTC - * @param string $idate - * @param int $utc either 0 or 1 - * @return int (datetime) - */ - function iso8601_decode($idate, $utc=0) - { - $t=0; - if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) - { - if($utc) - { - $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); - } - else - { - $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); - } - } - return $t; - } - - /** - * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types. - * - * Works with xmlrpc message objects as input, too. - * - * Given proper options parameter, can rebuild generic php object instances - * (provided those have been encoded to xmlrpc format using a corresponding - * option in php_xmlrpc_encode()) - * PLEASE NOTE that rebuilding php objects involves calling their constructor function. - * This means that the remote communication end can decide which php code will - * get executed on your server, leaving the door possibly open to 'php-injection' - * style of attacks (provided you have some classes defined on your server that - * might wreak havoc if instances are built outside an appropriate context). - * Make sure you trust the remote server/client before eanbling this! - * - * @author Dan Libby (dan@libby.com) - * - * @param xmlrpcval $xmlrpc_val - * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects - * @return mixed - */ - function php_xmlrpc_decode($xmlrpc_val, $options=array()) - { - switch($xmlrpc_val->kindOf()) - { - case 'scalar': - if (in_array('extension_api', $options)) - { - reset($xmlrpc_val->me); - list($typ,$val) = each($xmlrpc_val->me); - switch ($typ) - { - case 'dateTime.iso8601': - $xmlrpc_val->scalar = $val; - $xmlrpc_val->xmlrpc_type = 'datetime'; - $xmlrpc_val->timestamp = iso8601_decode($val); - return $xmlrpc_val; - case 'base64': - $xmlrpc_val->scalar = $val; - $xmlrpc_val->type = $typ; - return $xmlrpc_val; - default: - return $xmlrpc_val->scalarval(); - } - } - return $xmlrpc_val->scalarval(); - case 'array': - $size = $xmlrpc_val->arraysize(); - $arr = array(); - for($i = 0; $i < $size; $i++) - { - $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options); - } - return $arr; - case 'struct': - $xmlrpc_val->structreset(); - // If user said so, try to rebuild php objects for specific struct vals. - /// @todo should we raise a warning for class not found? - // shall we check for proper subclass of xmlrpcval instead of - // presence of _php_class to detect what we can do? - if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != '' - && class_exists($xmlrpc_val->_php_class)) - { - $obj = @new $xmlrpc_val->_php_class; - while(list($key,$value)=$xmlrpc_val->structeach()) - { - $obj->{$key} = php_xmlrpc_decode($value, $options); - } - return $obj; - } - else - { - $arr = array(); - while(list($key,$value)=$xmlrpc_val->structeach()) - { - $arr[$key] = php_xmlrpc_decode($value, $options); - } - return $arr; - } - case 'msg': - $paramcount = $xmlrpc_val->getNumParams(); - $arr = array(); - for($i = 0; $i < $paramcount; $i++) - { - $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i)); - } - return $arr; - } - } - - // This constant left here only for historical reasons... - // it was used to decide if we have to define xmlrpc_encode on our own, but - // we do not do it anymore - if(function_exists('xmlrpc_decode')) - { - define('XMLRPC_EPI_ENABLED','1'); - } - else - { - define('XMLRPC_EPI_ENABLED','0'); - } - - /** - * Takes native php types and encodes them into xmlrpc PHP object format. - * It will not re-encode xmlrpcval objects. - * - * Feature creep -- could support more types via optional type argument - * (string => datetime support has been added, ??? => base64 not yet) - * - * If given a proper options parameter, php object instances will be encoded - * into 'special' xmlrpc values, that can later be decoded into php objects - * by calling php_xmlrpc_decode() with a corresponding option - * - * @author Dan Libby (dan@libby.com) - * - * @param mixed $php_val the value to be converted into an xmlrpcval object - * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api' - * @return xmlrpcval - */ - function &php_xmlrpc_encode($php_val, $options=array()) - { - $type = gettype($php_val); - switch($type) - { - case 'string': - if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']); - else - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcString']); - break; - case 'integer': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']); - break; - case 'double': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']); - break; - // <G_Giunta_2001-02-29> - // Add support for encoding/decoding of booleans, since they are supported in PHP - case 'boolean': - $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']); - break; - // </G_Giunta_2001-02-29> - case 'array': - // PHP arrays can be encoded to either xmlrpc structs or arrays, - // depending on wheter they are hashes or plain 0..n integer indexed - // A shorter one-liner would be - // $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1)); - // but execution time skyrockets! - $j = 0; - $arr = array(); - $ko = false; - foreach($php_val as $key => $val) - { - $arr[$key] =& php_xmlrpc_encode($val, $options); - if(!$ko && $key !== $j) - { - $ko = true; - } - $j++; - } - if($ko) - { - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); - } - else - { - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcArray']); - } - break; - case 'object': - if(is_a($php_val, 'xmlrpcval')) - { - $xmlrpc_val = $php_val; - } - else - { - $arr = array(); - while(list($k,$v) = each($php_val)) - { - $arr[$k] = php_xmlrpc_encode($v, $options); - } - $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']); - if (in_array('encode_php_objs', $options)) - { - // let's save original class name into xmlrpcval: - // might be useful later on... - $xmlrpc_val->_php_class = get_class($php_val); - } - } - break; - case 'NULL': - if (in_array('extension_api', $options)) - { - $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcString']); - } - if (in_array('null_extension', $options)) - { - $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcNull']); - } - else - { - $xmlrpc_val =& new xmlrpcval(); - } - break; - case 'resource': - if (in_array('extension_api', $options)) - { - $xmlrpc_val =& new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); - } - else - { - $xmlrpc_val =& new xmlrpcval(); - } - // catch "user function", "unknown type" - default: - // giancarlo pinerolo <ping@alt.it> - // it has to return - // an empty object in case, not a boolean. - $xmlrpc_val =& new xmlrpcval(); - break; - } - return $xmlrpc_val; - } - - /** - * Convert the xml representation of a method response, method request or single - * xmlrpc value into the appropriate object (a.k.a. deserialize) - * @param string $xml_val - * @param array $options - * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp - */ - function php_xmlrpc_decode_xml($xml_val, $options=array()) - { - $GLOBALS['_xh'] = array(); - $GLOBALS['_xh']['ac'] = ''; - $GLOBALS['_xh']['stack'] = array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['params'] = array(); - $GLOBALS['_xh']['pt'] = array(); - $GLOBALS['_xh']['isf'] = 0; - $GLOBALS['_xh']['isf_reason'] = ''; - $GLOBALS['_xh']['method'] = false; - $GLOBALS['_xh']['rt'] = ''; - /// @todo 'guestimate' encoding - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8! - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee'); - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - if(!xml_parse($parser, $xml_val, 1)) - { - $errstr = sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser)); - error_log($errstr); - xml_parser_free($parser); - return false; - } - xml_parser_free($parser); - if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too??? - { - error_log($GLOBALS['_xh']['isf_reason']); - return false; - } - switch ($GLOBALS['_xh']['rt']) - { - case 'methodresponse': - $v =& $GLOBALS['_xh']['value']; - if ($GLOBALS['_xh']['isf'] == 1) - { - $vc = $v->structmem('faultCode'); - $vs = $v->structmem('faultString'); - $r =& new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval()); - } - else - { - $r =& new xmlrpcresp($v); - } - return $r; - case 'methodcall': - $m =& new xmlrpcmsg($GLOBALS['_xh']['method']); - for($i=0; $i < count($GLOBALS['_xh']['params']); $i++) - { - $m->addParam($GLOBALS['_xh']['params'][$i]); - } - return $m; - case 'value': - return $GLOBALS['_xh']['value']; - default: - return false; - } - } - - /** - * decode a string that is encoded w/ "chunked" transfer encoding - * as defined in rfc2068 par. 19.4.6 - * code shamelessly stolen from nusoap library by Dietrich Ayala - * - * @param string $buffer the string to be decoded - * @return string - */ - function decode_chunked($buffer) - { - // length := 0 - $length = 0; - $new = ''; - - // read chunk-size, chunk-extension (if any) and crlf - // get the position of the linebreak - $chunkend = strpos($buffer,"\r\n") + 2; - $temp = substr($buffer,0,$chunkend); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend; - while($chunk_size > 0) - { - $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size); - - // just in case we got a broken connection - if($chunkend == false) - { - $chunk = substr($buffer,$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - $length += strlen($chunk); - break; - } - - // read chunk-data and crlf - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - // length := length + chunk-size - $length += strlen($chunk); - // read chunk-size and crlf - $chunkstart = $chunkend + 2; - - $chunkend = strpos($buffer,"\r\n",$chunkstart)+2; - if($chunkend == false) - { - break; //just in case we got a broken connection - } - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend; - } - return $new; - } - - /** - * xml charset encoding guessing helper function. - * Tries to determine the charset encoding of an XML chunk received over HTTP. - * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type, - * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers, - * which will be most probably using UTF-8 anyway... - * - * @param string $httpheaders the http Content-type header - * @param string $xmlchunk xml content buffer - * @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled) - * - * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!! - */ - function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null) - { - // discussion: see http://www.yale.edu/pclt/encoding/ - // 1 - test if encoding is specified in HTTP HEADERS - - //Details: - // LWS: (\13\10)?( |\t)+ - // token: (any char but excluded stuff)+ - // quoted string: " (any char but double quotes and cointrol chars)* " - // header: Content-type = ...; charset=value(; ...)* - // where value is of type token, no LWS allowed between 'charset' and value - // Note: we do not check for invalid chars in VALUE: - // this had better be done using pure ereg as below - // Note 2: we might be removing whitespace/tabs that ought to be left in if - // the received charset is a quoted string. But nobody uses such charset names... - - /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it? - $matches = array(); - if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches)) - { - return strtoupper(trim($matches[1], " \t\"")); - } - - // 2 - scan the first bytes of the data for a UTF-16 (or other) BOM pattern - // (source: http://www.w3.org/TR/2000/REC-xml-20001006) - // NOTE: actually, according to the spec, even if we find the BOM and determine - // an encoding, we should check if there is an encoding specified - // in the xml declaration, and verify if they match. - /// @todo implement check as described above? - /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM) - if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk)) - { - return 'UCS-4'; - } - elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk)) - { - return 'UTF-16'; - } - elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) - { - return 'UTF-8'; - } - - // 3 - test if encoding is specified in the xml declaration - // Details: - // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ - // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* - if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", - $xmlchunk, $matches)) - { - return strtoupper(substr($matches[2], 1, -1)); - } - - // 4 - if mbstring is available, let it do the guesswork - // NB: we favour finding an encoding that is compatible with what we can process - if(extension_loaded('mbstring')) - { - if($encoding_prefs) - { - $enc = mb_detect_encoding($xmlchunk, $encoding_prefs); - } - else - { - $enc = mb_detect_encoding($xmlchunk); - } - // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... - // IANA also likes better US-ASCII, so go with it - if($enc == 'ASCII') - { - $enc = 'US-'.$enc; - } - return $enc; - } - else - { - // no encoding specified: as per HTTP1.1 assume it is iso-8859-1? - // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types - // this should be the standard. And we should be getting text/xml as request and response. - // BUT we have to be backward compatible with the lib, which always used UTF-8 as default... - return $GLOBALS['xmlrpc_defencoding']; - } - } - - /** - * Checks if a given charset encoding is present in a list of encodings or - * if it is a valid subset of any encoding in the list - * @param string $encoding charset to be tested - * @param mixed $validlist comma separated list of valid charsets (or array of charsets) - */ - function is_valid_charset($encoding, $validlist) - { - $charset_supersets = array( - 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', - 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', - 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12', - 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8', - 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN') - ); - if (is_string($validlist)) - $validlist = explode(',', $validlist); - if (@in_array(strtoupper($encoding), $validlist)) - return true; - else - { - if (array_key_exists($encoding, $charset_supersets)) - foreach ($validlist as $allowed) - if (in_array($allowed, $charset_supersets[$encoding])) - return true; - return false; - } - } - -?> diff --git a/core/class/web_service/lib/xmlrpc_wrappers.inc b/core/class/web_service/lib/xmlrpc_wrappers.inc deleted file mode 100755 index f0433a5bfe852512adeeccf6f83871580adfb88e..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/xmlrpc_wrappers.inc +++ /dev/null @@ -1,944 +0,0 @@ -<?php -/** - * PHP-XMLRPC "wrapper" functions - * Generate stubs to transparently access xmlrpc methods as php functions and viceversa - * - * @version $Id: xmlrpc_wrappers.inc,v 1.13 2008/09/20 01:23:47 ggiunta Exp $ - * @author Gaetano Giunta - * @copyright (C) 2006-2008 G. Giunta - * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt - * - * @todo separate introspection from code generation for func-2-method wrapping - * @todo use some better templating system for code generation? - * @todo implement method wrapping with preservation of php objs in calls - * @todo when wrapping methods without obj rebuilding, use return_type = 'phpvals' (faster) - * @todo implement self-parsing of php code for PHP <= 4 - */ - - // requires: xmlrpc.inc - - /** - * Given a string defining a php type or phpxmlrpc type (loosely defined: strings - * accepted come from javadoc blocks), return corresponding phpxmlrpc type. - * NB: for php 'resource' types returns empty string, since resources cannot be serialized; - * for php class names returns 'struct', since php objects can be serialized as xmlrpc structs - * @param string $phptype - * @return string - */ - function php_2_xmlrpc_type($phptype) - { - switch(strtolower($phptype)) - { - case 'string': - return $GLOBALS['xmlrpcString']; - case 'integer': - case $GLOBALS['xmlrpcInt']: // 'int' - case $GLOBALS['xmlrpcI4']: - return $GLOBALS['xmlrpcInt']; - case 'double': - return $GLOBALS['xmlrpcDouble']; - case 'boolean': - return $GLOBALS['xmlrpcBoolean']; - case 'array': - return $GLOBALS['xmlrpcArray']; - case 'object': - return $GLOBALS['xmlrpcStruct']; - case $GLOBALS['xmlrpcBase64']: - case $GLOBALS['xmlrpcStruct']: - return strtolower($phptype); - case 'resource': - return ''; - default: - if(class_exists($phptype)) - { - return $GLOBALS['xmlrpcStruct']; - } - else - { - // unknown: might be any 'extended' xmlrpc type - return $GLOBALS['xmlrpcValue']; - } - } - } - - /** - * Given a string defining a phpxmlrpc type return corresponding php type. - * @param string $xmlrpctype - * @return string - */ - function xmlrpc_2_php_type($xmlrpctype) - { - switch(strtolower($xmlrpctype)) - { - case 'base64': - case 'datetime.iso8601': - case 'string': - return $GLOBALS['xmlrpcString']; - case 'int': - case 'i4': - return 'integer'; - case 'struct': - case 'array': - return 'array'; - case 'double': - return 'float'; - case 'undefined': - return 'mixed'; - case 'boolean': - case 'null': - default: - // unknown: might be any xmlrpc type - return strtolower($xmlrpctype); - } - } - - /** - * Given a user-defined PHP function, create a PHP 'wrapper' function that can - * be exposed as xmlrpc method from an xmlrpc_server object and called from remote - * clients (as well as its corresponding signature info). - * - * Since php is a typeless language, to infer types of input and output parameters, - * it relies on parsing the javadoc-style comment block associated with the given - * function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64) - * in the @param tag is also allowed, if you need the php function to receive/send - * data in that particular format (note that base64 encoding/decoding is transparently - * carried out by the lib, while datetime vals are passed around as strings) - * - * Known limitations: - * - requires PHP 5.0.3 + - * - only works for user-defined functions, not for PHP internal functions - * (reflection does not support retrieving number/type of params for those) - * - functions returning php objects will generate special xmlrpc responses: - * when the xmlrpc decoding of those responses is carried out by this same lib, using - * the appropriate param in php_xmlrpc_decode, the php objects will be rebuilt. - * In short: php objects can be serialized, too (except for their resource members), - * using this function. - * Other libs might choke on the very same xml that will be generated in this case - * (i.e. it has a nonstandard attribute on struct element tags) - * - usage of javadoc @param tags using param names in a different order from the - * function prototype is not considered valid (to be fixed?) - * - * Note that since rel. 2.0RC3 the preferred method to have the server call 'standard' - * php functions (ie. functions not expecting a single xmlrpcmsg obj as parameter) - * is by making use of the functions_parameters_type class member. - * - * @param string $funcname the name of the PHP user function to be exposed as xmlrpc method; array($obj, 'methodname') and array('class', 'methodname') are ok too - * @param string $newfuncname (optional) name for function to be created - * @param array $extra_options (optional) array of options for conversion. valid values include: - * bool return_source when true, php code w. function definition will be returned, not evaluated - * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects - * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers --- - * bool suppress_warnings remove from produced xml any runtime warnings due to the php function being invoked - * @return false on error, or an array containing the name of the new php function, - * its signature and docs, to be used in the server dispatch map - * - * @todo decide how to deal with params passed by ref: bomb out or allow? - * @todo finish using javadoc info to build method sig if all params are named but out of order - * @todo add a check for params of 'resource' type - * @todo add some trigger_errors / error_log when returning false? - * @todo what to do when the PHP function returns NULL? we are currently returning an empty string value... - * @todo add an option to suppress php warnings in invocation of user function, similar to server debug level 3? - * @todo if $newfuncname is empty, we could use create_user_func instead of eval, as it is possibly faster - * @todo add a verbatim_object_copy parameter to allow avoiding the same obj instance? - */ - function wrap_php_function($funcname, $newfuncname='', $extra_options=array()) - { - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $catch_warnings = isset($extra_options['suppress_warnings']) && $extra_options['suppress_warnings'] ? '@' : ''; - - if(version_compare(phpversion(), '5.0.3') == -1) - { - // up to php 5.0.3 some useful reflection methods were missing - error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3'); - return false; - } - - $exists = false; - if(is_array($funcname)) - { - if(count($funcname) < 2 || (!is_string($funcname[0]) && !is_object($funcname[0]))) - { - error_log('XML-RPC: syntax for function to be wrapped is wrong'); - return false; - } - if(is_string($funcname[0])) - { - $plainfuncname = implode('::', $funcname); - } - elseif(is_object($funcname[0])) - { - $plainfuncname = get_class($funcname[0]) . '->' . $funcname[1]; - } - $exists = method_exists($funcname[0], $funcname[1]); - } - else - { - $plainfuncname = $funcname; - $exists = function_exists($funcname); - } - - if(!$exists) - { - error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname); - return false; - } - else - { - // determine name of new php function - if($newfuncname == '') - { - if(is_array($funcname)) - { - if(is_string($funcname[0])) - $xmlrpcfuncname = "{$prefix}_".implode('_', $funcname); - else - $xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1]; - } - else - { - $xmlrpcfuncname = "{$prefix}_$funcname"; - } - } - else - { - $xmlrpcfuncname = $newfuncname; - } - while($buildit && function_exists($xmlrpcfuncname)) - { - $xmlrpcfuncname .= 'x'; - } - - // start to introspect PHP code - if(is_array($funcname)) - { - $func =& new ReflectionMethod($funcname[0], $funcname[1]); - if($func->isPrivate()) - { - error_log('XML-RPC: method to be wrapped is private: '.$plainfuncname); - return false; - } - if($func->isProtected()) - { - error_log('XML-RPC: method to be wrapped is protected: '.$plainfuncname); - return false; - } - if($func->isConstructor()) - { - error_log('XML-RPC: method to be wrapped is the constructor: '.$plainfuncname); - return false; - } - if($func->isDestructor()) - { - error_log('XML-RPC: method to be wrapped is the destructor: '.$plainfuncname); - return false; - } - if($func->isAbstract()) - { - error_log('XML-RPC: method to be wrapped is abstract: '.$plainfuncname); - return false; - } - /// @todo add more checks for static vs. nonstatic? - } - else - { - $func =& new ReflectionFunction($funcname); - } - if($func->isInternal()) - { - // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs - // instead of getparameters to fully reflect internal php functions ? - error_log('XML-RPC: function to be wrapped is internal: '.$plainfuncname); - return false; - } - - // retrieve parameter names, types and description from javadoc comments - - // function description - $desc = ''; - // type of return val: by default 'any' - $returns = $GLOBALS['xmlrpcValue']; - // desc of return val - $returnsDocs = ''; - // type + name of function parameters - $paramDocs = array(); - - $docs = $func->getDocComment(); - if($docs != '') - { - $docs = explode("\n", $docs); - $i = 0; - foreach($docs as $doc) - { - $doc = trim($doc, " \r\t/*"); - if(strlen($doc) && strpos($doc, '@') !== 0 && !$i) - { - if($desc) - { - $desc .= "\n"; - } - $desc .= $doc; - } - elseif(strpos($doc, '@param') === 0) - { - // syntax: @param type [$name] desc - if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) - { - if(strpos($matches[1], '|')) - { - //$paramDocs[$i]['type'] = explode('|', $matches[1]); - $paramDocs[$i]['type'] = 'mixed'; - } - else - { - $paramDocs[$i]['type'] = $matches[1]; - } - $paramDocs[$i]['name'] = trim($matches[2]); - $paramDocs[$i]['doc'] = $matches[3]; - } - $i++; - } - elseif(strpos($doc, '@return') === 0) - { - // syntax: @return type desc - //$returns = preg_split('/\s+/', $doc); - if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) - { - $returns = php_2_xmlrpc_type($matches[1]); - if(isset($matches[2])) - { - $returnsDocs = $matches[2]; - } - } - } - } - } - - // execute introspection of actual function prototype - $params = array(); - $i = 0; - foreach($func->getParameters() as $paramobj) - { - $params[$i] = array(); - $params[$i]['name'] = '$'.$paramobj->getName(); - $params[$i]['isoptional'] = $paramobj->isOptional(); - $i++; - } - - - // start building of PHP code to be eval'd - $innercode = ''; - $i = 0; - $parsvariations = array(); - $pars = array(); - $pnum = count($params); - foreach($params as $param) - { - if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name'])) - { - // param name from phpdoc info does not match param definition! - $paramDocs[$i]['type'] = 'mixed'; - } - - if($param['isoptional']) - { - // this particular parameter is optional. save as valid previous list of parameters - $innercode .= "if (\$paramcount > $i) {\n"; - $parsvariations[] = $pars; - } - $innercode .= "\$p$i = \$msg->getParam($i);\n"; - if ($decode_php_objects) - { - $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n"; - } - else - { - $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n"; - } - - $pars[] = "\$p$i"; - $i++; - if($param['isoptional']) - { - $innercode .= "}\n"; - } - if($i == $pnum) - { - // last allowed parameters combination - $parsvariations[] = $pars; - } - } - - $sigs = array(); - $psigs = array(); - if(count($parsvariations) == 0) - { - // only known good synopsis = no parameters - $parsvariations[] = array(); - $minpars = 0; - } - else - { - $minpars = count($parsvariations[0]); - } - - if($minpars) - { - // add to code the check for min params number - // NB: this check needs to be done BEFORE decoding param values - $innercode = "\$paramcount = \$msg->getNumParams();\n" . - "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode; - } - else - { - $innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode; - } - - $innercode .= "\$np = false;\n"; - // since there are no closures in php, if we are given an object instance, - // we store a pointer to it in a global var... - if ( is_array($funcname) && is_object($funcname[0]) ) - { - $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0]; - $innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n"; - $realfuncname = '$obj->'.$funcname[1]; - } - else - { - $realfuncname = $plainfuncname; - } - foreach($parsvariations as $pars) - { - $innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$realfuncname(" . implode(',', $pars) . "); else\n"; - // build a 'generic' signature (only use an appropriate return type) - $sig = array($returns); - $psig = array($returnsDocs); - for($i=0; $i < count($pars); $i++) - { - if (isset($paramDocs[$i]['type'])) - { - $sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']); - } - else - { - $sig[] = $GLOBALS['xmlrpcValue']; - } - $psig[] = isset($paramDocs[$i]['doc']) ? $paramDocs[$i]['doc'] : ''; - } - $sigs[] = $sig; - $psigs[] = $psig; - } - $innercode .= "\$np = true;\n"; - $innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n"; - //$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n"; - $innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n"; - if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) - { - $innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));"; - } - else - { - if ($encode_php_objects) - $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n"; - else - $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n"; - } - // shall we exclude functions returning by ref? - // if($func->returnsReference()) - // return false; - $code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}"; - //print_r($code); - if ($buildit) - { - $allOK = 0; - eval($code.'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - - if(!$allOK) - { - error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$plainfuncname); - return false; - } - } - - /// @todo examine if $paramDocs matches $parsvariations and build array for - /// usage as method signature, plus put together a nice string for docs - - $ret = array('function' => $xmlrpcfuncname, 'signature' => $sigs, 'docstring' => $desc, 'signature_docs' => $psigs, 'source' => $code); - return $ret; - } - } - - /** - * Given a user-defined PHP class or php object, map its methods onto a list of - * PHP 'wrapper' functions that can be exposed as xmlrpc methods from an xmlrpc_server - * object and called from remote clients (as well as their corresponding signature info). - * - * @param mixed $classname the name of the class whose methods are to be exposed as xmlrpc methods, or an object instance of that class - * @param array $extra_options see the docs for wrap_php_method for more options - * string method_type 'static', 'nonstatic', 'all' and 'auto' (default); the latter will switch between static and non-static depending on wheter $classname is a class name or object instance - * @return array or false on failure - * - * @todo get_class_methods will return both static and non-static methods. - * we have to differentiate the action, depending on wheter we recived a class name or object - */ - function wrap_php_class($classname, $extra_options=array()) - { - $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; - $methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto'; - - if(version_compare(phpversion(), '5.0.3') == -1) - { - // up to php 5.0.3 some useful reflection methods were missing - error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3'); - return false; - } - - $result = array(); - $mlist = get_class_methods($classname); - foreach($mlist as $mname) - { - if ($methodfilter == '' || preg_match($methodfilter, $mname)) - { - // echo $mlist."\n"; - $func =& new ReflectionMethod($classname, $mname); - if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) - { - if(($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) || - (!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname))))) - { - $methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options); - if ( $methodwrap ) - { - $result[$methodwrap['function']] = $methodwrap['function']; - } - } - } - } - } - return $result; - } - - /** - * Given an xmlrpc client and a method name, register a php wrapper function - * that will call it and return results using native php types for both - * params and results. The generated php function will return an xmlrpcresp - * oject for failed xmlrpc calls - * - * Known limitations: - * - server must support system.methodsignature for the wanted xmlrpc method - * - for methods that expose many signatures, only one can be picked (we - * could in priciple check if signatures differ only by number of params - * and not by type, but it would be more complication than we can spare time) - * - nested xmlrpc params: the caller of the generated php function has to - * encode on its own the params passed to the php function if these are structs - * or arrays whose (sub)members include values of type datetime or base64 - * - * Notes: the connection properties of the given client will be copied - * and reused for the connection used during the call to the generated - * php function. - * Calling the generated php function 'might' be slow: a new xmlrpc client - * is created on every invocation and an xmlrpc-connection opened+closed. - * An extra 'debug' param is appended to param list of xmlrpc method, useful - * for debugging purposes. - * - * @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server - * @param string $methodname the xmlrpc method to be mapped to a php function - * @param array $extra_options array of options that specify conversion details. valid ptions include - * integer signum the index of the method signature to use in mapping (if method exposes many sigs) - * integer timeout timeout (in secs) to be used when executing function/calling remote method - * string protocol 'http' (default), 'http11' or 'https' - * string new_function_name the name of php function to create. If unsepcified, lib will pick an appropriate name - * string return_source if true return php code w. function definition instead fo function name - * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects - * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers --- - * mixed return_on_fault a php value to be returned when the xmlrpc call fails/returns a fault response (by default the xmlrpcresp object is returned in this case). If a string is used, '%faultCode%' and '%faultString%' tokens will be substituted with actual error values - * bool debug set it to 1 or 2 to see debug results of querying server for method synopsis - * @return string the name of the generated php function (or false) - OR AN ARRAY... - */ - function wrap_xmlrpc_method($client, $methodname, $extra_options=0, $timeout=0, $protocol='', $newfuncname='') - { - // mind numbing: let caller use sane calling convention (as per javadoc, 3 params), - // OR the 2.0 calling convention (no options) - we really love backward compat, don't we? - if (!is_array($extra_options)) - { - $signum = $extra_options; - $extra_options = array(); - } - else - { - $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; - $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; - $newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : ''; - } - //$encode_php_objects = in_array('encode_php_objects', $extra_options); - //$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 : - // in_array('build_class_code', $extra_options) ? 2 : 0; - - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0; - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - if (isset($extra_options['return_on_fault'])) - { - $decode_fault = true; - $fault_response = $extra_options['return_on_fault']; - } - else - { - $decode_fault = false; - $fault_response = ''; - } - $debug = isset($extra_options['debug']) ? ($extra_options['debug']) : 0; - - $msgclass = $prefix.'msg'; - $valclass = $prefix.'val'; - $decodefunc = 'php_'.$prefix.'_decode'; - - $msg =& new $msgclass('system.methodSignature'); - $msg->addparam(new $valclass($methodname)); - $client->setDebug($debug); - $response =& $client->send($msg, $timeout, $protocol); - if($response->faultCode()) - { - error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname); - return false; - } - else - { - $msig = $response->value(); - if ($client->return_type != 'phpvals') - { - $msig = $decodefunc($msig); - } - if(!is_array($msig) || count($msig) <= $signum) - { - error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname); - return false; - } - else - { - // pick a suitable name for the new function, avoiding collisions - if($newfuncname != '') - { - $xmlrpcfuncname = $newfuncname; - } - else - { - // take care to insure that methodname is translated to valid - // php function name - $xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $methodname); - } - while($buildit && function_exists($xmlrpcfuncname)) - { - $xmlrpcfuncname .= 'x'; - } - - $msig = $msig[$signum]; - $mdesc = ''; - // if in 'offline' mode, get method description too. - // in online mode, favour speed of operation - if(!$buildit) - { - $msg =& new $msgclass('system.methodHelp'); - $msg->addparam(new $valclass($methodname)); - $response =& $client->send($msg, $timeout, $protocol); - if (!$response->faultCode()) - { - $mdesc = $response->value(); - if ($client->return_type != 'phpvals') - { - $mdesc = $mdesc->scalarval(); - } - } - } - - $results = build_remote_method_wrapper_code($client, $methodname, - $xmlrpcfuncname, $msig, $mdesc, $timeout, $protocol, $simple_client_copy, - $prefix, $decode_php_objects, $encode_php_objects, $decode_fault, - $fault_response); - - //print_r($code); - if ($buildit) - { - $allOK = 0; - eval($results['source'].'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - if($allOK) - { - return $xmlrpcfuncname; - } - else - { - error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname); - return false; - } - } - else - { - $results['function'] = $xmlrpcfuncname; - return $results; - } - } - } - } - - /** - * Similar to wrap_xmlrpc_method, but will generate a php class that wraps - * all xmlrpc methods exposed by the remote server as own methods. - * For more details see wrap_xmlrpc_method. - * @param xmlrpc_client $client the client obj all set to query the desired server - * @param array $extra_options list of options for wrapped code - * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options) - */ - function wrap_xmlrpc_server($client, $extra_options=array()) - { - $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; - //$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; - $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; - $newclassname = isset($extra_options['new_class_name']) ? $extra_options['new_class_name'] : ''; - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; - $verbatim_client_copy = isset($extra_options['simple_client_copy']) ? !($extra_options['simple_client_copy']) : true; - $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; - $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; - - $msgclass = $prefix.'msg'; - //$valclass = $prefix.'val'; - $decodefunc = 'php_'.$prefix.'_decode'; - - $msg =& new $msgclass('system.listMethods'); - $response =& $client->send($msg, $timeout, $protocol); - if($response->faultCode()) - { - error_log('XML-RPC: could not retrieve method list from remote server'); - return false; - } - else - { - $mlist = $response->value(); - if ($client->return_type != 'phpvals') - { - $mlist = $decodefunc($mlist); - } - if(!is_array($mlist) || !count($mlist)) - { - error_log('XML-RPC: could not retrieve meaningful method list from remote server'); - return false; - } - else - { - // pick a suitable name for the new function, avoiding collisions - if($newclassname != '') - { - $xmlrpcclassname = $newclassname; - } - else - { - $xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $client->server).'_client'; - } - while($buildit && class_exists($xmlrpcclassname)) - { - $xmlrpcclassname .= 'x'; - } - - /// @todo add function setdebug() to new class, to enable/disable debugging - $source = "class $xmlrpcclassname\n{\nvar \$client;\n\n"; - $source .= "function $xmlrpcclassname()\n{\n"; - $source .= build_client_wrapper_code($client, $verbatim_client_copy, $prefix); - $source .= "\$this->client =& \$client;\n}\n\n"; - $opts = array('simple_client_copy' => 2, 'return_source' => true, - 'timeout' => $timeout, 'protocol' => $protocol, - 'encode_php_objs' => $encode_php_objects, 'prefix' => $prefix, - 'decode_php_objs' => $decode_php_objects - ); - /// @todo build javadoc for class definition, too - foreach($mlist as $mname) - { - if ($methodfilter == '' || preg_match($methodfilter, $mname)) - { - $opts['new_function_name'] = preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), - array('_', ''), $mname); - $methodwrap = wrap_xmlrpc_method($client, $mname, $opts); - if ($methodwrap) - { - if (!$buildit) - { - $source .= $methodwrap['docstring']; - } - $source .= $methodwrap['source']."\n"; - } - else - { - error_log('XML-RPC: will not create class method to wrap remote method '.$mname); - } - } - } - $source .= "}\n"; - if ($buildit) - { - $allOK = 0; - eval($source.'$allOK=1;'); - // alternative - //$xmlrpcfuncname = create_function('$m', $innercode); - if($allOK) - { - return $xmlrpcclassname; - } - else - { - error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server); - return false; - } - } - else - { - return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => ''); - } - } - } - } - - /** - * Given the necessary info, build php code that creates a new function to - * invoke a remote xmlrpc method. - * Take care that no full checking of input parameters is done to ensure that - * valid php code is emitted. - * Note: real spaghetti code follows... - * @access private - */ - function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname, - $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc', - $decode_php_objects=false, $encode_php_objects=false, $decode_fault=false, - $fault_response='') - { - $code = "function $xmlrpcfuncname ("; - if ($client_copy_mode < 2) - { - // client copy mode 0 or 1 == partial / full client copy in emitted code - $innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix); - $innercode .= "\$client->setDebug(\$debug);\n"; - $this_ = ''; - } - else - { - // client copy mode 2 == no client copy in emitted code - $innercode = ''; - $this_ = 'this->'; - } - $innercode .= "\$msg =& new {$prefix}msg('$methodname');\n"; - - if ($mdesc != '') - { - // take care that PHP comment is not terminated unwillingly by method description - $mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n"; - } - else - { - $mdesc = "/**\nFunction $xmlrpcfuncname\n"; - } - - // param parsing - $plist = array(); - $pcount = count($msig); - for($i = 1; $i < $pcount; $i++) - { - $plist[] = "\$p$i"; - $ptype = $msig[$i]; - if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' || - $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null') - { - // only build directly xmlrpcvals when type is known and scalar - $innercode .= "\$p$i =& new {$prefix}val(\$p$i, '$ptype');\n"; - } - else - { - if ($encode_php_objects) - { - $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n"; - } - else - { - $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n"; - } - } - $innercode .= "\$msg->addparam(\$p$i);\n"; - $mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n"; - } - if ($client_copy_mode < 2) - { - $plist[] = '$debug=0'; - $mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; - } - $plist = implode(', ', $plist); - $mdesc .= '* @return '.xmlrpc_2_php_type($msig[0])." (or an {$prefix}resp obj instance if call fails)\n*/\n"; - - $innercode .= "\$res =& \${$this_}client->send(\$msg, $timeout, '$protocol');\n"; - if ($decode_fault) - { - if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false))) - { - $respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')"; - } - else - { - $respcode = var_export($fault_response, true); - } - } - else - { - $respcode = '$res'; - } - if ($decode_php_objects) - { - $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));"; - } - else - { - $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());"; - } - - $code = $code . $plist. ") {\n" . $innercode . "\n}\n"; - - return array('source' => $code, 'docstring' => $mdesc); - } - - /** - * Given necessary info, generate php code that will rebuild a client object - * Take care that no full checking of input parameters is done to ensure that - * valid php code is emitted. - * @access private - */ - function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc') - { - $code = "\$client =& new {$prefix}_client('".str_replace("'", "\'", $client->path). - "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n"; - - // copy all client fields to the client that will be generated runtime - // (this provides for future expansion or subclassing of client obj) - if ($verbatim_client_copy) - { - foreach($client as $fld => $val) - { - if($fld != 'debug' && $fld != 'return_type') - { - $val = var_export($val, true); - $code .= "\$client->{$fld} = $val;\n"; - } - } - } - // only make sure that client always returns the correct data type - $code .= "\$client->return_type = '{$prefix}vals';\n"; - //$code .= "\$client->setDebug(\$debug);\n"; - return $code; - } -?> \ No newline at end of file diff --git a/core/class/web_service/lib/xmlrpcs.inc b/core/class/web_service/lib/xmlrpcs.inc deleted file mode 100755 index 423daa7d1312248b7242161d6b9ab93c2bbcff5b..0000000000000000000000000000000000000000 --- a/core/class/web_service/lib/xmlrpcs.inc +++ /dev/null @@ -1,1198 +0,0 @@ -<?php -// by Edd Dumbill (C) 1999-2002 -// <edd@usefulinc.com> -// $Id: xmlrpcs.inc,v 1.71 2008/10/29 23:41:28 ggiunta Exp $ - -// Copyright (c) 1999,2000,2002 Edd Dumbill. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of the "XML-RPC for PHP" nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - - // XML RPC Server class - // requires: xmlrpc.inc - - $GLOBALS['xmlrpcs_capabilities'] = array( - // xmlrpc spec: always supported - 'xmlrpc' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/spec', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'), - // if we support system.xxx functions, we always support multicall, too... - // Note that, as of 2006/09/17, the following URL does not respond anymore - 'system.multicall' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'), - // introspection: version 2! we support 'mixed', too - 'introspection' => new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'), - 'specVersion' => new xmlrpcval(2, 'int') - ), 'struct') - ); - - /* Functions that implement system.XXX methods of xmlrpc servers */ - $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); - $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; - $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); - function _xmlrpcs_getCapabilities($server, $m=null) - { - $outAr = $GLOBALS['xmlrpcs_capabilities']; - // NIL extension - if ($GLOBALS['xmlrpc_null_extension']) { - $outAr['nil'] = new xmlrpcval(array( - 'specUrl' => new xmlrpcval('http://www.ontosys.com/xml-rpc/extensions.php', 'string'), - 'specVersion' => new xmlrpcval(1, 'int') - ), 'struct'); - } - return new xmlrpcresp(new xmlrpcval($outAr, 'struct')); - } - - // listMethods: signature was either a string, or nothing. - // The useless string variant has been removed - $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); - $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; - $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); - function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing - { - - $outAr=array(); - foreach($server->dmap as $key => $val) - { - $outAr[]=&new xmlrpcval($key, 'string'); - } - if($server->allow_system_funcs) - { - foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) - { - $outAr[]=&new xmlrpcval($key, 'string'); - } - } - return new xmlrpcresp(new xmlrpcval($outAr, 'array')); - } - - $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); - $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; - $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); - function _xmlrpcs_methodSignature($server, $m) - { - // let accept as parameter both an xmlrpcval or string - if (is_object($m)) - { - $methName=$m->getParam(0); - $methName=$methName->scalarval(); - } - else - { - $methName=$m; - } - if(strpos($methName, "system.") === 0) - { - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; - } - else - { - $dmap=$server->dmap; $sysCall=0; - } - if(isset($dmap[$methName])) - { - if(isset($dmap[$methName]['signature'])) - { - $sigs=array(); - foreach($dmap[$methName]['signature'] as $inSig) - { - $cursig=array(); - foreach($inSig as $sig) - { - $cursig[]=&new xmlrpcval($sig, 'string'); - } - $sigs[]=&new xmlrpcval($cursig, 'array'); - } - $r=&new xmlrpcresp(new xmlrpcval($sigs, 'array')); - } - else - { - // NB: according to the official docs, we should be returning a - // "none-array" here, which means not-an-array - $r=&new xmlrpcresp(new xmlrpcval('undef', 'string')); - } - } - else - { - $r=&new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); - } - return $r; - } - - $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); - $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; - $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); - function _xmlrpcs_methodHelp($server, $m) - { - // let accept as parameter both an xmlrpcval or string - if (is_object($m)) - { - $methName=$m->getParam(0); - $methName=$methName->scalarval(); - } - else - { - $methName=$m; - } - if(strpos($methName, "system.") === 0) - { - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; - } - else - { - $dmap=$server->dmap; $sysCall=0; - } - if(isset($dmap[$methName])) - { - if(isset($dmap[$methName]['docstring'])) - { - $r=&new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); - } - else - { - $r=&new xmlrpcresp(new xmlrpcval('', 'string')); - } - } - else - { - $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); - } - return $r; - } - - $_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray'])); - $_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details'; - $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); - function _xmlrpcs_multicall_error($err) - { - if(is_string($err)) - { - $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; - $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; - } - else - { - $code = $err->faultCode(); - $str = $err->faultString(); - } - $struct = array(); - $struct['faultCode'] =& new xmlrpcval($code, 'int'); - $struct['faultString'] =& new xmlrpcval($str, 'string'); - return new xmlrpcval($struct, 'struct'); - } - - function _xmlrpcs_multicall_do_call($server, $call) - { - if($call->kindOf() != 'struct') - { - return _xmlrpcs_multicall_error('notstruct'); - } - $methName = @$call->structmem('methodName'); - if(!$methName) - { - return _xmlrpcs_multicall_error('nomethod'); - } - if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') - { - return _xmlrpcs_multicall_error('notstring'); - } - if($methName->scalarval() == 'system.multicall') - { - return _xmlrpcs_multicall_error('recursion'); - } - - $params = @$call->structmem('params'); - if(!$params) - { - return _xmlrpcs_multicall_error('noparams'); - } - if($params->kindOf() != 'array') - { - return _xmlrpcs_multicall_error('notarray'); - } - $numParams = $params->arraysize(); - - $msg =& new xmlrpcmsg($methName->scalarval()); - for($i = 0; $i < $numParams; $i++) - { - if(!$msg->addParam($params->arraymem($i))) - { - $i++; - return _xmlrpcs_multicall_error(new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['incorrect_params'], - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); - } - } - - $result = $server->execute($msg); - - if($result->faultCode() != 0) - { - return _xmlrpcs_multicall_error($result); // Method returned fault. - } - - return new xmlrpcval(array($result->value()), 'array'); - } - - function _xmlrpcs_multicall_do_call_phpvals($server, $call) - { - if(!is_array($call)) - { - return _xmlrpcs_multicall_error('notstruct'); - } - if(!array_key_exists('methodName', $call)) - { - return _xmlrpcs_multicall_error('nomethod'); - } - if (!is_string($call['methodName'])) - { - return _xmlrpcs_multicall_error('notstring'); - } - if($call['methodName'] == 'system.multicall') - { - return _xmlrpcs_multicall_error('recursion'); - } - if(!array_key_exists('params', $call)) - { - return _xmlrpcs_multicall_error('noparams'); - } - if(!is_array($call['params'])) - { - return _xmlrpcs_multicall_error('notarray'); - } - - // this is a real dirty and simplistic hack, since we might have received a - // base64 or datetime values, but they will be listed as strings here... - $numParams = count($call['params']); - $pt = array(); - foreach($call['params'] as $val) - $pt[] = php_2_xmlrpc_type(gettype($val)); - - $result = $server->execute($call['methodName'], $call['params'], $pt); - - if($result->faultCode() != 0) - { - return _xmlrpcs_multicall_error($result); // Method returned fault. - } - - return new xmlrpcval(array($result->value()), 'array'); - } - - function _xmlrpcs_multicall($server, $m) - { - $result = array(); - // let accept a plain list of php parameters, beside a single xmlrpc msg object - if (is_object($m)) - { - $calls = $m->getParam(0); - $numCalls = $calls->arraysize(); - for($i = 0; $i < $numCalls; $i++) - { - $call = $calls->arraymem($i); - $result[$i] = _xmlrpcs_multicall_do_call($server, $call); - } - } - else - { - $numCalls=count($m); - for($i = 0; $i < $numCalls; $i++) - { - $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); - } - } - - return new xmlrpcresp(new xmlrpcval($result, 'array')); - } - - $GLOBALS['_xmlrpcs_dmap']=array( - 'system.listMethods' => array( - 'function' => '_xmlrpcs_listMethods', - 'signature' => $_xmlrpcs_listMethods_sig, - 'docstring' => $_xmlrpcs_listMethods_doc, - 'signature_docs' => $_xmlrpcs_listMethods_sdoc), - 'system.methodHelp' => array( - 'function' => '_xmlrpcs_methodHelp', - 'signature' => $_xmlrpcs_methodHelp_sig, - 'docstring' => $_xmlrpcs_methodHelp_doc, - 'signature_docs' => $_xmlrpcs_methodHelp_sdoc), - 'system.methodSignature' => array( - 'function' => '_xmlrpcs_methodSignature', - 'signature' => $_xmlrpcs_methodSignature_sig, - 'docstring' => $_xmlrpcs_methodSignature_doc, - 'signature_docs' => $_xmlrpcs_methodSignature_sdoc), - 'system.multicall' => array( - 'function' => '_xmlrpcs_multicall', - 'signature' => $_xmlrpcs_multicall_sig, - 'docstring' => $_xmlrpcs_multicall_doc, - 'signature_docs' => $_xmlrpcs_multicall_sdoc), - 'system.getCapabilities' => array( - 'function' => '_xmlrpcs_getCapabilities', - 'signature' => $_xmlrpcs_getCapabilities_sig, - 'docstring' => $_xmlrpcs_getCapabilities_doc, - 'signature_docs' => $_xmlrpcs_getCapabilities_sdoc) - ); - - $GLOBALS['_xmlrpcs_occurred_errors'] = ''; - $GLOBALS['_xmlrpcs_prev_ehandler'] = ''; - /** - * Error handler used to track errors that occur during server-side execution of PHP code. - * This allows to report back to the client whether an internal error has occurred or not - * using an xmlrpc response object, instead of letting the client deal with the html junk - * that a PHP execution error on the server generally entails. - * - * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors. - * - */ - function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) - { - // obey the @ protocol - if (error_reporting() == 0) - return; - - //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING) - if($errcode != 2048) // do not use E_STRICT by name, since on PHP 4 it will not be defined - { - $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; - } - // Try to avoid as much as possible disruption to the previous error handling - // mechanism in place - if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') - { - // The previous error handler was the default: all we should do is log error - // to the default error log (if level high enough) - if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) - { - error_log($errstring); - } - } - else - { - // Pass control on to previous error handler, trying to avoid loops... - if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') - { - // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers - if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) - { - // the following works both with static class methods and plain object methods as error handler - call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); - } - else - { - $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context); - } - } - } - } - - $GLOBALS['_xmlrpc_debuginfo']=''; - - /** - * Add a string to the debug info that can be later seralized by the server - * as part of the response message. - * Note that for best compatbility, the debug string should be encoded using - * the $GLOBALS['xmlrpc_internalencoding'] character set. - * @param string $m - * @access public - */ - function xmlrpc_debugmsg($m) - { - $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; - } - - class xmlrpc_server - { - /// array defining php functions exposed as xmlrpc methods by this server - var $dmap=array(); - /** - * Defines how functions in dmap will be invokde: either using an xmlrpc msg object - * or plain php values. - * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' - */ - var $functions_parameters_type='xmlrpcvals'; - /// controls wether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3 - var $debug = 1; - /** - * When set to true, it will enable HTTP compression of the response, in case - * the client has declared its support for compression in the request. - */ - var $compress_response = false; - /** - * List of http compression methods accepted by the server for requests. - * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib - */ - var $accepted_compression = array(); - /// shall we serve calls to system.* methods? - var $allow_system_funcs = true; - /// list of charset encodings natively accepted for requests - var $accepted_charset_encodings = array(); - /** - * charset encoding to be used for response. - * NB: if we can, we will convert the generated response from internal_encoding to the intended one. - * can be: a supported xml encoding (only UTF-8 and ISO-8859-1 at present, unless mbstring is enabled), - * null (leave unspecified in response, convert output stream to US_ASCII), - * 'default' (use xmlrpc library default as specified in xmlrpc.inc, convert output stream if needed), - * or 'auto' (use client-specified charset encoding or same as request if request headers do not specify it (unless request is US-ASCII: then use library default anyway). - * NB: pretty dangerous if you accept every charset and do not have mbstring enabled) - */ - var $response_charset_encoding = ''; - /// storage for internal debug info - var $debug_info = ''; - /// extra data passed at runtime to method handling functions. Used only by EPI layer - var $user_data = null; - - /** - * @param array $dispmap the dispatch map withd efinition of exposed services - * @param boolean $servicenow set to false to prevent the server from runnung upon construction - */ - function xmlrpc_server($dispMap=null, $serviceNow=true) - { - // if ZLIB is enabled, let the server by default accept compressed requests, - // and compress responses sent to clients that support them - if(function_exists('gzinflate')) - { - $this->accepted_compression = array('gzip', 'deflate'); - $this->compress_response = true; - } - - // by default the xml parser can support these 3 charset encodings - $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); - - // dispMap is a dispatch array of methods - // mapped to function names and signatures - // if a method - // doesn't appear in the map then an unknown - // method error is generated - /* milosch - changed to make passing dispMap optional. - * instead, you can use the class add_to_map() function - * to add functions manually (borrowed from SOAPX4) - */ - if($dispMap) - { - $this->dmap = $dispMap; - if($serviceNow) - { - $this->service(); - } - } - } - - /** - * Set debug level of server. - * @param integer $in debug lvl: determines info added to xmlrpc responses (as xml comments) - * 0 = no debug info, - * 1 = msgs set from user with debugmsg(), - * 2 = add complete xmlrpc request (headers and body), - * 3 = add also all processing warnings happened during method processing - * (NB: this involves setting a custom error handler, and might interfere - * with the standard processing of the php function exposed as method. In - * particular, triggering an USER_ERROR level error will not halt script - * execution anymore, but just end up logged in the xmlrpc response) - * Note that info added at elevel 2 and 3 will be base64 encoded - * @access public - */ - function setDebug($in) - { - $this->debug=$in; - } - - /** - * Return a string with the serialized representation of all debug info - * @param string $charset_encoding the target charset encoding for the serialization - * @return string an XML comment (or two) - */ - function serializeDebug($charset_encoding='') - { - // Tough encoding problem: which internal charset should we assume for debug info? - // It might contain a copy of raw data received from client, ie with unknown encoding, - // intermixed with php generated data and user generated data... - // so we split it: system debug is base 64 encoded, - // user debug info should be encoded by the end user using the INTERNAL_ENCODING - $out = ''; - if ($this->debug_info != '') - { - $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; - } - if($GLOBALS['_xmlrpc_debuginfo']!='') - { - - $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; - // NB: a better solution MIGHT be to use CDATA, but we need to insert it - // into return payload AFTER the beginning tag - //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; - } - return $out; - } - - /** - * Execute the xmlrpc request, printing the response - * @param string $data the request body. If null, the http POST request will be examined - * @return xmlrpcresp the response object (usually not used by caller...) - * @access public - */ - function service($data=null, $return_payload=false) - { - if ($data === null) - { - // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA - $ver = phpversion(); - if ($ver[0] >= 5) - { - $data = file_get_contents('php://input'); - } - else - { - $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; - } - } - $raw_data = $data; - - // reset internal debug info - $this->debug_info = ''; - - // Echo back what we received, before parsing it - if($this->debug > 1) - { - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); - } - - $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); - if (!$r) - { - $r=$this->parseRequest($data, $req_charset); - } - - // save full body of request into response, for more debugging usages - $r->raw_data = $raw_data; - - if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) - { - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . - $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); - } - - $payload=$this->xml_header($resp_charset); - if($this->debug > 0) - { - $payload = $payload . $this->serializeDebug($resp_charset); - } - - // G. Giunta 2006-01-27: do not create response serialization if it has - // already happened. Helps building json magic - if (empty($r->payload)) - { - $r->serialize($resp_charset); - } - $payload = $payload . $r->payload; - - if ($return_payload) - { - return $payload; - } - - // if we get a warning/error that has output some text before here, then we cannot - // add a new header. We cannot say we are sending xml, either... - if(!headers_sent()) - { - header('Content-Type: '.$r->content_type); - // we do not know if client actually told us an accepted charset, but if he did - // we have to tell him what we did - header("Vary: Accept-Charset"); - - // http compression of output: only - // if we can do it, and we want to do it, and client asked us to, - // and php ini settings do not force it already - $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); - if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' - && $php_no_self_compress) - { - if(strpos($resp_encoding, 'gzip') !== false) - { - $payload = gzencode($payload); - header("Content-Encoding: gzip"); - header("Vary: Accept-Encoding"); - } - elseif (strpos($resp_encoding, 'deflate') !== false) - { - $payload = gzcompress($payload); - header("Content-Encoding: deflate"); - header("Vary: Accept-Encoding"); - } - } - - // do not ouput content-length header if php is compressing output for us: - // it will mess up measurements - if($php_no_self_compress) - { - header('Content-Length: ' . (int)strlen($payload)); - } - } - else - { - error_log('XML-RPC: xmlrpc_server::service: http headers already sent before response is fully generated. Check for php warning or error messages'); - } - - print $payload; - - // return request, in case subclasses want it - return $r; - } - - /** - * Add a method to the dispatch map - * @param string $methodname the name with which the method will be made available - * @param string $function the php function that will get invoked - * @param array $sig the array of valid method signatures - * @param string $doc method documentation - * @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type) - * @access public - */ - function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) - { - $this->dmap[$methodname] = array( - 'function' => $function, - 'docstring' => $doc - ); - if ($sig) - { - $this->dmap[$methodname]['signature'] = $sig; - } - if ($sigdoc) - { - $this->dmap[$methodname]['signature_docs'] = $sigdoc; - } - } - - /** - * Verify type and number of parameters received against a list of known signatures - * @param array $in array of either xmlrpcval objects or xmlrpc type definitions - * @param array $sig array of known signatures to match against - * @access private - */ - function verifySignature($in, $sig) - { - // check each possible signature in turn - if (is_object($in)) - { - $numParams = $in->getNumParams(); - } - else - { - $numParams = count($in); - } - foreach($sig as $cursig) - { - if(count($cursig)==$numParams+1) - { - $itsOK=1; - for($n=0; $n<$numParams; $n++) - { - if (is_object($in)) - { - $p=$in->getParam($n); - if($p->kindOf() == 'scalar') - { - $pt=$p->scalartyp(); - } - else - { - $pt=$p->kindOf(); - } - } - else - { - $pt= $in[$n] == 'i4' ? 'int' : $in[$n]; // dispatch maps never use i4... - } - - // param index is $n+1, as first member of sig is return type - if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) - { - $itsOK=0; - $pno=$n+1; - $wanted=$cursig[$n+1]; - $got=$pt; - break; - } - } - if($itsOK) - { - return array(1,''); - } - } - } - if(isset($wanted)) - { - return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); - } - else - { - return array(0, "No method signature matches number of parameters"); - } - } - - /** - * Parse http headers received along with xmlrpc request. If needed, inflate request - * @return null on success or an xmlrpcresp - * @access private - */ - function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression) - { - // Play nice to PHP 4.0.x: superglobals were not yet invented... - if(!isset($_SERVER)) - { - $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; - } - - if($this->debug > 1) - { - if(function_exists('getallheaders')) - { - $this->debugmsg(''); // empty line - foreach(getallheaders() as $name => $val) - { - $this->debugmsg("HEADER: $name: $val"); - } - } - - } - - if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) - { - $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); - } - else - { - $content_encoding = ''; - } - - // check if request body has been compressed and decompress it - if($content_encoding != '' && strlen($data)) - { - if($content_encoding == 'deflate' || $content_encoding == 'gzip') - { - // if decoding works, use it. else assume data wasn't gzencoded - if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) - { - if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) - { - $data = $degzdata; - if($this->debug > 1) - { - $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); - } - } - elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) - { - $data = $degzdata; - if($this->debug > 1) - $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); - } - else - { - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']); - return $r; - } - } - else - { - //error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); - $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']); - return $r; - } - } - } - - // check if client specified accepted charsets, and if we know how to fulfill - // the request - if ($this->response_charset_encoding == 'auto') - { - $resp_encoding = ''; - if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) - { - // here we should check if we can match the client-requested encoding - // with the encodings we know we can generate. - /// @todo we should parse q=0.x preferences instead of getting first charset specified... - $client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])); - // Give preference to internal encoding - $known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII'); - foreach ($known_charsets as $charset) - { - foreach ($client_accepted_charsets as $accepted) - if (strpos($accepted, $charset) === 0) - { - $resp_encoding = $charset; - break; - } - if ($resp_encoding) - break; - } - } - } - else - { - $resp_encoding = $this->response_charset_encoding; - } - - if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) - { - $resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING']; - } - else - { - $resp_compression = ''; - } - - // 'guestimate' request encoding - /// @todo check if mbstring is enabled and automagic input conversion is on: it might mingle with this check??? - $req_encoding = guess_encoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '', - $data); - - return null; - } - - /** - * Parse an xml chunk containing an xmlrpc request and execute the corresponding - * php function registered with the server - * @param string $data the xml request - * @param string $req_encoding (optional) the charset encoding of the xml request - * @return xmlrpcresp - * @access private - */ - function parseRequest($data, $req_encoding='') - { - // 2005/05/07 commented and moved into caller function code - //if($data=='') - //{ - // $data=$GLOBALS['HTTP_RAW_POST_DATA']; - //} - - // G. Giunta 2005/02/13: we do NOT expect to receive html entities - // so we do not try to convert them into xml character entities - //$data = xmlrpc_html_entity_xlate($data); - - $GLOBALS['_xh']=array(); - $GLOBALS['_xh']['ac']=''; - $GLOBALS['_xh']['stack']=array(); - $GLOBALS['_xh']['valuestack'] = array(); - $GLOBALS['_xh']['params']=array(); - $GLOBALS['_xh']['pt']=array(); - $GLOBALS['_xh']['isf']=0; - $GLOBALS['_xh']['isf_reason']=''; - $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not - $GLOBALS['_xh']['rt']=''; - - // decompose incoming XML into request structure - if ($req_encoding != '') - { - if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - // the following code might be better for mb_string enabled installs, but - // makes the lib about 200% slower... - //if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - error_log('XML-RPC: xmlrpc_server::parseRequest: invalid charset encoding of received request: '.$req_encoding); - $req_encoding = $GLOBALS['xmlrpc_defencoding']; - } - /// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue, - // the encoding is not UTF8 and there are non-ascii chars in the text... - /// @todo use an ampty string for php 5 ??? - $parser = xml_parser_create($req_encoding); - } - else - { - $parser = xml_parser_create(); - } - - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); - // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell - // the xml parser to give us back data in the expected charset - // What if internal encoding is not in one of the 3 allowed? - // we use the broadest one, ie. utf8 - // This allows to send data which is native in various charset, - // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding - if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - } - else - { - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); - } - - if ($this->functions_parameters_type != 'xmlrpcvals') - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); - else - xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); - xml_set_character_data_handler($parser, 'xmlrpc_cd'); - xml_set_default_handler($parser, 'xmlrpc_dh'); - if(!xml_parse($parser, $data, 1)) - { - // return XML error as a faultCode - $r=&new xmlrpcresp(0, - $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), - sprintf('XML error: %s at line %d, column %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser), xml_get_current_column_number($parser))); - xml_parser_free($parser); - } - elseif ($GLOBALS['_xh']['isf']) - { - xml_parser_free($parser); - $r=&new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['invalid_request'], - $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); - } - else - { - xml_parser_free($parser); - if ($this->functions_parameters_type != 'xmlrpcvals') - { - if($this->debug > 1) - { - $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); - } - $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']); - } - else - { - // build an xmlrpcmsg object with data parsed from xml - $m=&new xmlrpcmsg($GLOBALS['_xh']['method']); - // now add parameters in - for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) - { - $m->addParam($GLOBALS['_xh']['params'][$i]); - } - - if($this->debug > 1) - { - $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); - } - $r = $this->execute($m); - } - } - return $r; - } - - /** - * Execute a method invoked by the client, checking parameters used - * @param mixed $m either an xmlrpcmsg obj or a method name - * @param array $params array with method parameters as php types (if m is method name only) - * @param array $paramtypes array with xmlrpc types of method parameters (if m is method name only) - * @return xmlrpcresp - * @access private - */ - function execute($m, $params=null, $paramtypes=null) - { - if (is_object($m)) - { - $methName = $m->method(); - } - else - { - $methName = $m; - } - $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); - $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; - - if(!isset($dmap[$methName]['function'])) - { - // No such method - return new xmlrpcresp(0, - $GLOBALS['xmlrpcerr']['unknown_method'], - $GLOBALS['xmlrpcstr']['unknown_method']); - } - - // Check signature - if(isset($dmap[$methName]['signature'])) - { - $sig = $dmap[$methName]['signature']; - if (is_object($m)) - { - list($ok, $errstr) = $this->verifySignature($m, $sig); - } - else - { - list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); - } - if(!$ok) - { - // Didn't match. - return new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['incorrect_params'], - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" - ); - } - } - - $func = $dmap[$methName]['function']; - // let the 'class::function' syntax be accepted in dispatch maps - if(is_string($func) && strpos($func, '::')) - { - $func = explode('::', $func); - } - // verify that function to be invoked is in fact callable - if(!is_callable($func)) - { - error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler is not callable"); - return new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['server_error'], - $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" - ); - } - - // If debug level is 3, we should catch all errors generated during - // processing of user function, and log them as part of response - if($this->debug > 2) - { - $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); - } - if (is_object($m)) - { - if($sysCall) - { - $r = call_user_func($func, $this, $m); - } - else - { - $r = call_user_func($func, $m); - } - if (!is_a($r, 'xmlrpcresp')) - { - error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler does not return an xmlrpcresp object"); - if (is_a($r, 'xmlrpcval')) - { - $r =& new xmlrpcresp($r); - } - else - { - $r =& new xmlrpcresp( - 0, - $GLOBALS['xmlrpcerr']['server_error'], - $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" - ); - } - } - } - else - { - // call a 'plain php' function - if($sysCall) - { - array_unshift($params, $this); - $r = call_user_func_array($func, $params); - } - else - { - // 3rd API convention for method-handling functions: EPI-style - if ($this->functions_parameters_type == 'epivals') - { - $r = call_user_func_array($func, array($methName, $params, $this->user_data)); - // mimic EPI behaviour: if we get an array that looks like an error, make it - // an eror response - if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) - { - $r =& new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); - } - else - { - // functions using EPI api should NOT return resp objects, - // so make sure we encode the return type correctly - $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api'))); - } - } - else - { - $r = call_user_func_array($func, $params); - } - } - // the return type can be either an xmlrpcresp object or a plain php value... - if (!is_a($r, 'xmlrpcresp')) - { - // what should we assume here about automatic encoding of datetimes - // and php classes instances??? - $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates'))); - } - } - if($this->debug > 2) - { - // note: restore the error handler we found before calling the - // user func, even if it has been changed inside the func itself - if($GLOBALS['_xmlrpcs_prev_ehandler']) - { - set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); - } - else - { - restore_error_handler(); - } - } - return $r; - } - - /** - * add a string to the 'internal debug message' (separate from 'user debug message') - * @param string $strings - * @access private - */ - function debugmsg($string) - { - $this->debug_info .= $string."\n"; - } - - /** - * @access private - */ - function xml_header($charset_encoding='') - { - if ($charset_encoding != '') - { - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n"; - } - else - { - return "<?xml version=\"1.0\"?" . ">\n"; - } - } - - /** - * A debugging routine: just echoes back the input packet as a string value - * DEPRECATED! - */ - function echoInput() - { - $r=&new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); - print $r->serialize(); - } - } -?> diff --git a/core/class/ws.php b/core/class/ws.php deleted file mode 100755 index cb896894c1938a7f44f82bea60319330ef2e3457..0000000000000000000000000000000000000000 --- a/core/class/ws.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - - -// COMMON -$SOAP_typedef['returnArray'] = array( 'status'=>'string', - 'value'=>'string', - 'error'=>'string' - ); -/**************************************************************************************************/ -// DOCSERVERS -$SOAP_typedef['docservers'] = array( 'docserver_id'=>'string', - 'docserver_type_id'=>'string', - 'device_label'=>'string', - 'is_readonly'=>'string', - 'size_limit_number'=>'string', - 'path_template'=>'string', - 'coll_id'=>'string', - ); -$SOAP_typedef['returnViewResource'] = array('status'=>'string', - 'mime_type'=>'string', - 'ext'=>'string', - 'file_content'=>'string', - 'tmp_path'=>'string', - 'file_path'=>'string', - 'called_by_ws'=>'boolean', - 'error'=>'string' - ); -$SOAP_dispatch_map['viewResource'] = array( - 'in' => Array('gedId' => 'string', 'tableName' => 'string', 'adrTableName' => 'string', 'calledByWS' => 'string'), - 'out' => Array('return' => '{urn:MaarchSoapServer}returnViewResource'), - 'method' => "core#docservers::viewResource" - ); -/**************************************************************************************************/ -// DOCSERVERS TYPES -$SOAP_typedef['docserverTypes'] = array( 'docserver_type_id'=>'string', - 'docserver_type_label'=>'string', - 'fingerprint_mode'=>'string' - ); -/**************************************************************************************************/ -// USERS -$SOAP_typedef['users'] = array( 'user_id'=>'string', - 'password'=>'string', - 'firstname'=>'string', - 'lastname'=>'string', - 'phone'=>'string', - 'mail'=>'string', - 'loginmode'=>'string' - ); - -$SOAP_dispatch_map['userDelete'] = array( - 'in' => array('user' => '{urn:MaarchSoapServer}users'), - 'out' => array('out' => '{urn:MaarchSoapServer}returnArray'), - 'method' => "core#users::delete" - ); - -$SOAP_typedef['returnArrayUser'] = array( 'userEntities'=>'{urn:MaarchSoapServer}arrayOfEntities', - 'isUser'=>'boolean', - ); - -$SOAP_typedef['arrayOfEntities'] = array( - array( - 'arrayOfEntitiesContent' => '{urn:MaarchSoapServer}arrayOfEntitiesContent' - ) -); - -$SOAP_typedef['arrayOfEntitiesContent'] = array( - 'USER_ID' => 'string', - 'ENTITY_ID' => 'string', - 'PRIMARY' => 'string', - 'ROLE' => 'string', -); - -$SOAP_dispatch_map['checkUserMail'] = array( - 'in' => array('userMail' => 'string'), - 'out' => array('out' => '{urn:MaarchSoapServer}returnArrayUser'), - 'method' => "core#users::checkUserMail" - ); - -##################################### -## Web Service de versement de données issue du gros scanner -##################################### -$SOAP_typedef['arrayOfData'] = array( - array( - 'arrayOfDataContent' => '{urn:MaarchSoapServer}arrayOfDataContent' - ) -); - -$SOAP_typedef['arrayOfDataContent'] = array( - 'column' => 'string', - 'value' => 'string', - 'type' => 'string', -); - -$SOAP_typedef['returnResArray'] = array( - 'returnCode'=> 'int', - 'resId' => 'string', - 'error' => 'string' -); - -$SOAP_typedef['searchParams'] = array( - 'country' => 'string', - 'docDate' => 'date', -); - -$SOAP_typedef['listOfResources'] = array( - 'resid' => 'long', - 'identifier' => 'string', - 'contactName' => 'string', - 'country' => 'int', - 'amount' => 'string', - 'customer' => 'string', - 'docDate' => 'string', -); - -$SOAP_typedef['docListReturnArray'] = array( - 'status'=>'string', - 'value'=>'{urn:MaarchSoapServer}listOfResources', - 'error'=>'string', -); - -$SOAP_typedef['returnRetrieveMasterResByChrono'] = array( - 'returnCode'=> 'int', - 'resId' => 'string', - 'title' => 'string', - 'identifier' => 'string', - 'status' => 'string', - 'attachment_type' => 'string', - 'dest_contact_id' => 'long', - 'dest_address_id' => 'long', - 'error' => 'string' -); - -$SOAP_dispatch_map['retrieveMasterResByChrono'] = array( - 'in' => array( - 'identifier' => 'string', - 'collId' => 'string', - ), - 'out' => array('return' => '{urn:MaarchSoapServer}returnRetrieveMasterResByChrono'), - 'method' => "core#resources::retrieveMasterResByChrono", -); diff --git a/install/view/prerequisites_view.php b/install/view/prerequisites_view.php index c971f3d192a275cd10b902f751e94284013a7214..cfb489b9948da1f52ad5d6594463f440ef2e936b 100755 --- a/install/view/prerequisites_view.php +++ b/install/view/prerequisites_view.php @@ -268,20 +268,6 @@ <?php echo _PEAR;?> </td> </tr> - <!--tr> - <td class="voyantPrerequisites"> - <?php - // echo $Class_Install->checkPrerequisites( - // $Class_Install->isPearRequirements( - // 'MIME/Type.php' - // ) - // ); - ?> - </td> - <td> - <?php //echo _MIMETYPE;?> - </td> - </tr--> <tr> <td class="voyantPrerequisites"> <?php echo $Class_Install->checkPrerequisites( @@ -295,19 +281,6 @@ <?php echo _CLITOOLS;?> </td> </tr> - <tr> - <td class="voyantPrerequisites"> - <?php echo $Class_Install->checkPrerequisites( - $Class_Install->isPearRequirements( - 'SOAP/Disco.php' - ), - true - );?> - </td> - <td> - <?php echo 'SOAP';?> - </td> - </tr> <tr> <td> diff --git a/modules/attachments/class/attachments_controler_Abstract.php b/modules/attachments/class/attachments_controler_Abstract.php index 27ff13bc83b13eab3852b8cd828fadd0fd924bef..36fb69fb9f600ad49c0407c5d641fa55c51fcb54 100755 --- a/modules/attachments/class/attachments_controler_Abstract.php +++ b/modules/attachments/class/attachments_controler_Abstract.php @@ -32,211 +32,6 @@ abstract class attachments_controler_Abstract { - ##################################### - ## Attachment on a resource - ##################################### - //add datas to have the subject - public function storeAttachmentResource($resId, $collId, $encodedContent, $fileFormat, $title) - { - require_once 'core/class/class_db_pdo.php'; - require_once 'core/class/class_request.php'; - require_once 'core/class/class_resource.php'; - require_once 'core/class/docservers_controler.php'; - require_once 'core/class/class_security.php'; - $sec = new security(); - $table = $sec->retrieve_table_from_coll($collId); - $db = new Database(); - $query = 'select res_id from ' . $table . ' where res_id = ?'; - $stmt = $db->query($query, array($resId), true); - if ($stmt->rowCount() == 0) { - $returnCode = -2; - $error .= 'res_id inexistant'; - } else { - $fileContent = base64_decode($encodedContent); - $tmpFileName = 'tmp_file_ws_' - . rand() . "_" . md5($fileContent) - . "." . strtolower($fileFormat); - $Fnm = $_SESSION['config']['tmppath'] . $tmpFileName; - $inF = fopen($Fnm, "w"); - fwrite($inF, $fileContent); - fclose($inF); - $docserverControler = new docservers_controler(); - $docserver = $docserverControler->getDocserverToInsert( - $collId - ); - if (empty($docserver)) { - $returnCode = -3; - $error = _DOCSERVER_ERROR . ' : ' - . _NO_AVAILABLE_DOCSERVER . ". " . _MORE_INFOS . "."; - } else { - $newSize = $docserverControler->checkSize( - $docserver, - $_SESSION['upfile']['size'] - ); - if ($newSize == 0) { - $returnCode = -4; - $error = _DOCSERVER_ERROR . ' : ' - . _NOT_ENOUGH_DISK_SPACE . ". " . _MORE_INFOS . "."; - } else { - $fileInfos = array( - "tmpDir" => $_SESSION['config']['tmppath'], - "size" => filesize($Fnm), - "format" => strtolower($fileFormat), - "tmpFileName" => $tmpFileName, - ); - $storeResult = array(); - $storeResult = $docserverControler->storeResourceOnDocserver( - $collId, - $fileInfos - ); - if (isset($storeResult['error']) && $storeResult['error'] <> '') { - $returnCode = -5; - $error = $storeResult['error']; - } else { - unlink($Fnm); - $resAttach = new resource(); - $_SESSION['data'] = array(); - array_push( - $_SESSION['data'], - array( - 'column' => "typist", - 'value' => $_SESSION['user']['UserId'], - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "format", - 'value' => strtolower($fileFormat), - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "docserver_id", - 'value' => $storeResult['docserver_id'], - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "status", - 'value' => 'TRA', - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "offset_doc", - 'value' => ' ', - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "title", - 'value' => $title, - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "coll_id", - 'value' => $collId, - 'type' => "string", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "res_id_master", - 'value' => $resId, - 'type' => "integer", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "type_id", - 'value' => 0, - 'type' => "integer", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "relation", - 'value' => 1, - 'type' => "integer", - ) - ); - array_push( - $_SESSION['data'], - array( - 'column' => "attachment_type", - 'value' => 'simple_attachment', - 'type' => "string", - ) - ); - $id = $resAttach->load_into_db( - 'res_attachments', - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $_SESSION['data'], - $_SESSION['config']['databasetype'] - ); - if ($id == false) { - $returnCode = -6; - $error = $resAttach->get_error(); - } else { - $returnCode = 0; - if ($_SESSION['history']['attachadd'] == "true") { - $users = new history(); - $view = $sec->retrieve_view_from_coll_id( - $collId - ); - $users->add( - $view, - $resId, - "ADD", - 'attachadd', - ucfirst(_DOC_NUM) . $id . ' ' - . _NEW_ATTACH_ADDED . ' ' . _TO_MASTER_DOCUMENT - . $resId, - $_SESSION['config']['databasetype'], - 'apps' - ); - $users->add( - RES_ATTACHMENTS_TABLE, - $id, - "ADD", - 'attachadd', - _NEW_ATTACH_ADDED . " (" . $title - . ") ", - $_SESSION['config']['databasetype'], - 'attachments' - ); - } - } - } - } - } - } - $returnArray = array( - 'returnCode' => (int) $returnCode, - 'resId' => $id, - 'error' => $error, - ); - return $returnArray; - } public function initAttachmentInfos($resId) { diff --git a/modules/attachments/class/ws.php b/modules/attachments/class/ws.php deleted file mode 100755 index 65632dacf908f47eeb9bf236216c1e46953d06a5..0000000000000000000000000000000000000000 --- a/modules/attachments/class/ws.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - -$SOAP_dispatch_map['storeAttachmentResource'] = array( - 'in' => array( - 'resId' => 'long', - 'collId' => 'string', - 'encodedContent' => 'string', - 'fileFormat' => 'string', - 'title' => 'string', - ), - 'out' => array('out' => '{urn:MaarchSoapServer}returnResArray'), - 'method' => "modules/attachments#attachments::storeAttachmentResource" -); diff --git a/modules/basket/class/cmis/cmis_basket_controller.php b/modules/basket/class/cmis/cmis_basket_controller.php deleted file mode 100755 index 00b818f2f74cd86828bbb2bd2a4e7730eb19dafb..0000000000000000000000000000000000000000 --- a/modules/basket/class/cmis/cmis_basket_controller.php +++ /dev/null @@ -1,263 +0,0 @@ -<?php - -require_once 'modules/folder/class/cmis/cmis_folder_controller.php' ; -require_once 'apps/maarch_entreprise/class/cmis/cmis_class_property.php' ; -require_once 'apps/maarch_entreprise/class/cmis/cmis_res_controller.php' ; - -class basketCMIS extends folderCMIS -{ - private $basketId; - - - public function __construct() { - - $this->id = "cmis:basket"; - $this->queryName = "cmis:basket"; - $this->baseId = "cmis:folder"; - $this->parentId = null; //notset - $this->fileable = true; - $this->queryable = true; - $this->localName = "cmis:basket"; - $this->displayName = "cmis:basket"; - $this->creatable = false; - - //properties - $this->name = new PropertyString($required, $inherited, $propertyType, - $cardinality, $updatability, $choices, $openChoice, $queryable, - $orderable); - $this->name->setRequired(true); - $this->name->setInherited(false); - $this->name->setPropertyType('String'); - $this->name->setCardinality('Single'); - $this->name->setId('name'); - $this->name->setOpenChoice(true); - - $this->objectId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->objectId->setId('objectId'); - - $this->baseTypeId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->baseTypeId->setId('baseTypeId'); - - $this->objectTypeId = new PropertyId(true, false, 'Id', 'Single', - 'oncreate', 'NotApplicable', 'NotApplicable', false, false); - $this->objectTypeId->setId('objectTypeId'); - - $this->createdBy = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->createdBy->setId('createdBy'); - - $this->creationDate = new PropertyDateTime(false, false, 'DateTime', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->creationDate->setId('creationDate'); - - $this->lastModifiedBy = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->lastModifiedBy->setId('lastModifiedBy'); - - $this->lastModificationDate = new PropertyDateTime(false, false, 'DateTime', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->lastModificationDate->setId('lastModificationDate'); - - $this->changeToken = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->changeToken->setId('changeToken'); - - $this->parentId = new PropertyId(false, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->parentId->setId('parentId'); - - $this->path = new PropertyString(false, false, 'String', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->path->setId('path'); - - $this->allowedChildObjectTypeIds = new PropertyId(false, false, 'Id', 'Multi', - 'ReadOnly', 'NotApplicable', 'NotApplicable', false, false); - $this->allowedChildObjectTypeIds->setId('allowedChildObjectTypeIds'); - - $this->basketId = new PropertyId(true, false, 'Id', 'Single', - 'ReadOnly', 'NotApplicable', 'NotApplicable', true, true); - $this->basketId->setId('basketId'); - - - $this->properties = array( - $this->name, $this->objectId, $this->baseTypeId, $this->objectTypeId, $this->createdBy, $this->creationDate, - $this->lastModifiedBy, $this->lastModificationDate, $this->changeToken, $this->parentId, - $this->path, $this->allowedChildObjectTypeIds, $this->basketId - ); - - $this->propertiesInXml = array( $this->basketId ); - } - - - public function setBasketId($id){ - $this->basketId = $id; - } - - public function setUrl($url){ - $this->url = $url; - } - - public function getBasketId(){ - return $this->basketId; - } - - public function getUrl(){ - return $this->url; - } - - public function entryMethod ($atomFileContent, $requestedResourceId) - { - - if(!isset($atomFileContent)){ - if(!isset($requestedResourceId)){ - - //get list of baskets (no documents attached) - $cmisBaskets = $this->loadBaskets(); - - $basketDoc= new DOMDocument('1.0', 'utf-8'); - $basketDoc->xmlStandalone = true; - $basketDoc->formatOutput = true; - //TODO feed - - - $title = 'Baskets'; - $basketDoc = basketCMIS::getFeed($cmisBaskets, $title); - - echo $basketDoc->saveXML(); - - /**/ - } - else{ - $str = 'show documents in basket '; - - //get list of baskets (no documents attached) - $cmisBaskets = $this->loadBaskets(); - - $found=false; - $i=0; - - while(!$found && ($basket = $_SESSION['user']['baskets'][$i++])){ - $found = (strcmp($basket['id'],$requestedResourceId)==0); - } - - if($found){ - //get the list of documents in the basket whose id is $requestedResourceId - $documents = $this->getDocumentsInBasket($basket); - $title = trim('Documents in '.$requestedResourceId); - $resAtom = resCMIS::getFeed($documents, $title); - - echo $resAtom->saveXML(); - } - else{ - //TODO throw objectNotFound - echo "<br />ERREUR : objectNotFound.<br />"; - } - } - } - else{ - //TODO throw notSupported or invalidArgument - echo "<br />ERREUR : requete sql non réalisée throw notSupported or invalidArgument.<br />"; - } - - //return $requestedResourceId . ' ' . $atomFileContent; - } - - - private function getDocumentsInBasket($basket){ - require_once('core/class/class_db_pdo.php'); - $db = new Database(); - - //$resArray = null - - $view = $basket['view']; - $clause = $basket['clause']; - $statement = "select * from " . $view . " where " . $clause; - - $result = $db->query($statement); - - //TODO - if($result === false){ - //TODO throw objectNotFound or invalidArgument or runtime - echo "<br />ERREUR : requete sql non réalisée runtime.<br />"; - } - - $resArray = array(); - while ($recordset = $result->fetchObject()) { - $documentCmis = new resCMIS(); - $documentCmis->DocumentCmis(); - $documentCmis->setRes( - array('res_id' => $recordset->res_id, - 'type_label'=> $recordset->type_label, - 'contact_society' => $recordset->contact_society , - 'contact_firstname' => $recordset->contact_firstname , - 'contact_lastname' => $recordset->contact_lastname , - 'entity_label' => $recordset->entity_label , - 'dest_user' => $recordset->dest_user , - 'doc_date' => $recordset->doc_date , - 'process_limit_date' => $recordset->process_limit_date, - 'author' => $recordset->author - )); - - - $url = $_SESSION['config']['coreurl']."apps/maarch_entreprise/index.php?page=view_baskets&module=basket&directLinkToAction&baskets=". $basket['id'] . "&resid=" . $recordset->res_id; - $url = htmlentities($url, ENT_COMPAT | ENT_HTML401 , "utf-8"); - - $documentCmis->setUrl($url); - - array_push($resArray, $documentCmis); - } - - return $resArray; - } - - - - private function loadBaskets(){ - require_once('core/class/class_db_pdo.php'); - $db = new Database(); - - $userId = pg_escape_string($_SESSION['user']['UserId']); - $statement = "select group_id from usergroup_content where user_id = '" . $userId . "' and primary_group = 'Y'"; - $result = $db->query($statement); - - //TODO gerer les cas d erreurs - if($result === false){ - //TODO throw runtime - echo "<br />ERREUR : runtime.<br />"; - } - - $recordset = $result->fetchObject(); - $_SESSION['user']['primarygroup'] = $recordset->group_id; - - $userData = array( - 'UserId' => $_SESSION['user']['UserId'], - 'primarygroup' => $_SESSION['user']['primarygroup'] - ); - - require_once('modules/basket/class/class_modules_tools.php'); - $basketTools = new basket(); - $basketTools->load_module_var_session($userData); - - $cmisBaskets = array(); - - foreach($_SESSION['user']['baskets'] as $key => $basket){ - $cmisBaskets[$key] = $this->toCmisBasket($basket); - } - - return $cmisBaskets; - } - - - public function toCmisBasket($basket){ - $basketCmis = new basketCMIS(); - - $basketCmis->basketId->setValue($basket['id']); - $basketCmis->name->setValue($basket['name']); - - return $basketCmis; - } - -} - diff --git a/modules/basket/class/ws.php b/modules/basket/class/ws.php deleted file mode 100755 index 915406c397202ddc0941dd0669c39460a7c52b1e..0000000000000000000000000000000000000000 --- a/modules/basket/class/ws.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; -global $REST_dispatch_map; - -$REST_dispatch_map['basket'] = Array( - 'pathToController' => "modules/basket/class/cmis/cmis_basket_controller.php" -); \ No newline at end of file diff --git a/modules/content_management/class/ws.php b/modules/content_management/class/ws.php deleted file mode 100755 index 6ea5378cc3d812740ca5d0f7197c202ce8ad13a9..0000000000000000000000000000000000000000 --- a/modules/content_management/class/ws.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - diff --git a/modules/export_seda/RequestSeda.php b/modules/export_seda/RequestSeda.php index aa5ade43aee99ac3d684bfb75d30e0505a1892b7..0fce89544d07b9c6bf9312f3ffa016839f43a6fd 100755 --- a/modules/export_seda/RequestSeda.php +++ b/modules/export_seda/RequestSeda.php @@ -40,7 +40,6 @@ class RequestSeda require_once('core/class/class_db.php'); require_once('core/class/class_request.php'); require_once('core/class/class_core_tools.php'); - require_once('core/class/web_service/class_web_service.php'); //load Maarch session vars $portal = new portal(); diff --git a/modules/life_cycle/class/ws.php b/modules/life_cycle/class/ws.php deleted file mode 100755 index b9aa6e3f5247ed46e95070cf446e6ce96f7c6d61..0000000000000000000000000000000000000000 --- a/modules/life_cycle/class/ws.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - - diff --git a/modules/notes/class/ws.php b/modules/notes/class/ws.php deleted file mode 100755 index d8755e78a93e1ad7430db24b4ce225396df0a793..0000000000000000000000000000000000000000 --- a/modules/notes/class/ws.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - -$SOAP_dispatch_map['addNote'] = array( - 'in' => array( - 'resId' => 'long', - 'collId' => 'string', - 'noteContent' => 'string', - ), - 'out' => array('out' => '{urn:MaarchSoapServer}returnArray'), - 'method' => "modules/notes#notes::addNote" -); - diff --git a/src/core/models/CoreConfigModel.php b/src/core/models/CoreConfigModel.php index 3d23d7b09f1712e314faeaaf5447298208057956..4024a6c2a5ca14bb2780813b3d37a4775f13f71d 100755 --- a/src/core/models/CoreConfigModel.php +++ b/src/core/models/CoreConfigModel.php @@ -32,11 +32,7 @@ class CoreConfigModel $explodeUrl = explode('/', $_SERVER['SCRIPT_NAME']); - if (strpos($_SERVER['SCRIPT_NAME'], 'ws_server') !== false) { - $path = $explodeUrl[count($explodeUrl) - 2]; - } elseif (strpos($_SERVER['SCRIPT_NAME'], 'apps/maarch_entreprise/smartphone') !== false) { - $path = $explodeUrl[count($explodeUrl) - 5]; - } elseif (strpos($_SERVER['SCRIPT_NAME'], 'apps/maarch_entreprise') === false) { + if (strpos($_SERVER['SCRIPT_NAME'], 'apps/maarch_entreprise') === false) { $path = $explodeUrl[count($explodeUrl) - 3]; } else { $path = $explodeUrl[count($explodeUrl) - 4]; diff --git a/ws_server.php b/ws_server.php deleted file mode 100755 index ca775da6b422348fe25346d3ec7fca2cec60aaae..0000000000000000000000000000000000000000 --- a/ws_server.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -/* -* Copyright 2010 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Maarch web service root -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup core -*/ - -//include of classes -require_once('core/class/class_functions.php'); -include_once('core/init.php'); -require_once('core/class/class_portal.php'); -require_once('core/class/class_db.php'); -require_once('core/class/class_request.php'); -require_once('core/class/class_core_tools.php'); -require_once('core/class/web_service/class_web_service.php'); -//load Maarch session vars -$portal = new portal(); -$portal->unset_session(); -$portal->build_config(); -$coreTools = new core_tools(); -$_SESSION['custom_override_id'] = $coreTools->get_custom_id(); -if (isset($_SESSION['custom_override_id']) - && ! empty($_SESSION['custom_override_id']) - && isset($_SESSION['config']['corepath']) - && ! empty($_SESSION['config']['corepath']) -) { - $path = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR - . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR; - set_include_path( - $path . PATH_SEPARATOR . $_SESSION['config']['corepath'] - . PATH_SEPARATOR . get_include_path() - ); -} else if (isset($_SESSION['config']['corepath']) - && ! empty($_SESSION['config']['corepath']) -) { - set_include_path( - $_SESSION['config']['corepath'] . PATH_SEPARATOR . get_include_path() - ); -} -$coreTools->build_core_config('core' . DIRECTORY_SEPARATOR . 'xml' - . DIRECTORY_SEPARATOR . 'config.xml' -); -$_SESSION['config']['app_id'] = $_SESSION['businessapps'][0]['appid']; -require_once('apps' . DIRECTORY_SEPARATOR . $_SESSION['businessapps'][0]['appid'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR - . 'class_business_app_tools.php' -); -$businessAppTools = new business_app_tools(); -$businessAppTools->build_business_app_config(); -$coreTools->load_modules_config($_SESSION['modules']); -//load webservice engine -$webService = new webService(); -//http Authentication -//WARNING !!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!WARNING! -if($webService->authentication()) { -//if(1==1) { - $business = new business_app_tools(); - $business->load_app_var_session(); - //retrieve Maarch web service catalog - $webService->WSCoreCatalog(); - $webService->WSAppsCatalog(); - $webService->WSModulesCatalog(); - $webService->WScustomCatalog(); - //launch webservice engine - $webService->launchWs(); -} else { - header("WWW-Authenticate: Basic realm=\"Maarch WebServer Engine\""); - if (preg_match("/Microsoft/", $_SERVER["SERVER_SOFTWARE"])) { - header("Status: 401 Unauthorized"); - exit(); - } else { - header("HTTP/1.0 401 Unauthorized"); - echo 'Access denied'; - exit(); - } -}