Completed
Push — master ( dc7924...1aa479 )
by Michael
11s
created

print.php (8 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
/**
3
 *
4
 * Module: WF-Links
5
 * Developer: McDonald
6
 * Licence: GNU
7
 */
8
9
$moduleDirName = basename(__DIR__);
10
11
require_once __DIR__ . '/header.php';
12
require_once XOOPS_ROOT_PATH . '/class/template.php';
13
14
$lid = WflinksUtility::cleanRequestVars($_REQUEST, 'lid', 0);
15
$lid = (int)$lid;
16
17
$error_message = _MD_WFL_NOITEMSELECTED;
18
if ($lid == 0) {
19
    redirect_header('javascript:history.go(-1)', 1, $error_message);
20
}
21
22
global $xoopsDB, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
23
24
$result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0 AND published <= ' . time() . ' AND offline = 0 AND lid=' . $lid);
25
$myrow  = $xoopsDB->fetchArray($result);
26
27
$result2 = $xoopsDB->query('SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $myrow['cid']);
28
$mycat   = $xoopsDB->fetchArray($result2);
29
30
$xoopsTpl = new XoopsTpl();
31
$myts     = MyTextSanitizer::getInstance();
32
33
$xoopsTpl->assign('printsitename', XOOPS_URL);
34
$xoopsTpl->assign('printcategoryname', $mycat['title']);
35
36
if ($xoopsModuleConfig['screenshot']) {
37
    if ($xoopsModuleConfig['useautothumb']) {
38
        $xoopsTpl->assign('printscrshot', '<img src="http://mozshot.nemui.org/shot/200x200?' . $myrow['url'] . '" alt="" title="" border="0">');
39
    } else {
40
        $xoopsTpl->assign('printscrshot', '<img src="' . XOOPS_URL . '/' . $xoopsModuleConfig['screenshots'] . '/' . $myrow['screenshot'] . '" alt="" title="" border="0">');
41
    }
42
}
43
44
$xoopsTpl->assign('printtitle', $myts->displayTarea($myrow['title']));
45
$xoopsTpl->assign('printdescription', $myrow['description']);
46
$xoopsTpl->assign('printfooter', $xoopsModuleConfig['footerprint']);
47
$xoopsTpl->assign('lang_category', _MD_WFL_CATEGORY);
48
49
if ($xoopsModuleConfig['printlogourl']) {
50
    $xoopsTpl->assign('printlogo', '<img src="' . $xoopsModuleConfig['printlogourl'] . '" alt="" title="" border="0">');
51
} else {
52
    $xoopsTpl->assign('printlogo', '');
53
}
54
55
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/address.php';
56
$street1 = $myrow['street1'];
57
$street2 = $myrow['street2'];
58
$town    = $myrow['town'];
59
$state   = $myrow['state'];
60
$zip     = $myrow['zip'];
61
$tel     = $myrow['tel'];
62
$mobile  = $myrow['mobile'];
63
$voip    = $myrow['voip'];
64
$fax     = $myrow['fax'];
65
$url     = $myrow['url'];
66
$email   = printemailcnvrt($myrow['email']);
67
$country = WflinksUtility::getCountryName($myrow['country']);
68
69
if ($street1 === '' || $town === '' || $xoopsModuleConfig['useaddress'] == 0) {
70
    $print['addryn'] = 0;
71
} else {
72
    $print['addryn']  = 1;
73
    $address          = wfl_address($street1, $town, $state, $zip, $country);
74
    $print['address'] = '<b>' . _MD_WFL_ADDRESS . '</b><br>' . wfl_address($street1, $street2, $town, $state, $zip, $country) . '<br>' . $country;
75 View Code Duplication
    if ($tel === '') {
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...
76
        $print['tel'] = '';
77
    } else {
78
        $print['tel'] = '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/telephone.png" title="" alt="" align="absmiddle">&nbsp;' . $tel;
79
    }
80 View Code Duplication
    if ($mobile === '') {
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...
81
        $print['mobile'] = '';
82
    } else {
83
        $print['mobile'] = '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/phone.png" title="" alt="" align="absmiddle">&nbsp;' . $mobile;
84
    }
85 View Code Duplication
    if ($voip === '') {
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...
86
        $print['voip'] = '';
87
    } else {
88
        $print['voip'] = '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/voip.png" title="" alt="" align="absmiddle">&nbsp;' . $voip;
89
    }
90 View Code Duplication
    if ($fax === '') {
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...
91
        $print['fax'] = '';
92
    } else {
93
        $print['fax'] = '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/fax.png" title="" alt="" align="absmiddle">&nbsp;' . $fax;
94
    }
95 View Code Duplication
    if ($email === '') {
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...
96
        $print['email'] = '';
97
    } else {
98
        $print['email'] = '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/email.png" title="" alt="" align="absmiddle">&nbsp;' . $email;
99
    }
100
}
101
$xoopsTpl->assign('print', $print);
102
103
$xoopsTpl->assign('worldwideweb', '<br>' . '<img src="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icon/world.png" title="" alt="" align="absmiddle">&nbsp;' . $url);
104
105
// Start of meta tags
106
global $xoopsTpl, $xoTheme;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
107
108
$maxWords = 100;
109
$words    = array();
110
$words    = explode(' ', WflinksUtility::convertHtml2text($myrow['description']));
111
$newWords = array();
112
$i        = 0;
113
114 View Code Duplication
while ($i < $maxWords - 1 && $i < count($words)) {
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...
115
    if (isset($words[$i])) {
116
        $newWords[] = trim($words[$i]);
117
    }
118
    ++$i;
119
}
120
121
$link_meta_description = implode(' ', $newWords);
122
123
if (is_object($xoTheme)) {
124
    $xoTheme->addMeta('meta', 'keywords', $myrow['keywords']);
125
    $xoTheme->addMeta('meta', 'title', $myrow['title']);
126
    $xoTheme->addMeta('meta', 'description', $link_meta_description);
127
} else {
128
    $xoopsTpl->assign('xoops_meta_keywords', $myrow['keywords']);
129
    $xoopsTpl->assign('xoops_meta_description', $link_meta_description);
130
}
131
$xoopsTpl->assign('xoops_pagetitle', $myrow['title']);
132
$xoopsTpl->assign('xoops_meta_author', $myrow['publisher']);
133
$xoopsTpl->assign('xoops_sitename', $xoopsConfig['sitename']);
134
$xoopsTpl->assign('xoops_meta_robots', 'noindex,nofollow');
135
$xoopsTpl->assign('xoops_meta_copyright', $xoopsConfig['sitename']);
136
// End of meta tags
137
138
$xoopsTpl->assign('module_dir', $moduleDirName);
139
$xoopsTpl->display('db:wflinks_print.tpl');
140