compatibility with PHP7
authorKonrad Rosenbaum <konrad@silmor.de>
Sun, 20 Nov 2016 14:24:36 +0000 (15:24 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Sun, 20 Nov 2016 14:24:36 +0000 (15:24 +0100)
Change-Id: Icf5f3ddfd34e81d9fb28d2410b5425705773e4cd

pack
tzone
www/inc/classes/random.php

diff --git a/pack b/pack
index 29afc5c..c3ce038 160000 (submodule)
--- a/pack
+++ b/pack
@@ -1 +1 @@
-Subproject commit 29afc5ca5eb425565e0859a231939854aadcc13a
+Subproject commit c3ce03861e7e94ee5a87b8cb506b120af4d74348
diff --git a/tzone b/tzone
index 0f1d587..2e5d1ea 160000 (submodule)
--- a/tzone
+++ b/tzone
@@ -1 +1 @@
-Subproject commit 0f1d587c098800a35a274db150a4b38b31a13952
+Subproject commit 2e5d1ea7319bd0672770001170d0c9e81095e1a6
index 43872d5..36d7027 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// (c) Konrad Rosenbaum, 2007-2011
+// (c) Konrad Rosenbaum, 2007-2016
 // protected under the GNU AGPL version 3 or at your option any newer
 // see COPYING.AGPL
 
@@ -29,7 +29,7 @@ function randseedinit()
        $RANDSEED.=microtime().uniqid("",true);
        //attempt to use OpenSSL
        if (function_exists('openssl_random_pseudo_bytes')) {
-               $RANDSEED .= openssl_random_pseudo_bytes(64, $strong);
+               $RANDSEED .= bin2hex(openssl_random_pseudo_bytes(64, $strong));
                // if it was strong, be happy and leave (it probably already used /dev/random)
                if($strong === true) {
                        return;
@@ -57,7 +57,8 @@ function getRandom($bits)
                $RANDCTR++;
        }
        //return
-       return substr($ret,0,$bits);
+       $ret=substr($ret,0,$bits);
+       return $ret;
 }
 
 /**return a salt value for Customer::setPassword */
@@ -89,8 +90,7 @@ function getCode39ID($length,$range=RND_ANYRANGE)
        $ret="";
        for($i=0;$i<$length;$i++){
                //cut random
-               $r="0x".substr($rnd,$i*2,2);
-               $r=($r+0)&31;
+               $r=hexdec(substr($rnd,$i*2,2)) & 31;
                //if this is the first char, further manipulate it;
                //this is relied upon by the ticket/voucher/item code to minimize
                //search for existing keys