1 | <?php |
||
2 | /* |
||
3 | * You may not change or alter any portion of this comment or credits |
||
4 | * of supporting developers from this source code or any supporting source code |
||
5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | * |
||
7 | * This program is distributed in the hope that it will be useful, |
||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
14 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team |
||
18 | */ |
||
19 | |||
20 | use XoopsModules\Mylinks; |
||
21 | |||
22 | require_once __DIR__ . '/header.php'; |
||
23 | //xoops_load('utility', $xoopsModule->getVar('dirname')); |
||
24 | |||
25 | $lid = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
26 | $cid = Mylinks\Utility::cleanVars($_GET, 'cid', 0, 'int', ['min' => 0]); |
||
27 | if (empty($lid) || empty($cid)) { |
||
28 | redirect_header('index.php', 3, _MD_MYLINKS_IDERROR); |
||
29 | } |
||
30 | /* |
||
31 | $lid = isset($_GET['lid']) ? (int)($_GET['lid']): 0; |
||
32 | $cid = isset($_GET['cid']) ? (int)($_GET['cid']): 0; |
||
33 | if ( empty($lid) ) { |
||
34 | die("No lid!"); |
||
35 | } elseif ( empty($cid) ) { |
||
36 | die("No cid!"); |
||
37 | } |
||
38 | */ |
||
39 | $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"); |
||
40 | if (!$result) { |
||
41 | redirect_header('index.php', 3, _MD_MYLINKS_NORECORDFOUND); |
||
42 | } |
||
43 | |||
44 | list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result); |
||
45 | |||
46 | //qrcode func |
||
47 | switch ($mylinks_can_qrcode) { |
||
48 | case _MD_MYLINKS_MEMBERONLY: |
||
49 | $can_qrcode = $xoopsUser ? _MD_MYLINKS_ALLOW : _MD_MYLINKS_DISALLOW; |
||
50 | break; |
||
51 | case _MD_MYLINKS_ALLOW: |
||
52 | $can_qrcode = _MD_MYLINKS_ALLOW; |
||
53 | break; |
||
54 | case _MD_MYLINKS_DISALLOW: |
||
55 | default: |
||
56 | $can_qrcode = _MD_MYLINKS_DISALLOW; |
||
57 | break; |
||
58 | } |
||
59 | /* |
||
60 | if (_MD_MYLINKS_DISALLOW == $can_qrcode) { |
||
61 | $xoopsTpl->assign( 'mylinksextrafuncqrcode' , false ); |
||
62 | } else { |
||
63 | $xoopsTpl->assign( 'mylinksextrafuncqrcode' , true ); |
||
64 | } |
||
65 | |||
66 | $can_qrcode = 0; |
||
67 | if ($mylinks_can_qrcode == 0) { |
||
68 | $can_qrcode = 0; |
||
69 | } elseif ($mylinks_can_qrcode == 1) { |
||
70 | $can_qrcode = 1; |
||
71 | } elseif ($mylinks_can_qrcode == 2) { |
||
72 | if ($xoopsUser) { |
||
73 | $can_qrcode =1; |
||
74 | } else { |
||
75 | $can_qrcode =0; |
||
76 | } |
||
77 | } else { |
||
78 | $can_qrcode = 0; |
||
79 | } |
||
80 | */ |
||
81 | if (_MD_MYLINKS_DISALLOW == $can_qrcode) { |
||
82 | redirect_header('index.php', 3, _MD_MYLINKS_QRCODEDISALLOWED); |
||
83 | } |
||
84 | |||
85 | $myts = \MyTextSanitizer::getInstance(); |
||
86 | |||
87 | /** |
||
88 | * @param $str |
||
89 | * @param string $to |
||
90 | * @param string $from |
||
91 | * @return array|mixed|string |
||
92 | */ |
||
93 | function mylinks_qrcode_convert_encoding($str, $to = 'SJIS', $from = _CHARSET) |
||
94 | { |
||
95 | if (function_exists('mb_convert_encoding')) { |
||
96 | if (is_array($str)) { |
||
97 | foreach ($str as $key => $val) { |
||
98 | $str[$key] = mylinks_qrcode_convert_encoding($val, $to, $from); |
||
99 | } |
||
100 | |||
101 | return $str; |
||
102 | } |
||
103 | |||
104 | return mb_convert_encoding($str, $to, $from); |
||
105 | } |
||
106 | |||
107 | return $str; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param string $data |
||
112 | * @return array|mixed|string |
||
113 | */ |
||
114 | function mylinks_qrcode_encoding($data = '') |
||
115 | { |
||
116 | $data = mylinks_qrcode_convert_encoding($data); |
||
117 | $data = rawurlencode($data); |
||
118 | $data = preg_replace('/%20/', '+', $data); |
||
119 | |||
120 | return $data; |
||
121 | } |
||
122 | |||
123 | $link_data = []; |
||
124 | $link_data['text'] = $myts->displayTarea($myts->stripSlashesGPC($description, 0)); |
||
125 | $link_data['title'] = $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)); |
||
126 | $link_data['url'] = $myts->htmlSpecialChars($url); |
||
127 | $data = "{$link_data['title']}\r\n{$link_data['url']}\r\n{$link_data['text']}"; |
||
128 | $qrcodedata = mylinks_qrcode_encoding($data); |
||
129 | $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"; |
||
130 | |||
131 | echo "<!DOCTYPE HTML>\n" |
||
132 | . "<html>\n" |
||
133 | . "<head>\n" |
||
134 | . '<title>' |
||
135 | . $xoopsConfig['sitename'] |
||
136 | . "</title>\n" |
||
137 | . "<meta http-equiv='Content-Type' content='text/html; charset=" |
||
138 | . _CHARSET |
||
139 | . "'>\n" |
||
140 | . "<meta name='AUTHOR' content='" |
||
141 | . $xoopsConfig['sitename'] |
||
142 | . "'>\n" |
||
143 | . "<meta name='COPYRIGHT' content='Copyright (c) " |
||
144 | . date('Y') |
||
145 | . ' by ' |
||
146 | . $xoopsConfig['sitename'] |
||
147 | . "'>\n" |
||
148 | . "<meta name='DESCRIPTION' content='" |
||
149 | . $xoopsConfig['slogan'] |
||
150 | . "'>\n" |
||
151 | . "<meta name='GENERATOR' content='" |
||
152 | . XOOPS_VERSION |
||
153 | . "'>\n" |
||
154 | . "</head>\n" |
||
155 | . "<body style='background-color: #ffffff; color: #000000;'>\n" |
||
156 | . " <div style='width: 750px; border: 1px solid #000; padding: 20px;'>\n" |
||
157 | . " <div style='text-align: center; display: block; margin: 0 0 6px 0;'>\n" |
||
158 | . " <h2 style='margin: 0px;'>" |
||
159 | . _MD_MYLINKS_SITETITLE |
||
160 | . " {$link_data['title']}</h2>\n" |
||
161 | . " </div>\n" |
||
162 | . " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" |
||
163 | . " <div style='text-align: left'>" |
||
164 | . _MD_MYLINKS_SITEURL |
||
165 | . " : {$link_data['url']}</div>\n" |
||
166 | . " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" |
||
167 | . " <div style='text-align: left'>" |
||
168 | . _MD_MYLINKS_DESCRIPTIONC |
||
169 | . '<br>' |
||
170 | . $link_data['text'] |
||
171 | . "</div>\n" |
||
172 | . " <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>\n" |
||
173 | . " <div style='text-align: left'>LINK DATA QRCODE<br>{$linkqrcode}</div>\n" |
||
174 | . " <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div>\n" |
||
175 | . ' <p>From: ' |
||
176 | . XOOPSMYLINKURL |
||
177 | . "/singlelink.php?cid={$cid}&lid={$lid}</p>\n" |
||
178 | . " </div>\n" |
||
179 | . " <br>\n" |
||
180 | . " <br>\n" |
||
181 | . "</body>\n" |
||
182 | . '</html>'; |
||
183 |