Passed
Push — master ( 492cc7...e5a5fc )
by Michael
45s queued 11s
created
ratethread.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -37,48 +37,48 @@  discard block
 block discarded – undo
37 37
 $anonwaitdays = 1;
38 38
 $ip           = \Xmf\IPAddress::fromRequest()->asReadable();
39 39
 foreach (['topic_id', 'rate', 'forum'] as $var) {
40
-    //    ${$var} = isset($_POST[$var]) ? (int)($_POST[$var]) : (isset($_GET[$var])?(int)($_GET[$var]):0);
41
-    ${$var} = Request::getInt($var, Request::getInt($var, 0, 'POST'), 'GET');
40
+	//    ${$var} = isset($_POST[$var]) ? (int)($_POST[$var]) : (isset($_GET[$var])?(int)($_GET[$var]):0);
41
+	${$var} = Request::getInt($var, Request::getInt($var, 0, 'POST'), 'GET');
42 42
 }
43 43
 
44 44
 ///** @var Newbb\TopicHandler $topicHandler */
45 45
 //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
46 46
 $topicObject = $topicHandler->get($topic_id);
47 47
 if (!$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'post')
48
-    && !$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'reply')) {
49
-    // irmtfan - issue with javascript:history.go(-1)
50
-    redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM);
48
+	&& !$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'reply')) {
49
+	// irmtfan - issue with javascript:history.go(-1)
50
+	redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM);
51 51
 }
52 52
 
53 53
 if (empty($rate)) {
54
-    redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_NOVOTERATE);
54
+	redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_NOVOTERATE);
55 55
 }
56 56
 ///** @var Newbb\RateHandler $rateHandler */
57 57
 //$rateHandler = Newbb\Helper::getInstance()->getHandler('Rate');
58 58
 if (0 !== $ratinguser) {
59
-    // Check if Topic POSTER is voting (UNLESS Anonymous users allowed to post)
60
-    $crit_post = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
61
-    $crit_post->add(new \Criteria('uid', $ratinguser));
62
-    //    /** @var Newbb\PostHandler $postHandler */
63
-    //    $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
64
-    if ($postHandler->getCount($crit_post)) {
65
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_CANTVOTEOWN);
66
-    }
67
-    // Check if REG user is trying to vote twice.
68
-    $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
69
-    $crit_rate->add(new \Criteria('ratinguser', $ratinguser));
70
-    if ($rateHandler->getCount($crit_rate)) {
71
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
72
-    }
59
+	// Check if Topic POSTER is voting (UNLESS Anonymous users allowed to post)
60
+	$crit_post = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
61
+	$crit_post->add(new \Criteria('uid', $ratinguser));
62
+	//    /** @var Newbb\PostHandler $postHandler */
63
+	//    $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
64
+	if ($postHandler->getCount($crit_post)) {
65
+		redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_CANTVOTEOWN);
66
+	}
67
+	// Check if REG user is trying to vote twice.
68
+	$crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
69
+	$crit_rate->add(new \Criteria('ratinguser', $ratinguser));
70
+	if ($rateHandler->getCount($crit_rate)) {
71
+		redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
72
+	}
73 73
 } else {
74
-    // Check if ANONYMOUS user is trying to vote more than once per day.
75
-    $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
76
-    $crit_rate->add(new \Criteria('ratinguser', $ratinguser));
77
-    $crit_rate->add(new \Criteria('ratinghostname', $ip));
78
-    $crit_rate->add(new \Criteria('ratingtimestamp', time() - (86400 * $anonwaitdays), '>'));
79
-    if ($rateHandler->getCount($crit_rate)) {
80
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
81
-    }
74
+	// Check if ANONYMOUS user is trying to vote more than once per day.
75
+	$crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
76
+	$crit_rate->add(new \Criteria('ratinguser', $ratinguser));
77
+	$crit_rate->add(new \Criteria('ratinghostname', $ip));
78
+	$crit_rate->add(new \Criteria('ratingtimestamp', time() - (86400 * $anonwaitdays), '>'));
79
+	if ($rateHandler->getCount($crit_rate)) {
80
+		redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
81
+	}
82 82
 }
83 83
 $rateObject = $rateHandler->create();
84 84
 $rateObject->setVar('rating', $rate * 2);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 $votesDB     = $GLOBALS['xoopsDB']->getRowsNum($voteresult);
95 95
 $totalrating = 0;
96 96
 while (false !== (list($rating) = $GLOBALS['xoopsDB']->fetchRow($voteresult))) {
97
-    $totalrating += $rating;
97
+	$totalrating += $rating;
98 98
 }
99 99
 $finalrating = $totalrating / $votesDB;
100 100
 $finalrating = number_format($finalrating, 4);
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,42 +23,42 @@  discard block
 block discarded – undo
23 23
 //require_once $GLOBALS['xoops']->path('header.php');
24 24
 
25 25
 if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
26
-    require_once __DIR__ . '/seo_url.php';
27
-    /* for seo */
28
-    $toseo_url = ['index.php', 'viewforum.php', 'viewtopic.php', 'rss.php'];
26
+	require_once __DIR__ . '/seo_url.php';
27
+	/* for seo */
28
+	$toseo_url = ['index.php', 'viewforum.php', 'viewtopic.php', 'rss.php'];
29 29
 
30
-    if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite']) && (!isset($_POST) || count($_POST) <= 0)
31
-        && (false === strpos(getenv('REQUEST_URI'), '.html'))) {
32
-        $redir = false;
33
-        if (true === strpos(getenv('REQUEST_URI'), 'mark_read=') || true === strpos(getenv('REQUEST_URI'), 'mark=')) {
34
-            // Mark Forums
35
-        } else {
36
-            if (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) {
37
-                //rewrite only for files
30
+	if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite']) && (!isset($_POST) || count($_POST) <= 0)
31
+		&& (false === strpos(getenv('REQUEST_URI'), '.html'))) {
32
+		$redir = false;
33
+		if (true === strpos(getenv('REQUEST_URI'), 'mark_read=') || true === strpos(getenv('REQUEST_URI'), 'mark=')) {
34
+			// Mark Forums
35
+		} else {
36
+			if (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) {
37
+				//rewrite only for files
38 38
 
39
-                if ('' !== trim(getenv('SCRIPT_NAME'))) {
40
-                    if (false === strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) {
41
-                        $redir = true;
42
-                    } elseif (getenv('QUERY_STRING')) {
43
-                        $redir = true;
44
-                    }
45
-                }
46
-            }
47
-        }
39
+				if ('' !== trim(getenv('SCRIPT_NAME'))) {
40
+					if (false === strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) {
41
+						$redir = true;
42
+					} elseif (getenv('QUERY_STRING')) {
43
+						$redir = true;
44
+					}
45
+				}
46
+			}
47
+		}
48 48
 
49
-        if (true === $redir) {
50
-            $s      = 'http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI');
51
-            $s      = str_replace('/' . REAL_MODULE_NAME . '/', '/' . SEO_MODULE_NAME . '/', $s);
52
-            $newurl = seo_urls('<a href="' . $s . '"></a>');
53
-            $newurl = str_replace('<a href="', '', $newurl);
54
-            $newurl = str_replace('"></a>', '', $newurl);
55
-            if (!headers_sent()) {
56
-                header('HTTP/1.1 301 Moved Permanently');
57
-                header("Location: $newurl");
58
-                exit();
59
-            }
60
-        }
61
-    }
49
+		if (true === $redir) {
50
+			$s      = 'http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI');
51
+			$s      = str_replace('/' . REAL_MODULE_NAME . '/', '/' . SEO_MODULE_NAME . '/', $s);
52
+			$newurl = seo_urls('<a href="' . $s . '"></a>');
53
+			$newurl = str_replace('<a href="', '', $newurl);
54
+			$newurl = str_replace('"></a>', '', $newurl);
55
+			if (!headers_sent()) {
56
+				header('HTTP/1.1 301 Moved Permanently');
57
+				header("Location: $newurl");
58
+				exit();
59
+			}
60
+		}
61
+	}
62 62
 }
