0

I try to generate pay by square QR code but I have error in:

$x = proc_open("/usr/bin/xz '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'", [0 => ["pipe", "r"], 1 => ["pipe", "w"]], $p);

I dont know how to fix... any idea?

Whole code:

<?php
    $d = implode("\t", array(
        0 => '',
        1 => '1',
        2 => implode("\t", array(
            true,
            123.45,                     // SUMA
            'EUR',                      // JEDNOTKA
            '20170101',                 // DATUM
            123456789,                  // VARIABILNY SYMBOL
            '0308',                     // KONSTANTNY SYMBOL
            '1111',                     // SPECIFICKY SYMBOL
            '',
            'poznamka',                 // POZNAMKA
            '1',
            'SK8011000000001234567890', // IBAN
            'TATRSKBX',                 // SWIFT
            '0',
            '0'
        ))
    ));
    $d = strrev(hash("crc32b", $d, TRUE)) . $d;
    $x = proc_open("/usr/bin/xz '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'", [0 => ["pipe", "r"], 1 => ["pipe", "w"]], $p);
    fwrite($p[0], $d);
    fclose($p[0]);
    $o = stream_get_contents($p[1]);
    fclose($p[1]);
    proc_close($x);
    $d = bin2hex("\x00\x00" . pack("v", strlen($d)) . $o);
    $b = "";
    for ($i = 0;$i < strlen($d);$i++) {
        $b .= str_pad(base_convert($d[$i], 16, 2), 4, "0", STR_PAD_LEFT);
    }
    $l = strlen($b);
    $r = $l % 5;
    if ($r > 0) {
        $p = 5 - $r;
        $b .= str_repeat("0", $p);
        $l += $p;
    }
    $l = $l / 5;
    $d = str_repeat("_", $l);
    for ($i = 0;$i < $l;$i += 1) {
        $d[$i] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"[bindec(substr($b, $i * 5, 5))];
    }
    if (!empty($d)) {
        $u = '/chart?chs=200x200&cht=qr&chld=L|0&choe=UTF-8&chl=' . $d;
        $s = @fsockopen("chart.googleapis.com", 80, $e, $r, 1);
        if ($s) {
            $h = "GET " . $u . " HTTP/1.0\r\n";
            $h .= "Host: chart.googleapis.com\r\n";
            $h .= "Connection: close\r\n\r\n";
            fwrite($s, $h); $e = ''; $c = "";
            do {
                $e .= fgets($s, 128);
            } while (strpos($e, "\r\n\r\n") === false);
            while (!feof($s)) {
                $c .= fgets($s, 4096);
            }
            fclose($s);
        }
        header('Content-Type: image/png');
        echo $c;
    }
Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
Stanley01
  • 55
  • 8
  • Whats the error? – chris85 Jul 20 '17 at 16:02
  • Parse error: syntax error, unexpected '[' in /home/zh004600/www_root/public/text/atomia/qr.php on line 23 – Stanley01 Jul 20 '17 at 16:14
  • What PHP version are you using? I'd guess less than 5.4, https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them/29505827#29505827 – chris85 Jul 20 '17 at 16:28
  • 1
    Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – chris85 Jul 20 '17 at 16:28
  • Before posting your next question you should go through [the tour](https://stackoverflow.com/tour) and then go to the [Help Section](http://stackoverflow.com/help) to read [What types of questions should I avoid asking?](http://stackoverflow.com/help/on-topic). Finally, if you are sure your question fits the rules, read [How to Ask a question on StackOverflow](http://stackoverflow.com/help/how-to-ask) to be able to make a useful, well formed and on-topic question. – gp_sflover Jul 20 '17 at 21:00

1 Answers1

2

https://jan.fecik.sk/blog/qr-generator-platieb-pay-by-square-v-php.html

Tiež treba brať ohľad na funkčnosť a existenciu /usr/bin/xz ktorý je potrebný pre správne fungovanie a nachádza sa na 23. riadku v PHP skripte.

which can be roughly translated as:

Make sure your /usr/bin/xz exists and is functional, since it is used in the line 23 of the PHP script.

andrewsh
  • 1,115
  • 7
  • 12
Keeper1
  • 21
  • 1