Completed
Push — master ( 876a9b...234b0e )
by Michael
03:09
created

makepdf.php (9 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 'header.php';
34
include_once './class/utility.php';
35
//xoops_load('utility', $xoopsModule->getVar('dirname')) ;
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
37
$lid   = mylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min'=>0)) ;
0 ignored issues
show
'lid' is of type string, but the function expects a object<unknown_type>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
$cid   = mylinksUtility::mylinks_cleanVars($_GET, 'cid', 0, 'int', array('min'=>0)) ;
0 ignored issues
show
'cid' is of type string, but the function expects a object<unknown_type>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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
{
53
    case _MD_MYLINKS_MEMBERONLY:
0 ignored issues
show
There must be a comment when fall-through is intentional in a non-empty case body
Loading history...
54
        $can_pdf = ( $xoopsUser ) ? _MD_MYLINKS_ALLOW : _MD_MYLINKS_DISALLOW;
55
    case _MD_MYLINKS_ALLOW:
56
        $can_pdf = _MD_MYLINKS_ALLOW;
57
        break;
58
    case _MD_MYLINKS_DISALLOW:
59
    default:
60
        $can_pdf = _MD_MYLINKS_DISALLOW;
61
        break;
62
}
63
64
if ( _MD_MYLINKS_DISALLOW == $can_pdf) {
65
    redirect_header('index.php', 3, _MD_MYLINKS_PDFDISALLOWED);
66
}
67
68
$myts =& MyTextSanitizer::getInstance();
69
require_once XOOPSMYLINKPATH . '/fpdf/fpdf.inc.php' ;
70
71
//$pdf_data['title'] = $myts->htmlSpecialChars($ltitle);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
72
$pdf_data['title']       = $ltitle;
73
$pdf_data['subtitle']    = '';
74
$pdf_data['subsubtitle'] = $myts->htmlSpecialChars($url);
75
$pdf_data['date']        = formatTimestamp($time);
76
$pdf_data['filename']    = '';
77
$pdf_data['author']      = '';
78
79
// strip out unwanted html code from description
80
$description = html_entity_decode($description, ENT_QUOTES, 'UTF-8');
81
$allowable_tags = '<br><br/><br /><b><i><u><em><strong><p>';
82
$description = strip_tags($description, $allowable_tags);
83
$pdf_data['content'] = $myts->displayTarea($description, 1);
84
85
//Other stuff
86
$puff='<br>';
87
$puffer='<br><br><br>';
88
89
//create the A4-PDF...
90
$pdf_config['slogan']=$xoopsConfig['sitename'].' - '.$xoopsConfig['slogan'];
91
92
$pdf=new PDF();
93
if (method_exists($pdf, "encoding")) {
94
  $pdf->encoding($pdf_data, _CHARSET);
95
}
96
$pdf->SetCreator($pdf_config['creator']);
97
$pdf->SetTitle($pdf_data['title']);
98
$pdf->SetAuthor($pdf_config['url']);
99
$pdf->SetSubject($pdf_data['author']);
100
$out=$pdf_config['url'].', '.$pdf_data['author'].', '.$pdf_data['title'].', '.$pdf_data['subtitle'].', '.$pdf_data['subsubtitle'];
101
$pdf->SetKeywords($out);
102
$pdf->SetAutoPageBreak(true, 25);
103
$pdf->SetMargins($pdf_config['margin']['left'], $pdf_config['margin']['top'], $pdf_config['margin']['right']);
104
$pdf->Open();
105
106
//First page
107
$pdf->AddPage();
108
$pdf->SetXY(24, 25);
109
$pdf->SetTextColor(10, 60, 160);
110
$pdf->SetFont($pdf_config['font']['slogan']['family'],$pdf_config['font']['slogan']['style'], $pdf_config['font']['slogan']['size']);
111
$pdf->WriteHTML($pdf_config['slogan'], $pdf_config['scale']);
112
//$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']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
99% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
113
$pdf->Line(25, 30, 190, 30);
114
$pdf->SetXY(25, 35);
115
$pdf->SetFont($pdf_config['font']['title']['family'], $pdf_config['font']['title']['style'], $pdf_config['font']['title']['size']);
116
$pdf->WriteHTML($pdf_data['title'],$pdf_config['scale']);
117
118 View Code Duplication
if ($pdf_data['subtitle']<>'') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
  $pdf->WriteHTML($puff, $pdf_config['scale']);
120
  $pdf->SetFont($pdf_config['font']['subtitle']['family'], $pdf_config['font']['subtitle']['style'], $pdf_config['font']['subtitle']['size']);
121
  $pdf->WriteHTML($pdf_data['subtitle'], $pdf_config['scale']);
122
}
123 View Code Duplication
if ($pdf_data['subsubtitle']<>'') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
  $pdf->WriteHTML($puff, $pdf_config['scale']);
125
  $pdf->SetFont($pdf_config['font']['subsubtitle']['family'], $pdf_config['font']['subsubtitle']['style'], $pdf_config['font']['subsubtitle']['size']);
126
  $pdf->WriteHTML($pdf_data['subsubtitle'], $pdf_config['scale']);
127
}
128
129
$pdf->WriteHTML($puff, $pdf_config['scale']);
130
$pdf->SetFont($pdf_config['font']['author']['family'], $pdf_config['font']['author']['style'], $pdf_config['font']['author']['size']);
131
$out='';
132
$out.=$pdf_data['author'];
133
$pdf->WriteHTML($out, $pdf_config['scale']);
134
$pdf->WriteHTML($puff, $pdf_config['scale']);
135
$out=_DATE.':';
136
$out.=$pdf_data['date'];
137
$pdf->WriteHTML($out, $pdf_config['scale']);
138
$pdf->WriteHTML($puff, $pdf_config['scale']);
139
140
$pdf->SetTextColor(0, 0, 0);
141
$pdf->WriteHTML($puffer, $pdf_config['scale']);
142
143
$pdf->SetFont($pdf_config['font']['content']['family'], $pdf_config['font']['content']['style'], $pdf_config['font']['content']['size']);
144
$pdf->WriteHTML($pdf_data['content'], $pdf_config['scale']);
145
146
//$pdf->Output($pdf_data['filename'],'');
0 ignored issues
show
Unused Code Comprehensibility introduced by
92% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
147
$pdf->Output();
148