63 63
 
64 64
 require_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/vars.php');
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 //}
82 82
 
83 83
 if (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['welcome_forum'])
84
-    && !$GLOBALS['xoopsUser']->getVar('posts')) {
85
-    require_once __DIR__ . '/include/functions.welcome.php';
84
+	&& !$GLOBALS['xoopsUser']->getVar('posts')) {
85
+	require_once __DIR__ . '/include/functions.welcome.php';
86 86
 }
87 87
 // irmtfan for backward compatibility
88 88
 $pollmodules = $GLOBALS['xoopsModuleConfig']['poll_module'];
Please login to merge, or discard this patch.
dl_attachment.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 $postId   = Request::getInt('post_id', 0, 'GET');
21 21
 
22 22
 if (!$postId || !$attachId) {
23
-    exit(_MD_NEWBB_NO_SUCH_FILE . ': post_id:' . $postId . '; attachid' . $attachId);
23
+	exit(_MD_NEWBB_NO_SUCH_FILE . ': post_id:' . $postId . '; attachid' . $attachId);
24 24
 }
25 25
 
26 26
 ///** @var Newbb\PostHandler $postHandler */
@@ -29,36 +29,36 @@  discard block
 block discarded – undo
29 29
 /** @var Newbb\Post $forumpost */
30 30
 $forumpost = $postHandler->get($postId);
31 31
 if (!$approved = $forumpost->getVar('approved')) {
32
-    exit(_MD_NEWBB_NORIGHTTOVIEW);
32
+	exit(_MD_NEWBB_NORIGHTTOVIEW);
33 33
 }
34 34
 ///** @var TopicHandler $topicHandler */
35 35
 //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
36 36
 $topicObject = $topicHandler->getByPost($postId);
37 37
 $topic_id    = $topicObject->getVar('topic_id');
38 38
 if (!$approved = $topicObject->getVar('approved')) {
39
-    exit(_MD_NEWBB_NORIGHTTOVIEW);
39
+	exit(_MD_NEWBB_NORIGHTTOVIEW);
40 40
 }
41 41
 ///** @var NewbbForumHandler $forumHandler */
42 42
 //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
43 43
 $forumObject = $forumHandler->get($topicObject->getVar('forum_id'));
44 44
 if (!$forumHandler->getPermission($forumObject)) {
45
-    exit(_MD_NEWBB_NORIGHTTOACCESS);
45
+	exit(_MD_NEWBB_NORIGHTTOACCESS);
46 46
 }
47 47
 if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) {
48
-    exit(_MD_NEWBB_NORIGHTTOVIEW);
48
+	exit(_MD_NEWBB_NORIGHTTOVIEW);
49 49
 }
50 50
 
51 51
 $attachments = $forumpost->getAttachment();
52 52
 $attach      = $attachments[$attachId];
53 53
 if (!$attach) {
54
-    exit(_MD_NEWBB_NO_SUCH_FILE);
54
+	exit(_MD_NEWBB_NO_SUCH_FILE);
55 55
 }
56 56
 $file_saved = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
57 57
 if (!file_exists($file_saved)) {
58
-    exit(_MD_NEWBB_NO_SUCH_FILE);
58
+	exit(_MD_NEWBB_NO_SUCH_FILE);
59 59
 }
60 60
 if ($down = $forumpost->incrementDownload($attachId)) {
61
-    $forumpost->saveAttachment();
61
+	$forumpost->saveAttachment();
62 62
 }
63 63
 unset($forumpost);
64 64
 $msg = ob_get_contents();
@@ -66,41 +66,41 @@  discard block
 block discarded – undo
66 66
 
67 67
 $xoopsLogger->activated = false;
