01.
<center>
02.
03.
<?php
04.
$pis
= 1234;
05.
?>
06.
<?php
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
$PNG_TEMP_DIR
= dirname(
__FILE__
).DIRECTORY_SEPARATOR.
'temp'
.DIRECTORY_SEPARATOR;
34.
35.
36.
$PNG_WEB_DIR
=
'temp/'
;
37.
38.
include
"qrlib.php"
;
39.
40.
41.
if
(!
file_exists
(
$PNG_TEMP_DIR
))
42.
mkdir
(
$PNG_TEMP_DIR
);
43.
44.
45.
$filename
=
$PNG_TEMP_DIR
.
'test.png'
;
46.
47.
48.
49.
$errorCorrectionLevel
=
'H'
;
50.
if
(isset(
$_REQUEST
[
'level'
]) && in_array(
$_REQUEST
[
'level'
],
array
(
'L'
,
'M'
,
'Q'
,
'H'
)))
51.
$errorCorrectionLevel
=
$_REQUEST
[
'level'
];
52.
53.
$matrixPointSize
= 4;
54.
if
(isset(
$_REQUEST
[
'size'
]))
55.
$matrixPointSize
= min(max((int)
$_REQUEST
[
'size'
], 1), 10);
56.
57.
58.
if
(isset(
$_REQUEST
[
'data'
])) {
59.
60.
61.
if
(trim(
$_REQUEST
[
'data'
]) ==
''
)
62.
die
(
'data cannot be empty! <a href="?">back</a>'
);
63.
64.
65.
$filename
=
$PNG_TEMP_DIR
.
''
.md5(
$_REQUEST
[
'data'
].
'|'
.
$errorCorrectionLevel
.
'|'
.
$matrixPointSize
).
'.png'
;
66.
QRcode::png(
$_REQUEST
[
''
],
$filename
,
$errorCorrectionLevel
,
$matrixPointSize
, 2);
67.
68.
}
else
{
69.
70.
71.
72.
73.
QRcode::png (
'$pic'
,
$filename
,
$errorCorrectionLevel
,
$matrixPointSize
, 2);
74.
75.
}
76.
77.
echo
'<img src="'
.
$PNG_WEB_DIR
.
basename
(
$filename
).
'" /><hr/>'
;
78.