-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqrcode.php
114 lines (113 loc) · 3.79 KB
/
qrcode.php
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
114
<?php
// ------------------------------------------------------------------------ //
// Author: Designburo.nl ([email protected]) //
// http://www.designburo.nl //
// Project: QRcode v1.0 //
// ------------------------------------------------------------------------ //
/**
*
* qrcode.php - compatibility layer for Designburo.nl qrcode module
*
* This file was adapted and modified by Richard Griffith - [email protected]
* to provide a compatibility layer for use with existing implementations that
* use the Designburo.nl XOOPS module QRcode.
*
* This adaptation uses the local resources available in the geekwright qr module
* for generating qr codes rather than depending on network communication with
* designburo.nl for code generation.
*
* Additional differences in this implementation:
* - size is ignored. Code size is based on configured options and the data encoded.
*
* @copyright Designburo.nl, geekwright
* @license GNU General Public License (GPL)
* @since 1.2
* @author Designburo.nl ([email protected]), Richard Griffith ([email protected])
* @package qr
* @version $Id$
*
**/
function qrcode($type="",$data=array(),$size="250")
{
$dir = basename( dirname( __FILE__ ) ) ;
$modurl=XOOPS_URL.'/modules/'.$dir.'/';
if($type!='')
{
switch ($type)
{
//QRCode with sending e-mail
case "email":
if (!$data['email']) { return "error no e-mail"; break;}
else
{
$l = "SMTP:".$data['email'].":".$data['subject'].":".$data['txt'];
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
// QRCode with phonenumber
case "phone":
if (!$data['phonenr']) { return "error no phonenumber"; break;}
else {
$l = "TEL:".$data['phonenr'];
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
// QRCcode sending SMS
case "sms";
if (!$data['phonenr']) { return "error no gsm number"; break;}
else {
$l = "SMSTO:".$data['phonenr'].":".$data['txt'];
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
// QRCode plain text
case "txt";
if (!$data['txt']) { return "error no text"; break;}
else {
$l = $data['txt'];
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
//QRCode url
case "url";
if (!$data['url']) { return "error no url"; break;}
else {
$l = $data['url'];
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
//QRCode gps coordinates
case "gps";
$l = "geo:".$data['lat'].",".$data['long'].",100";
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
//QRcode business card
case "contact";
$eor= "\r\n";
$l = "MECARD:";
$l.= "N:".$data['surname'].",".$data['name'].";";
$l.= "TEL-AV:".$data['mobile'].";";
$l.= "TEL:".$data['phonenr'].";";
$l.= "ADR:,,".$data['adres'].",".$data['state'].",".$data['city'].",".$data['zipcode'].",".$data['country'].";";
$l.= "EMAIL:".$data['email'].";";
$l.= "URL:".$data['url'].";";
$l.= "NOTE:".$data['title']." @ ".$data['company'].";";
$l.= "BDAY:".$data['b_year'].$data['b_month'].$data['b_day'].";";
$l.= ";";
$ul = rawurlencode(utf8_encode($l));
return '<img src="'.$modurl.'getqrcode.php?qrdata='.$ul.'">';
break;
}
}
else
{
return "error no type definition";
}
}
?>