]> git.nbdom.net Git - nb.git/commitdiff
lib/php/out.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Dec 2017 16:05:22 +0000 (16:05 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Dec 2017 16:05:22 +0000 (16:05 +0000)
lib/php/nb.php
lib/php/out.php
www/dbq/dbq.php

index 847ddfe2ecfbf191a0245eb96970054faf64e031..c6a8102c4c55e7c6ada0d8c70319e19149e9268e 100644 (file)
@@ -1105,8 +1105,9 @@ class NB {
                                #debug($attributes[$j]);
                                $values = ldap_get_values_len($connect, $entry,$attributes[$j]);
                                unset($values['count']);
-                               if (false) for ($v=0; $v<count($values); $v++) {
-                                       $values[$v] = unpack("H*hex",$values[$v]);
+                               if ($attributes[$j] == 'jpegPhoto') for ($v=0; $v<count($values); $v++) {
+                                       #$values[$v] = unpack("H*hex",$values[$v]);
+                                       #$values[$v] = base64_decode($values[$v]);
                                }
                                #array_pop($values);
                                if (isset($values) and count($values) == 1) $values = $values[0];
@@ -1163,6 +1164,11 @@ class NB {
 
                return $date . '.' . $date_array[0];
        }
+
+       public static function is_binary($v) {
+               return (preg_match('~[^\x20-\x7E\t\r\n]~', $v) > 0 ? true : false);
+       }
+
 } # < Class NB
 
 /*
index e93c428800e55e6cdfecba75a654f0b3b20cf4f1..2a573d220c28f5d982583eddb30a8da950675ca5 100644 (file)
@@ -214,9 +214,6 @@ Class Out extends Nb {
       unset($opt[$k]);
     }
 
-# NB 05.12.16     if (isset($opt['format'])) self::type($opt['format']);
-# NB 05.12.16     unset($opt['format']);
-
     if (self::type() and !empty($data)) return self::rows(self::type(),$data,$head);
     return parent::__construct($opt);
   }
@@ -446,7 +443,7 @@ Class Out extends Nb {
       # Transform simple array into hash
       if (isset($row[0]) and $head) {
         #bye($conf);
-        if (is_scalar($row)) $row = array($row);
+        if (is_scalar($row)) $row = [$row];
 
         $new = array(); $i = 0;
         foreach ($head as $k => $h) {
@@ -457,7 +454,6 @@ Class Out extends Nb {
 
       }
 
-# NB 27.09.16       if ($count>0) self::row_end($conf);
       $count++;
 
       self::row($conf,$row);
@@ -601,6 +597,10 @@ Class Out extends Nb {
     $values = [];
 
     foreach (array_values($row) as $k=>$v) {
+                       if (self::is_binary($v)) {
+                               $values[] = $v;
+                               break;
+                       }
       if (!empty($o['quote'])) $v = $o['quote'] .
         str_replace($o['quote'],$o['quote_escape'].$o['quote'],$v)
       . $o['quote'];
@@ -811,26 +811,4 @@ Class Out extends Nb {
 } Out::init() ; # < Class
 /****************************************************************************/
 
-#die("A NB_EOL B \n");
-if (empty($argv) or count($argv) < 2 or $argv[1] != 'test') return true;
-$data = array(
-  'name' => 'Name 1',
-  'value' => 'Value 1',
-);
-/*
-$data = array( 'a', 'b', 'c' );
-$data = array(
-  array('a1','b1','c1'),
-  array('a2','b2','c2'),
-  array('a3','b3','c3'),
-);
-$field = array('A','B','C');
-$data = array(
-  array('a' => 'a1', 'b' => 'b1'),
-  array('a' => 'a2', 'b' => 'b2'),
-);
-*/
-#$data = array( array('a'=>'A'), array('b'=>'B'), array('c'=>'C') );
-$field = array();
-$o = self::rows(!empty($argv[2]) ? $argv[2] : 'csv',$data,$field);
 ?>
index 5be7fd433468bab3ad5a62674e699ec494c70ac0..c28467264c09113926bcc1bd31ac4ccea2f2c2b6 100644 (file)
@@ -1014,6 +1014,8 @@ EOF;
                                'filter' => ($this->params['table'] ? $this->params['table'] : ''),
                                'attrs' => ($this->params['action'] ? explode(',',$this->params['action']) : []),
                        ]);
+                       #echo $rows[0]['jpegPhoto']; exit;
+                       #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ];
                        if ($this->is_html) $rows = $this->array_fill_assoc($rows);
                        $this->page($rows);