Completed
Push — master ( 937117...931dfe )
by Michael
05:45 queued 02:42
created

article.php (3 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: Soapbox
5
 * Version: v 1.5
6
 * Release Date: 23 August 2004
7
 * Author: hsalazar
8
 * Licence: GNU
9
 */
10
11
use Xmf\Request;
12
13
require_once __DIR__ . '/header.php';
14
15
$xoopsConfig['module_cache']             = 0; //disable caching since the URL will be the same, but content different from one user to another
16
$GLOBALS['xoopsOption']['template_main'] = 'sb_article.tpl';
17
require_once XOOPS_ROOT_PATH . '/header.php';
18
global $xoopsModule;
19
//$pathIcon16 = $xoopsModule->getInfo('sysicons16');
20
$pathIcon16 = Xmf\Module\Admin::iconUrl('', 16);
21
22
$moduleDirName = $myts->htmlSpecialChars(basename(__DIR__));
23 View Code Duplication
if ($moduleDirName !== 'soapbox' && $moduleDirName !== '' && !preg_match('/^(\D+)(\d*)$/', $moduleDirName)) {
24
    echo('invalid dirname: ' . htmlspecialchars($moduleDirName, ENT_QUOTES));
25
}
26
//---GET view sort --
27
$sortname = isset($_GET['sortname']) ? strtolower(trim(strip_tags($myts->stripSlashesGPC($_GET['sortname'])))) : 'datesub';
28
if (!in_array($sortname, array('datesub', 'weight', 'counter', 'rating', 'headline'))) {
29
    $sortname = 'datesub';
30
}
31
$sortorder = isset($_GET['sortorder']) ? strtoupper(trim(strip_tags($myts->stripSlashesGPC($_GET['sortorder'])))) : 'DESC';
32
if (!in_array($sortorder, array('ASC', 'DESC'))) {
33
    $sortorder = 'DESC';
34
}
35
//---------------
36
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/cleantags.php';
37
//for ratefile update by domifara
38
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
39
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/gtickets.php';
40
41
$articleID = Request::getInt('articleID', 0, 'GET'); //isset($_GET['articleID']) ? (int)($_GET['articleID']) : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
82% 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...
42
$startpage = Request::getInt('page', 0, 'GET'); //isset($_GET['page']) ? (int)($_GET['page']) : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% 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...
43
//-------------------------------------
44
//move here  form ratefile.php
45
if (isset($_POST['submit']) && !empty($_POST['lid'])) {
46
    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/ratefile.inc.php')) {
47
        require XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/ratefile.inc.php';
48
    }
49
    trigger_error('not updated rate :');
50
    exit();
51
}
52
//-------------------------------------
53
//view start
54
$articles = array();
55
$category = array();
56
//module entry data handler
57
$entrydataHandler = xoops_getModuleHandler('entryget', $moduleDirName);
58
if (empty($articleID)) {
59
    //get entry object
60
    $_entryob_arr = $entrydataHandler->getArticlesAllPermcheck(1, 0, true, true, 0, 0, null, $sortname, $sortorder, null, null, true, false);
61
    //    $totalarts = $entrydataHandler->total_getArticlesAllPermcheck;
62
    if (empty($_entryob_arr) || count($_entryob_arr) === 0) {
63
        redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/index.php', 1, _MD_SOAPBOX_NOTHING);
64
    }
65
    $_entryob = $_entryob_arr[0];
66
} else {
67
    //get entry object
68
    $_entryob = $entrydataHandler->getArticleOnePermcheck($articleID, true, true);
69 View Code Duplication
    if (!is_object($_entryob)) {
70
        redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/index.php', 1, 'Not Found');
71
    }
72
}
73
//-------------------------------------
74
$articles = $_entryob->toArray();
75
//get category object
76
$_categoryob = $_entryob->_sbcolumns;
77
//get vars
78
$category = $_categoryob->toArray();
79
//-------------------------------------
80
//update count
81
$entrydataHandler->getUpArticlecount($_entryob, true);
82
83
//assign
84
$articles['id']     = $articles['articleID'];
85
$articles['posted'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $xoopsModuleConfig['dateformat']));
86
87
// includes code by toshimitsu
88
if (trim($articles['bodytext']) !== '') {
89
    $articletext    = explode('[pagebreak]', $_entryob->getVar('bodytext', 'none'));
90
    $articles_pages = count($articletext);
91
    if ($articles_pages > 1) {
92
        require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
93
        $pagenav = new XoopsPageNav($articles_pages, 1, $startpage, 'page', 'articleID=' . $articles['articleID']);
94
        $xoopsTpl->assign('pagenav', $pagenav->renderNav());
95
        if ($startpage === 0) {
96
            $articles['bodytext'] = $articles['lead'] . '<br><br>' . $myts->displayTarea($articletext[$startpage], $articles['html'], $articles['smiley'], $articles['xcodes'], 1, $articles['breaks']);
97
        } else {
98
            $articles['bodytext'] =& $myts->displayTarea($articletext[$startpage], $articles['html'], $articles['smiley'], $articles['xcodes'], 1, $articles['breaks']);
99
        }
100
    } else {
101
        $articles['bodytext'] = $articles['lead'] . '<br><br>' . $myts->displayTarea($_entryob->getVar('bodytext', 'none'), $articles['html'], $articles['smiley'], $articles['xcodes'], 1, $articles['breaks']);
102
    }
103
}
104
//Cleantags
105
$articles['bodytext'] = $GLOBALS['SoapboxCleantags']->cleanTags($articles['bodytext']);
106
107
if ($xoopsModuleConfig['includerating'] === 1) {
108
    $xoopsTpl->assign('showrating', '1');
109
    //-------------------------------------
110
    //for ratefile update by domifara
111
    $xoopsTpl->assign('rate_gtickets', $xoopsGTicket->getTicketHtml(__LINE__));
112
    //-------------------------------------
113
    if ($articles['rating'] != 0.0000) {
114
        $articles['rating'] = '' . _MD_SOAPBOX_RATING . ': ' . $myts->htmlSpecialChars(number_format($articles['rating'], 2));
115
        $articles['votes']  = '' . _MD_SOAPBOX_VOTES . ': ' . $myts->htmlSpecialChars($articles['votes']);
116
    } else {
117
        $articles['rating'] = _MD_SOAPBOX_NOTRATED;
118
    }
119
}
120
121
if (is_object($xoopsUser)) {
122
    $xoopsTpl->assign('authorpm_link', "<a href=\"javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $category['author'] . "', 'pmlite', 450, 380);\"><img src='" . $pathIcon16 . "/mail_new.png' alt=\"" . _MD_SOAPBOX_WRITEAUTHOR . '" /></a>');
123
} else {
124
    $xoopsTpl->assign('user_pmlink', '');
125
}
126
127
// Functional links
128
$articles['adminlinks'] = $entrydataHandler->getadminlinks($_entryob, $_categoryob);
129
$articles['userlinks']  = $entrydataHandler->getuserlinks($_entryob);
130
131
$articles['author']     = SoapboxUtility::getLinkedUnameFromId($category['author'], 0);
132
$articles['authorname'] = SoapboxUtility::getAuthorName($category['author']);
133
$articles['colname']    = $category['name'];
134
$articles['coldesc']    = $category['description'];
135
$articles['colimage']   = $category['colimage'];
136
137
$xoopsTpl->assign('xoops_pagetitle', $articles['headline']);
138
$xoopsTpl->assign('story', $articles);
139
//-----------------------------
140
$mbmail_subject = sprintf(_MD_SOAPBOX_INTART, $xoopsConfig['sitename']);
141
$mbmail_body    = sprintf(_MD_SOAPBOX_INTARTFOUND, $xoopsConfig['sitename']);
142
$al             = SoapboxUtility::getAcceptLang();
143 View Code Duplication
if ($al === 'ja') {
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...
144
    if (function_exists('mb_convert_encoding') && function_exists('mb_encode_mimeheader')
145
        && @mb_internal_encoding(_CHARSET)) {
146
        $mbmail_subject = mb_convert_encoding($mbmail_subject, 'SJIS', _CHARSET);
147
        $mbmail_body    = mb_convert_encoding($mbmail_body, 'SJIS', _CHARSET);
148
    }
149
}
150
$mbmail_subject = rawurlencode($mbmail_subject);
151
$mbmail_body    = rawurlencode($mbmail_body);
152
//-----------------------------
153
$xoopsTpl->assign('mail_link', 'mailto:?subject=' . $myts->htmlSpecialChars($mbmail_subject) . '&amp;body=' . $myts->htmlSpecialChars($mbmail_body) . ':  ' . XOOPS_URL . '/modules/' . $moduleDirName . '/article.php?articleID=' . $articles['articleID']);
154
$xoopsTpl->assign('articleID', $articles['articleID']);
155
$xoopsTpl->assign('lang_ratethis', _MD_SOAPBOX_RATETHIS);
156
$xoopsTpl->assign('lang_modulename', $xoopsModule->name());
157
$xoopsTpl->assign('lang_moduledirname', $moduleDirName);
158
$xoopsTpl->assign('imgdir', $myts->htmlSpecialChars($xoopsModuleConfig['sbimgdir']));
159
$xoopsTpl->assign('uploaddir', $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']));
160
161
//-------------------------------------
162
//box view
163
$listarts = array();
164
//-------------------------------------
165
$_other_entryob_arr = $entrydataHandler->getArticlesAllPermcheck((int)$xoopsModuleConfig['morearts'], 0, true, true, 0, 0, null, $sortname, $sortorder, $_categoryob, $articles['articleID'], true, false);
166
$totalartsbyauthor  = (int)$entrydataHandler->total_getArticlesAllPermcheck + 1;
167
168
if (!empty($_other_entryob_arr)) {
169
    foreach ($_other_entryob_arr as $_other_entryob) {
170
        $link = array();
171
        $link = $_other_entryob->toArray();
172
        //--------------------
173
        $link['id']        = $link['articleID'];
174
        $link['arttitle']  = $_other_entryob->getVar('headline');
175
        $link['published'] = $myts->htmlSpecialChars(formatTimestamp($_other_entryob->getVar('datesub'), $xoopsModuleConfig['dateformat']));
176
        //        $link['poster'] = XoopsUserUtility::getUnameFromId( $link['uid'] );
177
        $link['poster']      = SoapboxUtility::getLinkedUnameFromId($category['author']);
178
        $link['bodytext']    = xoops_substr($link['bodytext'], 0, 255);
179
        $listarts['links'][] = $link;
180
    }
181
    $xoopsTpl->assign('listarts', $listarts);
182
    $xoopsTpl->assign('readmore', "<a style='font-size: 9px;' href=" . XOOPS_URL . '/modules/' . $moduleDirName . '/column.php?columnID=' . $articles['columnID'] . '>' . _MD_SOAPBOX_READMORE . '[' . $totalartsbyauthor . ']</a> ');
183
}
184
185
if (isset($GLOBALS['xoopsModuleConfig']['globaldisplaycomments'])
186
    && $GLOBALS['xoopsModuleConfig']['globaldisplaycomments'] === 1) {
187
    if ($articles['commentable'] === 1) {
188
        include XOOPS_ROOT_PATH . '/include/comment_view.php';
189
    }
190
} else {
191
    include XOOPS_ROOT_PATH . '/include/comment_view.php';
192
}
193
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/style.css" />');
194
195
require_once XOOPS_ROOT_PATH . '/footer.php';
196