index.php
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* REQUIRE:
* * apt-get install php5-imagick
* * .htaccess -> _htaccess
* * Apache rewrite Modul
*
* links zum drauf zugreifen:
* * http://localhost/service/qrcode/?qrcode=test
* * http://localhost/service/qrcode/a:3:%7Bi:0;s:17:%22www.quaink.de/qr/%22;i:1;s:6:%22test_2%22;i:2;s:6:%22test_2%22;}
*
*
* ACHTUNG: BITTE NICHT AENDERN, DA SERVICEPLUS DRAUF ZUGREIFT!!!!! @since 20111219 @author neumann@netz.coop
*
*/
require_once('basepath.inc.php');
require_once($__PATH_to_mcClasses . 'include.php');
//D::show($_GET, 'get',1,1);
if(array_key_exists('qrcode', $_GET) && $_GET['qrcode']) {
// echo mcQRCode::createQRCode($_GET['qrcode']);
// return QRcode::png($_GET['qrcode'], $outfile = false, $level = QR_ECLEVEL_L, $size = 1, $margin = 4, $saveandprint=false);
//} else {
// $qrtxt = array(
// 'www.quaink.de/qr',
// 'user',
// 'XXSSAA'
// );
// $qrtxt = serialize($qrtxt);
//
$qrtxt = $_GET['qrcode'];
/**
* text
*/
if(strpos($qrtxt, '}')) {
$array_qrtxt = unserialize($qrtxt);
if(isset ($array_qrtxt) && is_array($array_qrtxt) && count($array_qrtxt) ==3) {
$_txt1 = $array_qrtxt[0];
$_txt2 = 'ID: '.$array_qrtxt[1];
$_txt3 = 'Passwort: '.$array_qrtxt[2];
$_url = 'http://'.$array_qrtxt[0].'/index_cs.php?user_id='.$array_qrtxt[1].'&pw='.$array_qrtxt[2];
}
} else {
$_txt1 = $qrtxt;
$_txt2 = 'ID: '.$qrtxt;
$_txt3 = 'Passwort: '.$qrtxt;
$_url = 'http://'.$qrtxt.'/';
}
$Nenner = 3;
// $qrcode_size = 200;
$qrcode_size = 581;
$tmp_qrfilepath = 'tmp/tmp_qrfile.png';
$margin = 2;
$font_size = 60;
$font_type = 'Arial';
$font_start = 38;
$qrcode_size = $qrcode_size / $Nenner;
$font_size = $font_size / $Nenner;
$font_start = $font_start / $Nenner;
QRcode::png($_url, $tmp_qrfilepath , $level = QR_ECLEVEL_L, $size = 10, $margin, $saveandprint=false);
$qr_image = new Imagick($tmp_qrfilepath);
$qr_image->scaleImage($qrcode_size,$qrcode_size);
$draw = new ImagickDraw();
$draw->setFillColor('black');
/**
* Achtung, Probleme kann es geben wenn die Fonts nicht installiert sind
*/
// $draw->setFont($font_type);
$draw->setFontSize( $font_size );
$text_image = new Imagick();
$text_image->newImage($qrcode_size/2, $qrcode_size, new ImagickPixel( 'white' ));
$text_image->setImageFormat('png');
$text_image->annotateImage($draw, 70, $font_start, 90, $_txt1);
$text_image->annotateImage($draw, 40, $font_start, 90, $_txt2);
$text_image->annotateImage($draw, 20, $font_start, 90, $_txt3);
$canvas = new Imagick();
$canvas->newImage($qrcode_size + $qrcode_size/2, $qrcode_size, new ImagickPixel("white"));
$canvas->setImageFormat("png");
$canvas->compositeImage($qr_image, imagick::COMPOSITE_OVER, 0, 0);
$canvas->compositeImage($text_image, imagick::COMPOSITE_OVER, $qr_image->getImageWidth() + 0, 0);
$canvas->borderImage(new ImagickPixel("black"), 5, 5);
header('Content-type: image/png');
echo $canvas;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//$image->thumbnailImage(100, 0);
// bild größe skalieren
// $image->adaptiveResizeImage(1024,768);
// $image->scaleImage(800,800);
// $qr_image->setSize(800,800);
?>