68 68
 if (!empty($GLOBALS['xoopsModuleConfig']['download_direct'])) {
69
-    header('Cache-Control: no-store, no-cache, must-revalidate');
70
-    header('Cache-Control: post-check=0, pre-check=0', false);
71
-    header('Pragma: no-cache');
72
-    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
73
-    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
74
-    header('location: ' . XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
69
+	header('Cache-Control: no-store, no-cache, must-revalidate');
70
+	header('Cache-Control: post-check=0, pre-check=0', false);
71
+	header('Pragma: no-cache');
72
+	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
73
+	header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
74
+	header('location: ' . XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
75 75
 } else {
76
-    $file_display = $attach['nameDisplay'];
77
-    //$mimetype = $attach['mimetype'];
76
+	$file_display = $attach['nameDisplay'];
77
+	//$mimetype = $attach['mimetype'];
78 78
 
79
-    if (ini_get('zlib.output_compression')) {
80
-        @ini_set('zlib.output_compression', 'Off');
81
-    }
79
+	if (ini_get('zlib.output_compression')) {
80
+		@ini_set('zlib.output_compression', 'Off');
81
+	}
82 82
 
83
-    if (function_exists('mb_http_output')) {
84
-        mb_http_output('pass');
85
-    }
86
-    header('Expires: 0');
87
-    //header('Content-Type: '.$mimetype);
88
-    header('Content-Type: application/octet-stream');
89
-    if (preg_match("/MSIE (\d\.\d{1,2})/", Request::getString('HTTP_USER_AGENT', '', 'SERVER'))) {
90
-        header('Content-Disposition: attachment; filename="' . $file_display . '"');
91
-        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
92
-        header('Pragma: public');
93
-    } else {
94
-        header('Content-Disposition: attachment; filename="' . $file_display . '"');
95
-        header('Pragma: no-cache');
96
-    }
97
-    header('Content-Type: application/force-download');
98
-    header('Content-Transfer-Encoding: binary');
83
+	if (function_exists('mb_http_output')) {
84
+		mb_http_output('pass');
85
+	}
86
+	header('Expires: 0');
87
+	//header('Content-Type: '.$mimetype);
88
+	header('Content-Type: application/octet-stream');
89
+	if (preg_match("/MSIE (\d\.\d{1,2})/", Request::getString('HTTP_USER_AGENT', '', 'SERVER'))) {
90
+		header('Content-Disposition: attachment; filename="' . $file_display . '"');
91
+		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
92
+		header('Pragma: public');
93
+	} else {
94
+		header('Content-Disposition: attachment; filename="' . $file_display . '"');
95
+		header('Pragma: no-cache');
96
+	}
97
+	header('Content-Type: application/force-download');
98
+	header('Content-Transfer-Encoding: binary');
99 99
 
100
-    $handle = fopen($file_saved, 'rb');
101
-    while (!feof($handle)) {
102
-        $buffer = fread($handle, 4096);
103
-        echo $buffer;
104
-    }
105
-    fclose($handle);
100
+	$handle = fopen($file_saved, 'rb');
101
+	while (!feof($handle)) {
102
+		$buffer = fread($handle, 4096);
103
+		echo $buffer;
104
+	}
105
+	fclose($handle);
106 106
 }
Please login to merge, or discard this patch.
edit.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 require_once __DIR__ . '/header.php';
16 16
 
17 17
 foreach (['forum', 'topic_id', 'post_id', 'order'] as $getint) {
18
-    ${$getint} = Request::getInt($getint, 0, 'GET');
18
+	${$getint} = Request::getInt($getint, 0, 'GET');
19 19
 }
20 20
 
21 21
 if (!$topic_id && !$post_id) {
22
-    $redirect = empty($forum) ? 'index.php' : "viewforum.php?forum={$forum}";
23
-    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
22
+	$redirect = empty($forum) ? 'index.php' : "viewforum.php?forum={$forum}";
23
+	redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
24 24
 }
25 25
 
26 26
 ///** @var Newbb\ForumHandler $forumHandler */
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 $topicObject = $topicHandler->get($postObject->getVar('topic_id'));
36 36
 $forumObject = $forumHandler->get($postObject->getVar('forum_id'));
37 37
 if (!$forumHandler->getPermission($forumObject)) {
38
-    redirect_header('index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
38
+	redirect_header('index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
39 39
 }
40 40
 
41 41
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
42
-    //    /** @var Newbb\OnlineHandler $onlineHandler */
43
-    //    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
44
-    $onlineHandler->init($forumObject);
42
+	//    /** @var Newbb\OnlineHandler $onlineHandler */
43
+	//    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
44
+	$onlineHandler->init($forumObject);
45 45
 }
46 46
 $isAdmin = newbbIsAdmin($forumObject);
47 47
 $uid     = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
 $error_msg    = null;
52 52
 
53 53
 if (!$topicHandler->getPermission($forumObject, $topic_status, 'edit') || (!$isAdmin && !$postObject->checkIdentity())) {
54
-    $error_msg = _MD_NEWBB_NORIGHTTOEDIT;
54
+	$error_msg = _MD_NEWBB_NORIGHTTOEDIT;
55 55
 } elseif (!$isAdmin && !$postObject->checkTimelimit('edit_timelimit')) {
56
-    $error_msg = _MD_NEWBB_TIMEISUP;
56
+	$error_msg = _MD_NEWBB_TIMEISUP;
57 57
 }
58 58
 
59 59
 if (!empty($error_msg)) {
60
-    /*
60
+	/*
61 61
      * Build the page query
62 62
      */
63
-    $query_vars  = ['topic_id', 'post_id', 'forum', 'status', 'order', 'mode', 'viewmode'];
64
-    $query_array = [];
65
-    foreach ($query_vars as $var) {
66
-        if (Request::getString($var, '', 'GET')) {
67
-            $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
68
-        }
69
-    }
70
-    $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
71
-    unset($query_array);
72
-    redirect_header("viewtopic.php?{$page_query}", 2, $error_msg);
63
+	$query_vars  = ['topic_id', 'post_id', 'forum', 'status', 'order', 'mode', 'viewmode'];
64
+	$query_array = [];
65
+	foreach ($query_vars as $var) {
66
+		if (Request::getString($var, '', 'GET')) {
67
+			$query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
68
+		}
69
+	}
70
+	$page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
71
+	unset($query_array);
72
+	redirect_header("viewtopic.php?{$page_query}", 2, $error_msg);
73 73
 }
74 74
 
75 75
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
76
-    //    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
77
-    $onlineHandler->init($forumObject);
76
+	//    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
77
+	$onlineHandler->init($forumObject);
78 78
 }
79 79
 
80 80
 $xoopsOption['template_main']                                        = 'newbb_edit_post.tpl';
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 $posts_context       = [];
126 126
 $posts_contextObject = $istopic ? [] : [$postHandler->get($postObject->getVar('pid'))];
127 127
 foreach ($posts_contextObject as $post_contextObject) {
128
-    if ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $post_contextObject->getVar('post_karma') > 0) {
129
-        $p_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $post_contextObject->getVar('post_karma')) . '</div>';
130
-    } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $post_contextObject->getVar('require_reply')) {
131
-        $p_message = _MD_NEWBB_REPLY_REQUIREMENT;
132
-    } else {
133
-        $p_message = $post_contextObject->getVar('post_text');
134
-    }
135
-
136
-    if ($post_contextObject->getVar('uid')) {
137
-        $p_name = newbbGetUnameFromId($post_contextObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']);
138
-    } else {
139
-        $poster_name = $post_contextObject->getVar('poster_name');
140
-        $p_name      = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5) : $poster_name;
141
-    }
142
-    $p_date    = formatTimestamp($post_contextObject->getVar('post_time'));
143
-    $p_subject = $post_contextObject->getVar('subject');
144
-
145
-    $posts_context[] = [
146
-        'subject' => $p_subject,
147
-        'meta'    => _MD_NEWBB_BY . ' ' . $p_name . ' ' . _MD_NEWBB_ON . ' ' . $p_date,
148
-        'content' => $p_message
149
-    ];
128
+	if ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $post_contextObject->getVar('post_karma') > 0) {
129
+		$p_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $post_contextObject->getVar('post_karma')) . '</div>';
130
+	} elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $post_contextObject->getVar('require_reply')) {
131
+		$p_message = _MD_NEWBB_REPLY_REQUIREMENT;
132
+	} else {
133
+		$p_message = $post_contextObject->getVar('post_text');
134
+	}
135
+
136
+	if ($post_contextObject->getVar('uid')) {
137
+		$p_name = newbbGetUnameFromId($post_contextObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']);
138
+	} else {
139
+		$poster_name = $post_contextObject->getVar('poster_name');
140
+		$p_name      = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5) : $poster_name;
141
+	}
142
+	$p_date    = formatTimestamp($post_contextObject->getVar('post_time'));
143
+	$p_subject = $post_contextObject->getVar('subject');
144
+
145
+	$posts_context[] = [
146
+		'subject' => $p_subject,
147
+		'meta'    => _MD_NEWBB_BY . ' ' . $p_name . ' ' . _MD_NEWBB_ON . ' ' . $p_date,
148
+		'content' => $p_message
149
+	];
150 150
 }
151 151
 $xoopsTpl->assign_by_ref('posts_context', $posts_context);
152 152
 // irmtfan move to footer.php
Please login to merge, or discard this patch.
seo.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -16,60 +16,60 @@  discard block
 block discarded – undo
16 16
 $seos = ['c', 'f', 't', 'p', 'rc', 'rf', 'v', 'pr', 'pdf'];
17 17
 
18 18
 $seoMap = [
19
-    'c'   => 'index.php',
20
-    'f'   => 'viewforum.php',
21
-    't'   => 'viewtopic.php',
22
-    'p'   => 'viewtopic.php',
23
-    'rc'  => 'rss.php',
24
-    'rf'  => 'rss.php',
25
-    'pr'  => 'print.php',
26
-    'pdf' => 'makepdf.php'
19
+	'c'   => 'index.php',
20
+	'f'   => 'viewforum.php',
21
+	't'   => 'viewtopic.php',
22
+	'p'   => 'viewtopic.php',
23
+	'rc'  => 'rss.php',
24
+	'rf'  => 'rss.php',
25
+	'pr'  => 'print.php',
26
+	'pdf' => 'makepdf.php'
27 27
 ];
28 28
 
