function is_hexbin($value)
 {
     # first see if there are any invalid chars
     $l = strlen($value);
     if ($l < 1 || strspn($value, '0123456789ABCDEFabcdef') != $l) {
         return FALSE;
     }
     $bin = ilBMFType_hexBinary::to_bin($value);
     $hex = ilBMFType_hexBinary::to_hex($bin);
     return strcasecmp($value, $hex) == 0;
 }
Beispiel #2
0
 /**
  * Converts a PHP type to a SOAP type.
  *
  * @access   private
  *
  * @param string $value  The value to inspect.
  *
  * @return string  The value's SOAP type.
  */
 function _getType(&$value)
 {
     global $SOAP_OBJECT_STRUCT, $SOAP_RAW_CONVERT;
     $type = gettype($value);
     switch ($type) {
         case 'object':
             if (is_a($value, 'ilbmfvalue')) {
                 $type = $value->type;
             } else {
                 $type = 'Struct';
             }
             break;
         case 'array':
             // Hashes are always handled as structs.
             if ($this->_isHash($value)) {
                 $type = 'Struct';
             } else {
                 $ar_size = count($value);
                 reset($value);
                 $key1 = key($value);
                 if ($ar_size > 0 && is_a($key1, 'ilBMFValue')) {
                     // FIXME: for non-wsdl structs that are all the same type
                     $key2 = key($value);
                     if ($ar_size > 1 && $this->_isSoapValue($key1) && $this->_isSoapValue($key2) && $key1->name != $key2->name) {
                         // This is a struct, not an array.
                         $type = 'Struct';
                     } else {
                         $type = 'Array';
                     }
                 } else {
                     $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 = 'decimal';
             break;
         case 'null':
             $type = '';
             break;
         case 'string':
             /* Databay: Changes for BMF */
             /*            if ($SOAP_RAW_CONVERT) {
                             if (is_numeric($value)) {
                                 if (strstr($value, '.')) {
                                     $type = 'float';
                                 } else {
                                     $type = 'int';
                                 }
                             } else {
                                 if (ilBMFType_hexBinary::is_hexbin($value)) {
                                     $type = 'hexBinary';
                                 } else {
                                     if ($this->_isBase64($value)) {
                                         $type = 'base64Binary';
                                     } else {
                                         $dt =& new ilBMFType_dateTime($value);
                                         if ($dt->toUnixtime() != -1) {
                                             $type = 'dateTime';
                                         }
                                     }
                                 }
                             }
                         }
                         break;*/
             if ($SOAP_RAW_CONVERT) {
                 if (is_numeric($value)) {
                     if (strstr($value, '.')) {
                         $type = 'float';
                     } else {
                         $type = 'int';
                     }
                 } else {
                     if (ilBMFType_hexBinary::is_hexbin($value)) {
                         $type = 'hexBinary';
                     } else {
                         if ($this->_isBase64($value)) {
                             $type = 'base64Binary';
                         } else {
                             $dt =& new ilBMFType_dateTime($value);
                             if ($dt->toUnixtime() != -1) {
                                 $type = 'dateTime';
                                 #$value = $dt->toSOAP();
                             }
                         }
                     }
                 }
             } else {
                 $dt =& new ilBMFType_dateTime($value);
                 if ($dt->toUnixtime() != -1) {
                     $type = 'dateTime';
                     #$value = $dt->toSOAP();
                 }
             }
         default:
             break;
     }
     return $type;
 }