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