29 29
 if (!empty($seoOp) && !empty($seoMap[$seoOp]) && in_array($seoOp, $seos)) {
30
-    // module specific dispatching logic, other module must implement as
31
-    // per their requirements.
32
-    $ori_self               = Request::getString('PHP_SELF', '', 'SERVER');
33
-    $ori_self               = explode('modules/newbb', $ori_self);
34
-    $newUrl                 = $ori_self[0] . 'modules/newbb/' . $seoMap[$seoOp];
35
-    $_ENV['PHP_SELF']       = $newUrl;
36
-    $_SERVER['SCRIPT_NAME'] = $newUrl;
37
-    $_SERVER['PHP_SELF']    = $newUrl;
38
-    switch ($seoOp) {
39
-        case 'c':
40
-            $_SERVER['REQUEST_URI'] = $newUrl . '?cat=' . $seoArg;
41
-            $_GET['cat']            = $seoArg;
42
-            break;
43
-        case 'f':
44
-            $_SERVER['REQUEST_URI'] = $newUrl . '?forum=' . $seoArg;
45
-            $_GET['forum']          = $seoArg;
46
-            break;
47
-        case 'p':
48
-            $_SERVER['REQUEST_URI'] = $newUrl . '?post_id=' . $seoArg;
49
-            $_GET['post_id']        = $seoArg;
50
-            break;
51
-        case 'rc':
52
-            $_SERVER['REQUEST_URI'] = $newUrl . '?c=' . $seoArg;
53
-            $_GET['c']              = $seoArg;
54
-            break;
55
-        case 'rf':
56
-            $_SERVER['REQUEST_URI'] = $newUrl . '?f=' . $seoArg;
57
-            $_GET['f']              = $seoArg;
58
-            break;
59
-        default:
60
-        case 't':
61
-        case 'pr':
62
-            $_SERVER['REQUEST_URI'] = $newUrl . '?topic_id=' . $seoArg;
63
-            $_GET['topic_id']       = $seoArg;
64
-            break;
65
-    }
66
-    require_once $seoMap[$seoOp];
30
+	// module specific dispatching logic, other module must implement as
31
+	// per their requirements.
32
+	$ori_self               = Request::getString('PHP_SELF', '', 'SERVER');
33
+	$ori_self               = explode('modules/newbb', $ori_self);
34
+	$newUrl                 = $ori_self[0] . 'modules/newbb/' . $seoMap[$seoOp];
35
+	$_ENV['PHP_SELF']       = $newUrl;
36
+	$_SERVER['SCRIPT_NAME'] = $newUrl;
37
+	$_SERVER['PHP_SELF']    = $newUrl;
38
+	switch ($seoOp) {
39
+		case 'c':
40
+			$_SERVER['REQUEST_URI'] = $newUrl . '?cat=' . $seoArg;
41
+			$_GET['cat']            = $seoArg;
42
+			break;
43
+		case 'f':
44
+			$_SERVER['REQUEST_URI'] = $newUrl . '?forum=' . $seoArg;
45
+			$_GET['forum']          = $seoArg;
46
+			break;
47
+		case 'p':
48
+			$_SERVER['REQUEST_URI'] = $newUrl . '?post_id=' . $seoArg;
49
+			$_GET['post_id']        = $seoArg;
50
+			break;
51
+		case 'rc':
52
+			$_SERVER['REQUEST_URI'] = $newUrl . '?c=' . $seoArg;
53
+			$_GET['c']              = $seoArg;
54
+			break;
55
+		case 'rf':
56
+			$_SERVER['REQUEST_URI'] = $newUrl . '?f=' . $seoArg;
57
+			$_GET['f']              = $seoArg;
58
+			break;
59
+		default:
60
+		case 't':
61
+		case 'pr':
62
+			$_SERVER['REQUEST_URI'] = $newUrl . '?topic_id=' . $seoArg;
63
+			$_GET['topic_id']       = $seoArg;
64
+			break;
65
+	}
66
+	require_once $seoMap[$seoOp];
67 67
 } else {
68
-    $last = $seoOp . '/' . $seoArg;
69
-    if ('' !== $seoOther) {
70
-        $last .= '/' . $seoOther;
71
-    }
72
-    require_once $last;
68
+	$last = $seoOp . '/' . $seoArg;
69
+	if ('' !== $seoOther) {
70
+		$last .= '/' . $seoOther;
71
+	}
72
+	require_once $last;
73 73
 }
74 74
 exit();
75 75
 
@@ -79,45 +79,45 @@  discard block
 block discarded – undo
79 79
  */
80 80
 function checker(&$value)
81 81
 {
82
-    // keine Tags erlaubt
83
-    $value = strip_tags($value);
82
+	// keine Tags erlaubt
83
+	$value = strip_tags($value);
84 84
 
85
-    // HTML-Tags maskieren
86
-    $value = htmlspecialchars($value, ENT_QUOTES);
85
+	// HTML-Tags maskieren
86
+	$value = htmlspecialchars($value, ENT_QUOTES);
87 87
 
88
-    // Leerzeichen am Anfang und Ende beseitigen
89
-    $value = trim($value);
88
+	// Leerzeichen am Anfang und Ende beseitigen
89
+	$value = trim($value);
90 90
 
91
-    // pruefe auf javascript include
92
-    if (false !== strpos($value, '<script')) {
93
-        $value = '';
94
-    }
91
+	// pruefe auf javascript include
92
+	if (false !== strpos($value, '<script')) {
93
+		$value = '';
94
+	}
95 95
 
96
-    // pruefe auf Kommentare (SQL-Injections)
97
-    if (false !== strpos($value, '/*')) {
98
-        $value = '';
99
-    }
96
+	// pruefe auf Kommentare (SQL-Injections)
97
+	if (false !== strpos($value, '/*')) {
98
+		$value = '';
99
+	}
100 100
 
101
-    // pruefe UNION Injections
102
-    if (preg_match('/\sUNION\s+(ALL|SELECT)/i', $value)) {
103
-        $value = '';
104
-    }
101
+	// pruefe UNION Injections
102
+	if (preg_match('/\sUNION\s+(ALL|SELECT)/i', $value)) {
103
+		$value = '';
104
+	}
105 105
 
106
-    // Nullbyte Injection
107
-    if (false !== strpos($value, chr(0))) {
108
-        $value = '';
109
-    }
106
+	// Nullbyte Injection
107
+	if (false !== strpos($value, chr(0))) {
108
+		$value = '';
109
+	}
110 110
 
111
-    //pruefe Verzeichnis
112
-    if (false !== strpos($value, '../')) {
113
-        $value = '';
114
-    }
111
+	//pruefe Verzeichnis
112
+	if (false !== strpos($value, '../')) {
113
+		$value = '';
114
+	}
115 115
 
116
-    //pruefe auf externe
117
-    $str = strstr($value, '://');
118
-    if (false !== strpos($value, '://')) {
119
-        $value = '';
120
-    }
116
+	//pruefe auf externe
117
+	$str = strstr($value, '://');
118
+	if (false !== strpos($value, '://')) {
119
+		$value = '';
120
+	}
121 121
 
122
-    return $value;
122
+	return $value;
123 123
 }
Please login to merge, or discard this patch.
preloads/autoloader.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
  * @see http://www.php-fig.org/psr/psr-4/examples/
5 5
  */
6 6
 spl_autoload_register(function ($class) {
7
-    // project-specific namespace prefix
8
-    $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__)));
7
+	// project-specific namespace prefix
8
+	$prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__)));
9 9
 
10
-    // base directory for the namespace prefix
11
-    $base_dir =  dirname(__DIR__) . '/class/';
10
+	// base directory for the namespace prefix
11
+	$base_dir =  dirname(__DIR__) . '/class/';
12 12
 
13
-    // does the class use the namespace prefix?
14
-    $len = strlen($prefix);
13
+	// does the class use the namespace prefix?
14
+	$len = strlen($prefix);
15 15
 
16
-    if (0 !== strncmp($prefix, $class, $len)) {
17
-        return;
18
-    }
16
+	if (0 !== strncmp($prefix, $class, $len)) {
17
+		return;
18
+	}
19 19
 
20
-    // get the relative class name
21
-    $relativeClass = substr($class, $len);
20
+	// get the relative class name
21
+	$relativeClass = substr($class, $len);
22 22
 
23
-    // replace the namespace prefix with the base directory, replace namespace
24
-    // separators with directory separators in the relative class name, append
25
-    // with .php
26
-    $file = $base_dir . str_replace('\\', '/', $relativeClass) . '.php';
23
+	// replace the namespace prefix with the base directory, replace namespace
24
+	// separators with directory separators in the relative class name, append
25
+	// with .php
26
+	$file = $base_dir . str_replace('\\', '/', $relativeClass) . '.php';
27 27
 
28
-    // if the file exists, require it
29
-    if (file_exists($file)) {
30
-        require_once $file;
31
-    }
28
+	// if the file exists, require it
29
+	if (file_exists($file)) {
30
+		require_once $file;
31
+	}
32 32
 });
Please login to merge, or discard this patch.
preloads/core.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
  */
23 23
 class NewbbCorePreload extends \XoopsPreloadItem
24 24
 {
25
-    // to add PSR-4 autoloader
26
-    /**
27
-     * @param $args
28
-     */
29
-    public static function eventCoreIncludeCommonEnd($args)
30
-    {
31
-        require_once __DIR__   . '/autoloader.php';
32
-    }
25
+	// to add PSR-4 autoloader
26
+	/**
27
+	 * @param $args
28
+	 */
29
+	public static function eventCoreIncludeCommonEnd($args)
30
+	{
31
+		require_once __DIR__   . '/autoloader.php';
32
+	}
33 33
 }
Please login to merge, or discard this patch.
rss.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.rpc.php');
37 37
 
38 38
 if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
39
-    require_once __DIR__ . '/seo_url.php';
39
+	require_once __DIR__ . '/seo_url.php';
40 40
 }
41 41
 /* for seo */
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 $category = Request::getInt('c', 0, 'GET');
48 48
 $forumSet = Request::getString('f', '', 'GET');
49 49
 if ('' !== $forumSet) {
50
-    $forums = array_map('intval', array_map('trim', explode('|', $forumSet)));
50
+	$forums = array_map('intval', array_map('trim', explode('|', $forumSet)));
51 51
 }
52 52
 
53 53
 ///** @var Newbb\ForumHandler $forumHandler */
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 $validForums = $forumHandler->getIdsByPermission(); // get all accessible forums
57 57
 
58 58
 if (is_array($forums) && count($forums) > 0) {
59
-    $validForums = array_intersect($forums, $validForums);
59
+	$validForums = array_intersect($forums, $validForums);
60 60
 } elseif ($category > 0) {
61
-    $crit_top = new \CriteriaCompo(new \Criteria('cat_id', $category));
62
-    $crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'));
63
-    $forums_top  = $forumHandler->getIds($crit_top);
64
-    $validForums = array_intersect($forums_top, $validForums);
61
+	$crit_top = new \CriteriaCompo(new \Criteria('cat_id', $category));
62
+	$crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'));
63
+	$forums_top  = $forumHandler->getIds($crit_top);
64
+	$validForums = array_intersect($forums_top, $validForums);
65 65
 }
66 66
 if (0 === count($validForums)) {
67
-    newbbTrackbackResponse(1, _NOPERM);
67
+	newbbTrackbackResponse(1, _NOPERM);
68 68
 }
69 69
 
70 70
 asort($validForums);
@@ -77,137 +77,137 @@  discard block
 block discarded – undo
77 77
 $tpl->caching        = 2;
78 78
 $tpl->cache_lifetime = $GLOBALS['xoopsModuleConfig']['rss_cachetime'] * 60;
79 79
 if (!empty($GLOBALS['xoopsConfig']['rewrite'])) {
80
-    $tpl->load_filter('output', 'xoRewriteModule');
80
+	$tpl->load_filter('output', 'xoRewriteModule');
81 81
 }
82 82
 
83 83
 //mod_loadFunctions('cache');
84 84
 $xoopsCachedTemplateId = "newbbb_rss_$forumSet";
85 85
 $compile_id            = null;
86 86
 if (!$tpl->is_cached('db:newbb_rss.tpl', $xoopsCachedTemplateId, $compile_id)) {
87
-    require_once __DIR__ . '/include/functions.time.php';
88
-
89
-    //    /** @var Newbb\XmlrssHandler $xmlrssHandler */
90
-    //    $xmlrssHandler = Newbb\Helper::getInstance()->getHandler('Xmlrss');
91
-    $rss = $xmlrssHandler->create();
92
-
93
-    $rss->setVarRss('channel_title', $GLOBALS['xoopsConfig']['sitename'] . ' :: ' . _MD_NEWBB_FORUM);
94
-    $rss->channel_link = XOOPS_URL . '/';
95
-    $rss->setVarRss('channel_desc', $GLOBALS['xoopsConfig']['slogan'] . ' :: ' . $xoopsModule->getInfo('description'));
96
-    $rss->setVarRss('channel_lastbuild', formatTimestamp(time(), 'rss'));
97
-    $rss->channel_webmaster = $GLOBALS['xoopsConfig']['adminmail'];
98
-    $rss->channel_editor    = $GLOBALS['xoopsConfig']['adminmail'];
99
-    $rss->setVarRss('channel_category', $xoopsModule->getVar('name'));
100
-    $rss->channel_generator = 'NewBB ' . $xoopsModule->getInfo('version');
101
-    $rss->channel_language  = _LANGCODE;
102
-    $rss->xml_encoding      = $charset;
103
-    $rss->image_url         = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image');
104
-
105
-    $dimension = @getimagesize($GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image')));
106
-    if (empty($dimension[0])) {
107
-        $width = 88;
108
-    } else {
109
-        $width = ($dimension[0] > 144) ? 144 : $dimension[0];
110
-    }
111
-    if (empty($dimension[1])) {
112
-        $height = 31;
113
-    } else {
114
-        $height = ($dimension[1] > 400) ? 400 : $dimension[1];
115
-    }
116
-    $rss->image_width  = $width;
117
-    $rss->image_height = $height;
118
-
119
-    $rss->max_items            = $GLOBALS['xoopsModuleConfig']['rss_maxitems'];
120
-    $rss->max_item_description = $GLOBALS['xoopsModuleConfig']['rss_maxdescription'];
121
-
122
-    $forumCriteria = ' AND t.forum_id IN (' . implode(',', $validForums) . ')';
123
-    unset($validForums);
124
-    $approveCriteria = ' AND t.approved = 1 AND p.approved = 1';
125
-
126
-    $query = 'SELECT'
127
-             . '    f.forum_id, f.forum_name,'
128
-             . '    t.topic_id, t.topic_title, t.type_id,'
129
-             . '    p.post_id, p.post_time, p.subject, p.uid, p.poster_name, p.post_karma, p.require_reply, '
130
-             . '    pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr,'
131
-             . '    pt.post_text'
132
-             . '    FROM '
133
-             . $GLOBALS['xoopsDB']->prefix('newbb_posts')
134
-             . ' AS p'
135
-             . '    LEFT JOIN '
136
-             . $GLOBALS['xoopsDB']->prefix('newbb_topics')
137
-             . ' AS t ON t.topic_last_post_id=p.post_id'
138
-             . '    LEFT JOIN '
139
-             . $GLOBALS['xoopsDB']->prefix('newbb_posts_text')
140
-             . ' AS pt ON pt.post_id=p.post_id'
141
-             . '    LEFT JOIN '
142
-             . $GLOBALS['xoopsDB']->prefix('newbb_forums')
143
-             . ' AS f ON f.forum_id=p.forum_id'
144
-             . '    WHERE 1=1 '
145
-             . $forumCriteria
146
-             . $approveCriteria
147
-             . ' ORDER BY p.post_id DESC';
148
-    $limit = (int)($GLOBALS['xoopsModuleConfig']['rss_maxitems'] * 1.5);
149
-    if (!$result = $GLOBALS['xoopsDB']->query($query, $limit)) {
150
-        newbbTrackbackResponse(1, _MD_NEWBB_ERROR);
151
-        //xoops_error($GLOBALS['xoopsDB']->error());
152
-        //return $xmlrssHandler->get($rss);
153
-    }
154
-    $rows  = [];
155
-    $types = [];
156
-    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
157
-        $users[$row['uid']] = 1;
158
-        if ($row['type_id'] > 0) {
159
-            $types[$row['type_id']] = 1;
160
-        }
161
-        $rows[] = $row;
162
-    }
163
-
164
-    if (count($rows) < 1) {
165
-        newbbTrackbackResponse(1, _MD_NEWBB_NORSS_DATA);
166
-        //return $xmlrssHandler->get($rss);
167
-    }
168
-    $users = newbbGetUnameFromIds(array_keys($users), $GLOBALS['xoopsModuleConfig']['show_realname']);
169
-    if (count($types) > 0) {
170
-        //        /** @var Newbb\TypeHandler $typeHandler */
171
-        //        $typeHandler = Newbb\Helper::getInstance()->getHandler('Type');
172
-        $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
173
-    }
174
-
175
-    foreach ($rows as $topic) {
176
-        if ($topic['post_karma'] > 0 && $GLOBALS['xoopsModuleConfig']['enable_karma']) {
177
-            continue;
178
-        }
179
-        if ($topic['require_reply'] && $GLOBALS['xoopsModuleConfig']['allow_require_reply']) {
180
-            continue;
181
-        }
182
-        if (!empty($users[$topic['uid']])) {
183
-            $topic['uname'] = $users[$topic['uid']];
184
-        } else {
185
-            $topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
186
-        }
187
-        $description            = $topic['forum_name'] . '::';
188
-        $topic['topic_subject'] = empty($type_list[$topic['type_id']]) ? '' : '[' . $type_list[$topic['type_id']] . '] ';
189
-        $description            .= $topic['topic_subject'] . $topic['topic_title'] . "<br>\n";
190
-        $description            .= $myts->displayTarea($topic['post_text'], $topic['dohtml'], $topic['dosmiley'], $topic['doxcode'], $topic['dobr']);
191
-        $label                  = _MD_NEWBB_BY . ' ' . $topic['uname'];
192
-        $time                   = formatTimestamp($topic['post_time'], 'rss');
193
-        $link                   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
194
-        if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
195
-            $link   = XOOPS_URL . '/' . REAL_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
196
-            $oldurl = '<a href=\'' . $link . '\'>';
197
-            $newurl = seo_urls($oldurl);
198
-            $newurl = str_replace('<a href=\'', '', $newurl);
199
-            $newurl = str_replace('\'>', '', $newurl);
200
-            $link   = $newurl;
201
-        }
202
-        $title = $topic['subject'];
203
-        if (!$rss->addItem($title, $link, $description, $label, $time)) {
204
-            break;
205
-        }
206
-    }
207
-
208
-    $rss_feed = $xmlrssHandler->get($rss);
209
-
210
-    $tpl->assign('rss', $rss_feed);
211
-    unset($rss);
87
+	require_once __DIR__ . '/include/functions.time.php';
88
+
89
+	//    /** @var Newbb\XmlrssHandler $xmlrssHandler */
90
+	//    $xmlrssHandler = Newbb\Helper::getInstance()->getHandler('Xmlrss');
91
+	$rss = $xmlrssHandler->create();
92
+
93
+	$rss->setVarRss('channel_title', $GLOBALS['xoopsConfig']['sitename'] . ' :: ' . _MD_NEWBB_FORUM);
94
+	$rss->channel_link = XOOPS_URL . '/';
95
+	$rss->setVarRss('channel_desc', $GLOBALS['xoopsConfig']['slogan'] . ' :: ' . $xoopsModule->getInfo('description'));
96
+	$rss->setVarRss('channel_lastbuild', formatTimestamp(time(), 'rss'));
97
+	$rss->channel_webmaster = $GLOBALS['xoopsConfig']['adminmail'];
98
+	$rss->channel_editor    = $GLOBALS['xoopsConfig']['adminmail'];
99
+	$rss->setVarRss('channel_category', $xoopsModule->getVar('name'));
100
+	$rss->channel_generator = 'NewBB ' . $xoopsModule->getInfo('version');
101
+	$rss->channel_language  = _LANGCODE;
102
+	$rss->xml_encoding      = $charset;
103
+	$rss->image_url         = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image');
104
+
105
+	$dimension = @getimagesize($GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image')));
106
+	if (empty($dimension[0])) {
107
+		$width = 88;
108
+	} else {
109
+		$width = ($dimension[0] > 144) ? 144 : $dimension[0];
110
+	}
111
+	if (empty($dimension[1])) {
112
+		$height = 31;
113
+	} else {
114
+		$height = ($dimension[1] > 400) ? 400 : $dimension[1];
115
+	}
116
+	$rss->image_width  = $width;
117
+	$rss->image_height = $height;
118
+
119
+	$rss->max_items            = $GLOBALS['xoopsModuleConfig']['rss_maxitems'];
120
+	$rss->max_item_description = $GLOBALS['xoopsModuleConfig']['rss_maxdescription'];
121
+
122
+	$forumCriteria = ' AND t.forum_id IN (' . implode(',', $validForums) . ')';
123
+	unset($validForums);
124
+	$approveCriteria = ' AND t.approved = 1 AND p.approved = 1';
125
+
126
+	$query = 'SELECT'
127
+			 . '    f.forum_id, f.forum_name,'
128
+			 . '    t.topic_id, t.topic_title, t.type_id,'
129
+			 . '    p.post_id, p.post_time, p.subject, p.uid, p.poster_name, p.post_karma, p.require_reply, '
130
+			 . '    pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr,'
131
+			 . '    pt.post_text'
132
+			 . '    FROM '
133
+			 . $GLOBALS['xoopsDB']->prefix('newbb_posts')
134
+			 . ' AS p'
135
+			 . '    LEFT JOIN '
136
+			 . $GLOBALS['xoopsDB']->prefix('newbb_topics')
137
+			 . ' AS t ON t.topic_last_post_id=p.post_id'
138
+			 . '    LEFT JOIN '
139
+			 . $GLOBALS['xoopsDB']->prefix('newbb_posts_text')
140
+			 . ' AS pt ON pt.post_id=p.post_id'
141
+			 . '    LEFT JOIN '
142
+			 . $GLOBALS['xoopsDB']->prefix('newbb_forums')
143
+			 . ' AS f ON f.forum_id=p.forum_id'
144
+			 . '    WHERE 1=1 '
145
+			 . $forumCriteria
146
+			 . $approveCriteria
147
+			 . ' ORDER BY p.post_id DESC';
148
+	$limit = (int)($GLOBALS['xoopsModuleConfig']['rss_maxitems'] * 1.5);
149
+	if (!$result = $GLOBALS['xoopsDB']->query($query, $limit)) {
150
+		newbbTrackbackResponse(1, _MD_NEWBB_ERROR);
151
+		//xoops_error($GLOBALS['xoopsDB']->error());
152
+		//return $xmlrssHandler->get($rss);
153
+	}
154
+	$rows  = [];
155
+	$types = [];
156
+	while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
157
+		$users[$row['uid']] = 1;
158
+		if ($row['type_id'] > 0) {
159
+			$types[$row['type_id']] = 1;
160
+		}
161
+		$rows[] = $row;
162
+	}
163
+
164
+	if (count($rows) < 1) {
165
+		newbbTrackbackResponse(1, _MD_NEWBB_NORSS_DATA);
166
+		//return $xmlrssHandler->get($rss);
167
+	}
168
+	$users = newbbGetUnameFromIds(array_keys($users), $GLOBALS['xoopsModuleConfig']['show_realname']);
169
+	if (count($types) > 0) {
170
+		//        /** @var Newbb\TypeHandler $typeHandler */
171
+		//        $typeHandler = Newbb\Helper::getInstance()->getHandler('Type');
172
+		$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
173
+	}
174
+
175
+	foreach ($rows as $topic) {
176
+		if ($topic['post_karma'] > 0 && $GLOBALS['xoopsModuleConfig']['enable_karma']) {
177
+			continue;
178
+		}
179
+		if ($topic['require_reply'] && $GLOBALS['xoopsModuleConfig']['allow_require_reply']) {
180
+			continue;
181
+		}
182
+		if (!empty($users[$topic['uid']])) {
183
+			$topic['uname'] = $users[$topic['uid']];
184
+		} else {
185
+			$topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
186
+		}
187
+		$description            = $topic['forum_name'] . '::';
188
+		$topic['topic_subject'] = empty($type_list[$topic['type_id']]) ? '' : '[' . $type_list[$topic['type_id']] . '] ';
189
+		$description            .= $topic['topic_subject'] . $topic['topic_title'] . "<br>\n";
190
+		$description            .= $myts->displayTarea($topic['post_text'], $topic['dohtml'], $topic['dosmiley'], $topic['doxcode'], $topic['dobr']);
191
+		$label                  = _MD_NEWBB_BY . ' ' . $topic['uname'];
192
+		$time                   = formatTimestamp($topic['post_time'], 'rss');
193
+		$link                   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
194
+		if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
195
+			$link   = XOOPS_URL . '/' . REAL_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
196
+			$oldurl = '<a href=\'' . $link . '\'>';
197
+			$newurl = seo_urls($oldurl);
198
+			$newurl = str_replace('<a href=\'', '', $newurl);
199
+			$newurl = str_replace('\'>', '', $newurl);
200
+			$link   = $newurl;
201
+		}
202
+		$title = $topic['subject'];
203
+		if (!$rss->addItem($title, $link, $description, $label, $time)) {
204
+			break;
205
+		}
206
+	}
207
+
208
+	$rss_feed = $xmlrssHandler->get($rss);
209
+
210
+	$tpl->assign('rss', $rss_feed);
211
+	unset($rss);
212 212
 }
