|
1
|
|
|
<?php |
|
2
|
|
|
// $Id: makepdf.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
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
|
28
|
|
|
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|
29
|
|
|
// Project: The XOOPS Project // |
|
30
|
|
|
// ------------------------------------------------------------------------- // |
|
31
|
|
|
|
|
32
|
|
|
error_reporting(0); |
|
33
|
|
|
include_once __DIR__ . '/header.php'; |
|
34
|
|
|
include_once __DIR__ . '/class/utility.php'; |
|
35
|
|
|
//xoops_load('utility', $xoopsModule->getVar('dirname')) ; |
|
36
|
|
|
|
|
37
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
|
|
38
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_GET, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
if (empty($lid) || empty($cid)) { |
|
41
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_IDERROR); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$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"); |
|
45
|
|
|
list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result); |
|
46
|
|
|
|
|
47
|
|
|
if (empty($lid)) { |
|
48
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_NORECORDFOUND); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
switch ($mylinks_can_pdf) { |
|
52
|
|
|
case _MD_MYLINKS_MEMBERONLY: |
|
53
|
|
|
$can_pdf = $xoopsUser ? _MD_MYLINKS_ALLOW : _MD_MYLINKS_DISALLOW; |
|
54
|
|
|
case _MD_MYLINKS_ALLOW: |
|
55
|
|
|
$can_pdf = _MD_MYLINKS_ALLOW; |
|
56
|
|
|
break; |
|
57
|
|
|
case _MD_MYLINKS_DISALLOW: |
|
58
|
|
|
default: |
|
59
|
|
|
$can_pdf = _MD_MYLINKS_DISALLOW; |
|
60
|
|
|
break; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if (_MD_MYLINKS_DISALLOW == $can_pdf) { |
|
64
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_PDFDISALLOWED); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
68
|
|
|
require_once XOOPSMYLINKPATH . '/fpdf/fpdf.inc.php'; |
|
69
|
|
|
|
|
70
|
|
|
//$pdf_data['title'] = $myts->htmlSpecialChars($ltitle); |
|
71
|
|
|
$pdf_data['title'] = $ltitle; |
|
72
|
|
|
$pdf_data['subtitle'] = ''; |
|
73
|
|
|
$pdf_data['subsubtitle'] = $myts->htmlSpecialChars($url); |
|
74
|
|
|
$pdf_data['date'] = formatTimestamp($time); |
|
75
|
|
|
$pdf_data['filename'] = ''; |
|
76
|
|
|
$pdf_data['author'] = ''; |
|
77
|
|
|
|
|
78
|
|
|
// strip out unwanted html code from description |
|
79
|
|
|
$description = html_entity_decode($description, ENT_QUOTES, 'UTF-8'); |
|
80
|
|
|
$allowable_tags = '<br><br/><br /><b><i><u><em><strong><p>'; |
|
81
|
|
|
$description = strip_tags($description, $allowable_tags); |
|
82
|
|
|
$pdf_data['content'] = $myts->displayTarea($description, 1); |
|
83
|
|
|
|
|
84
|
|
|
//Other stuff |
|
85
|
|
|
$puff = '<br>'; |
|
86
|
|
|
$puffer = '<br><br><br>'; |
|
87
|
|
|
|
|
88
|
|
|
//create the A4-PDF... |
|
89
|
|
|
$pdf_config['slogan'] = $xoopsConfig['sitename'] . ' - ' . $xoopsConfig['slogan']; |
|
90
|
|
|
|
|
91
|
|
|
$pdf = new PDF(); |
|
92
|
|
|
if (method_exists($pdf, 'encoding')) { |
|
93
|
|
|
$pdf->encoding($pdf_data, _CHARSET); |
|
94
|
|
|
} |
|
95
|
|
|
$pdf->SetCreator($pdf_config['creator']); |
|
96
|
|
|
$pdf->SetTitle($pdf_data['title']); |
|
97
|
|
|
$pdf->SetAuthor($pdf_config['url']); |
|
98
|
|
|
$pdf->SetSubject($pdf_data['author']); |
|
99
|
|
|
$out = $pdf_config['url'] . ', ' . $pdf_data['author'] . ', ' . $pdf_data['title'] . ', ' . $pdf_data['subtitle'] . ', ' . $pdf_data['subsubtitle']; |
|
100
|
|
|
$pdf->SetKeywords($out); |
|
101
|
|
|
$pdf->SetAutoPageBreak(true, 25); |
|
102
|
|
|
$pdf->SetMargins($pdf_config['margin']['left'], $pdf_config['margin']['top'], $pdf_config['margin']['right']); |
|
103
|
|
|
$pdf->Open(); |
|
104
|
|
|
|
|
105
|
|
|
//First page |
|
106
|
|
|
$pdf->AddPage(); |
|
107
|
|
|
$pdf->SetXY(24, 25); |
|
108
|
|
|
$pdf->SetTextColor(10, 60, 160); |
|
109
|
|
|
$pdf->SetFont($pdf_config['font']['slogan']['family'], $pdf_config['font']['slogan']['style'], $pdf_config['font']['slogan']['size']); |
|
110
|
|
|
$pdf->WriteHTML($pdf_config['slogan'], $pdf_config['scale']); |
|
111
|
|
|
//$pdf->Image($pdf_config['logo']['path'],$pdf_config['logo']['left'],$pdf_config['logo']['top'],$pdf_config['logo']['width'],$pdf_config['logo']['height'],'',$pdf_config['url']); |
|
112
|
|
|
$pdf->Line(25, 30, 190, 30); |
|
113
|
|
|
$pdf->SetXY(25, 35); |
|
114
|
|
|
$pdf->SetFont($pdf_config['font']['title']['family'], $pdf_config['font']['title']['style'], $pdf_config['font']['title']['size']); |
|
115
|
|
|
$pdf->WriteHTML($pdf_data['title'], $pdf_config['scale']); |
|
116
|
|
|
|
|
117
|
|
View Code Duplication |
if ($pdf_data['subtitle'] <> '') { |
|
118
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
|
119
|
|
|
$pdf->SetFont($pdf_config['font']['subtitle']['family'], $pdf_config['font']['subtitle']['style'], $pdf_config['font']['subtitle']['size']); |
|
120
|
|
|
$pdf->WriteHTML($pdf_data['subtitle'], $pdf_config['scale']); |
|
121
|
|
|
} |
|
122
|
|
View Code Duplication |
if ($pdf_data['subsubtitle'] <> '') { |
|
123
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
|
124
|
|
|
$pdf->SetFont($pdf_config['font']['subsubtitle']['family'], $pdf_config['font']['subsubtitle']['style'], $pdf_config['font']['subsubtitle']['size']); |
|
125
|
|
|
$pdf->WriteHTML($pdf_data['subsubtitle'], $pdf_config['scale']); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
|
129
|
|
|
$pdf->SetFont($pdf_config['font']['author']['family'], $pdf_config['font']['author']['style'], $pdf_config['font']['author']['size']); |
|
130
|
|
|
$out = ''; |
|
131
|
|
|
$out .= $pdf_data['author']; |
|
132
|
|
|
$pdf->WriteHTML($out, $pdf_config['scale']); |
|
133
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
|
134
|
|
|
$out = _DATE . ':'; |
|
135
|
|
|
$out .= $pdf_data['date']; |
|
136
|
|
|
$pdf->WriteHTML($out, $pdf_config['scale']); |
|
137
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
|
138
|
|
|
|
|
139
|
|
|
$pdf->SetTextColor(0, 0, 0); |
|
140
|
|
|
$pdf->WriteHTML($puffer, $pdf_config['scale']); |
|
141
|
|
|
|
|
142
|
|
|
$pdf->SetFont($pdf_config['font']['content']['family'], $pdf_config['font']['content']['style'], $pdf_config['font']['content']['size']); |
|
143
|
|
|
$pdf->WriteHTML($pdf_data['content'], $pdf_config['scale']); |
|
144
|
|
|
|
|
145
|
|
|
//$pdf->Output($pdf_data['filename'],''); |
|
146
|
|
|
$pdf->Output(); |
|
147
|
|
|
|
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: