From 6458123e1276147095f296522a61823676006f3f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 9 Jun 2016 17:32:33 +0200 Subject: Use PHP library for QR codes Signed-off-by: Florian Pritz --- .gitmodules | 3 +++ README.md | 1 - application/controllers/file.php | 6 +++++- application/libraries/Customautoloader.php | 3 +++ application/third_party/QrCode | 1 + docker/Dockerfile | 2 +- install.php | 8 -------- 7 files changed, 13 insertions(+), 11 deletions(-) create mode 160000 application/third_party/QrCode diff --git a/.gitmodules b/.gitmodules index 7209fd166..8e18180fc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "application/third_party/mockery"] path = application/third_party/mockery url = https://github.com/padraic/mockery.git +[submodule "application/third_party/QrCode"] + path = application/third_party/QrCode + url = https://github.com/endroid/QrCode.git diff --git a/README.md b/README.md index 0724eae01..289ead211 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ not need to register to be allowed to post. * [pygmentize](http://pygments.org/) for code highlighting * [ansi2html](http://pypi.python.org/pypi/ansi2html) for shell output rendering (ANSI color codes) -* [qrencode](http://megaui.net/fukuchi/works/qrencode/index.en.html) for qrcode generation * [imagemagick](http://www.imagemagick.org/) for additional thumbnail generation * [node.js](https://nodejs.org/) for javascript minification diff --git a/application/controllers/file.php b/application/controllers/file.php index 56928015f..7c49988bf 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -131,7 +131,11 @@ class File extends MY_Controller { handle_etag($etag); header("Content-disposition: inline; filename=\"".$id."_qr.png\"\n"); header("Content-Type: image/png\n"); - echo (new \libraries\ProcRunner(array('qrencode', '-s', '10', '-o', '-', site_url($id).'/')))->execSafe()['stdout']; + $qr = new \Endroid\QrCode\QrCode(); + $qr->setText(site_url($id).'/') + ->setSize(350) + ->setErrorCorrection('low') + ->render(); exit(); case "info": diff --git a/application/libraries/Customautoloader.php b/application/libraries/Customautoloader.php index 6a616ba7f..426364ee3 100644 --- a/application/libraries/Customautoloader.php +++ b/application/libraries/Customautoloader.php @@ -17,6 +17,9 @@ class CustomAutoloader{ public function loader($className) { $namespaces = array( + 'Endroid\QrCode' => [ + ["path" => APPPATH."/third_party/QrCode/src/"], + ], '' => [ ["path" => APPPATH], ["path" => APPPATH."/third_party/mockery/library/"] diff --git a/application/third_party/QrCode b/application/third_party/QrCode new file mode 160000 index 000000000..4638f11b6 --- /dev/null +++ b/application/third_party/QrCode @@ -0,0 +1 @@ +Subproject commit 4638f11b6944cccce997db7fa7508b5a7ad1a61b diff --git a/docker/Dockerfile b/docker/Dockerfile index 395faf4d6..70e82f9e2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update -y && \ apt-get install -y php5 php5-mysql php5-gd php5-imagick libtext-markdown-perl expect \ - python-pygments qrencode imagemagick git python-pip realpath curl apt-transport-https + python-pygments imagemagick git python-pip realpath curl apt-transport-https RUN echo 'deb https://deb.nodesource.com/node_4.x trusty main' > /etc/apt/sources.list.d/nodesource.list RUN echo 'deb-src https://deb.nodesource.com/node_4.x trusty main' >> /etc/apt/sources.list.d/nodesource.list diff --git a/install.php b/install.php index 3d486d911..1deb8cc2a 100644 --- a/install.php +++ b/install.php @@ -60,14 +60,6 @@ if ($buf != "0") { $errors .= " - Error when testing ansi2html: Return code was \"$buf\".\n"; } -// test qrencode -ob_start(); -passthru("qrencode -V 2>&1", $buf); -ob_end_clean(); -if ($buf != "0") { - $errors .= " - Error when testing qrencode: Return code was \"$buf\".\n"; -} - // test imagemagick ob_start(); passthru("convert --version 2>&1", $buf); -- cgit v1.2.3-24-g4f1b