213 213
 $tpl->display('db:newbb_rss.tpl', $xoopsCachedTemplateId, $compile_id);
Please login to merge, or discard this patch.
admin/admin_report.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -47,146 +47,146 @@
 block discarded – undo
47 47
 xoops_cp_header();
48 48
 
49 49
 switch ($op) {
50
-    case 'save':
51
-        $report_ids = Request::getArray('report_id', '', 'POST');
52
-        //        $report_ids = Request::getInt('report_id', 0, 'POST'); //$_POST['report_id'];
53
-        // irmtfan add error redirect header
54
-        if (0 === count($report_ids)) {
55
-            redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTNOTSELECT);
56
-        }
57
-        $report_memos = Request::getArray('report_memo', [], 'POST'); // isset($_POST['report_memo']) ? $_POST['report_memo'] : array();
58
-        foreach ($report_ids as $rid => $value) {
59
-            if (!$value) {
60
-                continue;
61
-            }
62
-            $reportObject = $reportHandler->get($rid);
63
-            $reportObject->setVar('report_result', 1);
64
-            $reportObject->setVar('report_memo', $report_memos[$rid]);
65
-            $reportHandler->insert($reportObject);
66
-        }
67
-        // irmtfan add message
68
-        redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTSAVE);
69
-        break;
50
+	case 'save':
51
+		$report_ids = Request::getArray('report_id', '', 'POST');
52
+		//        $report_ids = Request::getInt('report_id', 0, 'POST'); //$_POST['report_id'];
53
+		// irmtfan add error redirect header
54
+		if (0 === count($report_ids)) {
55
+			redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTNOTSELECT);
56
+		}
57
+		$report_memos = Request::getArray('report_memo', [], 'POST'); // isset($_POST['report_memo']) ? $_POST['report_memo'] : array();
58
+		foreach ($report_ids as $rid => $value) {
59
+			if (!$value) {
60
+				continue;
61
+			}
62
+			$reportObject = $reportHandler->get($rid);
63
+			$reportObject->setVar('report_result', 1);
64
+			$reportObject->setVar('report_memo', $report_memos[$rid]);
65
+			$reportHandler->insert($reportObject);
66
+		}
67
+		// irmtfan add message
68
+		redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTSAVE);
69
+		break;
70 70
 
71
-    case 'delete':
72
-        $report_ids = Request::getArray('report_id', [], 'POST');// $_POST['report_id'];
73
-        // irmtfan add error redirect header
74
-        if (0 === count($report_ids)) {
75
-            redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTNOTSELECT);
76
-        }
77
-        foreach ($report_ids as $rid => $value) {
78
-            if (!$value) {
79
-                continue;
80
-            }
81
-            if ($reportObject = $reportHandler->get($rid)) {
82
-                $reportHandler->delete($reportObject);
83
-            }
84
-        }
85
-        // irmtfan add message
86
-        redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTDELETE);
87
-        break;
71
+	case 'delete':
72
+		$report_ids = Request::getArray('report_id', [], 'POST');// $_POST['report_id'];
73
+		// irmtfan add error redirect header
74
+		if (0 === count($report_ids)) {
75
+			redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTNOTSELECT);
76
+		}
77
+		foreach ($report_ids as $rid => $value) {
78
+			if (!$value) {
79
+				continue;
80
+			}
81
+			if ($reportObject = $reportHandler->get($rid)) {
82
+				$reportHandler->delete($reportObject);
83
+			}
84
+		}
85
+		// irmtfan add message
86
+		redirect_header("admin_report.php?item={$item}" . (empty($start) ? '' : "&start={$start}"), 1, _AM_NEWBB_REPORTDELETE);
87
+		break;
88 88
 
89
-    case 'default':
90
-    default:
91
-        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
92
-        require_once  dirname(__DIR__) . '/include/functions.user.php';
89
+	case 'default':
90
+	default:
91
+		require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
92
+		require_once  dirname(__DIR__) . '/include/functions.user.php';
93 93
 
94
-        if ('processed' !== $item) {
95
-            $process_result = 0;
96
-            $item_other     = 'admin_report.php?item=processed';
97
-            $title_other    = _AM_NEWBB_PROCESSEDREPORT;
98
-            $extra          = _AM_NEWBB_REPORTEXTRA;
99
-        } else {
100
-            $process_result = 1;
101
-            $item_other     = 'admin_report.php?item=process';
102
-            $title_other    = _AM_NEWBB_PROCESSREPORT;
103
-            $extra          = _DELETE;
104
-        }
94
+		if ('processed' !== $item) {
95
+			$process_result = 0;
96
+			$item_other     = 'admin_report.php?item=processed';
97
+			$title_other    = _AM_NEWBB_PROCESSEDREPORT;
98
+			$extra          = _AM_NEWBB_REPORTEXTRA;
99
+		} else {
100
+			$process_result = 1;
101
+			$item_other     = 'admin_report.php?item=process';
102
+			$title_other    = _AM_NEWBB_PROCESSREPORT;
103
+			$extra          = _DELETE;
104
+		}
105 105
 
106
-        $limit = 10;
106
+		$limit = 10;
107 107
 
108
-        $adminObject->displayNavigation(basename(__FILE__));
108
+		$adminObject->displayNavigation(basename(__FILE__));
109 109
 
110
-        //if (!$newXoopsModuleGui) loadModuleAdminMenu(6,_AM_NEWBB_REPORTADMIN);
111
-        //    else $adminObject->displayNavigation(basename(__FILE__));
112
-        $adminObject->addItemButton($title_other, $item_other, $icon = 'add');
113
-        $adminObject->displayButton('left');
114
-        echo _AM_NEWBB_REPORTADMIN_HELP;
115
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
116
-        echo '<form action="' . xoops_getenv('PHP_SELF') . '" method="post">';
117
-        echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
118
-        echo "<tr align='center'>";
119
-        echo "<th class='bg3' width='80%'>" . _AM_NEWBB_REPORTTITLE . '</th>';
120
-        echo "<th class='bg3' width='10%'>" . $extra . '</th>';
121
-        echo '</tr>';
110
+		//if (!$newXoopsModuleGui) loadModuleAdminMenu(6,_AM_NEWBB_REPORTADMIN);
111
+		//    else $adminObject->displayNavigation(basename(__FILE__));
112
+		$adminObject->addItemButton($title_other, $item_other, $icon = 'add');
113
+		$adminObject->displayButton('left');
114
+		echo _AM_NEWBB_REPORTADMIN_HELP;
115
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
116
+		echo '<form action="' . xoops_getenv('PHP_SELF') . '" method="post">';
117
+		echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
118
+		echo "<tr align='center'>";
119
+		echo "<th class='bg3' width='80%'>" . _AM_NEWBB_REPORTTITLE . '</th>';
120
+		echo "<th class='bg3' width='10%'>" . $extra . '</th>';
121
+		echo '</tr>';
122 122
 
