1
|
|
|
<?php |
2
|
|
|
// $Id: qrcode.php 11158 2013-03-05 14:10:36Z zyspec $ |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
6
|
|
|
// <http://www.xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------- // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
|
28
|
|
|
include __DIR__ . '/header.php'; |
29
|
|
|
include_once __DIR__ . '/class/utility.php'; |
30
|
|
|
//xoops_load('utility', $xoopsModule->getVar('dirname')); |
31
|
|
|
|
32
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
33
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_GET, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
34
|
|
|
if (empty($lid) || empty($cid)) { |
35
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_IDERROR); |
36
|
|
|
} |
37
|
|
|
/* |
38
|
|
|
$lid = isset($_GET['lid']) ? intval($_GET['lid']) : 0; |
39
|
|
|
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0; |
40
|
|
|
if ( empty($lid) ) { |
41
|
|
|
die("No lid!"); |
42
|
|
|
} elseif ( empty($cid) ) { |
43
|
|
|
die("No cid!"); |
44
|
|
|
} |
45
|
|
|
*/ |
46
|
|
|
$result = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.url, l.logourl, l.status, l.date, l.hits, l.rating, l.votes, l.comments, t.description FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . " t where l.lid={$lid} AND l.lid=t.lid and status>0"); |
47
|
|
|
if (!$result) { |
48
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_NORECORDFOUND); |
49
|
|
|
exit(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result); |
53
|
|
|
|
54
|
|
|
//qrcode func |
55
|
|
View Code Duplication |
switch ($mylinks_can_qrcode) { |
|
|
|
|
56
|
|
|
case _MD_MYLINKS_MEMBERONLY: |
57
|
|
|
$can_qrcode = $xoopsUser ? _MD_MYLINKS_ALLOW : _MD_MYLINKS_DISALLOW; |
58
|
|
|
break; |
59
|
|
|
case _MD_MYLINKS_ALLOW: |
60
|
|
|
$can_qrcode = _MD_MYLINKS_ALLOW; |
61
|
|
|
break; |
62
|
|
|
case _MD_MYLINKS_DISALLOW: |
63
|
|
|
default: |
64
|
|
|
$can_qrcode = _MD_MYLINKS_DISALLOW; |
65
|
|
|
break; |
66
|
|
|
} |
67
|
|
|
/* |
68
|
|
|
if ( _MD_MYLINKS_DISALLOW == $can_qrcode ) { |
69
|
|
|
$xoopsTpl->assign( 'mylinksextrafuncqrcode' , false ); |
70
|
|
|
} else { |
71
|
|
|
$xoopsTpl->assign( 'mylinksextrafuncqrcode' , true ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
$can_qrcode = 0; |
75
|
|
|
if ( $mylinks_can_qrcode == 0 ) { |
76
|
|
|
$can_qrcode = 0; |
77
|
|
|
} |
78
|
|
|
else if ( $mylinks_can_qrcode == 1) { |
79
|
|
|
$can_qrcode = 1; |
80
|
|
|
} |
81
|
|
|
else if ( $mylinks_can_qrcode == 2) { |
82
|
|
|
if ( $xoopsUser ) { |
83
|
|
|
$can_qrcode =1; |
84
|
|
|
} |
85
|
|
|
else { |
86
|
|
|
$can_qrcode =0; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
else { |
90
|
|
|
$can_qrcode = 0; |
91
|
|
|
} |
92
|
|
|
*/ |
93
|
|
|
if (_MD_MYLINKS_DISALLOW == $can_qrcode) { |
94
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_QRCODEDISALLOWED); |
95
|
|
|
exit(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
$myts = MyTextSanitizer::getInstance(); |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param $str |
102
|
|
|
* @param string $to |
103
|
|
|
* @param string $from |
104
|
|
|
* @return array|string |
105
|
|
|
*/ |
106
|
|
View Code Duplication |
function mylinks_qrcode_convert_encoding($str, $to = 'SJIS', $from = _CHARSET) |
|
|
|
|
107
|
|
|
{ |
108
|
|
|
if (function_exists('mb_convert_encoding')) { |
109
|
|
|
if (is_array($str)) { |
110
|
|
|
foreach ($str as $key => $val) { |
111
|
|
|
$str[$key] = mylinks_qrcode_convert_encoding($val, $to, $from); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $str; |
115
|
|
|
} else { |
116
|
|
|
return mb_convert_encoding($str, $to, $from); |
117
|
|
|
} |
118
|
|
|
} else { |
119
|
|
|
return $str; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param string $data |
125
|
|
|
* @return array|string |
126
|
|
|
*/ |
127
|
|
|
function mylinks_qrcode_encoding($data = '') |
128
|
|
|
{ |
129
|
|
|
$data = mylinks_qrcode_convert_encoding($data); |
130
|
|
|
$data = rawurlencode($data); |
131
|
|
|
$data = ereg_replace('%20', '+', $data); |
132
|
|
|
|
133
|
|
|
return $data; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
$link_data = array(); |
137
|
|
|
$link_data['text'] = $myts->displayTarea($myts->stripSlashesGPC($description, 0)); |
138
|
|
|
$link_data['title'] = $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)); |
139
|
|
|
$link_data['url'] = $myts->htmlSpecialChars($url); |
140
|
|
|
$data = "{$link_data['title']}\r\n{$link_data['url']}\r\n{$link_data['text']}"; |
141
|
|
|
$qrcodedata = mylinks_qrcode_encoding($data); |
142
|
|
|
$linkqrcode = "<img alt='qrcode of linkdata' title='qrcode of linkdata'src='" . XOOPS_URL . "/modules/qrcode/qrcode_image.php?d={$qrcodedata}&e=M&s=4&v=0&t=P&rgb=000000'>\n"; |
143
|
|
|
|
144
|
|
|
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n" . "<html>\n" . "<head>\n" . '<title>' . $xoopsConfig['sitename'] . "</title>\n" . "<meta http-equiv='Content-Type' content='text/html; charset=" . _CHARSET . "'>\n" . "<meta name='AUTHOR' content='" . $xoopsConfig['sitename'] |
145
|
|
|
. "'>\n" . "<meta name='COPYRIGHT' content='Copyright (c) " . date('Y') . ' by ' . $xoopsConfig['sitename'] . "'>\n" . "<meta name='DESCRIPTION' content='" . $xoopsConfig['slogan'] . "'>\n" . "<meta name='GENERATOR' content='" . XOOPS_VERSION . "'>\n" . "</head>\n" |
146
|
|
|
. "<body style='background-color: #ffffff; color: #000000;'>\n" . " <div style='width: 750px; border: 1px solid #000; padding: 20px;'>\n" . " <div style='text-align: center; display: block; margin: 0 0 6px 0;'>\n" . " <h2 style='margin: 0px;'>" . _MD_MYLINKS_SITETITLE |
147
|
|
|
. " {$link_data['title']}</h2>\n" . " </div>\n" . " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" . " <div style='text-align: left'>" . _MD_MYLINKS_SITEURL |
148
|
|
|
. " : {$link_data['url']}</div>\n" . " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" . " <div style='text-align: left'>" . _MD_MYLINKS_DESCRIPTIONC . '<br>' . $link_data['text'] . "</div>\n" |
149
|
|
|
. " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" . " <div style='text-align: left'>LINK DATA QRCODE<br>{$linkqrcode}</div>\n" . " <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div>\n" |
150
|
|
|
. ' <p>From: ' . XOOPSMYLINKURL . "/singlelink.php?cid={$cid}&lid={$lid}</p>\n" . " </div>\n" . " <br>\n" . " <br>\n" . "</body>\n" . '</html>'; |
151
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: