PluginProbe
Ebook Store / 6.25
Ebook Store v6.25
6.25 6.24 6.23 6.22 6.21 6.20 trunk
ebook-store / qrcode.class.php

qrcode.class.php in Ebook Store 6.25, at qrcode.class.php

202 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 global $ebook_store_page_counter;
3 $ebook_store_page_counter = 0;
4
5
6 class QRPDF extends FPDI_Protection {
7
8 function Footer() {
9
10 global $ebook_png_path, $pdfHeaderText, $ebook_store_page_counter;
11
12 if (get_option('ebook_store_watermark_mode','every') == 'first' && $ebook_store_page_counter >= 1) {
13 error_log("PAGE COUNTER $ebook_store_page_counter");
14 return;
15 }
16
17 if (get_option('qr_code')) {
18
19 $this->Image($ebook_png_path,$this->w - 20,$this->h - 20,20,20);
20 //$this->Image($ebook_png_path,1,1,19.5,19.5);
21
22 }
23 if (get_option('buyer_info')) {
24 //error_reporting(E_ALL);
25 $this->SetFont('Helvetica');
26 // $this->AddFont('FreeSerif');
27 // $this->SetFont('FreeSerif');
28 $this->SetTextColor(255, 0, 0);
29 $hex = esc_attr(get_option('ebook_store_watermark_color_hex','#FF0000'));
30 list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
31 $this->SetTextColor($r, $g, $b);
32 // $this->SetXY(3, 3);
33 // $this->SetFontSize(10);
34 // $this->Write(0, $pdfHeaderText);
35 if (function_exists('inconv')) {
36 $pdfHeaderText = iconv('UTF-8', 'windows-1251', $pdfHeaderText);
37 }
38 $ebook_store_buyer_info_position = esc_attr(get_option('ebook_store_buyer_info_position','top'));
39 if ($ebook_store_buyer_info_position == 'top') {
40 $this->Cell(0, 0, $pdfHeaderText, 0, 0, 'C');
41 } else if ($ebook_store_buyer_info_position == 'middle') {
42 $this->Cell($this->w, $this->h, $pdfHeaderText, 0, 0, 'C');
43 } else if ($ebook_store_buyer_info_position == 'bottom') {
44 $this->SetY(-15);
45 $this->Cell(0, 10, $pdfHeaderText, 0, 0, 'C');
46 }
47 }
48
49 $ebook_store_page_counter++;
50
51 }
52
53 }
54
55 class QRClass{
56
57
58
59 /* Plain text */
60
61
62
63 public function text($text, $size_h = 350, $size_w = 350) {
64
65
66
67 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl='.urlencode($text);
68 //return 'https://api.qrserver.com/v1/create-qr-code/?size='.$size_w.'x'.$size_h.'&data='.urlencode($text);
69
70
71
72 }
73
74
75
76 /* E-mail addresses */
77
78
79
80 function email($email, $size_h = 350, $size_w = 350) {
81
82
83
84 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl=mailto%3A'.urlencode($email);
85 //return 'https://api.qrserver.com/v1/create-qr-code/?size='.$size_w.'x'.$size_h.'&data='.urlencode($text);
86
87
88
89 }
90
91
92
93 /* Phone numbers */
94
95
96
97 function phone_numbers($number, $size_h = 350, $size_w = 350) {
98
99
100
101 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl=tel%3A'.urlencode($number);
102
103
104
105 }
106
107
108
109 /* URL */
110
111
112
113 function url($url, $size_h = 350, $size_w = 350) {
114
115
116
117 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl='.urlencode($url);
118
119
120
121 }
122
123
124
125 /* SMS */
126
127
128
129 function sms($receiver, $message, $size_h = 350, $size_w = 350) {
130
131
132
133 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl=smsto%3A'.urlencode($receiver).'%3A'.urlencode($message);
134
135
136
137 }
138
139
140
141 /* Wifi network */
142
143
144
145 function wifi($ssid, $password, $type, $size_h = 350, $size_w = 350) {
146
147
148
149 return 'http://chart.apis.google.com/chart?cht=qr&chs='.$size_w.'x'.$size_h.'&chl=WIFI%3AS%3A'.$ssid.'%3BT%3A'.$type.'%3BP%3A'.$password.'%3B%3B';
150
151
152
153 }
154
155
156
157 /* Save image */
158
159
160
161 function save($image, $destination) {
162
163
164
165 if(file_exists($destination)) {
166
167
168
169 return FALSE;
170
171
172
173 } else {
174
175
176
177 $img = imagecreatefrompng($image);
178
179 imagepng($img, $destination);
180
181 //file_put_contents($destination,file_get_contents($image));
182
183 return TRUE;
184
185
186
187 }
188
189
190
191 }
192
193
194
195
196
197 }
198
199
200
201 ?>
202