123
-        $reports = $reportHandler->getAllReports('report_id', 'ASC', $limit, $start, $process_result);
124
-        foreach ($reports as $report) {
125
-            $post_link = '<a href="'
126
-                         . XOOPS_URL
127
-                         . '/modules/'
128
-                         . $xoopsModule->getVar('dirname')
129
-                         . '/viewtopic.php?post_id='
130
-                         . $report['post_id']
131
-                         . '&amp;topic_id='
132
-                         . $report['topic_id']
133
-                         . '&amp;forum='
134
-                         . $report['forum_id']
135
-                         . '&amp;viewmode=thread" target="checkreport">'
136
-                         . $myts->htmlSpecialChars($report['subject'])
137
-                         . '</a>';
138
-            $checkbox  = '<input type="checkbox" name="report_id[' . $report['report_id'] . ']" value="1" checked />';
139
-            if ('processed' !== $item) {
140
-                $memo = '<input type="text" name="report_memo[' . $report['report_id'] . ']" maxlength="255" size="80" />';
141
-            } else {
142
-                $memo = $myts->htmlSpecialChars($report['report_memo']);
143
-            }
144
-            echo "<tr class='odd' align='left'>";
145
-            echo '<td>' . _AM_NEWBB_REPORTPOST . ': ' . $post_link . '</td>';
146
-            echo "<td align='center'>" . $report['report_id'] . '</td>';
147
-            echo '</tr>';
148
-            echo "<tr class='odd' align='left'>";
149
-            echo '<td>' . _AM_NEWBB_REPORTTEXT . ': ' . $myts->htmlSpecialChars($report['report_text']) . '</td>';
150
-            $uid           = (int)$report['reporter_uid'];
151
-            $reporter_name = newbbGetUnameFromId($uid, $GLOBALS['xoopsModuleConfig']['show_realname']);
152
-            $reporter      = !empty($uid) ? "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $uid . "'>" . $reporter_name . '</a><br>' : '';
153
-            echo "<td align='center'>" . $reporter . $report['reporter_ip'] . '</td>';
154
-            echo '</tr>';
155
-            echo "<tr class='odd' align='left'>";
156
-            echo '<td>' . _AM_NEWBB_REPORTMEMO . ': ' . $memo . '</td>';
157
-            echo "<td align='center' >" . $checkbox . '</td>';
158
-            echo '</tr>';
159
-            echo "<tr colspan='2'><td height='2'></td></tr>";
160
-        }
161
-        $buttons = '';
162
-        if ('processed' !== $item) {
163
-            $submit  = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
164
-            $buttons .= $submit->render() . ' ';
165
-        }
166
-        $delete  = new \XoopsFormButton('', 'delete', _DELETE, 'submit');
167
-        $buttons .= $delete->render() . ' ';
168
-        $cancel  = new \XoopsFormButton('', 'cancel', _CANCEL, 'reset');
169
-        $buttons .= $cancel->render();
170
-        echo "<tr colspan='2'><td align='center'>{$buttons}</td></tr>";
171
-        $hidden = new \XoopsFormHidden('start', $start);
172
-        echo $hidden->render();
173
-        $hidden = new \XoopsFormHidden('item', $item);
174
-        echo $hidden->render() . '</form>';
123
+		$reports = $reportHandler->getAllReports('report_id', 'ASC', $limit, $start, $process_result);
124
+		foreach ($reports as $report) {
125
+			$post_link = '<a href="'
126
+						 . XOOPS_URL
127
+						 . '/modules/'
128
+						 . $xoopsModule->getVar('dirname')
129
+						 . '/viewtopic.php?post_id='
130
+						 . $report['post_id']
131
+						 . '&amp;topic_id='
132
+						 . $report['topic_id']
133
+						 . '&amp;forum='
134
+						 . $report['forum_id']
135
+						 . '&amp;viewmode=thread" target="checkreport">'
136
+						 . $myts->htmlSpecialChars($report['subject'])
137
+						 . '</a>';
138
+			$checkbox  = '<input type="checkbox" name="report_id[' . $report['report_id'] . ']" value="1" checked />';
139
+			if ('processed' !== $item) {
140
+				$memo = '<input type="text" name="report_memo[' . $report['report_id'] . ']" maxlength="255" size="80" />';
141
+			} else {
142
+				$memo = $myts->htmlSpecialChars($report['report_memo']);
143
+			}
144
+			echo "<tr class='odd' align='left'>";
145
+			echo '<td>' . _AM_NEWBB_REPORTPOST . ': ' . $post_link . '</td>';
146
+			echo "<td align='center'>" . $report['report_id'] . '</td>';
147
+			echo '</tr>';
148
+			echo "<tr class='odd' align='left'>";
149
+			echo '<td>' . _AM_NEWBB_REPORTTEXT . ': ' . $myts->htmlSpecialChars($report['report_text']) . '</td>';
150
+			$uid           = (int)$report['reporter_uid'];
151
+			$reporter_name = newbbGetUnameFromId($uid, $GLOBALS['xoopsModuleConfig']['show_realname']);
152
+			$reporter      = !empty($uid) ? "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $uid . "'>" . $reporter_name . '</a><br>' : '';
153
+			echo "<td align='center'>" . $reporter . $report['reporter_ip'] . '</td>';
154
+			echo '</tr>';
155
+			echo "<tr class='odd' align='left'>";
156
+			echo '<td>' . _AM_NEWBB_REPORTMEMO . ': ' . $memo . '</td>';
157
+			echo "<td align='center' >" . $checkbox . '</td>';
158
+			echo '</tr>';
159
+			echo "<tr colspan='2'><td height='2'></td></tr>";
160
+		}
161
+		$buttons = '';
162
+		if ('processed' !== $item) {
163
+			$submit  = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
164
+			$buttons .= $submit->render() . ' ';
165
+		}
166
+		$delete  = new \XoopsFormButton('', 'delete', _DELETE, 'submit');
167
+		$buttons .= $delete->render() . ' ';
168
+		$cancel  = new \XoopsFormButton('', 'cancel', _CANCEL, 'reset');
169
+		$buttons .= $cancel->render();
170
+		echo "<tr colspan='2'><td align='center'>{$buttons}</td></tr>";
171
+		$hidden = new \XoopsFormHidden('start', $start);
172
+		echo $hidden->render();
173
+		$hidden = new \XoopsFormHidden('item', $item);
174
+		echo $hidden->render() . '</form>';
175 175
 
176
-        echo '</table>';
177
-        echo '</td></tr></table>';
178
-        $nav = new \XoopsPageNav(
179
-            $reportHandler->getCount(new \Criteria('report_result', $process_result)),
180
-            $limit,
181
-            $start,
182
-            'start',
183
-            'item=' . $item
184
-        );
185
-        echo $nav->renderNav(4);
186
-        echo '<fieldset>';
187
-        echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_REPORT . '&nbsp;</legend>';
188
-        echo _AM_NEWBB_HELP_REPORT_TAB;
189
-        echo '</fieldset>';
190
-        break;
176
+		echo '</table>';
177
+		echo '</td></tr></table>';
178
+		$nav = new \XoopsPageNav(
179
+			$reportHandler->getCount(new \Criteria('report_result', $process_result)),
180
+			$limit,
181
+			$start,
182
+			'start',
183
+			'item=' . $item
184
+		);
185
+		echo $nav->renderNav(4);
186
+		echo '<fieldset>';
187
+		echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_REPORT . '&nbsp;</legend>';
188
+		echo _AM_NEWBB_HELP_REPORT_TAB;
189
+		echo '</fieldset>';
190
+		break;
191 191
 }
192 192
 require_once __DIR__ . '/admin_footer.php';
Please login to merge, or discard this patch.