Completed
Push — master ( a50592...10bab4 )
by Michael
01:56
created
Severity

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
/**
3
 * FPDF creator framework for XOOPS
4
 *
5
 * Supporting multi-byte languages as well as utf-8 charset
6
 *
7
 * @copyright   XOOPS Project (https://xoops.org)
8
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
9
 * @author      Taiwen Jiang (phppp or D.J.) <[email protected]>
10
 * @since       1.00
11
 * @package     frameworks
12
 */
13
14
//ob_start();
15
16
/**
17
 * If no pdf_data is set, build it from the module
18
 *
19
 * <ul>The data fields to be built:
20
 *      <li>title</li>
21
 *      <li>subtitle (optional)</li>
22
 *      <li>subsubtitle (optional)</li>
23
 *      <li>date</li>
24
 *      <li>author</li>
25
 *      <li>content</li>
26
 *      <li>filename</li>
27
 * </ul>
28
 */
29
30
use Xmf\Request;
31
32
include __DIR__ . '/header.php';
33
global $pdf_data;
34
if (!empty($_POST['pdf_data'])) {
35
    $pdf_data = unserialize(base64_decode(Request::getText('pdf_data', '', 'POST')));
36
} elseif (!empty($pdf_data)) {
0 ignored issues
show
This elseif statement is empty, and could be removed.

This check looks for the bodies of elseif statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These elseif bodies can be removed. If you have an empty elseif but statements in the else branch, consider inverting the condition.

Loading history...
37
} else {
38
    error_reporting(0);
39
    include __DIR__ . '/header.php';
40
    error_reporting(0);
41
42
    if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) {
43
        $args['article'] = @$args_num[0];
44
    }
45
46
    $article_id = (int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']);
47
48
    $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
49
    $article_obj    = $articleHandler->get($article_id);
50
51
    $article_data = [];
52
53
    // title
54
    $article_data['title'] = $article_obj->getVar('art_title');
55
56
    $article_data['author'] = $article_obj->getVar('art_author');
57
58
    // source
59
    $article_data['source'] = $article_obj->getVar('art_link');
60
61
    // publish time
62
    $article_data['time'] = $article_obj->getTime();
63
64
    // summary
65
    $article_data['summary'] = $article_obj->getSummary();
66
67
    // text of page
68
    $article_data['text'] = $article_obj->getVar('art_content');
69
70
    // Build the pdf_data array
71
    $pdf_data['title']   = $article_data['title'];
72
    $pdf_data['author']  = $article_data['author'];
73
    $pdf_data['date']    = $article_data['time'];
74
    $pdf_data['content'] = '';
75
    if ($article_data['summary']) {
76
        $pdf_data['content'] .= planet_constant('MD_SUMMARY') . ': ' . $article_data['summary'] . '<br><br>';
77
    }
78
    $pdf_data['content'] .= $article_data['text'] . '<br>';
79
    $pdf_data['url']     = XOOPS_URL . '/modules/' . $GLOBALS['artdirname'] . '/view.article.php' . URL_DELIMITER . $article_obj->getVar('art_id');
80
}
81
$pdf_data['filename'] = preg_replace("/[^0-9a-z\-_\.]/i", '', $pdf_data['title']);
82
83
include XOOPS_ROOT_PATH . '/Frameworks/fpdf/init.php';
84
error_reporting(0);
85
ob_end_clean();
86
87
$pdf = new xoopsPDF($xoopsConfig['language']);
88
$pdf->initialize();
89
$pdf->output($pdf_data, _CHARSET);
90